diff --git a/CHANGELOG.md b/CHANGELOG.md index e8e3f96e0..6aa47ee35 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,15 @@ 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.2] - 2025-01-12 + +### Added +- #2849 - Provide better compatibility for projects migrating from OAS 3.0 to OAS 3.1 + +### Fixed +- #2846 - ClassCastException with spring-data-rest and openapi version 3.1 bug +- #2844 - PageableObject and SortObject are called Pageablenull and Sortnull i + ## [2.8.1] - 2025-01-06 ### Fixed diff --git a/pom.xml b/pom.xml index 3bb41f32d..ea992c2c9 100644 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 org.springdoc springdoc-openapi - 2.8.1 + 2.8.2 pom Spring openapi documentation Spring openapi documentation @@ -35,7 +35,7 @@ scm:git:git@github.com:springdoc/springdoc-openapi.git scm:git:git@github.com:springdoc/springdoc-openapi.git - v2.8.1 + v2.8.2 diff --git a/springdoc-openapi-starter-common/pom.xml b/springdoc-openapi-starter-common/pom.xml index 59e6527a2..a355db7d5 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.1 + 2.8.2 springdoc-openapi-starter-common diff --git a/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/configuration/SpringDocConfiguration.java b/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/configuration/SpringDocConfiguration.java index d69abcb72..4c39763c9 100644 --- a/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/configuration/SpringDocConfiguration.java +++ b/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/configuration/SpringDocConfiguration.java @@ -21,7 +21,7 @@ * * * * * * * * * - * + * */ @@ -52,6 +52,7 @@ import org.springdoc.core.converters.AdditionalModelsConverter; import org.springdoc.core.converters.FileSupportConverter; import org.springdoc.core.converters.ModelConverterRegistrar; +import org.springdoc.core.converters.OAS31ModelConverter; import org.springdoc.core.converters.PolymorphicModelConverter; import org.springdoc.core.converters.PropertyCustomizingConverter; import org.springdoc.core.converters.ResponseSupportConverter; @@ -597,14 +598,14 @@ public SpringDocCustomizers springDocCustomizers(Optional Optional> operationCustomizers, Optional> routerOperationCustomizers, Optional> dataRestRouterOperationCustomizers, - Optional> methodFilters, Optional> globalOpenApiCustomizers, + Optional> methodFilters, Optional> globalOpenApiCustomizers, Optional> globalOperationCustomizers, - Optional> globalOpenApiMethodFilters){ + Optional> globalOpenApiMethodFilters) { return new SpringDocCustomizers(openApiCustomizers, operationCustomizers, - routerOperationCustomizers, - dataRestRouterOperationCustomizers, - methodFilters, globalOpenApiCustomizers, globalOperationCustomizers, globalOpenApiMethodFilters); + routerOperationCustomizers, + dataRestRouterOperationCustomizers, + methodFilters, globalOpenApiCustomizers, globalOperationCustomizers, globalOpenApiMethodFilters); } /** @@ -658,4 +659,17 @@ ParameterObjectNamingStrategyCustomizer parameterObjectNamingStrategyCustomizer( GlobalOpenApiCustomizer globalOpenApiCustomizer() { return new OperationIdCustomizer(); } + + /** + * Oas 31 model converter oas 31 model converter. + * + * @param springDocConfigProperties the spring doc config properties + * @return the oas 31 model converter + */ + @Bean + @ConditionalOnMissingBean + @Lazy(false) + OAS31ModelConverter oas31ModelConverter(SpringDocConfigProperties springDocConfigProperties) { + return springDocConfigProperties.isOpenapi31() ? new OAS31ModelConverter() : null; + } } diff --git a/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/configuration/SpringDocHateoasConfiguration.java b/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/configuration/SpringDocHateoasConfiguration.java index f84cdbffd..5c35852ba 100644 --- a/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/configuration/SpringDocHateoasConfiguration.java +++ b/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/configuration/SpringDocHateoasConfiguration.java @@ -31,7 +31,7 @@ import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.databind.SerializerProvider; import org.springdoc.core.converters.CollectionModelContentConverter; -import org.springdoc.core.converters.RepresentationModelLinksOASMixin; +import org.springdoc.core.converters.HateoasLinksConverter; import org.springdoc.core.customizers.GlobalOpenApiCustomizer; import org.springdoc.core.customizers.OpenApiHateoasLinksCustomizer; import org.springdoc.core.properties.SpringDocConfigProperties; @@ -49,7 +49,6 @@ import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Lazy; import org.springframework.hateoas.Links; -import org.springframework.hateoas.RepresentationModel; import org.springframework.hateoas.server.LinkRelationProvider; /** @@ -99,20 +98,32 @@ CollectionModelContentConverter collectionModelContentConverter(HateoasHalProvid * * @param halProvider the hal provider * @param springDocConfigProperties the spring doc config properties - * @param objectMapperProvider the object mapper provider * @return the open api customizer - * @see org.springframework.hateoas.mediatype.hal.Jackson2HalModule.HalLinkListSerializer#serialize(Links, JsonGenerator, SerializerProvider) org.springframework.hateoas.mediatype.hal.Jackson2HalModule.HalLinkListSerializer#serialize(Links, JsonGenerator, SerializerProvider)org.springframework.hateoas.mediatype.hal.Jackson2HalModule.HalLinkListSerializer#serialize(Links, JsonGenerator, SerializerProvider)org.springframework.hateoas.mediatype.hal.Jackson2HalModule.HalLinkListSerializer#serialize(Links, JsonGenerator, SerializerProvider)org.springframework.hateoas.mediatype.hal.Jackson2HalModule.HalLinkListSerializer#serialize(Links, JsonGenerator, SerializerProvider)org.springframework.hateoas.mediatype.hal.Jackson2HalModule.HalLinkListSerializer#serialize(Links, JsonGenerator, SerializerProvider)org.springframework.hateoas.mediatype.hal.Jackson2HalModule.HalLinkListSerializer#serialize(Links, JsonGenerator, SerializerProvider) + * @see org.springframework.hateoas.mediatype.hal.Jackson2HalModule.HalLinkListSerializer#serialize(Links, JsonGenerator, SerializerProvider) org.springframework.hateoas.mediatype.hal.Jackson2HalModule.HalLinkListSerializer#serialize(Links, JsonGenerator, SerializerProvider)org.springframework.hateoas.mediatype.hal.Jackson2HalModule.HalLinkListSerializer#serialize(Links, JsonGenerator, SerializerProvider)org.springframework.hateoas.mediatype.hal.Jackson2HalModule.HalLinkListSerializer#serialize(Links, JsonGenerator, SerializerProvider)org.springframework.hateoas.mediatype.hal.Jackson2HalModule.HalLinkListSerializer#serialize(Links, JsonGenerator, SerializerProvider)org.springframework.hateoas.mediatype.hal.Jackson2HalModule.HalLinkListSerializer#serialize(Links, JsonGenerator, SerializerProvider)org.springframework.hateoas.mediatype.hal.Jackson2HalModule.HalLinkListSerializer#serialize(Links, JsonGenerator, SerializerProvider)org.springframework.hateoas.mediatype.hal.Jackson2HalModule.HalLinkListSerializer#serialize(Links, JsonGenerator, SerializerProvider) */ @Bean(Constants.LINKS_SCHEMA_CUSTOMISER) @ConditionalOnMissingBean(name = Constants.LINKS_SCHEMA_CUSTOMISER) @Lazy(false) - GlobalOpenApiCustomizer linksSchemaCustomizer(HateoasHalProvider halProvider, SpringDocConfigProperties springDocConfigProperties, - ObjectMapperProvider objectMapperProvider) { + GlobalOpenApiCustomizer linksSchemaCustomizer(HateoasHalProvider halProvider, SpringDocConfigProperties springDocConfigProperties) { if (!halProvider.isHalEnabled()) { return openApi -> { }; } - objectMapperProvider.jsonMapper().addMixIn(RepresentationModel.class, RepresentationModelLinksOASMixin.class); return new OpenApiHateoasLinksCustomizer(springDocConfigProperties); } + + /** + * Hateoas links converter hateoas links converter. + * + * @param springDocObjectMapper the spring doc object mapper + * @return the hateoas links converter + */ + @Bean + @ConditionalOnMissingBean + @Lazy(false) + HateoasLinksConverter hateoasLinksConverter(ObjectMapperProvider springDocObjectMapper) { + return new HateoasLinksConverter(springDocObjectMapper) ; + } + + } \ No newline at end of file diff --git a/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/converters/AdditionalModelsConverter.java b/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/converters/AdditionalModelsConverter.java index a3fd6ab3b..7c7a34f6d 100644 --- a/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/converters/AdditionalModelsConverter.java +++ b/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/converters/AdditionalModelsConverter.java @@ -41,6 +41,8 @@ import org.slf4j.LoggerFactory; import org.springdoc.core.providers.ObjectMapperProvider; +import static org.springdoc.core.utils.SpringDocUtils.handleSchemaTypes; + /** * The type Additional models converter. * @@ -146,8 +148,11 @@ public Schema resolve(AnnotatedType type, ModelConverterContext context, Iterato Class cls = javaType.getRawClass(); if (modelToSchemaMap.containsKey(cls)) try { + Schema schema = modelToSchemaMap.get(cls); + if(springDocObjectMapper.isOpenapi31()) + handleSchemaTypes(schema); return springDocObjectMapper.jsonMapper() - .readValue(springDocObjectMapper.jsonMapper().writeValueAsString(modelToSchemaMap.get(cls)), new TypeReference() {}); + .readValue(springDocObjectMapper.jsonMapper().writeValueAsString(schema), new TypeReference() {}); } catch (JsonProcessingException e) { LOGGER.warn("Json Processing Exception occurred: {}", e.getMessage()); diff --git a/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/converters/HateoasLinksConverter.java b/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/converters/HateoasLinksConverter.java new file mode 100644 index 000000000..929115c4e --- /dev/null +++ b/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/converters/HateoasLinksConverter.java @@ -0,0 +1,92 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.converters; + + +import java.util.Iterator; + +import com.fasterxml.jackson.databind.JavaType; +import io.swagger.v3.core.converter.ModelConverter; +import io.swagger.v3.core.converter.ModelConverterContext; +import io.swagger.v3.core.util.AnnotationsUtils; +import io.swagger.v3.oas.models.Components; +import io.swagger.v3.oas.models.media.ArraySchema; +import io.swagger.v3.oas.models.media.JsonSchema; +import io.swagger.v3.oas.models.media.Schema; +import org.springdoc.core.providers.ObjectMapperProvider; + +import org.springframework.hateoas.RepresentationModel; + +/** + * The type Hateoas links converter. + * + * @author bnasslahsen + */ +public class HateoasLinksConverter implements ModelConverter { + + /** + * The Spring doc object mapper. + */ + private final ObjectMapperProvider springDocObjectMapper; + + /** + * Instantiates a new Hateoas links converter. + * + * @param springDocObjectMapper the spring doc object mapper + */ + public HateoasLinksConverter(ObjectMapperProvider springDocObjectMapper) { + this.springDocObjectMapper = springDocObjectMapper; + } + + @Override + public Schema resolve( + io.swagger.v3.core.converter.AnnotatedType type, + ModelConverterContext context, + Iterator chain + ) { + JavaType javaType = springDocObjectMapper.jsonMapper().constructType(type.getType()); + if (javaType != null) { + if (RepresentationModel.class.isAssignableFrom(javaType.getRawClass())) { + Schema schema = chain.next().resolve(type, context, chain); + String schemaName = schema.get$ref().substring(Components.COMPONENTS_SCHEMAS_REF.length()); + Schema original = context.getDefinedModels().get(schemaName); + Object links = original.getProperties().get("_links"); + if(links instanceof JsonSchema jsonSchema) { + jsonSchema.set$ref(AnnotationsUtils.COMPONENTS_REF + "Links"); + jsonSchema.setType(null); + jsonSchema.setItems(null); + jsonSchema.setTypes(null); + } else if (links instanceof ArraySchema arraySchema){ + arraySchema.set$ref(AnnotationsUtils.COMPONENTS_REF + "Links"); + } + return schema; + } + } + return chain.hasNext() ? chain.next().resolve(type, context, chain) : null; + } + +} diff --git a/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/converters/OAS31ModelConverter.java b/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/converters/OAS31ModelConverter.java new file mode 100644 index 000000000..17fbdbbb4 --- /dev/null +++ b/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/converters/OAS31ModelConverter.java @@ -0,0 +1,58 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.converters; + +import java.util.Iterator; + +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.oas.models.media.Schema; + +import static org.springdoc.core.utils.SpringDocUtils.handleSchemaTypes; +import static org.springdoc.core.utils.SpringDocUtils.isComposedSchema; + +/** + * The type OAS31 Model converter. + * + * @author bnasslahsen + */ +public class OAS31ModelConverter implements ModelConverter { + + @Override + public Schema resolve(AnnotatedType type, ModelConverterContext context, Iterator chain) { + if (chain.hasNext()) { + Schema resolvedSchema = chain.next().resolve(type, context, chain); + if (resolvedSchema != null && !isComposedSchema(resolvedSchema)) { + handleSchemaTypes(resolvedSchema); + } + return resolvedSchema; + } + return null; + } + +} diff --git a/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/converters/PageOpenAPIConverter.java b/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/converters/PageOpenAPIConverter.java index 281c6efb3..34e7e7f3a 100644 --- a/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/converters/PageOpenAPIConverter.java +++ b/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/converters/PageOpenAPIConverter.java @@ -35,12 +35,13 @@ import io.swagger.v3.core.converter.ModelConverter; import io.swagger.v3.core.converter.ModelConverterContext; import io.swagger.v3.oas.models.media.Schema; -import org.apache.commons.lang3.StringUtils; import org.springdoc.core.providers.ObjectMapperProvider; import org.springframework.core.ResolvableType; import org.springframework.data.web.PagedModel; +import static org.springdoc.core.utils.SpringDocUtils.getParentTypeName; + /** * The Spring Data Page type model converter. * @@ -95,7 +96,7 @@ public Schema resolve(AnnotatedType type, ModelConverterContext context, Iterato if (!type.isSchemaProperty()) type = resolvePagedModelType(type); else - type.name(cls.getSimpleName() + StringUtils.capitalize(type.getParent().getType())); + type.name(getParentTypeName(type, cls)); } } return (chain.hasNext()) ? chain.next().resolve(type, context, chain) : null; diff --git a/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/converters/PageableOpenAPIConverter.java b/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/converters/PageableOpenAPIConverter.java index 0e2864c88..0bae9272a 100644 --- a/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/converters/PageableOpenAPIConverter.java +++ b/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/converters/PageableOpenAPIConverter.java @@ -33,10 +33,11 @@ import io.swagger.v3.core.converter.ModelConverter; import io.swagger.v3.core.converter.ModelConverterContext; import io.swagger.v3.oas.models.media.Schema; -import org.apache.commons.lang3.StringUtils; import org.springdoc.core.converters.models.Pageable; import org.springdoc.core.providers.ObjectMapperProvider; +import static org.springdoc.core.utils.SpringDocUtils.getParentTypeName; + /** * The Pageable Type models converter. * @@ -90,7 +91,7 @@ public Schema resolve(AnnotatedType type, ModelConverterContext context, Iterato if (!type.isSchemaProperty()) type = PAGEABLE; else - type.name(cls.getSimpleName() + StringUtils.capitalize(type.getParent().getType())); + type.name(getParentTypeName(type, cls)); } } return (chain.hasNext()) ? chain.next().resolve(type, context, chain) : null; 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 338db8cde..2a8b57b41 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 @@ -21,7 +21,7 @@ * * * * * * * * * - * + * */ package org.springdoc.core.converters; @@ -64,6 +64,11 @@ public class PolymorphicModelConverter implements ModelConverter { */ private static final List PARENT_TYPES_TO_IGNORE = Collections.synchronizedList(new ArrayList<>()); + /** + * The constant PARENT_TYPES_TO_IGNORE. + */ + private static final List TYPES_TO_SKIP = Collections.synchronizedList(new ArrayList<>()); + static { PARENT_TYPES_TO_IGNORE.add("JsonSchema"); PARENT_TYPES_TO_IGNORE.add("Pageable"); @@ -115,6 +120,9 @@ public Schema resolve(AnnotatedType type, ModelConverterContext context, Iterato if (field.isAnnotationPresent(JsonUnwrapped.class)) { PARENT_TYPES_TO_IGNORE.add(javaType.getRawClass().getSimpleName()); } + else if (field.isAnnotationPresent(io.swagger.v3.oas.annotations.media.Schema.class)) { + TYPES_TO_SKIP.add(field.getType().getSimpleName()); + } } if (chain.hasNext()) { if (!type.isResolveAsRef() && type.getParent() != null @@ -149,12 +157,13 @@ public Schema resolve(AnnotatedType type, ModelConverterContext context, Iterato private Schema composePolymorphicSchema(AnnotatedType type, Schema schema, Collection schemas) { String ref = schema.get$ref(); List composedSchemas = findComposedSchemas(ref, schemas); - if (composedSchemas.isEmpty()) return schema; - ComposedSchema result = new ComposedSchema(); if (isConcreteClass(type)) result.addOneOfItem(schema); - composedSchemas.forEach(result::addOneOfItem); + JavaType javaType = springDocObjectMapper.jsonMapper().constructType(type.getType()); + Class clazz = javaType.getRawClass(); + if(TYPES_TO_SKIP.stream().noneMatch(typeToSkip -> typeToSkip.equals(clazz.getSimpleName()))) + composedSchemas.forEach(result::addOneOfItem); return result; } diff --git a/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/converters/RepresentationModelLinksOASMixin.java b/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/converters/RepresentationModelLinksOASMixin.java deleted file mode 100644 index 0d0fe462c..000000000 --- a/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/converters/RepresentationModelLinksOASMixin.java +++ /dev/null @@ -1,44 +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.converters; - -import io.swagger.v3.core.util.AnnotationsUtils; -import io.swagger.v3.oas.annotations.media.Schema; - -import org.springframework.hateoas.Links; -import org.springframework.hateoas.mediatype.hal.RepresentationModelMixin; - -/** - * The type Representation model links oas mixin. - * - * @author bnasslahsen - */ -public abstract class RepresentationModelLinksOASMixin extends RepresentationModelMixin { - @Override - @Schema(ref = AnnotationsUtils.COMPONENTS_REF + "Links") - public abstract Links getLinks(); -} diff --git a/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/converters/SortOpenAPIConverter.java b/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/converters/SortOpenAPIConverter.java index 875bba99c..3b2b77929 100644 --- a/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/converters/SortOpenAPIConverter.java +++ b/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/converters/SortOpenAPIConverter.java @@ -33,10 +33,11 @@ import io.swagger.v3.core.converter.ModelConverter; import io.swagger.v3.core.converter.ModelConverterContext; import io.swagger.v3.oas.models.media.Schema; -import org.apache.commons.lang3.StringUtils; import org.springdoc.core.converters.models.Sort; import org.springdoc.core.providers.ObjectMapperProvider; +import static org.springdoc.core.utils.SpringDocUtils.getParentTypeName; + /** * The Spring Data Sort type model converter. * @@ -85,7 +86,7 @@ public Schema resolve(AnnotatedType type, ModelConverterContext context, Iterato if (!type.isSchemaProperty()) type = SORT; else - type.name(cls.getSimpleName() + StringUtils.capitalize(type.getParent().getType())); + type.name(getParentTypeName(type, cls)); } } return (chain.hasNext()) ? chain.next().resolve(type, context, chain) : null; diff --git a/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/customizers/ActuatorOperationCustomizer.java b/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/customizers/ActuatorOperationCustomizer.java index 73eed5e8b..df37c2b43 100644 --- a/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/customizers/ActuatorOperationCustomizer.java +++ b/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/customizers/ActuatorOperationCustomizer.java @@ -54,6 +54,7 @@ import org.springframework.web.method.HandlerMethod; import static org.springdoc.core.providers.ActuatorProvider.getTag; +import static org.springdoc.core.utils.SpringDocUtils.handleSchemaTypes; /** * The type Actuator operation customizer. @@ -240,7 +241,9 @@ private Parameter getParameterFromField(OperationParameter operationParameter) { * @return the schema */ private Schema resolveSchema(Parameter parameter) { - return AnnotationsUtils.resolveSchemaFromType(parameter.getType(), null, null, springDocConfigProperties.isOpenapi31()); + Schema schema = AnnotationsUtils.resolveSchemaFromType(parameter.getType(), null, null, springDocConfigProperties.isOpenapi31()); + if(springDocConfigProperties.isOpenapi31()) handleSchemaTypes(schema); + return schema; } /** diff --git a/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/customizers/OpenApiHateoasLinksCustomizer.java b/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/customizers/OpenApiHateoasLinksCustomizer.java index 028725dcd..c3cae9d1e 100644 --- a/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/customizers/OpenApiHateoasLinksCustomizer.java +++ b/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/customizers/OpenApiHateoasLinksCustomizer.java @@ -33,7 +33,7 @@ import io.swagger.v3.core.util.AnnotationsUtils; import io.swagger.v3.oas.models.OpenAPI; import io.swagger.v3.oas.models.media.MapSchema; -import io.swagger.v3.oas.models.media.ObjectSchema; +import io.swagger.v3.oas.models.media.Schema; import io.swagger.v3.oas.models.media.StringSchema; import org.springdoc.core.properties.SpringDocConfigProperties; @@ -68,7 +68,7 @@ public void customise(OpenAPI openApi) { .schema("Link", resolvedLinkSchema.schema) .schema("Links", new MapSchema() .additionalProperties(new StringSchema()) - .additionalProperties(new ObjectSchema().$ref(AnnotationsUtils.COMPONENTS_REF + "Link"))); + .additionalProperties(new Schema<>().$ref(AnnotationsUtils.COMPONENTS_REF + "Link"))); if (springDocConfigProperties.isRemoveBrokenReferenceDefinitions()) this.removeBrokenReferenceDefinitions(openApi); } diff --git a/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/mixins/SortedOpenAPIMixin31.java b/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/mixins/SortedOpenAPIMixin31.java index bdc8dd369..8c7b53311 100644 --- a/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/mixins/SortedOpenAPIMixin31.java +++ b/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/mixins/SortedOpenAPIMixin31.java @@ -42,7 +42,7 @@ * * @author bnasslashen */ -@JsonPropertyOrder(value = { "openapi", "info", "externalDocs", "servers", "security", "tags", "paths", "components", "webhooks" }, alphabetic = true) +@JsonPropertyOrder(value = {"openapi", "info", "externalDocs", "servers", "security", "tags", "paths", "components", "webhooks"}, alphabetic = true) public interface SortedOpenAPIMixin31 { /** @@ -71,5 +71,4 @@ public interface SortedOpenAPIMixin31 { */ @JsonSerialize(using = PathsSerializer.class) Paths getPaths(); - } \ No newline at end of file diff --git a/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/mixins/SortedSchemaMixin31.java b/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/mixins/SortedSchemaMixin31.java index 55595e81c..a7f820a71 100644 --- a/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/mixins/SortedSchemaMixin31.java +++ b/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/mixins/SortedSchemaMixin31.java @@ -36,13 +36,15 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import io.swagger.v3.core.jackson.mixin.Schema31Mixin; /** * The interface Sorted schema mixin 31. * * @author bnasslashen */ -@JsonPropertyOrder(value = { "type", "format" }, alphabetic = true) +@JsonPropertyOrder(value = {"type", "format", "if", "then", "else"}, alphabetic = true) public interface SortedSchemaMixin31 { /** @@ -116,6 +118,7 @@ public interface SortedSchemaMixin31 { * @return the types */ @JsonProperty("type") + @JsonSerialize(using = Schema31Mixin.TypeSerializer.class) Set getTypes(); /** @@ -140,7 +143,7 @@ public interface SortedSchemaMixin31 { * * @return the example */ - @JsonInclude(JsonInclude.Include.CUSTOM) + @JsonInclude(value = JsonInclude.Include.NON_NULL) Object getExample(); /** @@ -151,4 +154,12 @@ public interface SortedSchemaMixin31 { @JsonIgnore Object getJsonSchemaImpl(); + /** + * Gets boolean schema value. + * + * @return the boolean schema value + */ + @JsonIgnore + Boolean getBooleanSchemaValue(); + } \ No newline at end of file diff --git a/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/providers/ObjectMapperProvider.java b/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/providers/ObjectMapperProvider.java index f5823daf3..1b5f8eeb9 100644 --- a/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/providers/ObjectMapperProvider.java +++ b/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/providers/ObjectMapperProvider.java @@ -58,12 +58,18 @@ public class ObjectMapperProvider extends ObjectMapperFactory { */ private final ObjectMapper yamlMapper; + /** + * The Spring doc config properties. + */ + private final SpringDocConfigProperties springDocConfigProperties; + /** * Instantiates a new Spring doc object mapper. * * @param springDocConfigProperties the spring doc config properties */ public ObjectMapperProvider(SpringDocConfigProperties springDocConfigProperties) { + this.springDocConfigProperties = springDocConfigProperties; OpenApiVersion openApiVersion = springDocConfigProperties.getApiDocs().getVersion(); if (openApiVersion == OpenApiVersion.OPENAPI_3_1) { jsonMapper = Json31.mapper(); @@ -132,4 +138,12 @@ public ObjectMapper yamlMapper() { return yamlMapper; } + /** + * Is openapi 31 boolean. + * + * @return the boolean + */ + public boolean isOpenapi31() { + return springDocConfigProperties.isOpenapi31(); + } } 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 442344d87..c0a19ed07 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 @@ -302,7 +302,7 @@ public Operation build(HandlerMethod handlerMethod, RequestMethod requestMethod, for (MethodParameter methodParameter : parameters) { // check if query param - Parameter parameter = null; + Parameter parameter; io.swagger.v3.oas.annotations.Parameter parameterDoc = AnnotatedElementUtils.findMergedAnnotation( AnnotatedElementUtils.forAnnotations(methodParameter.getParameterAnnotations()), io.swagger.v3.oas.annotations.Parameter.class); diff --git a/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/service/GenericParameterService.java b/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/service/GenericParameterService.java index f605afa41..f29c91198 100644 --- a/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/service/GenericParameterService.java +++ b/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/service/GenericParameterService.java @@ -21,7 +21,7 @@ * * * * * * * * * - * + * */ package org.springdoc.core.service; @@ -53,7 +53,6 @@ import io.swagger.v3.oas.annotations.media.Schema.RequiredMode; import io.swagger.v3.oas.models.Components; import io.swagger.v3.oas.models.examples.Example; -import io.swagger.v3.oas.models.media.ArraySchema; import io.swagger.v3.oas.models.media.Content; import io.swagger.v3.oas.models.media.FileSchema; import io.swagger.v3.oas.models.media.ObjectSchema; @@ -74,6 +73,7 @@ import org.springdoc.core.utils.Constants; import org.springdoc.core.utils.PropertyResolverUtils; import org.springdoc.core.utils.SpringDocAnnotationsUtils; +import org.springdoc.core.utils.SpringDocUtils; import org.springframework.beans.factory.config.BeanExpressionContext; import org.springframework.beans.factory.config.BeanExpressionResolver; @@ -89,6 +89,7 @@ import static org.springdoc.core.utils.Constants.DOT; import static org.springdoc.core.utils.SpringDocUtils.getParameterAnnotations; +import static org.springdoc.core.utils.SpringDocUtils.handleSchemaTypes; /** * The type Generic parameter builder. @@ -299,6 +300,8 @@ public Parameter buildParameterFromDoc(io.swagger.v3.oas.annotations.Parameter p if (parameterDoc.content().length > 0) { Optional optionalContent = AnnotationsUtils.getContent(parameterDoc.content(), null, null, null, components, jsonView, propertyResolverUtils.isOpenapi31()); + if (propertyResolverUtils.isOpenapi31()) + optionalContent.ifPresent(SpringDocUtils::handleSchemaTypes); optionalContent.ifPresent(parameter::setContent); } else @@ -350,6 +353,8 @@ private void setSchema(io.swagger.v3.oas.annotations.Parameter parameterDoc, Com schema.setDefault(defaultValue); } } + if (isOpenapi31()) + handleSchemaTypes(schema); parameter.setSchema(schema); } } @@ -427,7 +432,7 @@ private Schema calculateRequestBodySchema(Components components, ParameterInfo p requestBodyInfo.getMergedSchema().addProperty(paramName, schemaN); schemaN = requestBodyInfo.getMergedSchema(); } - else if (parameterInfo.isRequestPart() || schemaN instanceof FileSchema || schemaN instanceof ArraySchema && ((ArraySchema) schemaN).getItems() instanceof FileSchema) { + else if (parameterInfo.isRequestPart() || schemaN instanceof FileSchema || (schemaN!=null && schemaN.getItems() instanceof FileSchema)) { schemaN = new ObjectSchema().addProperty(paramName, schemaN); requestBodyInfo.setMergedSchema(schemaN); } @@ -470,7 +475,7 @@ private void setExamples(io.swagger.v3.oas.annotations.Parameter parameterDoc, P * @param parameter the parameter * @param locale the locale */ - private void setExtensions(io.swagger.v3.oas.annotations.Parameter parameterDoc, Parameter parameter, Locale locale) { + private void setExtensions(io.swagger.v3.oas.annotations.Parameter parameterDoc, Parameter parameter, Locale locale) { if (parameterDoc.extensions().length > 0) { Map extensionMap = AnnotationsUtils.getExtensions(propertyResolverUtils.isOpenapi31(), parameterDoc.extensions()); if (propertyResolverUtils.isResolveExtensionsProperties()) { @@ -537,7 +542,7 @@ private boolean isExplodable(io.swagger.v3.oas.annotations.Parameter p) { * @return the boolean */ public boolean isFile(MethodParameter methodParameter) { - if (methodParameter.getGenericParameterType() instanceof ParameterizedType ) { + if (methodParameter.getGenericParameterType() instanceof ParameterizedType) { ParameterizedType parameterizedType = (ParameterizedType) methodParameter.getGenericParameterType(); return isFile(parameterizedType); } diff --git a/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/service/OpenAPIService.java b/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/service/OpenAPIService.java index 858238d6c..596e61395 100644 --- a/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/service/OpenAPIService.java +++ b/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/service/OpenAPIService.java @@ -61,7 +61,6 @@ import io.swagger.v3.oas.models.info.Contact; import io.swagger.v3.oas.models.info.Info; import io.swagger.v3.oas.models.info.License; -import io.swagger.v3.oas.models.media.ArraySchema; import io.swagger.v3.oas.models.media.Schema; import io.swagger.v3.oas.models.security.SecurityScheme; import io.swagger.v3.oas.models.servers.Server; @@ -477,15 +476,14 @@ public Schema resolveProperties(Schema schema, Locale locale) { if (!CollectionUtils.isEmpty(properties)) { LinkedHashMap resolvedSchemas = properties.entrySet().stream().map(es -> { es.setValue(resolveProperties(es.getValue(), locale)); - if (es.getValue() instanceof ArraySchema arraySchema) { - resolveProperties(arraySchema.getItems(), locale); + if (es.getValue().getItems() !=null ) { + resolveProperties(es.getValue().getItems(), locale); } return es; }).collect(Collectors.toMap(Entry::getKey, Entry::getValue, (e1, e2) -> e2, LinkedHashMap::new)); schema.setProperties(resolvedSchemas); } - return schema; } @@ -606,12 +604,14 @@ public Webhooks[] getWebhooks() { * @param locale the locale */ private void buildOpenAPIWithOpenAPIDefinition(OpenAPI openAPI, OpenAPIDefinition apiDef, Locale locale) { + boolean isOpenapi3 = propertyResolverUtils.isOpenapi31(); + Map extensions = AnnotationsUtils.getExtensions(isOpenapi3, apiDef.info().extensions()); // info - AnnotationsUtils.getInfo(apiDef.info(), propertyResolverUtils.isOpenapi31()).map(info -> resolveProperties(info, locale)).ifPresent(openAPI::setInfo); + AnnotationsUtils.getInfo(apiDef.info(),true).map(info -> resolveProperties(info, extensions, locale)).ifPresent(openAPI::setInfo); // OpenApiDefinition security requirements securityParser.getSecurityRequirements(apiDef.security()).ifPresent(openAPI::setSecurity); // OpenApiDefinition external docs - AnnotationsUtils.getExternalDocumentation(apiDef.externalDocs(), propertyResolverUtils.isOpenapi31()).ifPresent(openAPI::setExternalDocs); + AnnotationsUtils.getExternalDocumentation(apiDef.externalDocs(), isOpenapi3).ifPresent(openAPI::setExternalDocs); // OpenApiDefinition tags AnnotationsUtils.getTags(apiDef.tags(), false).ifPresent(tags -> openAPI.setTags(new ArrayList<>(tags))); // OpenApiDefinition servers @@ -623,7 +623,7 @@ private void buildOpenAPIWithOpenAPIDefinition(OpenAPI openAPI, OpenAPIDefinitio ); // OpenApiDefinition extensions if (apiDef.extensions().length > 0) { - openAPI.setExtensions(AnnotationsUtils.getExtensions(propertyResolverUtils.isOpenapi31(), apiDef.extensions())); + openAPI.setExtensions(AnnotationsUtils.getExtensions(isOpenapi3, apiDef.extensions())); } } @@ -647,11 +647,12 @@ private List resolveProperties(List servers, Locale locale) { /** * Resolve properties info. * - * @param info the info - * @param locale the locale + * @param info the info + * @param extensions + * @param locale the locale * @return the info */ - private Info resolveProperties(Info info, Locale locale) { + private Info resolveProperties(Info info, Map extensions, Locale locale) { resolveProperty(info::getTitle, info::title, propertyResolverUtils, locale); resolveProperty(info::getDescription, info::description, propertyResolverUtils, locale); resolveProperty(info::getVersion, info::version, propertyResolverUtils, locale); @@ -670,9 +671,12 @@ private Info resolveProperties(Info info, Locale locale) { resolveProperty(contact::getUrl, contact::url, propertyResolverUtils, locale); } - if (propertyResolverUtils.isResolveExtensionsProperties()) { - Map extensionsResolved = propertyResolverUtils.resolveExtensions(locale, info.getExtensions()); - info.setExtensions(extensionsResolved); + if (propertyResolverUtils.isResolveExtensionsProperties() && extensions != null) { + Map extensionsResolved = propertyResolverUtils.resolveExtensions(locale, extensions); + if(propertyResolverUtils.isOpenapi31()) + extensionsResolved.forEach(info::addExtension31); + else + info.setExtensions(extensionsResolved); } return info; 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 faed6bba9..d9b151cb5 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 @@ -57,6 +57,7 @@ import io.swagger.v3.oas.models.media.ComposedSchema; import io.swagger.v3.oas.models.media.Content; import io.swagger.v3.oas.models.media.MediaType; +import io.swagger.v3.oas.models.media.ObjectSchema; import io.swagger.v3.oas.models.media.Schema; import io.swagger.v3.oas.models.media.StringSchema; import org.apache.commons.lang3.ArrayUtils; @@ -69,6 +70,8 @@ import org.springframework.util.CollectionUtils; import org.springframework.web.bind.annotation.RequestAttribute; +import static org.springdoc.core.utils.SpringDocUtils.handleSchemaTypes; + /** * The type Spring doc annotations utils. * @@ -131,7 +134,8 @@ public static Schema extractSchema(Components components, Type returnType, JsonV try { resolvedSchema = ModelConverters.getInstance(openapi31) .resolveAsResolvedSchema( - new AnnotatedType(returnType).resolveAsRef(true).jsonViewAnnotation(jsonView).ctxAnnotations(annotations)); + new AnnotatedType(returnType) + .resolveAsRef(true).jsonViewAnnotation(jsonView).ctxAnnotations(annotations)); } catch (Exception e) { LOGGER.warn(Constants.GRACEFUL_EXCEPTION_OCCURRED, e); @@ -168,13 +172,16 @@ else if (componentSchemas.containsKey(entry.getKey()) && schemaMap.containsKey(e components.setSchemas(componentSchemas); } if (resolvedSchema.schema != null) { - schemaN = new Schema(); + schemaN = new Schema(specVersion); if (StringUtils.isNotBlank(resolvedSchema.schema.getName())) schemaN.set$ref(COMPONENTS_REF + resolvedSchema.schema.getName()); else schemaN = resolvedSchema.schema; } } + if(openapi31) + handleSchemaTypes(schemaN); + return schemaN; } @@ -215,9 +222,10 @@ public static Optional getContent(io.swagger.v3.oas.annotations.media.C } } - if (content.size() == 0 && annotationContents.length != 1) { + if (content.isEmpty() && annotationContents.length != 1) { return Optional.empty(); } + handleSchemaTypes(content); return Optional.of(content); } @@ -386,7 +394,7 @@ private static MediaType getMediaType(Schema schema, Components components, Json getSchema(annotationContent, components, jsonViewAnnotation, openapi31).ifPresent(mediaType::setSchema); if (annotationContent.schemaProperties().length > 0) { if (mediaType.getSchema() == null) { - mediaType.schema(new Schema().type("object")); + mediaType.schema(new ObjectSchema()); } Schema oSchema = mediaType.getSchema(); for (SchemaProperty sp : annotationContent.schemaProperties()) { diff --git a/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/utils/SpringDocDataRestUtils.java b/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/utils/SpringDocDataRestUtils.java index 9306a6c3f..636ccc229 100644 --- a/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/utils/SpringDocDataRestUtils.java +++ b/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/utils/SpringDocDataRestUtils.java @@ -21,7 +21,7 @@ * * * * * * * * * - * + * */ package org.springdoc.core.utils; @@ -43,8 +43,8 @@ import io.swagger.v3.oas.models.PathItem; import io.swagger.v3.oas.models.SpecVersion; import io.swagger.v3.oas.models.media.ArraySchema; -import io.swagger.v3.oas.models.media.ComposedSchema; import io.swagger.v3.oas.models.media.Content; +import io.swagger.v3.oas.models.media.JsonSchema; import io.swagger.v3.oas.models.media.MediaType; import io.swagger.v3.oas.models.media.Schema; import io.swagger.v3.oas.models.media.StringSchema; @@ -65,6 +65,8 @@ import org.springframework.hateoas.server.LinkRelationProvider; import org.springframework.util.CollectionUtils; +import static org.springdoc.core.utils.SpringDocUtils.isComposedSchema; + /** * The class Spring doc data rest utils. * @@ -191,8 +193,8 @@ private void updateRequestBody(OpenAPI openAPI, RequestBody requestBody, boolean if (entityInoMap.containsKey(key)) updateRequestBodySchema(key, schema, openAPI.getComponents(), openapi31); } - else if (schema instanceof ComposedSchema) { - updateComposedSchema((ComposedSchema) schema, REQUEST_BODY, openAPI.getComponents(), openapi31); + else if (isComposedSchema(schema)) { + updateComposedSchema(schema.getAllOf(), schema.getOneOf(), REQUEST_BODY, openAPI.getComponents(), openapi31); } }); } @@ -223,8 +225,8 @@ private void updateRequestBodySchema(String className, Schema schema, Components referencedSchema.setName(key + REQUEST_BODY); Map properties = referencedSchema.getProperties(); updateRequestBodySchemaProperties(key, referencedSchema, properties); - if (referencedSchema instanceof ComposedSchema) - updateComposedSchema((ComposedSchema) referencedSchema, REQUEST_BODY, components, openapi31); + if (isComposedSchema(referencedSchema)) + updateComposedSchema(referencedSchema.getAllOf(), referencedSchema.getOneOf(), REQUEST_BODY, components, openapi31); }); } } @@ -244,10 +246,11 @@ private void updateRequestBodySchemaProperties(String key, Schema referencedSche Entry entry = it.next(); String propId = entry.getKey(); if (entityInoMap.containsKey(key) && entityInoMap.get(key).getAssociationsFields().contains(propId)) { - if (entry.getValue() instanceof ArraySchema) + if (entry.getValue().getItems()!=null) referencedSchema.addProperty(propId, new ArraySchema().items(new StringSchema())); else - referencedSchema.addProperty(propId, new StringSchema()); + referencedSchema.addProperty(propId, new StringSchema()); { + } } } } @@ -290,9 +293,18 @@ else if (EMBEDDED.equals(propId)) { */ private void updateResponseSchemaEmbedded(Components components, EntityInfo entityInfo, Entry entry, boolean openapi31) { String entityClassName = linkRelationProvider.getCollectionResourceRelFor(entityInfo.getDomainType()).value(); - ArraySchema arraySchema = (ArraySchema) entry.getValue().getProperties().get(entityClassName); - if (arraySchema != null) { - Schema itemsSchema = arraySchema.getItems(); + Schema itemsSchema = null; + if (openapi31) { + JsonSchema jsonSchema = (JsonSchema) entry.getValue().getProperties().get(entityClassName); + if (jsonSchema != null) + itemsSchema = jsonSchema.getItems(); + } + else { + ArraySchema arraySchema = (ArraySchema) entry.getValue().getProperties().get(entityClassName); + if (arraySchema != null) + itemsSchema = arraySchema.getItems(); + } + if (itemsSchema != null) { Set entitiesNames = entityInoMap.keySet(); if (itemsSchema.get$ref() != null && !itemsSchema.get$ref().endsWith(RESPONSE)) { String key = itemsSchema.get$ref().substring(Components.COMPONENTS_SCHEMAS_REF.length()); @@ -303,8 +315,8 @@ private void updateResponseSchemaEmbedded(Components components, EntityInfo enti updateResponseSchema(key, components.getSchemas().get(key + RESPONSE), components, openapi31); } } - else if (itemsSchema instanceof ComposedSchema) { - updateComposedSchema((ComposedSchema) itemsSchema, RESPONSE, components, openapi31); + else if (isComposedSchema(itemsSchema)) { + updateComposedSchema(itemsSchema.getAllOf(), itemsSchema.getOneOf(), RESPONSE, components, openapi31); } } } @@ -354,8 +366,8 @@ private void addSchemas(Components components, String key, Schema referencedSche } } } - if (referencedSchema instanceof ComposedSchema) { - updateComposedSchema((ComposedSchema) referencedSchema, RESPONSE, null, openapi31); + if (isComposedSchema(referencedSchema)) { + updateComposedSchema(referencedSchema.getAllOf(), referencedSchema.getOneOf(), RESPONSE, null, openapi31); } components.addSchemas(key + RESPONSE, referencedSchema); } @@ -363,18 +375,18 @@ private void addSchemas(Components components, String key, Schema referencedSche /** * Update composed schema. * - * @param referencedSchema the referenced schema - * @param suffix the suffix - * @param components the components - * @param openapi31 the openapi 31 + * @param allOf the all of + * @param oneOf the one of + * @param suffix the suffix + * @param components the components + * @param openapi31 the openapi 31 */ - private void updateComposedSchema(ComposedSchema referencedSchema, String suffix, Components components, boolean openapi31) { + private void updateComposedSchema(List allOf, List oneOf, String suffix, Components components, boolean openapi31) { //Update the allOf - ComposedSchema composedSchema = referencedSchema; - List allOfSchemas = composedSchema.getAllOf(); + List allOfSchemas = allOf; updateKey(allOfSchemas, suffix, components, openapi31); //Update the oneOf - List oneOfSchemas = composedSchema.getOneOf(); + List oneOfSchemas = oneOf; updateKey(oneOfSchemas, suffix, components, openapi31); } diff --git a/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/utils/SpringDocUtils.java b/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/utils/SpringDocUtils.java index a41acc816..7b6a8f718 100644 --- a/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/utils/SpringDocUtils.java +++ b/springdoc-openapi-starter-common/src/main/java/org/springdoc/core/utils/SpringDocUtils.java @@ -31,6 +31,8 @@ import java.util.List; import java.util.function.Predicate; +import io.swagger.v3.core.converter.AnnotatedType; +import io.swagger.v3.oas.models.media.Content; import io.swagger.v3.oas.models.media.Schema; import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.StringUtils; @@ -46,6 +48,7 @@ import org.springdoc.core.service.GenericResponseService; import org.springframework.core.MethodParameter; +import org.springframework.util.CollectionUtils; /** * The type Spring doc utils. @@ -442,5 +445,62 @@ public static Annotation[] getParameterAnnotations(MethodParameter methodParamet // Convert the list to an array and return return resultAnnotations.toArray(new Annotation[0]); } + + /** + * Gets parent type name. + * + * @param type the type + * @param cls the cls + * @return the parent type name + */ + @NotNull + public static String getParentTypeName(AnnotatedType type, Class cls) { + return cls.getSimpleName() + StringUtils.capitalize(type.getParent().getType() != null ? type.getParent().getType() : "object"); + } + + /** + * Is composed schema boolean. + * + * @param referencedSchema the referenced schema + * @return the boolean + */ + public static boolean isComposedSchema(Schema referencedSchema) { + return referencedSchema.getOneOf() != null || referencedSchema.getAllOf() != null || referencedSchema.getAnyOf() != null; + } + + /** + * Handle schema types. + * + * @param schema the schema + */ + public static void handleSchemaTypes(Schema schema) { + if (schema != null) { + if (schema.getType() != null && CollectionUtils.isEmpty(schema.getTypes())) { + schema.addType(schema.getType()); + } + else if (schema.getItems() != null && schema.getItems().getType() != null + && CollectionUtils.isEmpty(schema.getItems().getTypes())) { + schema.getItems().addType(schema.getItems().getType()); + } + if(schema.getProperties() != null){ + schema.getProperties().forEach((key, value) -> handleSchemaTypes(value)); + } + } + } + + /** + * Handle schema types. + * + * @param content the content + */ + public static void handleSchemaTypes(Content content) { + if(content !=null){ + content.values().forEach(mediaType -> { + if (mediaType.getSchema() != null) { + handleSchemaTypes(mediaType.getSchema()); + } + }); + } + } } diff --git a/springdoc-openapi-starter-webflux-api/pom.xml b/springdoc-openapi-starter-webflux-api/pom.xml index 809c66428..7c13c829b 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.1 + 2.8.2 springdoc-openapi-starter-webflux-api diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/AbstractCommonTest.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/AbstractCommonTest.java deleted file mode 100644 index 3f94f121c..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/AbstractCommonTest.java +++ /dev/null @@ -1,37 +0,0 @@ -package test.org.springdoc.api; - -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.web.reactive.AutoConfigureWebTestClient; -import org.springframework.test.context.ActiveProfiles; -import org.springframework.test.context.TestPropertySource; -import org.springframework.test.web.reactive.server.WebTestClient; - -@AutoConfigureWebTestClient(timeout = "3600000") -@ActiveProfiles("test") -@TestPropertySource(properties = "springdoc.api-docs.version=openapi_3_0" ) -public abstract class AbstractCommonTest { - - protected static final Logger LOGGER = LoggerFactory.getLogger(AbstractCommonTest.class); - - @Autowired - protected WebTestClient webTestClient; - - protected String getContent(String fileName) { - try { - Path path = Paths.get(AbstractCommonTest.class.getClassLoader().getResource(fileName).toURI()); - byte[] fileBytes = Files.readAllBytes(path); - return new String(fileBytes, StandardCharsets.UTF_8); - } - catch (Exception e) { - throw new RuntimeException("Failed to read file: " + fileName, e); - } - } -} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/AbstractSpringDocTest.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/AbstractSpringDocTest.java deleted file mode 100644 index 5bbdda803..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/AbstractSpringDocTest.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * - * * Copyright 2019-2020 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; - -import org.junit.jupiter.api.Test; -import org.springdoc.core.utils.Constants; - -import org.springframework.boot.test.autoconfigure.web.reactive.AutoConfigureWebTestClient; -import org.springframework.boot.test.autoconfigure.web.reactive.WebFluxTest; -import org.springframework.test.web.reactive.server.EntityExchangeResult; -import org.springframework.web.reactive.function.server.HandlerFunction; -import org.springframework.web.reactive.function.server.ServerResponse; - -import static org.skyscreamer.jsonassert.JSONAssert.assertEquals; - - -@WebFluxTest -@AutoConfigureWebTestClient(timeout = "3600000") -public abstract class AbstractSpringDocTest extends AbstractCommonTest { - - public static final HandlerFunction HANDLER_FUNCTION = request -> ServerResponse.ok().build(); - - protected String groupName = ""; - - - @Test - void testApp() throws Exception { - String result = null; - try { - EntityExchangeResult getResult = webTestClient.get().uri(Constants.DEFAULT_API_DOCS_URL + groupName).exchange() - .expectStatus().isOk().expectBody().returnResult(); - - result = new String(getResult.getResponseBody()); - String className = getClass().getSimpleName(); - String testNumber = className.replaceAll("[^0-9]", ""); - String expected = getContent("results/app" + testNumber + ".json"); - assertEquals(expected, result, true); - } - catch (java.lang.AssertionError e) { - LOGGER.error(result); - throw e; - } - } -} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app102/InheritedRequestParams.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app102/InheritedRequestParams.java deleted file mode 100644 index 97878ab29..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app102/InheritedRequestParams.java +++ /dev/null @@ -1,18 +0,0 @@ -package test.org.springdoc.api.app102; - -import io.swagger.v3.oas.annotations.Parameter; -import jakarta.validation.constraints.NotBlank; - -public class InheritedRequestParams extends RequestParams { - @Parameter(description = "parameter from child of RequestParams") - @NotBlank - private String childParam; - - public String getChildParam() { - return childParam; - } - - public void setChildParam(String childParam) { - this.childParam = childParam; - } -} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app102/RequestParams.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app102/RequestParams.java deleted file mode 100644 index 9c40ff49f..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app102/RequestParams.java +++ /dev/null @@ -1,122 +0,0 @@ -package test.org.springdoc.api.app102; - -import java.math.BigInteger; -import java.util.List; -import java.util.Optional; - -import io.swagger.v3.oas.annotations.Parameter; - -import org.springframework.lang.Nullable; - -public class RequestParams { - - @Parameter(description = "string parameter") - private String stringParam; - - @Deprecated - private String stringParam1; - - @Parameter(description = "string parameter2", required = true) - private String stringParam2; - - @Parameter(description = "int parameter") - private int intParam; - - private Optional intParam2; - - @Nullable - private String intParam3; - - private Nested nested; - - private List nestedList; - - public String getStringParam() { - return stringParam; - } - - public void setStringParam(String stringParam) { - this.stringParam = stringParam; - } - - public int getIntParam() { - return intParam; - } - - public void setIntParam(int intParam) { - this.intParam = intParam; - } - - public Optional getIntParam2() { - return intParam2; - } - - public void setIntParam2(Optional intParam2) { - this.intParam2 = intParam2; - } - - @Nullable - public String getIntParam3() { - return intParam3; - } - - public void setIntParam3(@Nullable String intParam3) { - this.intParam3 = intParam3; - } - - public String getStringParam1() { - return stringParam1; - } - - public void setStringParam1(String stringParam1) { - this.stringParam1 = stringParam1; - } - - public String getStringParam2() { - return stringParam2; - } - - public void setStringParam2(String stringParam2) { - this.stringParam2 = stringParam2; - } - - public Nested getNested() { - return nested; - } - - public void setNested(Nested nested) { - this.nested = nested; - } - - public List getNestedList() { - return nestedList; - } - - public void setNestedList(List nestedList) { - this.nestedList = nestedList; - } - - public static class Nested { - private String param1; - - private BigInteger param2; - - @Parameter(description = "nested string parameter") - public String getParam1() { - return param1; - } - - public void setParam1(String param1) { - this.param1 = param1; - } - - @Parameter(description = "nested BigInteger parameter") - public BigInteger getParam2() { - return param2; - } - - public void setParam2(BigInteger param2) { - this.param2 = param2; - } - } -} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app102/SpringDocApp102Test.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app102/SpringDocApp102Test.java deleted file mode 100644 index ce596b782..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app102/SpringDocApp102Test.java +++ /dev/null @@ -1,14 +0,0 @@ -package test.org.springdoc.api.app102; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.ComponentScan; - -public class SpringDocApp102Test extends AbstractSpringDocTest { - - @SpringBootApplication - @ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.app102" }) - static class SpringDocTestApp {} - -} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app102/TestController.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app102/TestController.java deleted file mode 100644 index 20ab82688..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app102/TestController.java +++ /dev/null @@ -1,15 +0,0 @@ -package test.org.springdoc.api.app102; - -import org.springdoc.core.annotations.ParameterObject; - -import org.springframework.lang.Nullable; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -@RestController -public class TestController { - @GetMapping("test") - public void getTest(@RequestParam @Nullable String param, @ParameterObject InheritedRequestParams requestParams) { - } -} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app149/HelloController.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app149/HelloController.java deleted file mode 100644 index 942e91c67..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app149/HelloController.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app149; - -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.media.Content; -import io.swagger.v3.oas.annotations.media.Schema; -import io.swagger.v3.oas.annotations.responses.ApiResponse; - -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.ResponseBody; - -/** - * To test the case a user does not use @RestController but puts @Operation on handler methods - * and wants these methods to be exposed. - * - * @author Azige - */ -@Controller -public class HelloController { - - @GetMapping("/hello") - @Operation(responses = @ApiResponse( - responseCode = "200", - description = "OK", - content = @Content(schema = @Schema(implementation = HelloMessage.class)) - )) - public String hello() { - return "forward:/message"; - } - - @GetMapping("/message") - @Operation - @ResponseBody - public HelloMessage message() { - return new HelloMessage("Lucky numbers!", 777); - } - - @GetMapping("/helloModelAndView") - @Operation(responses = @ApiResponse( - responseCode = "200", - description = "OK", - content = @Content(schema = @Schema(implementation = HelloMessage.class)) - )) - public HelloMessage helloModelAndView() { - return null; - } -} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app149/HelloMessage.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app149/HelloMessage.java deleted file mode 100644 index df05150c9..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app149/HelloMessage.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app149; - -public class HelloMessage { - public String text; - - public int number; - - public HelloMessage(String text, int number) { - this.text = text; - this.number = number; - } -} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app149/HiddenHelloController.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app149/HiddenHelloController.java deleted file mode 100644 index addf06c49..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app149/HiddenHelloController.java +++ /dev/null @@ -1,22 +0,0 @@ -package test.org.springdoc.api.app149; - -import io.swagger.v3.oas.annotations.Operation; - -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * @author bnasslahsen - */ -@RestController -@RequestMapping("/api") -public class HiddenHelloController { - - @Operation(description = "I want here some custom config") - @GetMapping("/{entity}/{id}") - public ResponseEntity getEntity() { - throw new UnsupportedOperationException("the body is not relevant now"); - } -} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app149/SpringDocApp149Test.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app149/SpringDocApp149Test.java deleted file mode 100644 index 0e4086819..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app149/SpringDocApp149Test.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app149; - -import org.springdoc.core.utils.SpringDocUtils; -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.ComponentScan; - -public class SpringDocApp149Test extends AbstractSpringDocTest { - - static { - SpringDocUtils.getConfig().addHiddenRestControllers(HiddenHelloController.class); - } - - @SpringBootApplication - @ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.app149" }) - static class SpringDocTestApp {} -} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app150/HelloRouter.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app150/HelloRouter.java deleted file mode 100644 index 0e2352158..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app150/HelloRouter.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * - * * - * * * Copyright 2019-2020 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.app150; - -import java.util.function.Consumer; -import java.util.function.Supplier; - -import org.springdoc.core.fn.builders.operation.Builder; -import org.springdoc.webflux.core.fn.SpringdocRouteBuilder; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.web.reactive.function.server.RequestPredicates; -import org.springframework.web.reactive.function.server.RouterFunction; -import org.springframework.web.reactive.function.server.RouterFunctions; -import org.springframework.web.reactive.function.server.ServerResponse; - -import static org.springframework.web.reactive.function.server.RequestPredicates.path; -import static org.springframework.web.reactive.function.server.RouterFunctions.nest; -import static test.org.springdoc.api.AbstractSpringDocTest.HANDLER_FUNCTION; - -@Configuration -public class HelloRouter { - - @Bean - RouterFunction routeSample() { - Supplier> routerFunctionSupplier = - () -> SpringdocRouteBuilder.route() - .GET("toto", HANDLER_FUNCTION, builder -> builder.operationId("get-user-groups")) - - .POST("/titi", HANDLER_FUNCTION, builder -> builder.operationId("create-user-group-special")).build(); - - Consumer operationsConsumer = builder -> { - }; - - return RouterFunctions.nest(RequestPredicates.path("/users"), nest(path("/test"), nest(path("/greeter"), - SpringdocRouteBuilder.route() - .GET(HANDLER_FUNCTION, builder -> builder.operationId("get-users")) - .POST("/special", HANDLER_FUNCTION, builder -> builder.operationId("create-user-special")) - .nest(path("/groups"), routerFunctionSupplier, operationsConsumer) - .nest(path("/groups2"), routerFunctionSupplier, operationsConsumer) - .nest(path("/greeter3").or(path("/greeter4")), routerFunctionSupplier, operationsConsumer) - .build()))); - - } - -} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app150/SpringDocApp150Test.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app150/SpringDocApp150Test.java deleted file mode 100644 index 8ed30cedf..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app150/SpringDocApp150Test.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * - * * - * * * Copyright 2019-2020 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.app150; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.ComponentScan; - -public class SpringDocApp150Test extends AbstractSpringDocTest { - - @SpringBootApplication - @ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.app150" }) - static class SpringDocTestApp {} -} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app151/HelloRouter.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app151/HelloRouter.java deleted file mode 100644 index 8c47adf95..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app151/HelloRouter.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * - * * - * * * Copyright 2019-2020 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.app151; - -import java.util.function.Consumer; -import java.util.function.Supplier; - -import org.springdoc.core.fn.builders.operation.Builder; -import org.springdoc.webflux.core.fn.SpringdocRouteBuilder; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.web.reactive.function.server.RequestPredicates; -import org.springframework.web.reactive.function.server.RouterFunction; -import org.springframework.web.reactive.function.server.RouterFunctions; -import org.springframework.web.reactive.function.server.ServerResponse; - -import static org.springframework.web.reactive.function.server.RequestPredicates.path; -import static org.springframework.web.reactive.function.server.RouterFunctions.nest; -import static test.org.springdoc.api.AbstractSpringDocTest.HANDLER_FUNCTION; - -@Configuration -public class HelloRouter { - - @Bean - RouterFunction routeSample() { - Supplier> routerFunctionSupplier = - () -> SpringdocRouteBuilder.route() - .GET("toto", HANDLER_FUNCTION, builder -> builder.operationId("get-user-groups")) - - .POST("/titi", HANDLER_FUNCTION, builder -> builder.operationId("create-user-group-special")).build(); - - Consumer operationsConsumer = builder -> { - }; - - return RouterFunctions.nest(RequestPredicates.path("/users"), nest(path("/test"), nest(path("/greeter"), - SpringdocRouteBuilder.route() - .GET("", HANDLER_FUNCTION, builder -> builder.operationId("get-users")) - .POST("/special", HANDLER_FUNCTION, builder -> builder.operationId("create-user-special")) - .nest(path("/groups"), routerFunctionSupplier, operationsConsumer) - .nest(path("/groups2"), routerFunctionSupplier, operationsConsumer) - .nest(path("/greeter3").or(path("/greeter4")), routerFunctionSupplier, operationsConsumer) - .build()))); - - } - -} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app151/SpringDocApp151Test.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app151/SpringDocApp151Test.java deleted file mode 100644 index 0a089de8b..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app151/SpringDocApp151Test.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * - * * - * * * Copyright 2019-2020 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.app151; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.ComponentScan; - -public class SpringDocApp151Test extends AbstractSpringDocTest { - - @SpringBootApplication - @ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.app151" }) - static class SpringDocTestApp {} -} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app152/HelloController.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app152/HelloController.java deleted file mode 100644 index 3a16a637e..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app152/HelloController.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * - * * Copyright 2019-2021 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.app152; - -import org.reactivestreams.Publisher; -import org.springdoc.core.models.GroupedOpenApi; -import reactor.core.publisher.Mono; - -import org.springframework.context.annotation.Bean; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -@RestController -public class HelloController { - - @GetMapping("/persons") - public Publisher persons() { - return Mono.just("OK"); - } - - @Bean - public GroupedOpenApi userOpenApi() { - return GroupedOpenApi.builder() - .group("users") - .packagesToScan("test.org.springdoc.api.app152") - .build(); - } -} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app152/SpringDocApp152Test.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app152/SpringDocApp152Test.java deleted file mode 100644 index 3e7267632..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app152/SpringDocApp152Test.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * - * * - * * * Copyright 2019-2021 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.app152; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.ComponentScan; - -public class SpringDocApp152Test extends AbstractSpringDocTest { - - @SpringBootApplication - @ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.app152" }) - static class SpringDocTestApp {} -} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app153/DefaultRequestMappingHandlerMapping.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app153/DefaultRequestMappingHandlerMapping.java deleted file mode 100644 index a665a4e53..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app153/DefaultRequestMappingHandlerMapping.java +++ /dev/null @@ -1,42 +0,0 @@ -package test.org.springdoc.api.app153; - -import org.springframework.expression.ParserContext; -import org.springframework.expression.spel.standard.SpelExpressionParser; -import org.springframework.expression.spel.support.StandardEvaluationContext; -import org.springframework.util.StringValueResolver; -import org.springframework.web.reactive.result.method.annotation.RequestMappingHandlerMapping; - -public class DefaultRequestMappingHandlerMapping extends RequestMappingHandlerMapping { - - private static final SpelExpressionParser PARSER = new SpelExpressionParser(); - - private static ThreadLocal handlerHolder = new ThreadLocal<>(); - - @Override - public void setEmbeddedValueResolver(StringValueResolver resolver) { - super.setEmbeddedValueResolver(new StringValueResolver() { - @Override - public String resolveStringValue(String strVal) { - Object handler = handlerHolder.get(); - if (handler != null) { - strVal = String.valueOf(PARSER.parseExpression(strVal, ParserContext.TEMPLATE_EXPRESSION) - .getValue(new StandardEvaluationContext(handler))); - } - if (resolver != null) { - strVal = resolver.resolveStringValue(strVal); - } - return strVal; - } - }); - } - - @Override - protected void detectHandlerMethods(Object handler) { - Object handlerObject = (handler instanceof String ? obtainApplicationContext().getBean((String) handler) - : handler); - handlerHolder.set(handlerObject); - super.detectHandlerMethods(handler); - handlerHolder.remove(); - } - -} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app153/DefaultWebFluxRegistrations.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app153/DefaultWebFluxRegistrations.java deleted file mode 100644 index 32de6f885..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app153/DefaultWebFluxRegistrations.java +++ /dev/null @@ -1,15 +0,0 @@ -package test.org.springdoc.api.app153; - -import org.springframework.boot.autoconfigure.web.reactive.WebFluxRegistrations; -import org.springframework.stereotype.Component; -import org.springframework.web.reactive.result.method.annotation.RequestMappingHandlerMapping; - -@Component -public class DefaultWebFluxRegistrations implements WebFluxRegistrations { - - @Override - public RequestMappingHandlerMapping getRequestMappingHandlerMapping() { - return new DefaultRequestMappingHandlerMapping(); - } - -} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app153/SpringDocApp153Test.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app153/SpringDocApp153Test.java deleted file mode 100644 index d6a2a9f42..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app153/SpringDocApp153Test.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * - * * - * * * Copyright 2019-2021 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.app153; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.ComponentScan; - -public class SpringDocApp153Test extends AbstractSpringDocTest { - - @SpringBootApplication - @ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.app153" }) - static class SpringDocTestApp {} -} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app153/TestController.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app153/TestController.java deleted file mode 100644 index e7ce82d1f..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app153/TestController.java +++ /dev/null @@ -1,13 +0,0 @@ -package test.org.springdoc.api.app153; - -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RestController; - -@RestController -public class TestController { - - @PostMapping("/echo") - public String echo(String content) { - return content; - } -} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app184/HelloController.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app184/HelloController.java deleted file mode 100644 index 30c0effa2..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app184/HelloController.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * - * * 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.app184; - - -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -@RestController -public class HelloController { - - @GetMapping("/globalBeanFiltered") - public String globalBeanFiltered() { - return "globalBeanFiltered"; - } - - @GetMapping("/beanFiltered") - public String beanFiltered() { - return "beanFiltered"; - } - - @GetMapping("/group1Filtered") - public String group1Filtered() { - return "group1Filtered"; - } - - @GetMapping("/group2Filtered") - public String group2Filtered() { - return "group2Filtered"; - } - - @GetMapping("/group3Filtered") - public String group3Filtered() { - return "group3Filtered"; - } - -} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app184/SpringDocApp184Test.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app184/SpringDocApp184Test.java deleted file mode 100644 index a666d7e51..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app184/SpringDocApp184Test.java +++ /dev/null @@ -1,126 +0,0 @@ -/* - * - * * - * * * Copyright 2019-2020 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.app184; - -import java.util.Objects; - -import io.swagger.v3.oas.models.parameters.HeaderParameter; -import io.swagger.v3.oas.models.servers.Server; -import org.junit.jupiter.api.Test; -import org.springdoc.core.customizers.GlobalOpenApiCustomizer; -import org.springdoc.core.customizers.GlobalOperationCustomizer; -import org.springdoc.core.customizers.OpenApiCustomizer; -import org.springdoc.core.customizers.OperationCustomizer; -import org.springdoc.core.filters.GlobalOpenApiMethodFilter; -import org.springdoc.core.filters.OpenApiMethodFilter; -import org.springdoc.core.models.GroupedOpenApi; -import org.springdoc.core.utils.Constants; -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.test.context.TestPropertySource; - -@TestPropertySource(properties = { - "springdoc.group-configs[0].group=group1", - "springdoc.group-configs[0].paths-to-exclude=/group1Filtered", -}) -public class SpringDocApp184Test extends AbstractSpringDocTest { - - @Test - void testGroup1() throws Exception { - webTestClient.get().uri(Constants.DEFAULT_API_DOCS_URL + "/group1").exchange() - .expectStatus().isOk() - .expectBody().json(getContent("results/app184-1.json"), true); - } - - @Test - void testGroup2() throws Exception { - webTestClient.get().uri(Constants.DEFAULT_API_DOCS_URL + "/group2").exchange() - .expectStatus().isOk() - .expectBody().json(getContent("results/app184-2.json"), true); - } - - @Test - void testGroup3() throws Exception { - webTestClient.get().uri(Constants.DEFAULT_API_DOCS_URL + "/group3").exchange() - .expectStatus().isOk() - .expectBody().json(getContent("results/app184-3.json"), true); - } - - @SpringBootApplication - @ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.app184" }) - static class SpringDocTestApp { - - @Bean - public GlobalOpenApiCustomizer addUrlGlobalBean() { - return openApi -> openApi.getServers().add(new Server().url("urlGlobalBean")); - } - - @Bean - public OpenApiCustomizer addUrlBean() { - return openApi -> openApi.getServers().add(new Server().url("urlBean")); - } - - @Bean - public GlobalOperationCustomizer addHeaderGlobaBeanl() { - return (operation, handlerMethod) -> operation.addParametersItem(new HeaderParameter().name("headerGlobalBean")); - } - - @Bean - public OperationCustomizer addHeaderBean() { - return (operation, handlerMethod) -> operation.addParametersItem(new HeaderParameter().name("headerBean")); - } - - @Bean - public GlobalOpenApiMethodFilter globalFilterBean() { - return method -> !Objects.equals(method.getName(), "globalBeanFiltered"); - } - - @Bean - public OpenApiMethodFilter filterBean() { - return method -> !Objects.equals(method.getName(), "beanFiltered"); - } - - @Bean - public GroupedOpenApi group2() { - return GroupedOpenApi.builder() - .group("group2") - .addOpenApiCustomizer(openApi -> openApi.getServers().add(new Server().url("urlGroup2"))) - .addOperationCustomizer((operation, handlerMethod) -> operation.addParametersItem(new HeaderParameter().name("headerGroup2"))) - .addOpenApiMethodFilter(method -> !Objects.equals(method.getName(), "group2Filtered")) - .build(); - } - - @Bean - public GroupedOpenApi group3() { - return GroupedOpenApi.builder() - .group("group3") - .addOpenApiCustomizer(openApi -> openApi.getServers().add(new Server().url("urlGroup3"))) - .addOperationCustomizer((operation, handlerMethod) -> operation.addParametersItem(new HeaderParameter().name("headerGroup3"))) - .addOpenApiMethodFilter(method -> !Objects.equals(method.getName(), "group3Filtered")) - .build(); - } - - } - -} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app187/DuplicatedPathController.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app187/DuplicatedPathController.java deleted file mode 100644 index a9df9a8dd..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app187/DuplicatedPathController.java +++ /dev/null @@ -1,19 +0,0 @@ -package test.org.springdoc.api.app187; - -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -@RestController -public class DuplicatedPathController { - - @GetMapping("/duplicated") - public String duplicated1() { - return "globalBeanFiltered"; - } - - @GetMapping(value = "/duplicated", params = "filter=params") - public String duplicated2() { - return "beanFiltered"; - } - -} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app187/SpringDocApp187Test.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app187/SpringDocApp187Test.java deleted file mode 100644 index c077434bb..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app187/SpringDocApp187Test.java +++ /dev/null @@ -1,36 +0,0 @@ -package test.org.springdoc.api.app187; - -import org.junit.jupiter.api.Test; -import org.springdoc.core.customizers.RouterOperationCustomizer; -import org.springdoc.core.utils.Constants; -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; - -class SpringDocApp187Test extends AbstractSpringDocTest { - - @Test - void testAddRouterOperationCustomizerBean() { - webTestClient.get().uri(Constants.DEFAULT_API_DOCS_URL).exchange() - .expectStatus().isOk() - .expectBody().json(getContent("results/app187.json"), true); - } - - @SpringBootApplication - @ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.app187" }) - static class SpringDocTestApp { - - @Bean - public RouterOperationCustomizer addRouterOperationCustomizer() { - return (routerOperation, handlerMethod) -> { - if (routerOperation.getParams().length > 0) { - routerOperation.setPath(routerOperation.getPath() + "?" + String.join("&", routerOperation.getParams())); - } - return routerOperation; - }; - } - } - -} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app188/OrderDemo.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app188/OrderDemo.java deleted file mode 100644 index 638f9c0e9..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app188/OrderDemo.java +++ /dev/null @@ -1,41 +0,0 @@ -package test.org.springdoc.api.app188; - -import io.swagger.v3.oas.models.OpenAPI; -import io.swagger.v3.oas.models.tags.Tag; -import org.springdoc.core.customizers.GlobalOpenApiCustomizer; -import org.springdoc.core.customizers.OpenApiCustomizer; - -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - - -public class OrderDemo { - - public static class Customizer2 implements OpenApiCustomizer, GlobalOpenApiCustomizer { - public void customise(OpenAPI openApi) { - openApi.addTagsItem(new Tag().name("2")); - } - } - - public static class Customizer3 implements OpenApiCustomizer, GlobalOpenApiCustomizer { - public void customise(OpenAPI openApi) { - openApi.addTagsItem(new Tag().name("3")); - } - } - - public static class Customizer1 implements OpenApiCustomizer, GlobalOpenApiCustomizer { - public void customise(OpenAPI openApi) { - openApi.addTagsItem(new Tag().name("1")); - } - } - - @RestController - public static class MyController { - - @GetMapping("/test") - public String testingMethod() { - return "foo"; - } - } - -} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app188/SpringDocApp188Test.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app188/SpringDocApp188Test.java deleted file mode 100644 index 295640c02..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app188/SpringDocApp188Test.java +++ /dev/null @@ -1,31 +0,0 @@ -package test.org.springdoc.api.app188; - -import org.junit.jupiter.api.Test; -import org.springdoc.core.utils.Constants; -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Import; -import org.springframework.test.context.TestPropertySource; - -@TestPropertySource(properties = { "springdoc.group-configs[0].group=mygroup", "springdoc.group-configs[0].paths-to-match=/test" }) -class SpringDocApp188Test extends AbstractSpringDocTest { - - @Test - void testApp1() { - webTestClient.get().uri(Constants.DEFAULT_API_DOCS_URL +"/mygroup").exchange() - .expectStatus().isOk() - .expectBody().json(getContent("results/app188.json"), true); - } - - @SpringBootApplication - @Import({ - OrderDemo.Customizer1.class, - OrderDemo.Customizer2.class, - OrderDemo.Customizer3.class, - }) - @ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.app188" }) - static class SpringDocTestApp {} - -} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app189/HelloController.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app189/HelloController.java deleted file mode 100644 index a147a697f..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app189/HelloController.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app189; - -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.media.Content; -import io.swagger.v3.oas.annotations.responses.ApiResponse; -import io.swagger.v3.oas.annotations.responses.ApiResponses; -import reactor.core.publisher.Mono; - -import org.springframework.http.MediaType; -import org.springframework.http.codec.multipart.FilePart; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestPart; -import org.springframework.web.bind.annotation.RestController; - - -@RestController -public class HelloController { - - - @Operation(summary = "Parse Resume") - @PostMapping(value = "/parse-resume", produces = { MediaType.APPLICATION_JSON_VALUE }, consumes = { - MediaType.MULTIPART_FORM_DATA_VALUE }) - @ApiResponses({ @ApiResponse(responseCode = "400", description = "Invalid input") }) - public Mono parse( - @RequestPart(name = "resumeFile") @Parameter(description = "Resume file to be parsed", content = @Content(mediaType = MediaType.APPLICATION_OCTET_STREAM_VALUE)) FilePart resumeFile) { - return null; - } -} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app189/SpringDocApp189Test.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app189/SpringDocApp189Test.java deleted file mode 100644 index 542d56c64..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app189/SpringDocApp189Test.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app189; - -import java.time.Duration; - -import org.json.JSONException; -import org.junit.jupiter.api.Test; -import org.springdoc.core.utils.Constants; -import test.org.springdoc.api.AbstractCommonTest; - -import org.springframework.boot.test.autoconfigure.web.reactive.WebFluxTest; -import org.springframework.test.web.reactive.server.EntityExchangeResult; - -import static org.skyscreamer.jsonassert.JSONAssert.assertEquals; - -@WebFluxTest -public class SpringDocApp189Test extends AbstractCommonTest { - - @Test - public void testWithDifferentLocales() throws Exception { - runTestWithLocale("en-GB"); - runTestWithLocale("de-DE"); - } - private void runTestWithLocale(String locale) throws JSONException { - EntityExchangeResult getResult = webTestClient.mutate().responseTimeout(Duration.ofMinutes(1000)).build() - .get().uri(Constants.DEFAULT_API_DOCS_URL) - .header("Accept-Language", locale) - .exchange() - .expectStatus().isOk().expectBody().returnResult(); - - String result = new String(getResult.getResponseBody()); - String className = getClass().getSimpleName(); - String testNumber = className.replaceAll("[^0-9]", ""); - String expected = getContent("results/app" + testNumber + ".json"); - assertEquals(expected, result, true); - } - -} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app189/SpringDocTestApp.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app189/SpringDocTestApp.java deleted file mode 100644 index fae77fa39..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app189/SpringDocTestApp.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app189; - -import io.swagger.v3.oas.models.Components; -import io.swagger.v3.oas.models.OpenAPI; -import io.swagger.v3.oas.models.info.Info; -import io.swagger.v3.oas.models.info.License; -import io.swagger.v3.oas.models.security.SecurityScheme; -import org.springdoc.core.customizers.OpenApiCustomizer; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; - -@SpringBootApplication -@ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.app189" }) -public class SpringDocTestApp { - - @Bean - public OpenAPI customOpenAPI() { - return new OpenAPI() - .components(new Components().addSecuritySchemes("basicScheme", - new SecurityScheme().type(SecurityScheme.Type.HTTP).scheme("basic"))) - .info(new Info().title("Tweet API").version("v0") - .license(new License().name("Apache 2.0").url("http://springdoc.org"))); - } - - @Bean - OpenApiCustomizer serverUrlCustomizer() { - return openApi -> - openApi.getServers().forEach(server -> { - server.setDescription("customized description"); - server.setUrl("https://customized.url"); - }); - } -} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app190/SpringDocApp190Test.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app190/SpringDocApp190Test.java deleted file mode 100644 index c98dbb03e..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app190/SpringDocApp190Test.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app190; - -import org.junit.jupiter.api.Test; -import org.springdoc.core.utils.Constants; -import test.org.springdoc.api.AbstractCommonTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.test.autoconfigure.web.reactive.WebFluxTest; -import org.springframework.context.annotation.ComponentScan; - -import static org.springdoc.core.utils.Constants.SPRINGDOC_ENABLE_DEFAULT_API_DOCS; - -@WebFluxTest(properties = SPRINGDOC_ENABLE_DEFAULT_API_DOCS+"=false") -public class SpringDocApp190Test extends AbstractCommonTest { - - @SpringBootApplication - @ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.app190" }) - static class SpringDocTestApp {} - - @Test - void test_disable_default_api_docs() throws Exception { - webTestClient.get().uri(Constants.DEFAULT_API_DOCS_URL).exchange() - .expectStatus().isNotFound(); - } -} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app190/SpringDocApp190bisTest.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app190/SpringDocApp190bisTest.java deleted file mode 100644 index 21a048c82..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app190/SpringDocApp190bisTest.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app190; - -import org.junit.jupiter.api.Test; -import org.springdoc.core.utils.Constants; -import test.org.springdoc.api.AbstractCommonTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.test.autoconfigure.web.reactive.WebFluxTest; -import org.springframework.context.annotation.ComponentScan; - -import static org.springdoc.core.utils.Constants.SPRINGDOC_ENABLE_DEFAULT_API_DOCS; - -@WebFluxTest(properties = SPRINGDOC_ENABLE_DEFAULT_API_DOCS+"=true") -public class SpringDocApp190bisTest extends AbstractCommonTest { - - @SpringBootApplication - @ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.app190" }) - static class SpringDocTestApp {} - - @Test - void test_enable_default_api_docs() throws Exception { - webTestClient.get().uri(Constants.DEFAULT_API_DOCS_URL).exchange() - .expectStatus().isOk(); - } -} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app191/Handler/BaseHandler.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app191/Handler/BaseHandler.java deleted file mode 100644 index 0bcc587f1..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app191/Handler/BaseHandler.java +++ /dev/null @@ -1,16 +0,0 @@ -package test.org.springdoc.api.app191.Handler; - -import reactor.core.publisher.Mono; - -import org.springframework.stereotype.Component; -import org.springframework.web.reactive.function.server.ServerRequest; -import org.springframework.web.reactive.function.server.ServerResponse; - -@Component -public abstract class BaseHandler { - protected abstract Mono apply (ServerRequest serverRequest); - - public Mono handle(ServerRequest serverRequest) { - return this.apply(serverRequest); - } -} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app191/Handler/GetNameHandler.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app191/Handler/GetNameHandler.java deleted file mode 100644 index 00854782a..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app191/Handler/GetNameHandler.java +++ /dev/null @@ -1,19 +0,0 @@ -package test.org.springdoc.api.app191.Handler; - -import reactor.core.publisher.Mono; - -import org.springframework.http.MediaType; -import org.springframework.stereotype.Component; -import org.springframework.web.reactive.function.server.ServerRequest; -import org.springframework.web.reactive.function.server.ServerResponse; - -@Component -public class GetNameHandler extends BaseHandler{ - @Override - protected Mono apply(ServerRequest serverRequest) { - return ServerResponse.ok() - .contentType(MediaType.APPLICATION_JSON) - .bodyValue("Name API is called"); - } - -} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app191/Router/GetNameRouter.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app191/Router/GetNameRouter.java deleted file mode 100644 index 92e1b5d40..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app191/Router/GetNameRouter.java +++ /dev/null @@ -1,37 +0,0 @@ -package test.org.springdoc.api.app191.Router; - -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.media.Content; -import io.swagger.v3.oas.annotations.media.Schema; -import io.swagger.v3.oas.annotations.responses.ApiResponse; -import org.springdoc.core.annotations.RouterOperation; -import org.springdoc.core.annotations.RouterOperations; -import test.org.springdoc.api.app191.Handler.GetNameHandler; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.http.MediaType; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.reactive.function.server.RequestPredicates; -import org.springframework.web.reactive.function.server.RouterFunction; -import org.springframework.web.reactive.function.server.RouterFunctions; -import org.springframework.web.reactive.function.server.ServerResponse; - - -@Configuration -public class GetNameRouter { - - @Bean - @RouterOperations( - value = { - @RouterOperation(path = "/v1/name", produces = {MediaType.APPLICATION_JSON_VALUE}, method = RequestMethod.GET, - beanClass = GetNameHandler.class, beanMethod = "handle", operation = @Operation(operationId = "getName", - description = "get name", responses = {@ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = String.class)))}) - ) - }) - - public RouterFunction routerFunction(GetNameHandler getNameHandler) { - return RouterFunctions.route(RequestPredicates.GET("/v1/name"), getNameHandler::handle); - } - -} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app191/SpringDocApp191Test.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app191/SpringDocApp191Test.java deleted file mode 100644 index 7f7cbcc24..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app191/SpringDocApp191Test.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app191; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.ComponentScan; - -public class SpringDocApp191Test extends AbstractSpringDocTest { - - @SpringBootApplication - @ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.app191" }) - static class SpringDocTestApp {} -} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app3/SpringDocApp3Test.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app3/SpringDocApp3Test.java deleted file mode 100644 index 1b4bbc081..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app3/SpringDocApp3Test.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app3; - -import test.org.springdoc.api.AbstractSpringDocTest; - -public class SpringDocApp3Test extends AbstractSpringDocTest { - - -} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app3/SpringDocTestApp.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app3/SpringDocTestApp.java deleted file mode 100644 index 6262f30d7..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app3/SpringDocTestApp.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app3; - -import io.swagger.v3.oas.models.Components; -import io.swagger.v3.oas.models.OpenAPI; -import io.swagger.v3.oas.models.info.Info; -import io.swagger.v3.oas.models.info.License; -import io.swagger.v3.oas.models.security.SecurityScheme; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; - -@SpringBootApplication -@ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.app3" }) -public class SpringDocTestApp { - public static void main(String[] args) { - SpringApplication.run(SpringDocTestApp.class, args); - } - - @Bean - public OpenAPI customOpenAPI() { - return new OpenAPI() - .components(new Components().addSecuritySchemes("basicScheme", - new SecurityScheme().type(SecurityScheme.Type.HTTP).scheme("basic"))) - .info(new Info().title("Tweet API").version("v0") - .license(new License().name("Apache 2.0").url("http://springdoc.org"))); - } -} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app3/controller/ExceptionTranslator.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app3/controller/ExceptionTranslator.java deleted file mode 100644 index be9ffede6..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app3/controller/ExceptionTranslator.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app3.controller; - -import test.org.springdoc.api.app3.exception.TweetConflictException; -import test.org.springdoc.api.app3.exception.TweetNotFoundException; -import test.org.springdoc.api.app3.payload.ErrorResponse; - -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.ExceptionHandler; -import org.springframework.web.bind.annotation.ResponseStatus; -import org.springframework.web.bind.annotation.RestControllerAdvice; - -@RestControllerAdvice -public class ExceptionTranslator { - - - @SuppressWarnings("rawtypes") - @ExceptionHandler(TweetConflictException.class) - @ResponseStatus(HttpStatus.CONFLICT) - public ResponseEntity handleDuplicateKeyException(TweetConflictException ex) { - return ResponseEntity.status(HttpStatus.CONFLICT) - .body(new ErrorResponse("A Tweet with the same text already exists")); - } - - @SuppressWarnings("rawtypes") - @ExceptionHandler(TweetNotFoundException.class) - @ResponseStatus(HttpStatus.NOT_FOUND) - public ResponseEntity handleTweetNotFoundException(TweetNotFoundException ex) { - return ResponseEntity.notFound().build(); - } - -} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app3/controller/TweetController.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app3/controller/TweetController.java deleted file mode 100644 index a694e4daf..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app3/controller/TweetController.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app3.controller; - -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.responses.ApiResponse; -import io.swagger.v3.oas.annotations.responses.ApiResponses; -import jakarta.validation.Valid; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; -import test.org.springdoc.api.app3.dto.TweetDTO; - -import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.DeleteMapping; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RestController; - -/** - * Created by rajeevkumarsingh on 08/09/17. - */ -@RestController -public class TweetController { - - - @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "get All Tweets") }) - @GetMapping("/tweets") - public Flux getAllTweets() { - return null; - } - - @PostMapping("/tweets") - @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "create Tweets") }) - public Mono createTweets(@Valid @RequestBody TweetDTO tweetDTO) { - return null; - } - - @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "get Tweet By Id"), - @ApiResponse(responseCode = "404", description = "tweet not found") }) - @GetMapping("/tweets/{id}") - public Mono> getTweetById(@PathVariable(value = "id") String tweetId) { - return null; - } - - @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "update Tweet"), - @ApiResponse(responseCode = "404", description = "tweet not found") }) - @PutMapping("/tweets/{id}") - public Mono> updateTweet(@PathVariable(value = "id") String tweetId, - @Valid @RequestBody TweetDTO tweetDTO) { - return null; - } - - @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "delete Tweet"), - @ApiResponse(responseCode = "404", description = "tweet not found") }) - @DeleteMapping("/tweets/{id}") - public Mono> deleteTweet(@PathVariable(value = "id") String tweetId) { - return null; - } - - @Operation(description = "Tweets are Sent to the client as Server Sent Events", responses = { - @ApiResponse(responseCode = "200", description = "stream All Tweets") }) - @GetMapping(value = "/stream/tweets", produces = MediaType.TEXT_EVENT_STREAM_VALUE) - public Flux streamAllTweets() { - return null; - } - -} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app3/dto/TweetDTO.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app3/dto/TweetDTO.java deleted file mode 100644 index 54c7c32d2..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app3/dto/TweetDTO.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app3.dto; - -import java.util.Date; - -import jakarta.validation.constraints.NotBlank; -import jakarta.validation.constraints.NotNull; -import jakarta.validation.constraints.Size; - - -/** - * Created by rajeevkumarsingh on 08/09/17. - */ -public class TweetDTO { - private String id; - - @NotBlank - @Size(max = 140) - private String text; - - @NotNull - private Date createdAt = new Date(); - - public TweetDTO() { - - } - - public TweetDTO(String text) { - this.text = text; - } - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getText() { - return text; - } - - public void setText(String text) { - this.text = text; - } - - public Date getCreatedAt() { - return createdAt; - } - - public void setCreatedAt(Date createdAt) { - this.createdAt = createdAt; - } -} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app3/exception/TweetConflictException.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app3/exception/TweetConflictException.java deleted file mode 100644 index 3f21e25d5..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app3/exception/TweetConflictException.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app3.exception; - -/** - * Created by rajeevkumarsingh on 22/10/17. - */ -public class TweetConflictException extends RuntimeException { - - /** - * - */ - private static final long serialVersionUID = 1L; - - public TweetConflictException(String tweetId) { - super("Tweet conflict with id " + tweetId); - } -} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app3/exception/TweetNotFoundException.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app3/exception/TweetNotFoundException.java deleted file mode 100644 index 3dc9df446..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app3/exception/TweetNotFoundException.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app3.exception; - -/** - * Created by rajeevkumarsingh on 22/10/17. - */ -public class TweetNotFoundException extends RuntimeException { - - /** - * - */ - private static final long serialVersionUID = 1L; - - public TweetNotFoundException(String tweetId) { - super("Tweet not found with id " + tweetId); - } -} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app3/payload/ErrorResponse.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app3/payload/ErrorResponse.java deleted file mode 100644 index a1cdd1a98..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app3/payload/ErrorResponse.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app3.payload; - -/** - * Created by rajeevkumarsingh on 22/10/17. - */ -public class ErrorResponse { - private String message; - - public ErrorResponse(String message) { - this.message = message; - } - - public String getMessage() { - return message; - } - - public void setMessage(String message) { - this.message = message; - } -} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app39/HelloController.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app39/HelloController.java deleted file mode 100644 index eb119b6c4..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app39/HelloController.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app39; - -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.media.Content; -import io.swagger.v3.oas.annotations.media.Schema; -import io.swagger.v3.oas.annotations.parameters.RequestBody; -import reactor.core.publisher.Mono; - -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RestController; - -@RestController -public class HelloController { - - @Operation(summary = "test Request") - @RequestBody(description = "test value", required = true, content = @Content(schema = @Schema(implementation = String.class))) - @PostMapping("/test") - public Mono searchEmployee(String test) { - return Mono.empty(); - } - - @GetMapping("/hello") - public Mono hello() { - return Mono.just("hello"); - } -} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app39/SpringDocApp39Test.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app39/SpringDocApp39Test.java deleted file mode 100644 index 4c346c559..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app39/SpringDocApp39Test.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app39; - -import test.org.springdoc.api.AbstractSpringDocTest; - -public class SpringDocApp39Test extends AbstractSpringDocTest { - - -} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app39/SpringDocTestApp.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app39/SpringDocTestApp.java deleted file mode 100644 index 2bc6f4704..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app39/SpringDocTestApp.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app39; - -import io.swagger.v3.oas.models.Components; -import io.swagger.v3.oas.models.OpenAPI; -import io.swagger.v3.oas.models.media.StringSchema; -import io.swagger.v3.oas.models.parameters.HeaderParameter; -import org.springdoc.core.customizers.OpenApiCustomizer; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; - -@SpringBootApplication -@ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.app39" }) -public class SpringDocTestApp { - - public static void main(String[] args) { - SpringApplication.run(SpringDocTestApp.class, args); - } - - @Bean - public OpenAPI customOpenAPI() { - StringSchema schema = new StringSchema(); - return new OpenAPI() - .components(new Components().addParameters("myGlobalHeader", new HeaderParameter().required(true).name("My-Global-Header").description("My Global Header").schema(schema))); - } - - @Bean - public OpenApiCustomizer customerGlobalHeaderOpenApiCustomizer() { - return openApi -> openApi.getPaths().values().stream().flatMap(pathItem -> pathItem.readOperations().stream()) - .forEach(operation -> operation.addParametersItem(new HeaderParameter().$ref("#/components/parameters/myGlobalHeader"))); - } -} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app4/HelloController.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app4/HelloController.java deleted file mode 100644 index 7f1727c96..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app4/HelloController.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app4; - -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.media.Content; -import io.swagger.v3.oas.annotations.responses.ApiResponse; -import io.swagger.v3.oas.annotations.responses.ApiResponses; -import reactor.core.publisher.Mono; - -import org.springframework.http.MediaType; -import org.springframework.http.codec.multipart.FilePart; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestPart; -import org.springframework.web.bind.annotation.RestController; - - -@RestController -public class HelloController { - - - @Operation(summary = "Parse Resume") - @PostMapping(value = "/parse-resume", produces = { MediaType.APPLICATION_JSON_VALUE }, consumes = { - MediaType.MULTIPART_FORM_DATA_VALUE }) - @ApiResponses({ @ApiResponse(responseCode = "400", description = "Invalid input") }) - public Mono parse( - @RequestPart(name = "resumeFile") @Parameter(description = "Resume file to be parsed", content = @Content(mediaType = MediaType.APPLICATION_OCTET_STREAM_VALUE)) FilePart resumeFile) { - return null; - } -} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app4/SpringDocApp4Test.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app4/SpringDocApp4Test.java deleted file mode 100644 index cf11f1e8f..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app4/SpringDocApp4Test.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app4; - -import test.org.springdoc.api.AbstractSpringDocTest; - -public class SpringDocApp4Test extends AbstractSpringDocTest { - - -} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app4/SpringDocTestApp.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app4/SpringDocTestApp.java deleted file mode 100644 index 22ae0f622..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app4/SpringDocTestApp.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app4; - -import io.swagger.v3.oas.models.Components; -import io.swagger.v3.oas.models.OpenAPI; -import io.swagger.v3.oas.models.info.Info; -import io.swagger.v3.oas.models.info.License; -import io.swagger.v3.oas.models.security.SecurityScheme; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; - -@SpringBootApplication -@ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.app4" }) -public class SpringDocTestApp { - public static void main(String[] args) { - SpringApplication.run(SpringDocTestApp.class, args); - } - - @Bean - public OpenAPI customOpenAPI() { - return new OpenAPI() - .components(new Components().addSecuritySchemes("basicScheme", - new SecurityScheme().type(SecurityScheme.Type.HTTP).scheme("basic"))) - .info(new Info().title("Tweet API").version("v0") - .license(new License().name("Apache 2.0").url("http://springdoc.org"))); - } -} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app5/HelloController.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app5/HelloController.java deleted file mode 100644 index a20a51156..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app5/HelloController.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app5; - -import reactor.core.publisher.Mono; - -import org.springframework.http.HttpEntity; -import org.springframework.http.MediaType; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RestController; - -@RestController -public class HelloController { - - @PostMapping(value = "/tweets/does-not-work", consumes = MediaType.APPLICATION_JSON_VALUE) - public Mono postNotWorks(@RequestBody Mono tweet) { - return tweet; - } - - @GetMapping("/test") - public Mono> demo2() { - return null; - } - -} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app5/SpringDocApp5Test.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app5/SpringDocApp5Test.java deleted file mode 100644 index b96e55723..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app5/SpringDocApp5Test.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app5; - -import test.org.springdoc.api.AbstractSpringDocTest; - -public class SpringDocApp5Test extends AbstractSpringDocTest { - - -} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app5/SpringDocTestApp.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app5/SpringDocTestApp.java deleted file mode 100644 index df9ec8b30..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app5/SpringDocTestApp.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app5; - -import io.swagger.v3.oas.models.Components; -import io.swagger.v3.oas.models.OpenAPI; -import io.swagger.v3.oas.models.info.Info; -import io.swagger.v3.oas.models.info.License; -import io.swagger.v3.oas.models.security.SecurityScheme; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; - -@SpringBootApplication -@ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.app5" }) -public class SpringDocTestApp { - public static void main(String[] args) { - SpringApplication.run(SpringDocTestApp.class, args); - } - - @Bean - public OpenAPI customOpenAPI() { - return new OpenAPI() - .components(new Components().addSecuritySchemes("basicScheme", - new SecurityScheme().type(SecurityScheme.Type.HTTP).scheme("basic"))) - .info(new Info().title("Tweet API").version("v0") - .license(new License().name("Apache 2.0").url("http://springdoc.org"))); - } -} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app5/Tweet.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app5/Tweet.java deleted file mode 100644 index 03487c9bb..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app5/Tweet.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app5; - -import java.util.Date; - -import jakarta.validation.constraints.NotBlank; -import jakarta.validation.constraints.NotNull; -import jakarta.validation.constraints.Size; - -public class Tweet { - private String id; - - @NotBlank - @Size(max = 140) - private String text; - - @NotNull - private Date createdAt = new Date(); - - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getText() { - return text; - } - - public void setText(String text) { - this.text = text; - } - - public Date getCreatedAt() { - return createdAt; - } - - public void setCreatedAt(Date createdAt) { - this.createdAt = createdAt; - } -} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app63/HelloController.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app63/HelloController.java deleted file mode 100644 index 7ce2032ae..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app63/HelloController.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app63; - -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -@RestController -public class HelloController { - - @GetMapping("/test") - public void test(String hello) { - } - -} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app63/SpringDocApp63Test.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app63/SpringDocApp63Test.java deleted file mode 100644 index f6bc9e2e7..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app63/SpringDocApp63Test.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app63; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.test.context.TestPropertySource; - -@TestPropertySource(properties = "springdoc.packagesToScan=hell,hello1, hello.me") -public class SpringDocApp63Test extends AbstractSpringDocTest { - - @SpringBootApplication - @ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.app63" }) - static class SpringDocTestApp {} -} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app63/toto/HelloController2.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app63/toto/HelloController2.java deleted file mode 100644 index 826222b66..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app63/toto/HelloController2.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app63.toto; - -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -@RestController -public class HelloController2 { - - @GetMapping("/test1") - public void test1(String hello) { - } - -} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app64/HelloController.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app64/HelloController.java deleted file mode 100644 index 0245f3a24..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app64/HelloController.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app64; - -import io.swagger.v3.oas.annotations.Operation; - -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -@RestController -public class HelloController { - - @GetMapping("/v1/test") - public void test1(String hello) { - } - - @GetMapping(value = "/api/balance/abcd") - @Operation(summary = "This is the test endpoint") - public String test2(String from) { - return "This is a fake test"; - } - -} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app64/SpringDocApp64Test.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app64/SpringDocApp64Test.java deleted file mode 100644 index ecfe5a691..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app64/SpringDocApp64Test.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app64; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.test.context.TestPropertySource; - -@TestPropertySource(properties = "springdoc.paths-to-match=/v1, /api/**") -public class SpringDocApp64Test extends AbstractSpringDocTest { - - @SpringBootApplication - @ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.app64" }) - static class SpringDocTestApp {} -} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app65/HelloController.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app65/HelloController.java deleted file mode 100644 index 3896d2de0..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app65/HelloController.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app65; - -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; - -import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -@Tag(name = "Health", description = "Health check / ping API") -@RestController -public class HelloController { - - @Operation(summary = "Check server status", description = "Check server status, will return 200 with simple string if alive. Do nothing else.") - @GetMapping(value = { "/ping", "/health", "/" }, produces = MediaType.TEXT_PLAIN_VALUE) - public ResponseEntity ping() { - return ResponseEntity.ok("Healthy"); - } - -} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app65/SpringDocApp65Test.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app65/SpringDocApp65Test.java deleted file mode 100644 index 67e2721fc..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app65/SpringDocApp65Test.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app65; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.ComponentScan; - -public class SpringDocApp65Test extends AbstractSpringDocTest { - - @SpringBootApplication - @ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.app65" }) - static class SpringDocTestApp {} -} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app66/SpringDocApp66Test.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app66/SpringDocApp66Test.java deleted file mode 100644 index 16119b069..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app66/SpringDocApp66Test.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app66; - -import org.junit.jupiter.api.Test; -import org.springdoc.core.utils.Constants; -import test.org.springdoc.api.AbstractSpringDocTest; - -public class SpringDocApp66Test extends AbstractSpringDocTest { - - public SpringDocApp66Test() { - this.groupName = "/stream"; - } - - @Test - void testApp2() throws Exception { - webTestClient.get().uri(Constants.DEFAULT_API_DOCS_URL + "streams").exchange() - .expectStatus().isNotFound(); - } -} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app66/SpringDocTestApp.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app66/SpringDocTestApp.java deleted file mode 100644 index 18be50db4..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app66/SpringDocTestApp.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app66; - -import io.swagger.v3.oas.models.Components; -import io.swagger.v3.oas.models.OpenAPI; -import io.swagger.v3.oas.models.info.Info; -import io.swagger.v3.oas.models.info.License; -import io.swagger.v3.oas.models.security.SecurityScheme; -import org.springdoc.core.models.GroupedOpenApi; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; - -@SpringBootApplication -@ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.app66" }) -public class SpringDocTestApp { - public static void main(String[] args) { - SpringApplication.run(SpringDocTestApp.class, args); - } - - @Bean - public OpenAPI customOpenAPI() { - return new OpenAPI() - .components(new Components().addSecuritySchemes("basicScheme", - new SecurityScheme().type(SecurityScheme.Type.HTTP).scheme("basic"))) - .info(new Info().title("Tweet API").version("v0") - .license(new License().name("Apache 2.0").url("http://springdoc.org"))); - } - - @Bean - public GroupedOpenApi streamOpenApi() { - String[] paths = { "/stream/**" }; - String[] packagedToMatch = { "test.org.springdoc.api.app66" }; - return GroupedOpenApi.builder().group("stream").pathsToMatch(paths) - .build(); - } - -} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app66/controller/ExceptionTranslator.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app66/controller/ExceptionTranslator.java deleted file mode 100644 index dc81d1bfd..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app66/controller/ExceptionTranslator.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app66.controller; - -import test.org.springdoc.api.app66.exception.TweetConflictException; -import test.org.springdoc.api.app66.exception.TweetNotFoundException; -import test.org.springdoc.api.app66.payload.ErrorResponse; - -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.ExceptionHandler; -import org.springframework.web.bind.annotation.ResponseStatus; -import org.springframework.web.bind.annotation.RestControllerAdvice; - -@RestControllerAdvice -public class ExceptionTranslator { - - - @SuppressWarnings("rawtypes") - @ExceptionHandler(TweetConflictException.class) - @ResponseStatus(HttpStatus.CONFLICT) - public ResponseEntity handleDuplicateKeyException(TweetConflictException ex) { - return ResponseEntity.status(HttpStatus.CONFLICT) - .body(new ErrorResponse("A Tweet with the same text already exists")); - } - - @SuppressWarnings("rawtypes") - @ExceptionHandler(TweetNotFoundException.class) - @ResponseStatus(HttpStatus.NOT_FOUND) - public ResponseEntity handleTweetNotFoundException(TweetNotFoundException ex) { - return ResponseEntity.notFound().build(); - } - -} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app66/controller/TweetController.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app66/controller/TweetController.java deleted file mode 100644 index d62eeaf86..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app66/controller/TweetController.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app66.controller; - -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.responses.ApiResponse; -import io.swagger.v3.oas.annotations.responses.ApiResponses; -import jakarta.validation.Valid; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; -import test.org.springdoc.api.app66.dto.TweetDTO; - -import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.DeleteMapping; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RestController; - -/** - * Created by rajeevkumarsingh on 08/09/17. - */ -@RestController -public class TweetController { - - - @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "get All Tweets") }) - @GetMapping("/tweets") - public Flux getAllTweets() { - return null; - } - - @PostMapping("/tweets") - @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "create Tweets") }) - public Mono createTweets(@Valid @RequestBody TweetDTO tweetDTO) { - return null; - } - - @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "get Tweet By Id"), - @ApiResponse(responseCode = "404", description = "tweet not found") }) - @GetMapping("/tweets/{id}") - public Mono> getTweetById(@PathVariable(value = "id") String tweetId) { - return null; - } - - @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "update Tweet"), - @ApiResponse(responseCode = "404", description = "tweet not found") }) - @PutMapping("/tweets/{id}") - public Mono> updateTweet(@PathVariable(value = "id") String tweetId, - @Valid @RequestBody TweetDTO tweetDTO) { - return null; - } - - @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "delete Tweet"), - @ApiResponse(responseCode = "404", description = "tweet not found") }) - @DeleteMapping("/tweets/{id}") - public Mono> deleteTweet(@PathVariable(value = "id") String tweetId) { - return null; - } - - @Operation(description = "Tweets are Sent to the client as Server Sent Events", responses = { - @ApiResponse(responseCode = "200", description = "stream All Tweets") }) - @GetMapping(value = "/stream/tweets", produces = MediaType.TEXT_EVENT_STREAM_VALUE) - public Flux streamAllTweets() { - return null; - } - -} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app66/dto/TweetDTO.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app66/dto/TweetDTO.java deleted file mode 100644 index 51cdc3528..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app66/dto/TweetDTO.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app66.dto; - -import java.util.Date; - -import jakarta.validation.constraints.NotBlank; -import jakarta.validation.constraints.NotNull; -import jakarta.validation.constraints.Size; - - -/** - * Created by rajeevkumarsingh on 08/09/17. - */ -public class TweetDTO { - private String id; - - @NotBlank - @Size(max = 140) - private String text; - - @NotNull - private Date createdAt = new Date(); - - public TweetDTO() { - - } - - public TweetDTO(String text) { - this.text = text; - } - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getText() { - return text; - } - - public void setText(String text) { - this.text = text; - } - - public Date getCreatedAt() { - return createdAt; - } - - public void setCreatedAt(Date createdAt) { - this.createdAt = createdAt; - } -} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app66/exception/TweetConflictException.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app66/exception/TweetConflictException.java deleted file mode 100644 index 131049958..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app66/exception/TweetConflictException.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app66.exception; - -/** - * Created by rajeevkumarsingh on 22/10/17. - */ -public class TweetConflictException extends RuntimeException { - - /** - * - */ - private static final long serialVersionUID = 1L; - - public TweetConflictException(String tweetId) { - super("Tweet conflict with id " + tweetId); - } -} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app66/exception/TweetNotFoundException.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app66/exception/TweetNotFoundException.java deleted file mode 100644 index 1dcd1f9bc..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app66/exception/TweetNotFoundException.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app66.exception; - -/** - * Created by rajeevkumarsingh on 22/10/17. - */ -public class TweetNotFoundException extends RuntimeException { - - /** - * - */ - private static final long serialVersionUID = 1L; - - public TweetNotFoundException(String tweetId) { - super("Tweet not found with id " + tweetId); - } -} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app66/payload/ErrorResponse.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app66/payload/ErrorResponse.java deleted file mode 100644 index fb7fcdc09..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app66/payload/ErrorResponse.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app66.payload; - -/** - * Created by rajeevkumarsingh on 22/10/17. - */ -public class ErrorResponse { - private String message; - - public ErrorResponse(String message) { - this.message = message; - } - - public String getMessage() { - return message; - } - - public void setMessage(String message) { - this.message = message; - } -} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app67/HelloController.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app67/HelloController.java deleted file mode 100644 index c34093e7a..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app67/HelloController.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app67; - -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -@RestController -@RequestMapping("/api") -public class HelloController { - - @RequestMapping - public String test() { - return "ok"; - } - -} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app67/SpringDocApp67Test.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app67/SpringDocApp67Test.java deleted file mode 100644 index 279d52509..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app67/SpringDocApp67Test.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app67; - -import org.junit.jupiter.api.Test; -import org.springdoc.core.utils.Constants; -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.ComponentScan; - -public class SpringDocApp67Test extends AbstractSpringDocTest { - - @Test - void testApp() { - webTestClient.get().uri(Constants.DEFAULT_API_DOCS_URL + groupName).exchange().expectStatus().isOk().expectBody() - .jsonPath("$.openapi").isEqualTo("3.0.1") - .jsonPath("$.paths./api.get.tags[0]").isEqualTo("hello-controller") - .jsonPath("$.paths./api.get.responses.200.content.['*/*'].schema.type").isEqualTo("string") - .jsonPath("$.paths./api.post.tags[0]").isEqualTo("hello-controller") - .jsonPath("$.paths./api.post.responses.200.content.['*/*'].schema.type").isEqualTo("string") - .jsonPath("$.paths./api.put.tags[0]").isEqualTo("hello-controller") - .jsonPath("$.paths./api.put.responses.200.content.['*/*'].schema.type").isEqualTo("string") - .jsonPath("$.paths./api.patch.tags[0]").isEqualTo("hello-controller") - .jsonPath("$.paths./api.patch.responses.200.content.['*/*'].schema.type").isEqualTo("string") - .jsonPath("$.paths./api.delete.tags[0]").isEqualTo("hello-controller") - .jsonPath("$.paths./api.delete.responses.200.content.['*/*'].schema.type").isEqualTo("string") - .jsonPath("$.paths./api.options.tags[0]").isEqualTo("hello-controller") - .jsonPath("$.paths./api.options.responses.200.content.['*/*'].schema.type").isEqualTo("string") - .jsonPath("$.paths./api.head.tags[0]").isEqualTo("hello-controller") - .jsonPath("$.paths./api.head.responses.200.content.['*/*'].schema.type").isEqualTo("string"); - } - - @SpringBootApplication - @ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.app67" }) - static class SpringDocTestApp {} -} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app68/SpringDocApp68Test.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app68/SpringDocApp68Test.java deleted file mode 100644 index 91e941bab..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app68/SpringDocApp68Test.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app68; - -import io.swagger.v3.oas.models.Components; -import io.swagger.v3.oas.models.OpenAPI; -import io.swagger.v3.oas.models.info.Info; -import io.swagger.v3.oas.models.info.License; -import io.swagger.v3.oas.models.security.SecurityScheme; -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.test.context.TestPropertySource; - -@TestPropertySource(properties = { - "springdoc.group-configs[0].group=stream", - "springdoc.group-configs[0].pathsToMatch=/stream/**" -}) -public class SpringDocApp68Test extends AbstractSpringDocTest { - - public SpringDocApp68Test() { - this.groupName = "/stream"; - } - - - @SpringBootApplication - @ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.app68" }) - static class SpringDocTestApp { - @Bean - public OpenAPI customOpenAPI() { - return new OpenAPI() - .components(new Components().addSecuritySchemes("basicScheme", - new SecurityScheme().type(SecurityScheme.Type.HTTP).scheme("basic"))) - .info(new Info().title("Tweet API").version("v0") - .license(new License().name("Apache 2.0").url("http://springdoc.org"))); - } - } -} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app68/controller/ExceptionTranslator.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app68/controller/ExceptionTranslator.java deleted file mode 100644 index aca1d2d9f..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app68/controller/ExceptionTranslator.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app68.controller; - -import test.org.springdoc.api.app68.exception.TweetConflictException; -import test.org.springdoc.api.app68.exception.TweetNotFoundException; -import test.org.springdoc.api.app68.payload.ErrorResponse; - -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.ExceptionHandler; -import org.springframework.web.bind.annotation.ResponseStatus; -import org.springframework.web.bind.annotation.RestControllerAdvice; - -@RestControllerAdvice -public class ExceptionTranslator { - - - @SuppressWarnings("rawtypes") - @ExceptionHandler(TweetConflictException.class) - @ResponseStatus(HttpStatus.CONFLICT) - public ResponseEntity handleDuplicateKeyException(TweetConflictException ex) { - return ResponseEntity.status(HttpStatus.CONFLICT) - .body(new ErrorResponse("A Tweet with the same text already exists")); - } - - @SuppressWarnings("rawtypes") - @ExceptionHandler(TweetNotFoundException.class) - @ResponseStatus(HttpStatus.NOT_FOUND) - public ResponseEntity handleTweetNotFoundException(TweetNotFoundException ex) { - return ResponseEntity.notFound().build(); - } - -} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app68/controller/TweetController.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app68/controller/TweetController.java deleted file mode 100644 index 255677a2c..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app68/controller/TweetController.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app68.controller; - -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.responses.ApiResponse; -import io.swagger.v3.oas.annotations.responses.ApiResponses; -import jakarta.validation.Valid; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; -import test.org.springdoc.api.app68.dto.TweetDTO; - -import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.DeleteMapping; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RestController; - -/** - * Created by rajeevkumarsingh on 08/09/17. - */ -@RestController -public class TweetController { - - - @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "get All Tweets") }) - @GetMapping("/tweets") - public Flux getAllTweets() { - return null; - } - - @PostMapping("/tweets") - @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "create Tweets") }) - public Mono createTweets(@Valid @RequestBody TweetDTO tweetDTO) { - return null; - } - - @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "get Tweet By Id"), - @ApiResponse(responseCode = "404", description = "tweet not found") }) - @GetMapping("/tweets/{id}") - public Mono> getTweetById(@PathVariable(value = "id") String tweetId) { - return null; - } - - @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "update Tweet"), - @ApiResponse(responseCode = "404", description = "tweet not found") }) - @PutMapping("/tweets/{id}") - public Mono> updateTweet(@PathVariable(value = "id") String tweetId, - @Valid @RequestBody TweetDTO tweetDTO) { - return null; - } - - @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "delete Tweet"), - @ApiResponse(responseCode = "404", description = "tweet not found") }) - @DeleteMapping("/tweets/{id}") - public Mono> deleteTweet(@PathVariable(value = "id") String tweetId) { - return null; - } - - @Operation(description = "Tweets are Sent to the client as Server Sent Events", responses = { - @ApiResponse(responseCode = "200", description = "stream All Tweets") }) - @GetMapping(value = "/stream/tweets", produces = MediaType.TEXT_EVENT_STREAM_VALUE) - public Flux streamAllTweets() { - return null; - } - -} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app68/dto/TweetDTO.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app68/dto/TweetDTO.java deleted file mode 100644 index d2accbb1e..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app68/dto/TweetDTO.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app68.dto; - -import java.util.Date; - -import jakarta.validation.constraints.NotBlank; -import jakarta.validation.constraints.NotNull; -import jakarta.validation.constraints.Size; - - -/** - * Created by rajeevkumarsingh on 08/09/17. - */ -public class TweetDTO { - private String id; - - @NotBlank - @Size(max = 140) - private String text; - - @NotNull - private Date createdAt = new Date(); - - public TweetDTO() { - - } - - public TweetDTO(String text) { - this.text = text; - } - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getText() { - return text; - } - - public void setText(String text) { - this.text = text; - } - - public Date getCreatedAt() { - return createdAt; - } - - public void setCreatedAt(Date createdAt) { - this.createdAt = createdAt; - } -} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app68/exception/TweetConflictException.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app68/exception/TweetConflictException.java deleted file mode 100644 index 8e4af3d64..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app68/exception/TweetConflictException.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app68.exception; - -/** - * Created by rajeevkumarsingh on 22/10/17. - */ -public class TweetConflictException extends RuntimeException { - - /** - * - */ - private static final long serialVersionUID = 1L; - - public TweetConflictException(String tweetId) { - super("Tweet conflict with id " + tweetId); - } -} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app68/exception/TweetNotFoundException.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app68/exception/TweetNotFoundException.java deleted file mode 100644 index 799c9171c..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app68/exception/TweetNotFoundException.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app68.exception; - -/** - * Created by rajeevkumarsingh on 22/10/17. - */ -public class TweetNotFoundException extends RuntimeException { - - /** - * - */ - private static final long serialVersionUID = 1L; - - public TweetNotFoundException(String tweetId) { - super("Tweet not found with id " + tweetId); - } -} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app68/payload/ErrorResponse.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app68/payload/ErrorResponse.java deleted file mode 100644 index 81c38d169..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app68/payload/ErrorResponse.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app68.payload; - -/** - * Created by rajeevkumarsingh on 22/10/17. - */ -public class ErrorResponse { - private String message; - - public ErrorResponse(String message) { - this.message = message; - } - - public String getMessage() { - return message; - } - - public void setMessage(String message) { - this.message = message; - } -} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app69/RoutingConfiguration.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app69/RoutingConfiguration.java deleted file mode 100644 index 74237d287..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app69/RoutingConfiguration.java +++ /dev/null @@ -1,36 +0,0 @@ -package test.org.springdoc.api.app69; - -import org.springdoc.core.annotations.RouterOperation; -import org.springdoc.core.annotations.RouterOperations; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.http.MediaType; -import org.springframework.web.reactive.function.server.RouterFunction; -import org.springframework.web.reactive.function.server.ServerResponse; - -import static org.springframework.web.reactive.function.server.RequestPredicates.DELETE; -import static org.springframework.web.reactive.function.server.RequestPredicates.GET; -import static org.springframework.web.reactive.function.server.RequestPredicates.POST; -import static org.springframework.web.reactive.function.server.RequestPredicates.PUT; -import static org.springframework.web.reactive.function.server.RequestPredicates.accept; -import static org.springframework.web.reactive.function.server.RouterFunctions.route; - -@Configuration -public class RoutingConfiguration { - - @Bean - @RouterOperations({ @RouterOperation(path = "/api/user/index", beanClass = UserRepository.class, beanMethod = "getAllUsers"), - @RouterOperation(path = "/api/user/{id}", beanClass = UserRepository.class, beanMethod = "getUserById"), - @RouterOperation(path = "/api/user/post", beanClass = UserRepository.class, beanMethod = "saveUser"), - @RouterOperation(path = "/api/user/put/{id}", beanClass = UserRepository.class, beanMethod = "putUser"), - @RouterOperation(path = "/api/user/delete/{id}", beanClass = UserRepository.class, beanMethod = "deleteUser") }) - public RouterFunction monoRouterFunction(UserHandler userHandler) { - return route(GET("/api/user/index").and(accept(MediaType.APPLICATION_JSON)), userHandler::getAll) - .andRoute(GET("/api/user/{id}").and(accept(MediaType.APPLICATION_JSON)), userHandler::getUser) - .andRoute(POST("/api/user/post").and(accept(MediaType.APPLICATION_JSON)), userHandler::postUser) - .andRoute(PUT("/api/user/put/{id}").and(accept(MediaType.APPLICATION_JSON)), userHandler::putUser) - .andRoute(DELETE("/api/user/delete/{id}").and(accept(MediaType.APPLICATION_JSON)), userHandler::deleteUser); - } - -} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app69/SpringDocApp69Test.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app69/SpringDocApp69Test.java deleted file mode 100644 index 147d06810..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app69/SpringDocApp69Test.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app69; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.ComponentScan; - -public class SpringDocApp69Test extends AbstractSpringDocTest { - - @SpringBootApplication - @ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.app69" }) - static class SpringDocTestApp {} -} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app69/User.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app69/User.java deleted file mode 100644 index 92b8015b5..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app69/User.java +++ /dev/null @@ -1,59 +0,0 @@ -package test.org.springdoc.api.app69; - -public class User { - private long id; - - private String firstname; - - private String lastname; - - private int age; - - public User() { - } - - public User(long id, String firstname, String lastname, int age) { - this.id = id; - this.firstname = firstname; - this.lastname = lastname; - this.age = age; - } - - public long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getFirstname() { - return firstname; - } - - public void setFirstname(String firstname) { - this.firstname = firstname; - } - - public String getLastname() { - return lastname; - } - - public void setLastname(String lastname) { - this.lastname = lastname; - } - - public int getAge() { - return age; - } - - public void setAge(int age) { - this.age = age; - } - - @Override - public String toString() { - String info = String.format("id = %d, firstname = %s, lastname = %s, age = %d", id, firstname, lastname, age); - return info; - } -} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app69/UserHandler.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app69/UserHandler.java deleted file mode 100644 index 9d1c404b3..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app69/UserHandler.java +++ /dev/null @@ -1,93 +0,0 @@ -package test.org.springdoc.api.app69; - -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; - -import org.springframework.http.MediaType; -import org.springframework.stereotype.Component; -import org.springframework.web.reactive.function.server.ServerRequest; -import org.springframework.web.reactive.function.server.ServerResponse; - -import static org.springframework.web.reactive.function.BodyInserters.fromObject; - -@Component -public class UserHandler { - - private final UserRepository customerRepository; - - public UserHandler(UserRepository repository) { - this.customerRepository = repository; - } - - /** - * GET ALL Users - */ - public Mono getAll(ServerRequest request) { - // fetch all customers from repository - Flux customers = customerRepository.getAllUsers(); - - // build response - return ServerResponse.ok().contentType(MediaType.APPLICATION_JSON).body(customers, User.class); - } - - /** - * GET a User by ID - */ - public Mono getUser(ServerRequest request) { - // parse path-variable - long customerId = Long.valueOf(request.queryParam("id").get()); - - // build notFound response - Mono notFound = ServerResponse.notFound().build(); - - // get customer from repository - Mono customerMono = customerRepository.getUserById(customerId); - - // build response - return customerMono - .flatMap(customer -> ServerResponse.ok().contentType(MediaType.APPLICATION_JSON).body(fromObject(customer))) - .switchIfEmpty(notFound); - } - - /** - * POST a User - */ - public Mono postUser(ServerRequest request) { - Mono customer = request.bodyToMono(User.class); - return ServerResponse.ok().build(customerRepository.saveUser(customer)); - } - - /** - * PUT a User - */ - public Mono putUser(ServerRequest request) { - // parse id from path-variable - long customerId = Long.valueOf(request.pathVariable("id")); - - // get customer data from request object - Mono customer = request.bodyToMono(User.class); - - // get customer from repository - Mono responseMono = customerRepository.putUser(customerId, customer); - - // build response - return responseMono - .flatMap(cust -> ServerResponse.ok().contentType(MediaType.APPLICATION_JSON).body(fromObject(cust))); - } - - /** - * DELETE a User - */ - public Mono deleteUser(ServerRequest request) { - // parse id from path-variable - long customerId = Long.valueOf(request.pathVariable("id")); - - // get customer from repository - Mono responseMono = customerRepository.deleteUser(customerId); - - // build response - return responseMono - .flatMap(strMono -> ServerResponse.ok().contentType(MediaType.TEXT_PLAIN).body(fromObject(strMono))); - } - -} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app69/UserRepository.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app69/UserRepository.java deleted file mode 100644 index 85ecc348c..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app69/UserRepository.java +++ /dev/null @@ -1,25 +0,0 @@ -package test.org.springdoc.api.app69; - -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.enums.ParameterIn; -import io.swagger.v3.oas.annotations.parameters.RequestBody; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; - -public interface UserRepository { - - public Mono getUserById(@Parameter(in = ParameterIn.PATH, description = "The user Id") Long id); - - @Operation(description = "get all the users") - public Flux getAllUsers(); - - @Operation(description = "get all the users by firstname") - public Flux getAllUsers(String firstname); - - public Mono saveUser(Mono user); - - public Mono putUser(@Parameter(in = ParameterIn.PATH) Long id, @RequestBody Mono user); - - public Mono deleteUser(@Parameter(in = ParameterIn.PATH) Long id); -} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app69/UserRepositoryImpl.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app69/UserRepositoryImpl.java deleted file mode 100644 index 55cf5764c..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app69/UserRepositoryImpl.java +++ /dev/null @@ -1,72 +0,0 @@ -package test.org.springdoc.api.app69; - -import java.util.HashMap; -import java.util.Map; - -import jakarta.annotation.PostConstruct; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; - -import org.springframework.stereotype.Repository; - -@Repository -public class UserRepositoryImpl implements UserRepository { - private Map users = new HashMap(); - - @PostConstruct - public void init() throws Exception { - users.put(Long.valueOf(1), new User(1, "Jack", "Smith", 20)); - users.put(Long.valueOf(2), new User(2, "Peter", "Johnson", 25)); - } - - @Override - public Mono getUserById(Long id) { - return Mono.just(users.get(id)); - } - - @Override - public Flux getAllUsers() { - return Flux.fromIterable(this.users.values()); - } - - @Override - public Flux getAllUsers(String firstname) { - return Flux.fromIterable(this.users.values().stream().filter(user -> user.getFirstname().equals(firstname)).toList()); - } - - @Override - public Mono saveUser(Mono monoUser) { - Mono userMono = monoUser.doOnNext(user -> { - // do post - users.put(user.getId(), user); - - // log on console - System.out.println("########### POST:" + user); - }); - - return userMono.then(); - } - - @Override - public Mono putUser(Long id, Mono monoUser) { - Mono userMono = monoUser.doOnNext(user -> { - // reset user.Id - user.setId(id); - - // do put - users.put(id, user); - - // log on console - System.out.println("########### PUT:" + user); - }); - - return userMono; - } - - @Override - public Mono deleteUser(Long id) { - // delete processing - users.remove(id); - return Mono.just("Delete Succesfully!"); - } -} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app70/Coffee.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app70/Coffee.java deleted file mode 100644 index 0151623b1..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app70/Coffee.java +++ /dev/null @@ -1,60 +0,0 @@ -package test.org.springdoc.api.app70; - -import java.util.Objects; - -public class Coffee { - - private String id; - - private String name; - - public Coffee() { - } - - public Coffee(String name) { - this.name = name; - } - - public Coffee(String id, String name) { - this.id = id; - this.name = name; - } - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - Coffee coffee = (Coffee) o; - return Objects.equals(id, coffee.id) && - Objects.equals(name, coffee.name); - } - - @Override - public int hashCode() { - return Objects.hash(id, name); - } - - @Override - public String toString() { - return "Coffee{" + - "id='" + id + '\'' + - ", name='" + name + '\'' + - '}'; - } -} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app70/CoffeeOrder.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app70/CoffeeOrder.java deleted file mode 100644 index 1cb918689..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app70/CoffeeOrder.java +++ /dev/null @@ -1,48 +0,0 @@ -package test.org.springdoc.api.app70; - -import java.time.Instant; -import java.util.Objects; - -public class CoffeeOrder { - private String coffeeId; - - private Instant whenOrdered; - - public CoffeeOrder() { - } - - public CoffeeOrder(String coffeeId, Instant whenOrdered) { - this.coffeeId = coffeeId; - this.whenOrdered = whenOrdered; - } - - public String getCoffeeId() { - return coffeeId; - } - - public Instant getWhenOrdered() { - return whenOrdered; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - CoffeeOrder that = (CoffeeOrder) o; - return Objects.equals(coffeeId, that.coffeeId) && - Objects.equals(whenOrdered, that.whenOrdered); - } - - @Override - public int hashCode() { - return Objects.hash(coffeeId, whenOrdered); - } - - @Override - public String toString() { - return "CoffeeOrder{" + - "coffeeId='" + coffeeId + '\'' + - ", whenOrdered=" + whenOrdered + - '}'; - } -} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app70/CoffeeRepository.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app70/CoffeeRepository.java deleted file mode 100644 index 2243765ec..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app70/CoffeeRepository.java +++ /dev/null @@ -1,26 +0,0 @@ -package test.org.springdoc.api.app70; - -import org.reactivestreams.Publisher; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; - -import org.springframework.stereotype.Repository; - -@Repository -public class CoffeeRepository { - Flux deleteAll() { - return null; - } - - Mono findById(String id) { - return null; - } - - Publisher save(Coffee coffee) { - return null; - } - - Flux findAll() { - return null; - } -} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app70/CoffeeService.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app70/CoffeeService.java deleted file mode 100644 index 053cd196d..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app70/CoffeeService.java +++ /dev/null @@ -1,34 +0,0 @@ -package test.org.springdoc.api.app70; - -import java.time.Duration; -import java.time.Instant; - -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.enums.ParameterIn; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; - -import org.springframework.stereotype.Service; - -@Service -public class CoffeeService { - private final CoffeeRepository repo; - - public CoffeeService(CoffeeRepository repo) { - this.repo = repo; - } - - Flux getAllCoffees() { - return repo.findAll(); - } - - Mono getCoffeeById(@Parameter(in = ParameterIn.PATH) String id) { - return repo.findById(id); - } - - Flux getOrdersForCoffeeById(@Parameter(in = ParameterIn.PATH) String id) { - return Flux.interval(Duration.ofSeconds(1)) - .onBackpressureDrop() - .map(i -> new CoffeeOrder(id, Instant.now())); - } -} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app70/RouteConfig.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app70/RouteConfig.java deleted file mode 100644 index 2048118e4..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app70/RouteConfig.java +++ /dev/null @@ -1,50 +0,0 @@ -package test.org.springdoc.api.app70; - -import org.springdoc.core.annotations.RouterOperation; -import org.springdoc.core.annotations.RouterOperations; -import reactor.core.publisher.Mono; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.http.MediaType; -import org.springframework.web.reactive.function.server.RouterFunction; -import org.springframework.web.reactive.function.server.ServerRequest; -import org.springframework.web.reactive.function.server.ServerResponse; - -import static org.springframework.web.reactive.function.server.RequestPredicates.GET; -import static org.springframework.web.reactive.function.server.RouterFunctions.route; - -@Configuration -public class RouteConfig { - private final CoffeeService service; - - public RouteConfig(CoffeeService service) { - this.service = service; - } - - @Bean - @RouterOperations({ @RouterOperation(path = "/coffees", beanClass = CoffeeService.class, beanMethod = "getAllCoffees"), - @RouterOperation(path = "/coffees/{id}", beanClass = CoffeeService.class, beanMethod = "getCoffeeById"), - @RouterOperation(path = "/coffees/{id}/orders", beanClass = CoffeeService.class, beanMethod = "getOrdersForCoffeeById") }) - RouterFunction routerFunction() { - return route(GET("/coffees"), this::all) - .andRoute(GET("/coffees/{id}"), this::byId) - .andRoute(GET("/coffees/{id}/orders"), this::orders); - } - - private Mono all(ServerRequest req) { - return ServerResponse.ok() - .body(service.getAllCoffees(), Coffee.class); - } - - private Mono byId(ServerRequest req) { - return ServerResponse.ok() - .body(service.getCoffeeById(req.pathVariable("id")), Coffee.class); - } - - private Mono orders(ServerRequest req) { - return ServerResponse.ok() - .contentType(MediaType.TEXT_EVENT_STREAM) - .body(service.getOrdersForCoffeeById(req.pathVariable("id")), CoffeeOrder.class); - } -} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app70/SpringDocApp70Test.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app70/SpringDocApp70Test.java deleted file mode 100644 index e6cd2f115..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app70/SpringDocApp70Test.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app70; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.ComponentScan; - -public class SpringDocApp70Test extends AbstractSpringDocTest { - - @SpringBootApplication - @ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.app70" }) - static class SpringDocTestApp {} -} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app71/Employee.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app71/Employee.java deleted file mode 100644 index d4183422a..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app71/Employee.java +++ /dev/null @@ -1,24 +0,0 @@ -package test.org.springdoc.api.app71; - -public class Employee { - - private String id; - - private String name; - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } -} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app71/EmployeeFunctionalConfig.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app71/EmployeeFunctionalConfig.java deleted file mode 100644 index a662f5ba1..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app71/EmployeeFunctionalConfig.java +++ /dev/null @@ -1,82 +0,0 @@ -package test.org.springdoc.api.app71; - -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.enums.ParameterIn; -import io.swagger.v3.oas.annotations.media.Content; -import io.swagger.v3.oas.annotations.media.Schema; -import io.swagger.v3.oas.annotations.responses.ApiResponse; -import org.springdoc.core.annotations.RouterOperation; -import org.springdoc.core.annotations.RouterOperations; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.http.MediaType; -import org.springframework.web.reactive.function.BodyExtractors; -import org.springframework.web.reactive.function.server.RouterFunction; -import org.springframework.web.reactive.function.server.ServerResponse; - -import static org.springframework.web.reactive.function.server.RequestPredicates.GET; -import static org.springframework.web.reactive.function.server.RequestPredicates.POST; -import static org.springframework.web.reactive.function.server.RequestPredicates.accept; -import static org.springframework.web.reactive.function.server.RouterFunctions.route; -import static org.springframework.web.reactive.function.server.ServerResponse.ok; - -@Configuration -public class EmployeeFunctionalConfig { - - - @Bean - EmployeeRepository employeeRepository() { - return new EmployeeRepository(); - } - - @Bean - @RouterOperation(beanClass = EmployeeRepository.class, beanMethod = "findAllEmployees") - RouterFunction getAllEmployeesRoute() { - return route(GET("/employees").and(accept(MediaType.APPLICATION_JSON)), - req -> ok().body( - employeeRepository().findAllEmployees(), Employee.class)); - } - - @Bean - @RouterOperation(operation = @Operation(operationId = "findEmployeeById", summary = "Find purchase order by ID", tags = { "MyEmployee" }, - parameters = { @Parameter(in = ParameterIn.PATH, name = "id", description = "Employee Id") }, - responses = { @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(schema = @Schema(implementation = Employee.class))), - @ApiResponse(responseCode = "400", description = "Invalid Employee ID supplied"), - @ApiResponse(responseCode = "404", description = "Employee not found") })) - RouterFunction getEmployeeByIdRoute() { - return route(GET("/employees/{id}"), - req -> ok().body( - employeeRepository().findEmployeeById(req.pathVariable("id")), Employee.class)); - } - - - @Bean - @RouterOperation(beanClass = EmployeeRepository.class, beanMethod = "updateEmployee") - RouterFunction updateEmployeeRoute() { - return route(POST("/employees/update").and(accept(MediaType.APPLICATION_XML)), - req -> req.body(BodyExtractors.toMono(Employee.class)) - .doOnNext(employeeRepository()::updateEmployee) - .then(ok().build())); - } - - @Bean - @RouterOperations({ @RouterOperation(path = "/employees-composed/update", beanClass = EmployeeRepository.class, beanMethod = "updateEmployee"), - @RouterOperation(path = "/employees-composed/{id}", beanClass = EmployeeRepository.class, beanMethod = "findEmployeeById"), - @RouterOperation(path = "/employees-composed", beanClass = EmployeeRepository.class, beanMethod = "findAllEmployees") }) - RouterFunction composedRoutes() { - return - route(GET("/employees-composed"), - req -> ok().body( - employeeRepository().findAllEmployees(), Employee.class)) - .and(route(GET("/employees-composed/{id}"), - req -> ok().body( - employeeRepository().findEmployeeById(req.pathVariable("id")), Employee.class))) - .and(route(POST("/employees-composed/update"), - req -> req.body(BodyExtractors.toMono(Employee.class)) - .doOnNext(employeeRepository()::updateEmployee) - .then(ok().build()))); - } - -} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app71/EmployeeRepository.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app71/EmployeeRepository.java deleted file mode 100644 index 80e6e380d..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app71/EmployeeRepository.java +++ /dev/null @@ -1,32 +0,0 @@ -package test.org.springdoc.api.app71; - -import java.util.Map; - -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.enums.ParameterIn; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; - -public class EmployeeRepository { - - static Map employeeData; - - static Map employeeAccessData; - - - public Mono findEmployeeById(@Parameter(in = ParameterIn.PATH) String id) { - return Mono.just(employeeData.get(id)); - } - - public Flux findAllEmployees() { - return Flux.fromIterable(employeeData.values()); - } - - public Mono updateEmployee(Employee employee) { - Employee existingEmployee = employeeData.get(employee.getId()); - if (existingEmployee != null) { - existingEmployee.setName(employee.getName()); - } - return Mono.just(existingEmployee); - } -} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app71/SpringDocApp71Test.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app71/SpringDocApp71Test.java deleted file mode 100644 index 41f252f62..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app71/SpringDocApp71Test.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app71; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.ComponentScan; - -public class SpringDocApp71Test extends AbstractSpringDocTest { - - @SpringBootApplication - @ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.app71" }) - static class SpringDocTestApp {} -} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app72/SpringDocApp72Test.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app72/SpringDocApp72Test.java deleted file mode 100644 index 153324014..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app72/SpringDocApp72Test.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * - * * - * * * Copyright 2019-2020 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.app72; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.ComponentScan; - -public class SpringDocApp72Test extends AbstractSpringDocTest { - - @SpringBootApplication - @ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.app72" }) - static class SpringDocTestApp {} -} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app72/controller/PersonRouter.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app72/controller/PersonRouter.java deleted file mode 100644 index 850796b3c..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app72/controller/PersonRouter.java +++ /dev/null @@ -1,36 +0,0 @@ -package test.org.springdoc.api.app72.controller; - -import org.springdoc.core.annotations.RouterOperation; -import org.springdoc.core.annotations.RouterOperations; -import test.org.springdoc.api.app72.handler.PersonHandler; -import test.org.springdoc.api.app72.service.PersonService; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.http.MediaType; -import org.springframework.web.reactive.function.server.RouterFunction; -import org.springframework.web.reactive.function.server.RouterFunctions; -import org.springframework.web.reactive.function.server.ServerResponse; - -import static org.springframework.web.reactive.function.server.RequestPredicates.DELETE; -import static org.springframework.web.reactive.function.server.RequestPredicates.GET; -import static org.springframework.web.reactive.function.server.RequestPredicates.POST; -import static org.springframework.web.reactive.function.server.RequestPredicates.accept; - -@Configuration -public class PersonRouter { - - @RouterOperations({ @RouterOperation(path = "/getAllPersons", beanClass = PersonService.class, beanMethod = "getAll"), - @RouterOperation(path = "/getPerson/{id}", beanClass = PersonService.class, beanMethod = "getById"), - @RouterOperation(path = "/createPerson", beanClass = PersonService.class, beanMethod = "save"), - @RouterOperation(path = "/deletePerson/{id}", beanClass = PersonService.class, beanMethod = "delete") }) - @Bean - public RouterFunction personRoute(PersonHandler handler) { - return RouterFunctions - .route(GET("/getAllPersons").and(accept(MediaType.APPLICATION_JSON)), handler::findAll) - .andRoute(GET("/getPerson/{id}").and(accept(MediaType.APPLICATION_STREAM_JSON)), handler::findById) - .andRoute(POST("/createPerson").and(accept(MediaType.APPLICATION_JSON)), handler::save) - .andRoute(DELETE("/deletePerson/{id}").and(accept(MediaType.APPLICATION_JSON)), handler::delete); - } - -} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app72/controller/PositionRouter.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app72/controller/PositionRouter.java deleted file mode 100644 index cfbc715f0..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app72/controller/PositionRouter.java +++ /dev/null @@ -1,48 +0,0 @@ -package test.org.springdoc.api.app72.controller; - -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.enums.ParameterIn; -import io.swagger.v3.oas.annotations.media.ArraySchema; -import io.swagger.v3.oas.annotations.media.Content; -import io.swagger.v3.oas.annotations.media.Schema; -import io.swagger.v3.oas.annotations.parameters.RequestBody; -import io.swagger.v3.oas.annotations.responses.ApiResponse; -import org.springdoc.core.annotations.RouterOperation; -import org.springdoc.core.annotations.RouterOperations; -import test.org.springdoc.api.app72.entity.Position; -import test.org.springdoc.api.app72.handler.PositionHandler; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.http.MediaType; -import org.springframework.web.reactive.function.server.RouterFunction; -import org.springframework.web.reactive.function.server.RouterFunctions; -import org.springframework.web.reactive.function.server.ServerResponse; - -import static org.springframework.web.reactive.function.server.RequestPredicates.DELETE; -import static org.springframework.web.reactive.function.server.RequestPredicates.GET; -import static org.springframework.web.reactive.function.server.RequestPredicates.POST; -import static org.springframework.web.reactive.function.server.RequestPredicates.accept; - -@Configuration -public class PositionRouter { - - @Bean - @RouterOperations({ @RouterOperation(path = "/getAllPositions", operation = @Operation(description = "Get all positions", operationId = "findAll", tags = "positions", - responses = @ApiResponse(responseCode = "200", content = @Content(array = @ArraySchema(schema = @Schema(implementation = Position.class)))))), - @RouterOperation(path = "/getPosition/{id}", operation = @Operation(description = "Find all", operationId = "findById", tags = "positions", parameters = @Parameter(name = "id", in = ParameterIn.PATH), - responses = @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = Position.class))))), - @RouterOperation(path = "/createPosition", operation = @Operation(description = "Save position", operationId = "save", tags = "positions", requestBody = @RequestBody(content = @Content(schema = @Schema(implementation = Position.class))), - responses = @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = Position.class))))), - @RouterOperation(path = "/deletePosition/{id}", operation = @Operation(description = "Delete By Id", operationId = "deleteBy", tags = "positions", parameters = @Parameter(name = "id", in = ParameterIn.PATH), - responses = @ApiResponse(responseCode = "200", content = @Content))) }) - public RouterFunction positionRoute(PositionHandler handler) { - return RouterFunctions - .route(GET("/getAllPositions").and(accept(MediaType.APPLICATION_JSON)), handler::findAll) - .andRoute(GET("/getPosition/{id}").and(accept(MediaType.APPLICATION_STREAM_JSON)), handler::findById) - .andRoute(POST("/createPosition").and(accept(MediaType.APPLICATION_JSON)), handler::save) - .andRoute(DELETE("/deletePosition/{id}").and(accept(MediaType.APPLICATION_JSON)), handler::delete); - } - -} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app72/entity/Person.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app72/entity/Person.java deleted file mode 100644 index 1edfbe049..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app72/entity/Person.java +++ /dev/null @@ -1,74 +0,0 @@ -package test.org.springdoc.api.app72.entity; - -public class Person { - - private String id; - - private Sex sex; - - private String firstName; - - private String lastName; - - private String age; - - private String interests; - - private String email; - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public Sex getSex() { - return sex; - } - - public void setSex(Sex sex) { - this.sex = sex; - } - - public String getFirstName() { - return firstName; - } - - public void setFirstName(String firstName) { - this.firstName = firstName; - } - - public String getLastName() { - return lastName; - } - - public void setLastName(String lastName) { - this.lastName = lastName; - } - - public String getAge() { - return age; - } - - public void setAge(String age) { - this.age = age; - } - - public String getInterests() { - return interests; - } - - public void setInterests(String interests) { - this.interests = interests; - } - - public String getEmail() { - return email; - } - - public void setEmail(String email) { - this.email = email; - } -} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app72/entity/Position.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app72/entity/Position.java deleted file mode 100644 index ce147fc3a..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app72/entity/Position.java +++ /dev/null @@ -1,54 +0,0 @@ -package test.org.springdoc.api.app72.entity; - -import java.util.Date; - -import jakarta.validation.constraints.NotBlank; -import jakarta.validation.constraints.NotNull; -import jakarta.validation.constraints.Size; - - -public class Position { - - private String id; - - @NotBlank - @Size(max = 140) - private String positionName; - - private String description; - - @NotNull - private Date createdAt = new Date(); - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getPositionName() { - return positionName; - } - - public void setPositionName(String positionName) { - this.positionName = positionName; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public Date getCreatedAt() { - return createdAt; - } - - public void setCreatedAt(Date createdAt) { - this.createdAt = createdAt; - } -} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app72/entity/Sex.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app72/entity/Sex.java deleted file mode 100644 index 49e457b67..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app72/entity/Sex.java +++ /dev/null @@ -1,5 +0,0 @@ -package test.org.springdoc.api.app72.entity; - -public enum Sex { - MAN, WOMEN -} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app72/exception/PositionNotFoundException.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app72/exception/PositionNotFoundException.java deleted file mode 100644 index 4e2e5d872..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app72/exception/PositionNotFoundException.java +++ /dev/null @@ -1,8 +0,0 @@ -package test.org.springdoc.api.app72.exception; - -public class PositionNotFoundException extends RuntimeException { - - public PositionNotFoundException(String positionId) { - super("Position not found with id " + positionId); - } -} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app72/handler/PersonHandler.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app72/handler/PersonHandler.java deleted file mode 100644 index 8bc6b8c85..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app72/handler/PersonHandler.java +++ /dev/null @@ -1,52 +0,0 @@ -package test.org.springdoc.api.app72.handler; - -import reactor.core.publisher.Mono; -import test.org.springdoc.api.app72.entity.Person; -import test.org.springdoc.api.app72.service.PersonService; - -import org.springframework.http.MediaType; -import org.springframework.stereotype.Component; -import org.springframework.web.reactive.function.BodyInserters; -import org.springframework.web.reactive.function.server.ServerRequest; -import org.springframework.web.reactive.function.server.ServerResponse; - -import static org.springframework.web.reactive.function.server.ServerResponse.ok; - -@Component -@SuppressWarnings({ "deprecared", "unchecked" }) -public class PersonHandler { - - private final PersonService personService; - - public PersonHandler(PersonService personService) { - this.personService = personService; - } - - public Mono findById(ServerRequest request) { - String id = request.pathVariable("id"); - return ok() - .contentType(MediaType.APPLICATION_JSON) - .body(personService.getById(id), Person.class); - } - - public Mono findAll(ServerRequest request) { - return ok() - .contentType(MediaType.APPLICATION_JSON) - .body(personService.getAll(), Person.class); - } - - public Mono save(ServerRequest request) { - final Mono person = request.bodyToMono(Person.class); - return ok() - .contentType(MediaType.APPLICATION_JSON) - .body(BodyInserters.fromPublisher(person.flatMap(personService::save), Person.class)); - } - - public Mono delete(ServerRequest request) { - String id = request.pathVariable("id"); - return ok() - .contentType(MediaType.APPLICATION_JSON) - .body(personService.delete(id), Void.class); - } - -} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app72/handler/PositionHandler.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app72/handler/PositionHandler.java deleted file mode 100644 index feaa44aa0..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app72/handler/PositionHandler.java +++ /dev/null @@ -1,30 +0,0 @@ -package test.org.springdoc.api.app72.handler; - -import reactor.core.publisher.Mono; - -import org.springframework.stereotype.Component; -import org.springframework.web.reactive.function.server.ServerRequest; -import org.springframework.web.reactive.function.server.ServerResponse; - -@Component -public class PositionHandler { - - - public Mono findById(ServerRequest request) { - String id = request.pathVariable("id"); - return null; - } - - public Mono findAll(ServerRequest request) { - return null; - } - - public Mono save(ServerRequest request) { - return null; - } - - public Mono delete(ServerRequest request) { - return null; - } - -} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app72/payload/ErrorResponse.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app72/payload/ErrorResponse.java deleted file mode 100644 index f05cc7797..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app72/payload/ErrorResponse.java +++ /dev/null @@ -1,19 +0,0 @@ -package test.org.springdoc.api.app72.payload; - -public class ErrorResponse { - - private String message; - - public ErrorResponse(String message) { - this.message = message; - } - - public String getMessage() { - return message; - } - - public void setMessage(String message) { - this.message = message; - } - -} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app72/service/PersonService.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app72/service/PersonService.java deleted file mode 100644 index c1ac684bc..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app72/service/PersonService.java +++ /dev/null @@ -1,39 +0,0 @@ -package test.org.springdoc.api.app72.service; - -import java.util.Objects; - -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.enums.ParameterIn; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; -import test.org.springdoc.api.app72.entity.Person; - -import org.springframework.stereotype.Service; - -@Service -public class PersonService { - - public Flux getAll() { - return null; - } - - public Mono getById(@Parameter(in = ParameterIn.PATH) final String id) { - return null; - } - - public Mono update(@Parameter(in = ParameterIn.PATH) final String id, final Person person) { - return null; - } - - public Mono save(final Person person) { - return null; - } - - public Mono delete(@Parameter(in = ParameterIn.PATH) final String id) { - final Mono dbPerson = getById(id); - if (Objects.isNull(dbPerson)) { - return Mono.empty(); - } - return null; - } -} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app73/Quote.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app73/Quote.java deleted file mode 100644 index 34eb837d6..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app73/Quote.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * - * * - * * * Copyright 2019-2020 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.app73; - - -import java.math.BigDecimal; -import java.math.MathContext; -import java.time.Instant; - -public class Quote { - - private static final MathContext MATH_CONTEXT = new MathContext(2); - - private String ticker; - - private BigDecimal price; - - private Instant instant; - - public Quote() { - } - - public Quote(String ticker, BigDecimal price) { - this.ticker = ticker; - this.price = price; - } - - public Quote(String ticker, Double price) { - this(ticker, new BigDecimal(price, MATH_CONTEXT)); - } - - public String getTicker() { - return ticker; - } - - public void setTicker(String ticker) { - this.ticker = ticker; - } - - public BigDecimal getPrice() { - return price; - } - - public void setPrice(BigDecimal price) { - this.price = price; - } - - public Instant getInstant() { - return instant; - } - - public void setInstant(Instant instant) { - this.instant = instant; - } - - @Override - public String toString() { - return "Quote{" + - "ticker='" + ticker + '\'' + - ", price=" + price + - ", instant=" + instant + - '}'; - } -} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app73/QuoteGenerator.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app73/QuoteGenerator.java deleted file mode 100644 index 305934d2c..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app73/QuoteGenerator.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * - * * - * * * Copyright 2019-2020 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.app73; - - -import java.math.BigDecimal; -import java.math.MathContext; -import java.time.Duration; -import java.time.Instant; -import java.util.ArrayList; -import java.util.List; -import java.util.Random; - -import reactor.core.publisher.Flux; - -import org.springframework.stereotype.Component; - -@Component -public class QuoteGenerator { - - private final MathContext mathContext = new MathContext(2); - - private final Random random = new Random(); - - private final List prices = new ArrayList<>(); - - /** - * Bootstraps the generator with tickers and initial prices - */ - public QuoteGenerator() { - this.prices.add(new Quote("CTXS", 82.26)); - this.prices.add(new Quote("DELL", 63.74)); - this.prices.add(new Quote("GOOG", 847.24)); - this.prices.add(new Quote("MSFT", 65.11)); - this.prices.add(new Quote("ORCL", 45.71)); - this.prices.add(new Quote("RHT", 84.29)); - this.prices.add(new Quote("VMW", 92.21)); - } - - - public Flux fetchQuoteStream(Duration period) { - - // We want to emit quotes with a specific period; - // to do so, we create a Flux.interval - return Flux.interval(period) - // In case of back-pressure, drop events - .onBackpressureDrop() - // For each tick, generate a list of quotes - .map(this::generateQuotes) - // "flatten" that List into a Flux - .flatMapIterable(quotes -> quotes) - .log("io.spring.workshop.stockquotes"); - } - - /* - * Create quotes for all tickers at a single instant. - */ - private List generateQuotes(long interval) { - final Instant instant = Instant.now(); - return prices.stream() - .map(baseQuote -> { - BigDecimal priceChange = baseQuote.getPrice() - .multiply(new BigDecimal(0.05 * this.random.nextDouble()), this.mathContext); - Quote result = new Quote(baseQuote.getTicker(), baseQuote.getPrice().add(priceChange)); - result.setInstant(instant); - return result; - }) - .toList(); - } - -} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app73/QuoteHandler.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app73/QuoteHandler.java deleted file mode 100644 index d99c917fd..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app73/QuoteHandler.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * - * * - * * * Copyright 2019-2020 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.app73; - - -import java.time.Duration; - -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; - -import org.springframework.http.MediaType; -import org.springframework.stereotype.Component; -import org.springframework.web.reactive.function.BodyInserters; -import org.springframework.web.reactive.function.server.ServerRequest; -import org.springframework.web.reactive.function.server.ServerResponse; - -@Component -public class QuoteHandler { - - private final Flux quoteStream; - - public QuoteHandler(QuoteGenerator quoteGenerator) { - this.quoteStream = quoteGenerator.fetchQuoteStream(Duration.ofMillis(1000)).share(); - } - - public Mono hello(ServerRequest request) { - return ServerResponse.ok().contentType(MediaType.TEXT_PLAIN) - .body(BodyInserters.fromObject("Hello Spring!")); - } - - public Mono echo(ServerRequest request) { - return ServerResponse.ok().contentType(MediaType.TEXT_PLAIN) - .body(request.bodyToMono(String.class), String.class); - } - - public Mono streamQuotes(ServerRequest request) { - return ServerResponse.ok() - .contentType(MediaType.APPLICATION_STREAM_JSON) - .body(this.quoteStream, Quote.class); - } - - public Mono fetchQuotes(ServerRequest request) { - int size = Integer.parseInt(request.queryParam("size").orElse("10")); - return ServerResponse.ok() - .contentType(MediaType.APPLICATION_JSON) - .body(this.quoteStream.take(size), Quote.class); - } -} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app73/QuoteRouter.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app73/QuoteRouter.java deleted file mode 100644 index babcf8957..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app73/QuoteRouter.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * - * * - * * * Copyright 2019-2020 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.app73; - -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.enums.ParameterIn; -import io.swagger.v3.oas.annotations.media.ArraySchema; -import io.swagger.v3.oas.annotations.media.Content; -import io.swagger.v3.oas.annotations.media.Schema; -import io.swagger.v3.oas.annotations.parameters.RequestBody; -import io.swagger.v3.oas.annotations.responses.ApiResponse; -import org.springdoc.core.annotations.RouterOperation; -import org.springdoc.core.annotations.RouterOperations; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.web.reactive.function.server.RouterFunction; -import org.springframework.web.reactive.function.server.RouterFunctions; -import org.springframework.web.reactive.function.server.ServerResponse; - -import static org.springframework.http.MediaType.APPLICATION_JSON; -import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE; -import static org.springframework.http.MediaType.APPLICATION_STREAM_JSON; -import static org.springframework.http.MediaType.APPLICATION_STREAM_JSON_VALUE; -import static org.springframework.http.MediaType.TEXT_PLAIN; -import static org.springframework.http.MediaType.TEXT_PLAIN_VALUE; -import static org.springframework.web.reactive.function.server.RequestPredicates.GET; -import static org.springframework.web.reactive.function.server.RequestPredicates.POST; -import static org.springframework.web.reactive.function.server.RequestPredicates.accept; -import static org.springframework.web.reactive.function.server.RequestPredicates.contentType; - -@Configuration -public class QuoteRouter { - - @RouterOperations({ - @RouterOperation(path = "/hello", operation = @Operation(operationId = "hello", responses = @ApiResponse(responseCode = "200"))), - @RouterOperation(path = "/echo", produces = TEXT_PLAIN_VALUE, operation = @Operation(operationId = "echo", requestBody = @RequestBody(content = @Content(schema = @Schema(type = "string"))), - responses = @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(type = "string"))))), - @RouterOperation(path = "/echo", produces = APPLICATION_JSON_VALUE, operation = @Operation(operationId = "echo", requestBody = @RequestBody(content = @Content(schema = @Schema(type = "string"))), - responses = @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(type = "string"))))), - @RouterOperation(path = "/quotes", produces = APPLICATION_JSON_VALUE, operation = @Operation(operationId = "fetchQuotes", parameters = @Parameter(name = "size", in = ParameterIn.QUERY, schema = @Schema(type = "string")), - responses = @ApiResponse(responseCode = "200", content = @Content(array = @ArraySchema(schema = @Schema(implementation = Quote.class)))))), - @RouterOperation(path = "/quotes", produces = APPLICATION_STREAM_JSON_VALUE, operation = @Operation(operationId = "fetchQuotes", - responses = @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = Quote.class))))) }) - @Bean - public RouterFunction route(QuoteHandler quoteHandler) { - return RouterFunctions - .route(GET("/hello").and(accept(TEXT_PLAIN)), quoteHandler::hello) - .andRoute(POST("/echo").and(accept(TEXT_PLAIN).and(contentType(TEXT_PLAIN))), quoteHandler::echo) - .andRoute(POST("/echo").and(accept(APPLICATION_JSON).and(contentType(APPLICATION_JSON))), quoteHandler::echo) - .andRoute(GET("/quotes").and(accept(APPLICATION_JSON)), quoteHandler::fetchQuotes) - .andRoute(GET("/quotes").and(accept(APPLICATION_STREAM_JSON)), quoteHandler::streamQuotes); - } -} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app73/SpringDocApp73Test.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app73/SpringDocApp73Test.java deleted file mode 100644 index e65782664..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app73/SpringDocApp73Test.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * - * * - * * * Copyright 2019-2020 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.app73; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.ComponentScan; - -public class SpringDocApp73Test extends AbstractSpringDocTest { - - @SpringBootApplication - @ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.app73" }) - static class SpringDocTestApp {} -} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app74/Book.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app74/Book.java deleted file mode 100644 index 3cce755e9..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app74/Book.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * - * * - * * * Copyright 2019-2020 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.app74; - -public class Book { - - private String id; - - private String title; - - private String author; - - public Book(String id, String title, String author) { - this.id = id; - this.title = title; - this.author = author; - } - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getTitle() { - return title; - } - - public void setTitle(String title) { - this.title = title; - } - - public String getAuthor() { - return author; - } - - public void setAuthor(String author) { - this.author = author; - } -} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app74/BookRepository.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app74/BookRepository.java deleted file mode 100644 index 298dba914..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app74/BookRepository.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * - * * - * * * Copyright 2019-2020 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.app74; - -import reactor.core.publisher.Flux; - -import org.springframework.stereotype.Component; - -@Component -public class BookRepository { - - - Flux findByAuthor(String author) { - return Flux.just(new Book("1", "title1", "author1")); - } - - Flux findAll() { - return Flux.just(new Book("2", "title2", "author2")); - } -} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app74/BookRouter.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app74/BookRouter.java deleted file mode 100644 index 81577bddb..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app74/BookRouter.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * - * * - * * * Copyright 2019-2020 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.app74; - -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.enums.ParameterIn; -import org.springdoc.core.annotations.RouterOperation; -import org.springdoc.core.annotations.RouterOperations; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.http.MediaType; -import org.springframework.web.reactive.function.server.RouterFunction; - -import static org.springframework.web.reactive.function.server.RequestPredicates.GET; -import static org.springframework.web.reactive.function.server.RequestPredicates.accept; -import static org.springframework.web.reactive.function.server.RouterFunctions.route; -import static org.springframework.web.reactive.function.server.ServerResponse.ok; - -@Configuration -class BookRouter { - - @Bean - @RouterOperations({ - @RouterOperation(path = "/books", produces = { MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE }, beanClass = BookRepository.class, beanMethod = "findAll"), - @RouterOperation(path = "/books", produces = { MediaType.TEXT_PLAIN_VALUE, MediaType.APPLICATION_XML_VALUE }, beanClass = BookRepository.class, beanMethod = "findAll"), - @RouterOperation(path = "/books/{author}", beanClass = BookRepository.class, beanMethod = "findByAuthor", - operation = @Operation(operationId = "findByAuthor" - , parameters = { @Parameter(in = ParameterIn.PATH, name = "author") })) }) - RouterFunction routes(BookRepository br) { - return - route(GET("/books").and(accept(MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML)), req -> ok().body(br.findAll(), Book.class)) - .and(route(GET("/books").and(accept(MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN)), req -> ok().body(br.findAll(), Book.class))) - .andRoute(GET("/books/{author}"), req -> ok().body(br.findByAuthor(req.pathVariable("author")), Book.class)); - } -} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app74/SpringDocApp74Test.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app74/SpringDocApp74Test.java deleted file mode 100644 index 82ee9c754..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app74/SpringDocApp74Test.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * - * * - * * * Copyright 2019-2020 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.app74; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.ComponentScan; - -public class SpringDocApp74Test extends AbstractSpringDocTest { - - @SpringBootApplication - @ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.app74" }) - static class SpringDocTestApp {} -} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app75/Post.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app75/Post.java deleted file mode 100644 index f2013dd87..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app75/Post.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * - * * - * * * Copyright 2019-2020 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.app75; - -import java.time.LocalDateTime; - -public class Post { - - private String id; - - private String title; - - private String content; - - private LocalDateTime createdDate; - - public Post(String id, String title, String content) { - this.id = id; - this.title = title; - this.content = content; - this.createdDate = LocalDateTime.now(); - } - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getTitle() { - return title; - } - - public void setTitle(String title) { - this.title = title; - } - - public String getContent() { - return content; - } - - public void setContent(String content) { - this.content = content; - } - - public LocalDateTime getCreatedDate() { - return createdDate; - } - - public void setCreatedDate(LocalDateTime createdDate) { - this.createdDate = createdDate; - } -} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app75/PostHandler.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app75/PostHandler.java deleted file mode 100644 index 90f4d94a3..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app75/PostHandler.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * - * * - * * * Copyright 2019-2020 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.app75; - - -import java.net.URI; - -import reactor.core.publisher.Mono; - -import org.springframework.stereotype.Component; -import org.springframework.web.reactive.function.server.ServerRequest; -import org.springframework.web.reactive.function.server.ServerResponse; - -@Component -class PostHandler { - - private final PostRepository posts; - - public PostHandler(PostRepository posts) { - this.posts = posts; - } - - public Mono all(ServerRequest req) { - return ServerResponse.ok().body(this.posts.findAll(), Post.class); - } - - public Mono create(ServerRequest req) { - return req.bodyToMono(Post.class) - .flatMap(post -> this.posts.save(post)) - .flatMap(p -> ServerResponse.created(URI.create("/posts/" + p.getId())).build()); - } - - public Mono get(ServerRequest req) { - return this.posts.findById(req.pathVariable("id")) - .flatMap(post -> ServerResponse.ok().body(Mono.just(post), Post.class)) - .switchIfEmpty(ServerResponse.notFound().build()); - } - - public Mono update(ServerRequest req) { - - return Mono - .zip( - (data) -> { - Post p = (Post) data[0]; - Post p2 = (Post) data[1]; - p.setTitle(p2.getTitle()); - p.setContent(p2.getContent()); - return p; - }, - this.posts.findById(req.pathVariable("id")), - req.bodyToMono(Post.class) - ) - .cast(Post.class) - .flatMap(post -> this.posts.save(post)) - .flatMap(post -> ServerResponse.noContent().build()); - - } - -} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app75/PostRepository.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app75/PostRepository.java deleted file mode 100644 index 5277e026d..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app75/PostRepository.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * - * * - * * * Copyright 2019-2020 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.app75; - -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; - -import org.springframework.stereotype.Component; - -@Component -public class PostRepository { - - public Flux findByAuthor(String author) { - return Flux.just(new Post("1", "title1", "author1")); - } - - public Flux findAll() { - return Flux.just(new Post("2", "title2", "author2")); - } - - public Mono findById(String id) { - return Mono.just(new Post("3", "title2", "author2")); - } - - public Mono save(Post post) { - return Mono.just(new Post("4", "title2", "author2")); - } - -} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app75/PostRouter.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app75/PostRouter.java deleted file mode 100644 index c35101c1f..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app75/PostRouter.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * - * * - * * * Copyright 2019-2020 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.app75; - -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.enums.ParameterIn; -import io.swagger.v3.oas.annotations.media.ArraySchema; -import io.swagger.v3.oas.annotations.media.Content; -import io.swagger.v3.oas.annotations.media.Schema; -import io.swagger.v3.oas.annotations.parameters.RequestBody; -import io.swagger.v3.oas.annotations.responses.ApiResponse; -import org.springdoc.core.annotations.RouterOperation; -import org.springdoc.core.annotations.RouterOperations; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.reactive.function.server.RouterFunction; -import org.springframework.web.reactive.function.server.ServerResponse; - -import static org.springframework.web.reactive.function.server.RequestPredicates.GET; -import static org.springframework.web.reactive.function.server.RequestPredicates.POST; -import static org.springframework.web.reactive.function.server.RequestPredicates.PUT; -import static org.springframework.web.reactive.function.server.RequestPredicates.queryParam; -import static org.springframework.web.reactive.function.server.RouterFunctions.route; - -@Configuration -class PostRouter { - - @RouterOperations({ @RouterOperation(path = "/posts", method = RequestMethod.GET, headers = { "x-header1=test1", "x-header2=test2" }, operation = @Operation(operationId = "all", - parameters = { @Parameter(name = "key", description = "sample description"), @Parameter(name = "test", description = "sample desc") }, - responses = @ApiResponse(responseCode = "200", content = @Content(array = @ArraySchema(schema = @Schema(implementation = Post.class)))))), - @RouterOperation(path = "/posts", method = RequestMethod.POST, operation = @Operation(operationId = "create", - requestBody = @RequestBody(content = @Content(schema = @Schema(implementation = Post.class))), responses = @ApiResponse(responseCode = "201"))), - @RouterOperation(path = "/posts/{id}", method = RequestMethod.GET, operation = @Operation(operationId = "get", - parameters = @Parameter(name = "id", in = ParameterIn.PATH), - responses = @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = Post.class))))), - @RouterOperation(path = "/posts/{id}", method = RequestMethod.PUT, operation = @Operation(operationId = "update", - parameters = @Parameter(name = "id", in = ParameterIn.PATH), - responses = @ApiResponse(responseCode = "202", content = @Content(schema = @Schema(implementation = Post.class))))) }) - @Bean - public RouterFunction routes(PostHandler postController) { - return route(GET("/posts").and(queryParam("key", "value")), postController::all) - .andRoute(POST("/posts"), postController::create) - .andRoute(GET("/posts/{id}"), postController::get) - .andRoute(PUT("/posts/{id}"), postController::update); - } -} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app75/SpringDocApp75Test.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app75/SpringDocApp75Test.java deleted file mode 100644 index 826dab7ef..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app75/SpringDocApp75Test.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * - * * - * * * Copyright 2019-2020 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.app75; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.ComponentScan; - -public class SpringDocApp75Test extends AbstractSpringDocTest { - - @SpringBootApplication - @ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.app75" }) - static class SpringDocTestApp {} -} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app78/HelloController.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app78/HelloController.java deleted file mode 100644 index 256c7891b..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app78/HelloController.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app78; - -import java.io.File; -import java.io.IOException; -import java.nio.file.Path; -import java.nio.file.Paths; - -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.media.Content; -import reactor.core.publisher.Flux; - -import org.springframework.http.MediaType; -import org.springframework.http.codec.multipart.FilePart; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestPart; -import org.springframework.web.bind.annotation.RestController; - -@RestController -public class HelloController { - - - @PostMapping(value = "/files", produces = { MediaType.APPLICATION_JSON_VALUE }, consumes = { MediaType.MULTIPART_FORM_DATA_VALUE }) - @Operation(summary = "files") - public Flux handleFileUpload( - @RequestPart("files") @Parameter(description = "files", - content = @Content(mediaType = MediaType.APPLICATION_OCTET_STREAM_VALUE)) - Flux filePartFux) throws IOException { - File tmp = File.createTempFile("tmp", ""); - return filePartFux.flatMap(filePart -> { - Path path = Paths.get(tmp.toString() + filePart.filename()); - System.out.println(path); - return filePart.transferTo(path); - }); - } - -} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app78/SpringDocApp78Test.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app78/SpringDocApp78Test.java deleted file mode 100644 index 7f6ad9955..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app78/SpringDocApp78Test.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * - * * - * * * - * * * * Copyright 2019-2020 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.app78; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.ComponentScan; - -public class SpringDocApp78Test extends AbstractSpringDocTest { - - @SpringBootApplication - @ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.app78" }) - static class SpringDocTestApp {} -} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app79/BaseClientModel.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app79/BaseClientModel.java deleted file mode 100644 index 0b5878ba6..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app79/BaseClientModel.java +++ /dev/null @@ -1,8 +0,0 @@ -package test.org.springdoc.api.app79; - -import com.fasterxml.jackson.annotation.JsonProperty; - -public abstract class BaseClientModel { - @JsonProperty("id") - int id; -} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app79/BaseController.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app79/BaseController.java deleted file mode 100644 index 641dcc85d..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app79/BaseController.java +++ /dev/null @@ -1,20 +0,0 @@ -package test.org.springdoc.api.app79; - -import java.util.List; - -import reactor.core.publisher.Mono; - -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.GetMapping; - -public abstract class BaseController { - @GetMapping("/test1") - Mono> get1() { - return null; - } - - @GetMapping("/test2") - Mono>> get2() { - return null; - } -} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app79/SpecificClientModel.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app79/SpecificClientModel.java deleted file mode 100644 index c14081e21..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app79/SpecificClientModel.java +++ /dev/null @@ -1,10 +0,0 @@ -package test.org.springdoc.api.app79; - -import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.v3.oas.annotations.media.Schema; - -public class SpecificClientModel extends BaseClientModel { - @JsonProperty("name") - @Schema(title = "my title", pattern = "this is it", example = "this is example") - String name; -} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app79/SpecificController.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app79/SpecificController.java deleted file mode 100644 index ec6984aaa..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app79/SpecificController.java +++ /dev/null @@ -1,6 +0,0 @@ -package test.org.springdoc.api.app79; - -import org.springframework.web.bind.annotation.RestController; - -@RestController -public class SpecificController extends BaseController {} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app79/SpringDocApp79Test.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app79/SpringDocApp79Test.java deleted file mode 100644 index dc76a3d1f..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app79/SpringDocApp79Test.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * - * * - * * * - * * * * Copyright 2019-2020 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.app79; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.ComponentScan; - -public class SpringDocApp79Test extends AbstractSpringDocTest { - - @SpringBootApplication - @ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.app79" }) - static class SpringDocTestApp {} -} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app80/Book.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app80/Book.java deleted file mode 100644 index 5785cd907..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app80/Book.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * - * * - * * * Copyright 2019-2020 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.app80; - -public class Book { - - private String id; - - private String title; - - private String author; - - public Book(String id, String title, String author) { - this.id = id; - this.title = title; - this.author = author; - } - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getTitle() { - return title; - } - - public void setTitle(String title) { - this.title = title; - } - - public String getAuthor() { - return author; - } - - public void setAuthor(String author) { - this.author = author; - } -} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app80/BookRepository.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app80/BookRepository.java deleted file mode 100644 index 27dc79eec..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app80/BookRepository.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * - * * - * * * Copyright 2019-2020 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.app80; - -import reactor.core.publisher.Flux; - -import org.springframework.stereotype.Component; - -@Component -public class BookRepository { - - - Flux findByAuthor(String author) { - return Flux.just(new Book("1", "title1", "author1")); - } - - Flux findAll() { - return Flux.just(new Book("2", "title2", "author2")); - } -} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app80/BookRouter.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app80/BookRouter.java deleted file mode 100644 index a5a82f785..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app80/BookRouter.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - * - * * - * * * Copyright 2019-2020 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.app80; - -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.enums.ParameterIn; -import org.springdoc.core.annotations.RouterOperation; -import org.springdoc.core.annotations.RouterOperations; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.http.MediaType; -import org.springframework.web.reactive.function.server.RouterFunction; - -import static org.springframework.web.reactive.function.server.RequestPredicates.GET; -import static org.springframework.web.reactive.function.server.RequestPredicates.accept; -import static org.springframework.web.reactive.function.server.RequestPredicates.path; -import static org.springframework.web.reactive.function.server.RouterFunctions.nest; -import static org.springframework.web.reactive.function.server.RouterFunctions.route; -import static org.springframework.web.reactive.function.server.ServerResponse.ok; - -@Configuration -class BookRouter { - - @Bean - @RouterOperations({ - @RouterOperation(path = "/greeter/greeter2/books", produces = { MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE }, beanClass = BookRepository.class, beanMethod = "findAll"), - @RouterOperation(path = "/greeter/greeter2/books", produces = { MediaType.TEXT_PLAIN_VALUE, MediaType.APPLICATION_XML_VALUE }, beanClass = BookRepository.class, beanMethod = "findAll"), - @RouterOperation(path = "/greeter/greeter2/books/{author}", beanClass = BookRepository.class, beanMethod = "findByAuthor", - operation = @Operation(operationId = "findByAuthor" - , parameters = { @Parameter(in = ParameterIn.PATH, name = "author") })) }) - RouterFunction routes(BookRepository br) { - return - nest(path("/greeter").and(path("/greeter2")), - route(GET("/books").and(accept(MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML)), req -> ok().body(br.findAll(), Book.class)) - .and(route(GET("/books").and(accept(MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN)), req -> ok().body(br.findAll(), Book.class))) - .andRoute(GET("/books/{author}"), req -> ok().body(br.findByAuthor(req.pathVariable("author")), Book.class))); - } - - @Bean - @RouterOperations({ - @RouterOperation(path = "/books", produces = { MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE }, beanClass = BookRepository.class, beanMethod = "findAll"), - @RouterOperation(path = "/books/{author}", beanClass = BookRepository.class, beanMethod = "findByAuthor", - operation = @Operation(operationId = "findByAuthor" - , parameters = { @Parameter(in = ParameterIn.PATH, name = "author") })) }) - RouterFunction routes1(BookRepository br) { - return - nest(accept(MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML), - route(GET("/books"), req -> ok().body(br.findAll(), Book.class)) - .andRoute(GET("/books/{author}"), req -> ok().body(br.findByAuthor(req.pathVariable("author")), Book.class))); - } - - @Bean - @RouterOperations({ - @RouterOperation(path = "/greeter/books", produces = { MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE }, beanClass = BookRepository.class, beanMethod = "findAll"), - @RouterOperation(path = "/greeter/books", produces = { MediaType.TEXT_PLAIN_VALUE, MediaType.APPLICATION_XML_VALUE }, beanClass = BookRepository.class, beanMethod = "findAll"), - @RouterOperation(path = "/greeter/books/{author}", beanClass = BookRepository.class, beanMethod = "findByAuthor", - operation = @Operation(operationId = "findByAuthor" - , parameters = { @Parameter(in = ParameterIn.PATH, name = "author") })), - @RouterOperation(path = "/greeter2/books", produces = { MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE }, beanClass = BookRepository.class, beanMethod = "findAll"), - @RouterOperation(path = "/greeter2/books", produces = { MediaType.TEXT_PLAIN_VALUE, MediaType.APPLICATION_XML_VALUE }, beanClass = BookRepository.class, beanMethod = "findAll"), - @RouterOperation(path = "/greeter2/books/{author}", beanClass = BookRepository.class, beanMethod = "findByAuthor", - operation = @Operation(operationId = "findByAuthor" - , parameters = { @Parameter(in = ParameterIn.PATH, name = "author") })) }) - RouterFunction routes3(BookRepository br) { - return - nest(path("/greeter").or(path("/greeter2")), - route(GET("/books").and(accept(MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML)), req -> ok().body(br.findAll(), Book.class)) - .and(route(GET("/books").and(accept(MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN)), req -> ok().body(br.findAll(), Book.class))) - .andRoute(GET("/books/{author}"), req -> ok().body(br.findByAuthor(req.pathVariable("author")), Book.class))); - } - - @Bean - @RouterOperations({ - @RouterOperation(path = "/test/greeter/greeter2/books", produces = { MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE }, beanClass = BookRepository.class, beanMethod = "findAll"), - @RouterOperation(path = "/test/greeter/greeter2/books", produces = { MediaType.TEXT_PLAIN_VALUE, MediaType.APPLICATION_XML_VALUE }, beanClass = BookRepository.class, beanMethod = "findAll"), - @RouterOperation(path = "/test/greeter/greeter2/books/{author}", beanClass = BookRepository.class, beanMethod = "findByAuthor", - operation = @Operation(operationId = "findByAuthor" - , parameters = { @Parameter(in = ParameterIn.PATH, name = "author") })) }) - RouterFunction routes4(BookRepository br) { - return - nest(path("/test"), - nest(path("/greeter").and(path("/greeter2")), - route(GET("/books").and(accept(MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML)), req -> ok().body(br.findAll(), Book.class)) - .and(route(GET("/books").and(accept(MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN)), req -> ok().body(br.findAll(), Book.class))) - .andRoute(GET("/books/{author}"), req -> ok().body(br.findByAuthor(req.pathVariable("author")), Book.class)))); - } -} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app80/SpringDocApp80Test.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app80/SpringDocApp80Test.java deleted file mode 100644 index 799706e45..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app80/SpringDocApp80Test.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * - * * - * * * - * * * * Copyright 2019-2020 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.app80; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.ComponentScan; - -public class SpringDocApp80Test extends AbstractSpringDocTest { - - @SpringBootApplication - @ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.app80" }) - static class SpringDocTestApp {} -} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app81/OperationIdController.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app81/OperationIdController.java deleted file mode 100644 index cf380f511..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app81/OperationIdController.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app81; - -import reactor.core.publisher.Mono; - -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -@RestController -public class OperationIdController { - - @GetMapping(path = "/test_0") // gets operationId opIdTest_3 - public Mono opIdTest() { - return null; - } - - @GetMapping(path = "/test_1") // gets operationId opIdTest_2 - public Mono opIdTest(@RequestParam String param) { - return null; - } - - @GetMapping(path = "/test_2") // gets operationId opIdTest_1 - public Mono opIdTest(@RequestParam Integer param) { - return null; - } - - @GetMapping(path = "/test_3") // gets operationId opIdTest - public Mono opIdTest(@RequestParam Boolean param) { - return null; - } - -} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app81/SpringDocApp81Test.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app81/SpringDocApp81Test.java deleted file mode 100644 index 716e65061..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app81/SpringDocApp81Test.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * - * * - * * * - * * * * Copyright 2019-2020 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.app81; - -import java.net.URI; -import java.nio.charset.StandardCharsets; -import java.util.ArrayList; -import java.util.Comparator; -import java.util.List; -import java.util.Locale; -import java.util.Map; -import java.util.concurrent.ThreadLocalRandom; - -import org.junit.jupiter.api.RepeatedTest; -import org.springdoc.webflux.api.OpenApiWebfluxResource; -import test.org.springdoc.api.AbstractCommonTest; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.test.autoconfigure.web.reactive.WebFluxTest; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.http.server.reactive.ServerHttpRequest; -import org.springframework.web.method.HandlerMethod; -import org.springframework.web.reactive.result.method.RequestMappingInfo; -import org.springframework.web.reactive.result.method.RequestMappingInfoHandlerMapping; - -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; -import static org.skyscreamer.jsonassert.JSONAssert.assertEquals; -import static org.springdoc.core.utils.Constants.SPRINGDOC_CACHE_DISABLED; - - -/** - * Tests deterministic creation of operationIds - */ -@WebFluxTest(properties = SPRINGDOC_CACHE_DISABLED + "=true") -public class SpringDocApp81Test extends AbstractCommonTest { - - @Autowired - OpenApiWebfluxResource resource; - - @Autowired - RequestMappingInfoHandlerMapping mappingInfoHandlerMapping; - - @RepeatedTest(10) - public void shouldGenerateOperationIdsDeterministically() throws Exception { - shuffleSpringHandlerMethods(); - - ServerHttpRequest request = mock(ServerHttpRequest.class); - when(request.getURI()).thenReturn(URI.create("http://localhost")); - - String expected = getContent("results/app81.json"); - byte[] openApiBytes =resource.openapiJson(request, "", Locale.US).block(); - String openApi = new String(openApiBytes, StandardCharsets.UTF_8); // for UTF-8 encoding String openApi = resource.openapiJson(request, "", Locale.US).block(); - assertEquals(expected, openApi, true); - } - - private void shuffleSpringHandlerMethods() { - Map handlerMethods = mappingInfoHandlerMapping.getHandlerMethods(); - List> collect = new ArrayList<>(handlerMethods.entrySet()); - collect.sort(Comparator.comparing(a -> ThreadLocalRandom.current().nextBoolean() ? -1 : 1)); - - collect.forEach(e -> mappingInfoHandlerMapping.unregisterMapping(e.getKey())); - collect.forEach(e -> mappingInfoHandlerMapping.registerMapping(e.getKey(), e.getValue().getBean(), e.getValue().getMethod())); - } - - @SpringBootApplication - @ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.app81" }) - static class SpringDocTestApp { - } - -} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app82/RoutingConfiguration.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app82/RoutingConfiguration.java deleted file mode 100644 index 097484b5a..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app82/RoutingConfiguration.java +++ /dev/null @@ -1,39 +0,0 @@ -package test.org.springdoc.api.app82; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.web.reactive.function.server.RouterFunction; -import org.springframework.web.reactive.function.server.ServerResponse; - -import static org.springdoc.core.fn.builders.operation.Builder.operationBuilder; -import static org.springdoc.core.utils.Constants.OPERATION_ATTRIBUTE; -import static org.springframework.http.MediaType.APPLICATION_JSON; -import static org.springframework.web.reactive.function.server.RequestPredicates.DELETE; -import static org.springframework.web.reactive.function.server.RequestPredicates.GET; -import static org.springframework.web.reactive.function.server.RequestPredicates.POST; -import static org.springframework.web.reactive.function.server.RequestPredicates.PUT; -import static org.springframework.web.reactive.function.server.RequestPredicates.accept; -import static org.springframework.web.reactive.function.server.RouterFunctions.route; - -@Configuration -public class RoutingConfiguration { - - @Bean - public RouterFunction monoRouterFunction(UserHandler userHandler) { - return route(GET("/api/user/index").and(accept(APPLICATION_JSON)), userHandler::getAll) - .withAttribute(OPERATION_ATTRIBUTE, operationBuilder().beanClass(UserRepository.class).beanMethod("getAllUsers")) - - .and(route(GET("/api/user/{id}").and(accept(APPLICATION_JSON)), userHandler::getUser) - .withAttribute(OPERATION_ATTRIBUTE, operationBuilder().beanClass(UserRepository.class).beanMethod("getUserById"))) - - .and(route(POST("/api/user/post").and(accept(APPLICATION_JSON)), userHandler::postUser) - .withAttribute(OPERATION_ATTRIBUTE, operationBuilder().beanClass(UserRepository.class).beanMethod("saveUser"))) - - .and(route(PUT("/api/user/put").and(accept(APPLICATION_JSON)), userHandler::putUser) - .withAttribute(OPERATION_ATTRIBUTE, operationBuilder().beanClass(UserRepository.class).beanMethod("putUser"))) - - .and(route(DELETE("/api/user/delete/{id}").and(accept(APPLICATION_JSON)), userHandler::deleteUser) - .withAttribute(OPERATION_ATTRIBUTE, operationBuilder().beanClass(UserRepository.class).beanMethod("deleteUser"))); - } - -} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app82/SpringDocApp82Test.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app82/SpringDocApp82Test.java deleted file mode 100644 index 5515a48e2..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app82/SpringDocApp82Test.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app82; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.ComponentScan; - -public class SpringDocApp82Test extends AbstractSpringDocTest { - - @SpringBootApplication - @ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.app82" }) - static class SpringDocTestApp {} -} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app82/User.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app82/User.java deleted file mode 100644 index 9c3fede16..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app82/User.java +++ /dev/null @@ -1,59 +0,0 @@ -package test.org.springdoc.api.app82; - -public class User { - private long id; - - private String firstname; - - private String lastname; - - private int age; - - public User() { - } - - public User(long id, String firstname, String lastname, int age) { - this.id = id; - this.firstname = firstname; - this.lastname = lastname; - this.age = age; - } - - public long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getFirstname() { - return firstname; - } - - public void setFirstname(String firstname) { - this.firstname = firstname; - } - - public String getLastname() { - return lastname; - } - - public void setLastname(String lastname) { - this.lastname = lastname; - } - - public int getAge() { - return age; - } - - public void setAge(int age) { - this.age = age; - } - - @Override - public String toString() { - String info = String.format("id = %d, firstname = %s, lastname = %s, age = %d", id, firstname, lastname, age); - return info; - } -} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app82/UserHandler.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app82/UserHandler.java deleted file mode 100644 index d44aa3c1f..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app82/UserHandler.java +++ /dev/null @@ -1,93 +0,0 @@ -package test.org.springdoc.api.app82; - -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; - -import org.springframework.http.MediaType; -import org.springframework.stereotype.Component; -import org.springframework.web.reactive.function.server.ServerRequest; -import org.springframework.web.reactive.function.server.ServerResponse; - -import static org.springframework.web.reactive.function.BodyInserters.fromObject; - -@Component -public class UserHandler { - - private final UserRepository customerRepository; - - public UserHandler(UserRepository repository) { - this.customerRepository = repository; - } - - /** - * GET ALL Users - */ - public Mono getAll(ServerRequest request) { - // fetch all customers from repository - Flux customers = customerRepository.getAllUsers(); - - // build response - return ServerResponse.ok().contentType(MediaType.APPLICATION_JSON).body(customers, User.class); - } - - /** - * GET a User by ID - */ - public Mono getUser(ServerRequest request) { - // parse path-variable - long customerId = Long.valueOf(request.queryParam("id").get()); - - // build notFound response - Mono notFound = ServerResponse.notFound().build(); - - // get customer from repository - Mono customerMono = customerRepository.getUserById(customerId); - - // build response - return customerMono - .flatMap(customer -> ServerResponse.ok().contentType(MediaType.APPLICATION_JSON).body(fromObject(customer))) - .switchIfEmpty(notFound); - } - - /** - * POST a User - */ - public Mono postUser(ServerRequest request) { - Mono customer = request.bodyToMono(User.class); - return ServerResponse.ok().build(customerRepository.saveUser(customer)); - } - - /** - * PUT a User - */ - public Mono putUser(ServerRequest request) { - // parse id from path-variable - long customerId = Long.valueOf(request.pathVariable("id")); - - // get customer data from request object - Mono customer = request.bodyToMono(User.class); - - // get customer from repository - Mono responseMono = customerRepository.putUser(customerId, customer); - - // build response - return responseMono - .flatMap(cust -> ServerResponse.ok().contentType(MediaType.APPLICATION_JSON).body(fromObject(cust))); - } - - /** - * DELETE a User - */ - public Mono deleteUser(ServerRequest request) { - // parse id from path-variable - long customerId = Long.valueOf(request.pathVariable("id")); - - // get customer from repository - Mono responseMono = customerRepository.deleteUser(customerId); - - // build response - return responseMono - .flatMap(strMono -> ServerResponse.ok().contentType(MediaType.TEXT_PLAIN).body(fromObject(strMono))); - } - -} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app82/UserRepository.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app82/UserRepository.java deleted file mode 100644 index a0e7d888b..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app82/UserRepository.java +++ /dev/null @@ -1,25 +0,0 @@ -package test.org.springdoc.api.app82; - -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.enums.ParameterIn; -import io.swagger.v3.oas.annotations.parameters.RequestBody; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; - -public interface UserRepository { - - public Mono getUserById(@Parameter(in = ParameterIn.PATH, description = "The user Id") Long id); - - @Operation(description = "get all the users") - public Flux getAllUsers(); - - @Operation(description = "get all the users by firstname") - public Flux getAllUsers(String firstname); - - public Mono saveUser(Mono user); - - public Mono putUser(@Parameter(in = ParameterIn.QUERY) Long id, @RequestBody Mono user); - - public Mono deleteUser(@Parameter(in = ParameterIn.PATH) Long id); -} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app82/UserRepositoryImpl.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app82/UserRepositoryImpl.java deleted file mode 100644 index 236410585..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app82/UserRepositoryImpl.java +++ /dev/null @@ -1,72 +0,0 @@ -package test.org.springdoc.api.app82; - -import java.util.HashMap; -import java.util.Map; - -import jakarta.annotation.PostConstruct; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; - -import org.springframework.stereotype.Repository; - -@Repository -public class UserRepositoryImpl implements UserRepository { - private Map users = new HashMap(); - - @PostConstruct - public void init() throws Exception { - users.put(Long.valueOf(1), new User(1, "Jack", "Smith", 20)); - users.put(Long.valueOf(2), new User(2, "Peter", "Johnson", 25)); - } - - @Override - public Mono getUserById(Long id) { - return Mono.just(users.get(id)); - } - - @Override - public Flux getAllUsers() { - return Flux.fromIterable(this.users.values()); - } - - @Override - public Flux getAllUsers(String firstname) { - return Flux.fromIterable(this.users.values().stream().filter(user -> user.getFirstname().equals(firstname)).toList()); - } - - @Override - public Mono saveUser(Mono monoUser) { - Mono userMono = monoUser.doOnNext(user -> { - // do post - users.put(user.getId(), user); - - // log on console - System.out.println("########### POST:" + user); - }); - - return userMono.then(); - } - - @Override - public Mono putUser(Long id, Mono monoUser) { - Mono userMono = monoUser.doOnNext(user -> { - // reset user.Id - user.setId(id); - - // do put - users.put(id, user); - - // log on console - System.out.println("########### PUT:" + user); - }); - - return userMono; - } - - @Override - public Mono deleteUser(Long id) { - // delete processing - users.remove(id); - return Mono.just("Delete Succesfully!"); - } -} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app83/Coffee.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app83/Coffee.java deleted file mode 100644 index fbddaefda..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app83/Coffee.java +++ /dev/null @@ -1,60 +0,0 @@ -package test.org.springdoc.api.app83; - -import java.util.Objects; - -public class Coffee { - - private String id; - - private String name; - - public Coffee() { - } - - public Coffee(String name) { - this.name = name; - } - - public Coffee(String id, String name) { - this.id = id; - this.name = name; - } - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - Coffee coffee = (Coffee) o; - return Objects.equals(id, coffee.id) && - Objects.equals(name, coffee.name); - } - - @Override - public int hashCode() { - return Objects.hash(id, name); - } - - @Override - public String toString() { - return "Coffee{" + - "id='" + id + '\'' + - ", name='" + name + '\'' + - '}'; - } -} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app83/CoffeeOrder.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app83/CoffeeOrder.java deleted file mode 100644 index f7e17f17e..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app83/CoffeeOrder.java +++ /dev/null @@ -1,48 +0,0 @@ -package test.org.springdoc.api.app83; - -import java.time.Instant; -import java.util.Objects; - -public class CoffeeOrder { - private String coffeeId; - - private Instant whenOrdered; - - public CoffeeOrder() { - } - - public CoffeeOrder(String coffeeId, Instant whenOrdered) { - this.coffeeId = coffeeId; - this.whenOrdered = whenOrdered; - } - - public String getCoffeeId() { - return coffeeId; - } - - public Instant getWhenOrdered() { - return whenOrdered; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - CoffeeOrder that = (CoffeeOrder) o; - return Objects.equals(coffeeId, that.coffeeId) && - Objects.equals(whenOrdered, that.whenOrdered); - } - - @Override - public int hashCode() { - return Objects.hash(coffeeId, whenOrdered); - } - - @Override - public String toString() { - return "CoffeeOrder{" + - "coffeeId='" + coffeeId + '\'' + - ", whenOrdered=" + whenOrdered + - '}'; - } -} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app83/CoffeeRepository.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app83/CoffeeRepository.java deleted file mode 100644 index 366e447c8..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app83/CoffeeRepository.java +++ /dev/null @@ -1,26 +0,0 @@ -package test.org.springdoc.api.app83; - -import org.reactivestreams.Publisher; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; - -import org.springframework.stereotype.Repository; - -@Repository -public class CoffeeRepository { - Flux deleteAll() { - return null; - } - - Mono findById(String id) { - return null; - } - - Publisher save(Coffee coffee) { - return null; - } - - Flux findAll() { - return null; - } -} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app83/CoffeeService.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app83/CoffeeService.java deleted file mode 100644 index 6543bccbc..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app83/CoffeeService.java +++ /dev/null @@ -1,34 +0,0 @@ -package test.org.springdoc.api.app83; - -import java.time.Duration; -import java.time.Instant; - -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.enums.ParameterIn; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; - -import org.springframework.stereotype.Service; - -@Service -public class CoffeeService { - private final CoffeeRepository repo; - - public CoffeeService(CoffeeRepository repo) { - this.repo = repo; - } - - Flux getAllCoffees() { - return repo.findAll(); - } - - Mono getCoffeeById(@Parameter(in = ParameterIn.PATH) String id) { - return repo.findById(id); - } - - Flux getOrdersForCoffeeById(@Parameter(in = ParameterIn.PATH) String id) { - return Flux.interval(Duration.ofSeconds(1)) - .onBackpressureDrop() - .map(i -> new CoffeeOrder(id, Instant.now())); - } -} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app83/RouteConfig.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app83/RouteConfig.java deleted file mode 100644 index 7f1e9860c..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app83/RouteConfig.java +++ /dev/null @@ -1,52 +0,0 @@ -package test.org.springdoc.api.app83; - -import reactor.core.publisher.Mono; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.http.MediaType; -import org.springframework.web.reactive.function.server.RouterFunction; -import org.springframework.web.reactive.function.server.ServerRequest; -import org.springframework.web.reactive.function.server.ServerResponse; - -import static org.springdoc.core.fn.builders.operation.Builder.operationBuilder; -import static org.springdoc.core.utils.Constants.OPERATION_ATTRIBUTE; -import static org.springframework.web.reactive.function.server.RequestPredicates.GET; -import static org.springframework.web.reactive.function.server.RouterFunctions.route; - -@Configuration -public class RouteConfig { - private final CoffeeService service; - - public RouteConfig(CoffeeService service) { - this.service = service; - } - - @Bean - RouterFunction routerFunction() { - return route(GET("/coffees"), this::all) - .withAttribute(OPERATION_ATTRIBUTE, operationBuilder().beanClass(CoffeeService.class).beanMethod("getAllCoffees")) - - .and(route(GET("/coffees/{id}"), this::byId) - .withAttribute(OPERATION_ATTRIBUTE, operationBuilder().beanClass(CoffeeService.class).beanMethod("getCoffeeById"))) - - .and(route(GET("/coffees/{id}/orders"), this::orders) - .withAttribute(OPERATION_ATTRIBUTE, operationBuilder().beanClass(CoffeeService.class).beanMethod("getOrdersForCoffeeById"))); - } - - private Mono all(ServerRequest req) { - return ServerResponse.ok() - .body(service.getAllCoffees(), Coffee.class); - } - - private Mono byId(ServerRequest req) { - return ServerResponse.ok() - .body(service.getCoffeeById(req.pathVariable("id")), Coffee.class); - } - - private Mono orders(ServerRequest req) { - return ServerResponse.ok() - .contentType(MediaType.TEXT_EVENT_STREAM) - .body(service.getOrdersForCoffeeById(req.pathVariable("id")), CoffeeOrder.class); - } -} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app83/SpringDocApp83Test.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app83/SpringDocApp83Test.java deleted file mode 100644 index 405fa4e25..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app83/SpringDocApp83Test.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app83; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.ComponentScan; - -public class SpringDocApp83Test extends AbstractSpringDocTest { - - @SpringBootApplication - @ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.app83" }) - static class SpringDocTestApp {} -} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app84/Employee.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app84/Employee.java deleted file mode 100644 index 747e2caef..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app84/Employee.java +++ /dev/null @@ -1,24 +0,0 @@ -package test.org.springdoc.api.app84; - -public class Employee { - - private String id; - - private String name; - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } -} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app84/EmployeeFunctionalConfig.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app84/EmployeeFunctionalConfig.java deleted file mode 100644 index c5d630f1d..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app84/EmployeeFunctionalConfig.java +++ /dev/null @@ -1,81 +0,0 @@ -package test.org.springdoc.api.app84; - -import io.swagger.v3.oas.annotations.enums.ParameterIn; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.http.MediaType; -import org.springframework.web.reactive.function.BodyExtractors; -import org.springframework.web.reactive.function.server.RouterFunction; -import org.springframework.web.reactive.function.server.ServerResponse; - -import static org.springdoc.core.fn.builders.apiresponse.Builder.responseBuilder; -import static org.springdoc.core.fn.builders.operation.Builder.operationBuilder; -import static org.springdoc.core.fn.builders.parameter.Builder.parameterBuilder; -import static org.springdoc.core.utils.Constants.OPERATION_ATTRIBUTE; -import static org.springframework.web.reactive.function.server.RequestPredicates.GET; -import static org.springframework.web.reactive.function.server.RequestPredicates.POST; -import static org.springframework.web.reactive.function.server.RequestPredicates.accept; -import static org.springframework.web.reactive.function.server.RouterFunctions.route; -import static org.springframework.web.reactive.function.server.ServerResponse.ok; - -@Configuration -public class EmployeeFunctionalConfig { - - - @Bean - EmployeeRepository employeeRepository() { - return new EmployeeRepository(); - } - - @Bean - RouterFunction getAllEmployeesRoute() { - return route(GET("/employees").and(accept(MediaType.APPLICATION_JSON)), - req -> ok().body( - employeeRepository().findAllEmployees(), Employee.class)) - .withAttribute(OPERATION_ATTRIBUTE, operationBuilder().beanClass(EmployeeRepository.class).beanMethod("findAllEmployees")); - } - - @Bean - RouterFunction getEmployeeByIdRoute() { - return route(GET("/employees/{id}"), - req -> ok().body( - employeeRepository().findEmployeeById(req.pathVariable("id")), Employee.class)) - .withAttribute(OPERATION_ATTRIBUTE, - operationBuilder().operationId("findEmployeeById").summary("Find purchase order by ID").tags(new String[] { "MyEmployee" }) - .parameter(parameterBuilder().in(ParameterIn.PATH).name("id").description("Employee Id")) - .response(responseBuilder().responseCode("200").description("successful operation").implementation(Employee.class)) - .response(responseBuilder().responseCode("400").description("Invalid Employee ID supplied")) - .response(responseBuilder().responseCode("404").description("Employee not found"))); - } - - - @Bean - RouterFunction updateEmployeeRoute() { - return route(POST("/employees/update").and(accept(MediaType.APPLICATION_XML)), - req -> req.body(BodyExtractors.toMono(Employee.class)) - .doOnNext(employeeRepository()::updateEmployee) - .then(ok().build())) - .withAttribute(OPERATION_ATTRIBUTE, operationBuilder().beanClass(EmployeeRepository.class).beanMethod("updateEmployee")); - } - - @Bean - RouterFunction composedRoutes() { - return - route(GET("/employees-composed"), - req -> ok().body( - employeeRepository().findAllEmployees(), Employee.class)) - .withAttribute(OPERATION_ATTRIBUTE, operationBuilder().beanClass(EmployeeRepository.class).beanMethod("findAllEmployees")) - - .and(route(GET("/employees-composed/{id}"), req -> ok().body( - employeeRepository().findEmployeeById(req.pathVariable("id")), Employee.class)) - .withAttribute(OPERATION_ATTRIBUTE, operationBuilder().beanClass(EmployeeRepository.class).beanMethod("findEmployeeById"))) - - .and(route(POST("/employees-composed/update"), - req -> req.body(BodyExtractors.toMono(Employee.class)) - .doOnNext(employeeRepository()::updateEmployee) - .then(ok().build())) - .withAttribute(OPERATION_ATTRIBUTE, operationBuilder().beanClass(EmployeeRepository.class).beanMethod("updateEmployee"))); - } - -} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app84/EmployeeRepository.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app84/EmployeeRepository.java deleted file mode 100644 index 003e6fd35..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app84/EmployeeRepository.java +++ /dev/null @@ -1,32 +0,0 @@ -package test.org.springdoc.api.app84; - -import java.util.Map; - -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.enums.ParameterIn; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; - -public class EmployeeRepository { - - static Map employeeData; - - static Map employeeAccessData; - - - public Mono findEmployeeById(@Parameter(in = ParameterIn.PATH) String id) { - return Mono.just(employeeData.get(id)); - } - - public Flux findAllEmployees() { - return Flux.fromIterable(employeeData.values()); - } - - public Mono updateEmployee(Employee employee) { - Employee existingEmployee = employeeData.get(employee.getId()); - if (existingEmployee != null) { - existingEmployee.setName(employee.getName()); - } - return Mono.just(existingEmployee); - } -} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app84/SpringDocApp84Test.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app84/SpringDocApp84Test.java deleted file mode 100644 index 3e554b55f..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app84/SpringDocApp84Test.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app84; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.ComponentScan; - -public class SpringDocApp84Test extends AbstractSpringDocTest { - - @SpringBootApplication - @ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.app84" }) - static class SpringDocTestApp {} -} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app85/SpringDocApp85Test.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app85/SpringDocApp85Test.java deleted file mode 100644 index cffdeeec4..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app85/SpringDocApp85Test.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * - * * - * * * Copyright 2019-2020 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.app85; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.ComponentScan; - -public class SpringDocApp85Test extends AbstractSpringDocTest { - - @SpringBootApplication - @ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.app85" }) - static class SpringDocTestApp {} -} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app85/controller/PersonRouter.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app85/controller/PersonRouter.java deleted file mode 100644 index 15e0235f3..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app85/controller/PersonRouter.java +++ /dev/null @@ -1,39 +0,0 @@ -package test.org.springdoc.api.app85.controller; - -import test.org.springdoc.api.app85.handler.PersonHandler; -import test.org.springdoc.api.app85.service.PersonService; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.http.MediaType; -import org.springframework.web.reactive.function.server.RouterFunction; -import org.springframework.web.reactive.function.server.ServerResponse; - -import static org.springdoc.core.fn.builders.operation.Builder.operationBuilder; -import static org.springdoc.core.utils.Constants.OPERATION_ATTRIBUTE; -import static org.springframework.web.reactive.function.server.RequestPredicates.DELETE; -import static org.springframework.web.reactive.function.server.RequestPredicates.GET; -import static org.springframework.web.reactive.function.server.RequestPredicates.POST; -import static org.springframework.web.reactive.function.server.RequestPredicates.accept; -import static org.springframework.web.reactive.function.server.RouterFunctions.route; - - -@Configuration -public class PersonRouter { - - @Bean - public RouterFunction personRoute(PersonHandler handler) { - return route(GET("/getAllPersons").and(accept(MediaType.APPLICATION_JSON)), handler::findAll) - .withAttribute(OPERATION_ATTRIBUTE, operationBuilder().beanClass(PersonService.class).beanMethod("getAll")) - - .and(route(GET("/getPerson/{id}").and(accept(MediaType.APPLICATION_STREAM_JSON)), handler::findById) - .withAttribute(OPERATION_ATTRIBUTE, operationBuilder().beanClass(PersonService.class).beanMethod("getById"))) - - .and(route(POST("/createPerson").and(accept(MediaType.APPLICATION_JSON)), handler::save) - .withAttribute(OPERATION_ATTRIBUTE, operationBuilder().beanClass(PersonService.class).beanMethod("save"))) - - .and(route(DELETE("/deletePerson/{id}").and(accept(MediaType.APPLICATION_JSON)), handler::delete) - .withAttribute(OPERATION_ATTRIBUTE, operationBuilder().beanClass(PersonService.class).beanMethod("delete"))); - } - -} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app85/controller/PositionRouter.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app85/controller/PositionRouter.java deleted file mode 100644 index ee3f0a7c0..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app85/controller/PositionRouter.java +++ /dev/null @@ -1,53 +0,0 @@ -package test.org.springdoc.api.app85.controller; - -import io.swagger.v3.oas.annotations.enums.ParameterIn; -import test.org.springdoc.api.app85.entity.Position; -import test.org.springdoc.api.app85.handler.PositionHandler; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.http.MediaType; -import org.springframework.web.reactive.function.server.RouterFunction; -import org.springframework.web.reactive.function.server.ServerResponse; - -import static org.springdoc.core.fn.builders.apiresponse.Builder.responseBuilder; -import static org.springdoc.core.fn.builders.content.Builder.contentBuilder; -import static org.springdoc.core.fn.builders.operation.Builder.operationBuilder; -import static org.springdoc.core.fn.builders.parameter.Builder.parameterBuilder; -import static org.springdoc.core.fn.builders.requestbody.Builder.requestBodyBuilder; -import static org.springdoc.core.utils.Constants.OPERATION_ATTRIBUTE; -import static org.springframework.web.reactive.function.server.RequestPredicates.DELETE; -import static org.springframework.web.reactive.function.server.RequestPredicates.GET; -import static org.springframework.web.reactive.function.server.RequestPredicates.POST; -import static org.springframework.web.reactive.function.server.RequestPredicates.accept; -import static org.springframework.web.reactive.function.server.RouterFunctions.route; - -@Configuration -public class PositionRouter { - - @Bean - public RouterFunction positionRoute(PositionHandler handler) { - return route(GET("/getAllPositions").and(accept(MediaType.APPLICATION_JSON)), handler::findAll) - .withAttribute(OPERATION_ATTRIBUTE, operationBuilder().operationId("findAll").description("Get all positions").tags(new String[] { "positions" }) - .response(responseBuilder().responseCode("200").implementationArray(Position.class))) - - .and(route(GET("/getPosition/{id}").and(accept(MediaType.APPLICATION_STREAM_JSON)), handler::findById) - .withAttribute(OPERATION_ATTRIBUTE, - operationBuilder().operationId("findById").description("Find all").tags(new String[] { "positions" }) - .parameter(parameterBuilder().in(ParameterIn.PATH).name("id")) - .response(responseBuilder().responseCode("200").implementation(Position.class)))) - - .and(route(POST("/createPosition").and(accept(MediaType.APPLICATION_JSON)), handler::save) - .withAttribute(OPERATION_ATTRIBUTE, - operationBuilder().operationId("save").description("Save position").tags(new String[] { "positions" }) - .requestBody(requestBodyBuilder().implementation(Position.class)) - .response(responseBuilder().responseCode("200").implementation(Position.class)))) - - .and(route(DELETE("/deletePosition/{id}").and(accept(MediaType.APPLICATION_JSON)), handler::delete) - .withAttribute(OPERATION_ATTRIBUTE, - operationBuilder().operationId("deleteBy").description("Delete By Id").tags(new String[] { "positions" }) - .parameter(parameterBuilder().in(ParameterIn.PATH).name("id")) - .response(responseBuilder().responseCode("200").content(contentBuilder())))); - } - -} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app85/entity/Person.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app85/entity/Person.java deleted file mode 100644 index cc7a3b99e..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app85/entity/Person.java +++ /dev/null @@ -1,74 +0,0 @@ -package test.org.springdoc.api.app85.entity; - -public class Person { - - private String id; - - private Sex sex; - - private String firstName; - - private String lastName; - - private String age; - - private String interests; - - private String email; - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public Sex getSex() { - return sex; - } - - public void setSex(Sex sex) { - this.sex = sex; - } - - public String getFirstName() { - return firstName; - } - - public void setFirstName(String firstName) { - this.firstName = firstName; - } - - public String getLastName() { - return lastName; - } - - public void setLastName(String lastName) { - this.lastName = lastName; - } - - public String getAge() { - return age; - } - - public void setAge(String age) { - this.age = age; - } - - public String getInterests() { - return interests; - } - - public void setInterests(String interests) { - this.interests = interests; - } - - public String getEmail() { - return email; - } - - public void setEmail(String email) { - this.email = email; - } -} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app85/entity/Position.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app85/entity/Position.java deleted file mode 100644 index 4b17816ba..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app85/entity/Position.java +++ /dev/null @@ -1,54 +0,0 @@ -package test.org.springdoc.api.app85.entity; - -import java.util.Date; - -import jakarta.validation.constraints.NotBlank; -import jakarta.validation.constraints.NotNull; -import jakarta.validation.constraints.Size; - - -public class Position { - - private String id; - - @NotBlank - @Size(max = 140) - private String positionName; - - private String description; - - @NotNull - private Date createdAt = new Date(); - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getPositionName() { - return positionName; - } - - public void setPositionName(String positionName) { - this.positionName = positionName; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public Date getCreatedAt() { - return createdAt; - } - - public void setCreatedAt(Date createdAt) { - this.createdAt = createdAt; - } -} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app85/entity/Sex.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app85/entity/Sex.java deleted file mode 100644 index 6f830eb5e..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app85/entity/Sex.java +++ /dev/null @@ -1,5 +0,0 @@ -package test.org.springdoc.api.app85.entity; - -public enum Sex { - MAN, WOMEN -} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app85/exception/PositionNotFoundException.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app85/exception/PositionNotFoundException.java deleted file mode 100644 index ff959dd95..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app85/exception/PositionNotFoundException.java +++ /dev/null @@ -1,8 +0,0 @@ -package test.org.springdoc.api.app85.exception; - -public class PositionNotFoundException extends RuntimeException { - - public PositionNotFoundException(String positionId) { - super("Position not found with id " + positionId); - } -} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app85/handler/PersonHandler.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app85/handler/PersonHandler.java deleted file mode 100644 index 0f1f6b13d..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app85/handler/PersonHandler.java +++ /dev/null @@ -1,52 +0,0 @@ -package test.org.springdoc.api.app85.handler; - -import reactor.core.publisher.Mono; -import test.org.springdoc.api.app85.entity.Person; -import test.org.springdoc.api.app85.service.PersonService; - -import org.springframework.http.MediaType; -import org.springframework.stereotype.Component; -import org.springframework.web.reactive.function.BodyInserters; -import org.springframework.web.reactive.function.server.ServerRequest; -import org.springframework.web.reactive.function.server.ServerResponse; - -import static org.springframework.web.reactive.function.server.ServerResponse.ok; - -@Component -@SuppressWarnings({ "deprecared", "unchecked" }) -public class PersonHandler { - - private final PersonService personService; - - public PersonHandler(PersonService personService) { - this.personService = personService; - } - - public Mono findById(ServerRequest request) { - String id = request.pathVariable("id"); - return ok() - .contentType(MediaType.APPLICATION_JSON) - .body(personService.getById(id), Person.class); - } - - public Mono findAll(ServerRequest request) { - return ok() - .contentType(MediaType.APPLICATION_JSON) - .body(personService.getAll(), Person.class); - } - - public Mono save(ServerRequest request) { - final Mono person = request.bodyToMono(Person.class); - return ok() - .contentType(MediaType.APPLICATION_JSON) - .body(BodyInserters.fromPublisher(person.flatMap(personService::save), Person.class)); - } - - public Mono delete(ServerRequest request) { - String id = request.pathVariable("id"); - return ok() - .contentType(MediaType.APPLICATION_JSON) - .body(personService.delete(id), Void.class); - } - -} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app85/handler/PositionHandler.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app85/handler/PositionHandler.java deleted file mode 100644 index bd116293c..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app85/handler/PositionHandler.java +++ /dev/null @@ -1,30 +0,0 @@ -package test.org.springdoc.api.app85.handler; - -import reactor.core.publisher.Mono; - -import org.springframework.stereotype.Component; -import org.springframework.web.reactive.function.server.ServerRequest; -import org.springframework.web.reactive.function.server.ServerResponse; - -@Component -public class PositionHandler { - - - public Mono findById(ServerRequest request) { - String id = request.pathVariable("id"); - return null; - } - - public Mono findAll(ServerRequest request) { - return null; - } - - public Mono save(ServerRequest request) { - return null; - } - - public Mono delete(ServerRequest request) { - return null; - } - -} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app85/payload/ErrorResponse.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app85/payload/ErrorResponse.java deleted file mode 100644 index c6a2659f4..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app85/payload/ErrorResponse.java +++ /dev/null @@ -1,19 +0,0 @@ -package test.org.springdoc.api.app85.payload; - -public class ErrorResponse { - - private String message; - - public ErrorResponse(String message) { - this.message = message; - } - - public String getMessage() { - return message; - } - - public void setMessage(String message) { - this.message = message; - } - -} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app85/service/PersonService.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app85/service/PersonService.java deleted file mode 100644 index f2dc542a4..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app85/service/PersonService.java +++ /dev/null @@ -1,39 +0,0 @@ -package test.org.springdoc.api.app85.service; - -import java.util.Objects; - -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.enums.ParameterIn; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; -import test.org.springdoc.api.app85.entity.Person; - -import org.springframework.stereotype.Service; - -@Service -public class PersonService { - - public Flux getAll() { - return null; - } - - public Mono getById(@Parameter(in = ParameterIn.PATH) final String id) { - return null; - } - - public Mono update(@Parameter(in = ParameterIn.PATH) final String id, final Person person) { - return null; - } - - public Mono save(final Person person) { - return null; - } - - public Mono delete(@Parameter(in = ParameterIn.PATH) final String id) { - final Mono dbPerson = getById(id); - if (Objects.isNull(dbPerson)) { - return Mono.empty(); - } - return null; - } -} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app86/Quote.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app86/Quote.java deleted file mode 100644 index 77110537b..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app86/Quote.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * - * * - * * * Copyright 2019-2020 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.app86; - - -import java.math.BigDecimal; -import java.math.MathContext; -import java.time.Instant; - -public class Quote { - - private static final MathContext MATH_CONTEXT = new MathContext(2); - - private String ticker; - - private BigDecimal price; - - private Instant instant; - - public Quote() { - } - - public Quote(String ticker, BigDecimal price) { - this.ticker = ticker; - this.price = price; - } - - public Quote(String ticker, Double price) { - this(ticker, new BigDecimal(price, MATH_CONTEXT)); - } - - public String getTicker() { - return ticker; - } - - public void setTicker(String ticker) { - this.ticker = ticker; - } - - public BigDecimal getPrice() { - return price; - } - - public void setPrice(BigDecimal price) { - this.price = price; - } - - public Instant getInstant() { - return instant; - } - - public void setInstant(Instant instant) { - this.instant = instant; - } - - @Override - public String toString() { - return "Quote{" + - "ticker='" + ticker + '\'' + - ", price=" + price + - ", instant=" + instant + - '}'; - } -} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app86/QuoteGenerator.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app86/QuoteGenerator.java deleted file mode 100644 index 8b1619d43..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app86/QuoteGenerator.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * - * * - * * * Copyright 2019-2020 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.app86; - - -import java.math.BigDecimal; -import java.math.MathContext; -import java.time.Duration; -import java.time.Instant; -import java.util.ArrayList; -import java.util.List; -import java.util.Random; - -import reactor.core.publisher.Flux; - -import org.springframework.stereotype.Component; - -@Component -public class QuoteGenerator { - - private final MathContext mathContext = new MathContext(2); - - private final Random random = new Random(); - - private final List prices = new ArrayList<>(); - - /** - * Bootstraps the generator with tickers and initial prices - */ - public QuoteGenerator() { - this.prices.add(new Quote("CTXS", 82.26)); - this.prices.add(new Quote("DELL", 63.74)); - this.prices.add(new Quote("GOOG", 847.24)); - this.prices.add(new Quote("MSFT", 65.11)); - this.prices.add(new Quote("ORCL", 45.71)); - this.prices.add(new Quote("RHT", 84.29)); - this.prices.add(new Quote("VMW", 92.21)); - } - - - public Flux fetchQuoteStream(Duration period) { - - // We want to emit quotes with a specific period; - // to do so, we create a Flux.interval - return Flux.interval(period) - // In case of back-pressure, drop events - .onBackpressureDrop() - // For each tick, generate a list of quotes - .map(this::generateQuotes) - // "flatten" that List into a Flux - .flatMapIterable(quotes -> quotes) - .log("io.spring.workshop.stockquotes"); - } - - /* - * Create quotes for all tickers at a single instant. - */ - private List generateQuotes(long interval) { - final Instant instant = Instant.now(); - return prices.stream() - .map(baseQuote -> { - BigDecimal priceChange = baseQuote.getPrice() - .multiply(new BigDecimal(0.05 * this.random.nextDouble()), this.mathContext); - Quote result = new Quote(baseQuote.getTicker(), baseQuote.getPrice().add(priceChange)); - result.setInstant(instant); - return result; - }) - .toList(); - } - -} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app86/QuoteHandler.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app86/QuoteHandler.java deleted file mode 100644 index 37ac0b74b..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app86/QuoteHandler.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * - * * - * * * Copyright 2019-2020 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.app86; - - -import java.time.Duration; - -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; - -import org.springframework.http.MediaType; -import org.springframework.stereotype.Component; -import org.springframework.web.reactive.function.BodyInserters; -import org.springframework.web.reactive.function.server.ServerRequest; -import org.springframework.web.reactive.function.server.ServerResponse; - -@Component -public class QuoteHandler { - - private final Flux quoteStream; - - public QuoteHandler(QuoteGenerator quoteGenerator) { - this.quoteStream = quoteGenerator.fetchQuoteStream(Duration.ofMillis(1000)).share(); - } - - public Mono hello(ServerRequest request) { - return ServerResponse.ok().contentType(MediaType.TEXT_PLAIN) - .body(BodyInserters.fromObject("Hello Spring!")); - } - - public Mono echo(ServerRequest request) { - return ServerResponse.ok().contentType(MediaType.TEXT_PLAIN) - .body(request.bodyToMono(String.class), String.class); - } - - public Mono streamQuotes(ServerRequest request) { - return ServerResponse.ok() - .contentType(MediaType.APPLICATION_STREAM_JSON) - .body(this.quoteStream, Quote.class); - } - - public Mono fetchQuotes(ServerRequest request) { - int size = Integer.parseInt(request.queryParam("size").orElse("10")); - return ServerResponse.ok() - .contentType(MediaType.APPLICATION_JSON) - .body(this.quoteStream.take(size), Quote.class); - } -} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app86/QuoteRouter.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app86/QuoteRouter.java deleted file mode 100644 index dc00d70a9..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app86/QuoteRouter.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * - * * - * * * Copyright 2019-2020 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.app86; - -import io.swagger.v3.oas.annotations.enums.ParameterIn; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.web.reactive.function.server.RouterFunction; -import org.springframework.web.reactive.function.server.ServerResponse; - -import static org.springdoc.core.fn.builders.apiresponse.Builder.responseBuilder; -import static org.springdoc.core.fn.builders.operation.Builder.operationBuilder; -import static org.springdoc.core.fn.builders.parameter.Builder.parameterBuilder; -import static org.springdoc.core.fn.builders.requestbody.Builder.requestBodyBuilder; -import static org.springdoc.core.utils.Constants.OPERATION_ATTRIBUTE; -import static org.springframework.http.MediaType.APPLICATION_JSON; -import static org.springframework.http.MediaType.APPLICATION_STREAM_JSON; -import static org.springframework.http.MediaType.TEXT_PLAIN; -import static org.springframework.web.reactive.function.server.RequestPredicates.GET; -import static org.springframework.web.reactive.function.server.RequestPredicates.POST; -import static org.springframework.web.reactive.function.server.RequestPredicates.accept; -import static org.springframework.web.reactive.function.server.RequestPredicates.contentType; -import static org.springframework.web.reactive.function.server.RouterFunctions.route; - -@Configuration -public class QuoteRouter { - - @Bean - public RouterFunction myroute(QuoteHandler quoteHandler) { - return route(GET("/hello").and(accept(TEXT_PLAIN)), quoteHandler::hello) - .withAttribute(OPERATION_ATTRIBUTE, operationBuilder().operationId("hello").response(responseBuilder().responseCode("200"))) - - .and(route(POST("/echo").and(accept(TEXT_PLAIN).and(contentType(TEXT_PLAIN))), quoteHandler::echo) - .withAttribute(OPERATION_ATTRIBUTE, operationBuilder().operationId("echo") - .requestBody(requestBodyBuilder().implementation(String.class)) - .response(responseBuilder().responseCode("200").implementation(String.class)))) - - .and(route(POST("/echo").and(accept(APPLICATION_JSON).and(contentType(APPLICATION_JSON))), quoteHandler::echo) - .withAttribute(OPERATION_ATTRIBUTE, operationBuilder().operationId("echo") - .requestBody(requestBodyBuilder().implementation(String.class)) - .response(responseBuilder().responseCode("200").implementation(String.class))) - ) - - .and(route(GET("/quotes").and(accept(APPLICATION_JSON)), quoteHandler::fetchQuotes) - .withAttribute(OPERATION_ATTRIBUTE, operationBuilder().operationId("fetchQuotes") - .parameter(parameterBuilder().in(ParameterIn.QUERY).name("size").implementation(String.class)) - .response(responseBuilder().responseCode("200").implementationArray(Quote.class)))) - - .and(route(GET("/quotes").and(accept(APPLICATION_STREAM_JSON)), quoteHandler::streamQuotes) - .withAttribute(OPERATION_ATTRIBUTE, operationBuilder().operationId("fetchQuotes") - .response(responseBuilder().responseCode("200").implementation(Quote.class)))); - } - -} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app86/SpringDocApp86Test.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app86/SpringDocApp86Test.java deleted file mode 100644 index 0b2f53336..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app86/SpringDocApp86Test.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * - * * - * * * Copyright 2019-2020 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.app86; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.ComponentScan; - -public class SpringDocApp86Test extends AbstractSpringDocTest { - - @SpringBootApplication - @ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.app86" }) - static class SpringDocTestApp {} -} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app87/Book.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app87/Book.java deleted file mode 100644 index c1d4df2c3..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app87/Book.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * - * * - * * * Copyright 2019-2020 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.app87; - -public class Book { - - private String id; - - private String title; - - private String author; - - public Book(String id, String title, String author) { - this.id = id; - this.title = title; - this.author = author; - } - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getTitle() { - return title; - } - - public void setTitle(String title) { - this.title = title; - } - - public String getAuthor() { - return author; - } - - public void setAuthor(String author) { - this.author = author; - } -} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app87/BookRepository.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app87/BookRepository.java deleted file mode 100644 index eeae467f5..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app87/BookRepository.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * - * * - * * * Copyright 2019-2020 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.app87; - -import reactor.core.publisher.Flux; - -import org.springframework.stereotype.Component; - -@Component -public class BookRepository { - - - Flux findByAuthor(String author) { - return Flux.just(new Book("1", "title1", "author1")); - } - - Flux findAll() { - return Flux.just(new Book("2", "title2", "author2")); - } -} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app87/BookRouter.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app87/BookRouter.java deleted file mode 100644 index 36b4beed2..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app87/BookRouter.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * - * * - * * * Copyright 2019-2020 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.app87; - -import io.swagger.v3.oas.annotations.enums.ParameterIn; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.http.MediaType; -import org.springframework.web.reactive.function.server.RouterFunction; - -import static org.springdoc.core.fn.builders.operation.Builder.operationBuilder; -import static org.springdoc.core.fn.builders.parameter.Builder.parameterBuilder; -import static org.springdoc.core.utils.Constants.OPERATION_ATTRIBUTE; -import static org.springframework.web.reactive.function.server.RequestPredicates.GET; -import static org.springframework.web.reactive.function.server.RequestPredicates.accept; -import static org.springframework.web.reactive.function.server.RouterFunctions.route; -import static org.springframework.web.reactive.function.server.ServerResponse.ok; - -@Configuration -class BookRouter { - - @Bean - RouterFunction routes(BookRepository br) { - return route(GET("/books").and(accept(MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML)), req -> ok().body(br.findAll(), Book.class)) - .withAttribute(OPERATION_ATTRIBUTE, operationBuilder().beanClass(BookRepository.class).beanMethod("findAll")) - - .and(route(GET("/books").and(accept(MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN)), req -> ok().body(br.findAll(), Book.class)) - .withAttribute(OPERATION_ATTRIBUTE, operationBuilder().beanClass(BookRepository.class).beanMethod("findAll"))) - - .and(route(GET("/books/{author}"), req -> ok().body(br.findByAuthor(req.pathVariable("author")), Book.class)) - .withAttribute(OPERATION_ATTRIBUTE, operationBuilder() - .beanClass(BookRepository.class).beanMethod("findByAuthor") - .operationId("findByAuthor").parameter(parameterBuilder().in(ParameterIn.PATH).name("author")))); - } -} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app87/SpringDocApp87Test.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app87/SpringDocApp87Test.java deleted file mode 100644 index 43afc364a..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app87/SpringDocApp87Test.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * - * * - * * * Copyright 2019-2020 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.app87; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.ComponentScan; - -public class SpringDocApp87Test extends AbstractSpringDocTest { - - @SpringBootApplication - @ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.app87" }) - static class SpringDocTestApp {} -} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app88/Post.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app88/Post.java deleted file mode 100644 index d37df9bf4..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app88/Post.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * - * * - * * * Copyright 2019-2020 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.app88; - -import java.time.LocalDateTime; - -public class Post { - - private String id; - - private String title; - - private String content; - - private LocalDateTime createdDate; - - public Post(String id, String title, String content) { - this.id = id; - this.title = title; - this.content = content; - this.createdDate = LocalDateTime.now(); - } - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getTitle() { - return title; - } - - public void setTitle(String title) { - this.title = title; - } - - public String getContent() { - return content; - } - - public void setContent(String content) { - this.content = content; - } - - public LocalDateTime getCreatedDate() { - return createdDate; - } - - public void setCreatedDate(LocalDateTime createdDate) { - this.createdDate = createdDate; - } -} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app88/PostHandler.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app88/PostHandler.java deleted file mode 100644 index 867cf3839..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app88/PostHandler.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * - * * - * * * Copyright 2019-2020 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.app88; - - -import java.net.URI; - -import reactor.core.publisher.Mono; - -import org.springframework.stereotype.Component; -import org.springframework.web.reactive.function.server.ServerRequest; -import org.springframework.web.reactive.function.server.ServerResponse; - -@Component -class PostHandler { - - private final PostRepository posts; - - public PostHandler(PostRepository posts) { - this.posts = posts; - } - - public Mono all(ServerRequest req) { - return ServerResponse.ok().body(this.posts.findAll(), Post.class); - } - - public Mono create(ServerRequest req) { - return req.bodyToMono(Post.class) - .flatMap(post -> this.posts.save(post)) - .flatMap(p -> ServerResponse.created(URI.create("/posts/" + p.getId())).build()); - } - - public Mono get(ServerRequest req) { - return this.posts.findById(req.pathVariable("id")) - .flatMap(post -> ServerResponse.ok().body(Mono.just(post), Post.class)) - .switchIfEmpty(ServerResponse.notFound().build()); - } - - public Mono update(ServerRequest req) { - - return Mono - .zip( - (data) -> { - Post p = (Post) data[0]; - Post p2 = (Post) data[1]; - p.setTitle(p2.getTitle()); - p.setContent(p2.getContent()); - return p; - }, - this.posts.findById(req.pathVariable("id")), - req.bodyToMono(Post.class) - ) - .cast(Post.class) - .flatMap(post -> this.posts.save(post)) - .flatMap(post -> ServerResponse.noContent().build()); - - } - -} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app88/PostRepository.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app88/PostRepository.java deleted file mode 100644 index c1265ca9d..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app88/PostRepository.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * - * * - * * * Copyright 2019-2020 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.app88; - -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; - -import org.springframework.stereotype.Component; - -@Component -public class PostRepository { - - public Flux findByAuthor(String author) { - return Flux.just(new Post("1", "title1", "author1")); - } - - public Flux findAll() { - return Flux.just(new Post("2", "title2", "author2")); - } - - public Mono findById(String id) { - return Mono.just(new Post("3", "title2", "author2")); - } - - public Mono save(Post post) { - return Mono.just(new Post("4", "title2", "author2")); - } - -} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app88/PostRouter.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app88/PostRouter.java deleted file mode 100644 index c0eeebc94..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app88/PostRouter.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * - * * - * * * Copyright 2019-2020 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.app88; - -import io.swagger.v3.oas.annotations.enums.ParameterIn; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.web.reactive.function.server.RouterFunction; -import org.springframework.web.reactive.function.server.ServerResponse; - -import static org.springdoc.core.fn.builders.apiresponse.Builder.responseBuilder; -import static org.springdoc.core.fn.builders.operation.Builder.operationBuilder; -import static org.springdoc.core.fn.builders.parameter.Builder.parameterBuilder; -import static org.springdoc.core.fn.builders.requestbody.Builder.requestBodyBuilder; -import static org.springdoc.core.utils.Constants.OPERATION_ATTRIBUTE; -import static org.springframework.web.reactive.function.server.RequestPredicates.GET; -import static org.springframework.web.reactive.function.server.RequestPredicates.POST; -import static org.springframework.web.reactive.function.server.RequestPredicates.PUT; -import static org.springframework.web.reactive.function.server.RequestPredicates.queryParam; -import static org.springframework.web.reactive.function.server.RouterFunctions.route; - -@Configuration -class PostRouter { - - @Bean - public RouterFunction routes(PostHandler postController) { - return route(GET("/posts").and(queryParam("key", "value")), postController::all) - .withAttribute(OPERATION_ATTRIBUTE, - operationBuilder().operationId("all") - .parameter(parameterBuilder().name("key").description("sample description")) - .parameter(parameterBuilder().name("test").description("sample desc")) - .response(responseBuilder().responseCode("200").implementationArray(Post.class))) - - .and(route(POST("/posts"), postController::create) - .withAttribute(OPERATION_ATTRIBUTE, - operationBuilder().operationId("create") - .requestBody(requestBodyBuilder().implementation(Post.class)) - .response(responseBuilder().responseCode("201")))) - - .and(route(GET("/posts/{id}"), postController::get) - .withAttribute(OPERATION_ATTRIBUTE, - operationBuilder().operationId("get") - .parameter(parameterBuilder().in(ParameterIn.PATH).name("id")) - .response(responseBuilder().responseCode("200").implementation(Post.class)))) - - .and(route(PUT("/posts/{id}"), postController::update) - .withAttribute(OPERATION_ATTRIBUTE, - operationBuilder().operationId("update") - .parameter(parameterBuilder().in(ParameterIn.PATH).name("id")) - .response(responseBuilder().responseCode("202").implementation(Post.class)))); - } -} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app88/SpringDocApp88Test.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app88/SpringDocApp88Test.java deleted file mode 100644 index 758f61a2d..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app88/SpringDocApp88Test.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * - * * - * * * Copyright 2019-2020 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.app88; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.ComponentScan; - -public class SpringDocApp88Test extends AbstractSpringDocTest { - - @SpringBootApplication - @ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.app88" }) - static class SpringDocTestApp {} -} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app89/Book.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app89/Book.java deleted file mode 100644 index f9572f855..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app89/Book.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * - * * - * * * Copyright 2019-2020 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.app89; - -public class Book { - - private String id; - - private String title; - - private String author; - - public Book(String id, String title, String author) { - this.id = id; - this.title = title; - this.author = author; - } - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getTitle() { - return title; - } - - public void setTitle(String title) { - this.title = title; - } - - public String getAuthor() { - return author; - } - - public void setAuthor(String author) { - this.author = author; - } -} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app89/BookRepository.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app89/BookRepository.java deleted file mode 100644 index b307f733e..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app89/BookRepository.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * - * * - * * * Copyright 2019-2020 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.app89; - -import reactor.core.publisher.Flux; - -import org.springframework.stereotype.Component; - -@Component -public class BookRepository { - - - Flux findByAuthor(String author) { - return Flux.just(new Book("1", "title1", "author1")); - } - - Flux findAll() { - return Flux.just(new Book("2", "title2", "author2")); - } -} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app89/BookRouter.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app89/BookRouter.java deleted file mode 100644 index 3abd86779..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app89/BookRouter.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * - * * - * * * Copyright 2019-2020 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.app89; - -import io.swagger.v3.oas.annotations.enums.ParameterIn; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.http.MediaType; -import org.springframework.web.reactive.function.server.RouterFunction; - -import static org.springdoc.core.fn.builders.operation.Builder.operationBuilder; -import static org.springdoc.core.fn.builders.parameter.Builder.parameterBuilder; -import static org.springdoc.core.utils.Constants.OPERATION_ATTRIBUTE; -import static org.springframework.web.reactive.function.server.RequestPredicates.GET; -import static org.springframework.web.reactive.function.server.RequestPredicates.accept; -import static org.springframework.web.reactive.function.server.RequestPredicates.path; -import static org.springframework.web.reactive.function.server.RouterFunctions.nest; -import static org.springframework.web.reactive.function.server.RouterFunctions.route; -import static org.springframework.web.reactive.function.server.ServerResponse.ok; - -@Configuration -class BookRouter { - - @Bean - RouterFunction routes(BookRepository br) { - return nest(path("/greeter").and(path("/greeter2")), - route(GET("/books").and(accept(MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML)), req -> ok().body(br.findAll(), Book.class)) - .withAttribute(OPERATION_ATTRIBUTE, getFindAll()) - - .and(route(GET("/books").and(accept(MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN)), req -> ok().body(br.findAll(), Book.class)) - .withAttribute(OPERATION_ATTRIBUTE, getFindAll())) - - .and(route(GET("/books/{author}"), req -> ok().body(br.findByAuthor(req.pathVariable("author")), Book.class)) - .withAttribute(OPERATION_ATTRIBUTE, getRouterAttribute())) - ); - } - - @Bean - RouterFunction routes1(BookRepository br) { - return nest(accept(MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML), - route(GET("/books"), req -> ok().body(br.findAll(), Book.class)) - .withAttribute(OPERATION_ATTRIBUTE, getFindAll()) - - .and(route(GET("/books/{author}"), req -> ok().body(br.findByAuthor(req.pathVariable("author")), Book.class)) - .withAttribute(OPERATION_ATTRIBUTE, getRouterAttribute()))); - } - - @Bean - RouterFunction routes3(BookRepository br) { - return nest(path("/greeter").or(path("/greeter2")), - route(GET("/books").and(accept(MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML)), req -> ok().body(br.findAll(), Book.class)) - .withAttribute(OPERATION_ATTRIBUTE, getFindAll()) - - - .and(route(GET("/books").and(accept(MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN)), req -> ok().body(br.findAll(), Book.class)) - .withAttribute(OPERATION_ATTRIBUTE, getFindAll())) - - .and(route(GET("/books/{author}"), req -> ok().body(br.findByAuthor(req.pathVariable("author")), Book.class)) - .withAttribute(OPERATION_ATTRIBUTE, getRouterAttribute()))); - } - - @Bean - RouterFunction routes4(BookRepository br) { - return nest(path("/test"), nest(path("/greeter").and(path("/greeter2")), - route(GET("/books").and(accept(MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML)), req -> ok().body(br.findAll(), Book.class)) - .withAttribute(OPERATION_ATTRIBUTE, getFindAll()) - - .and(route(GET("/books").and(accept(MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN)), req -> ok().body(br.findAll(), Book.class)) - .withAttribute(OPERATION_ATTRIBUTE, getFindAll())) - - .and(route(GET("/books/{author}"), req -> ok().body(br.findByAuthor(req.pathVariable("author")), Book.class)) - .withAttribute(OPERATION_ATTRIBUTE, getRouterAttribute())))); - } - - private org.springdoc.core.fn.builders.operation.Builder getFindAll() { - return operationBuilder().beanClass(BookRepository.class).beanMethod("findAll"); - } - - private org.springdoc.core.fn.builders.operation.Builder getRouterAttribute() { - return operationBuilder() - .operationId("findByAuthor").parameter(parameterBuilder().name("author").in(ParameterIn.PATH)) - .beanClass(BookRepository.class).beanMethod("findByAuthor"); - } -} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app89/SpringDocApp89Test.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app89/SpringDocApp89Test.java deleted file mode 100644 index 679dc254f..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app89/SpringDocApp89Test.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * - * * - * * * - * * * * Copyright 2019-2020 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.app89; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.ComponentScan; - -public class SpringDocApp89Test extends AbstractSpringDocTest { - - @SpringBootApplication - @ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.app89" }) - static class SpringDocTestApp {} -} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app90/HelloRouter.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app90/HelloRouter.java deleted file mode 100644 index a92d1e9ff..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app90/HelloRouter.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * - * - * * - * * * - * * * * Copyright 2019-2020 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.app90; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.web.reactive.function.server.RouterFunction; - -import static org.springdoc.core.fn.builders.apiresponse.Builder.responseBuilder; -import static org.springdoc.core.fn.builders.parameter.Builder.parameterBuilder; -import static org.springdoc.webflux.core.fn.SpringdocRouteBuilder.route; -import static test.org.springdoc.api.AbstractSpringDocTest.HANDLER_FUNCTION; - -@Configuration -class HelloRouter { - - @Bean - RouterFunction routes() { - return route().GET("/foo", HANDLER_FUNCTION, ops -> ops - .operationId("hello") - .parameter(parameterBuilder().name("key1").description("My key1 description")) - .parameter(parameterBuilder().name("key2").description("My key2 description")) - .response(responseBuilder().responseCode("200").description("This is normal response description")) - .response(responseBuilder().responseCode("404").description("This is another response description")) - ).build(); - } - -} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app90/SpringDocApp90Test.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app90/SpringDocApp90Test.java deleted file mode 100644 index b73bbd41e..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app90/SpringDocApp90Test.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * - * - * * - * * * - * * * * Copyright 2019-2020 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.app90; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.ComponentScan; - -public class SpringDocApp90Test extends AbstractSpringDocTest { - - @SpringBootApplication - @ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.app90" }) - static class SpringDocTestApp {} -} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app90/book/BookRouter.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app90/book/BookRouter.java deleted file mode 100644 index 4ce631377..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app90/book/BookRouter.java +++ /dev/null @@ -1,144 +0,0 @@ -/* - * - * - * * - * * * - * * * * Copyright 2019-2020 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.app90.book; - -import java.util.function.Consumer; - -import io.swagger.v3.oas.annotations.enums.ParameterIn; -import reactor.core.publisher.Flux; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.http.MediaType; -import org.springframework.stereotype.Component; -import org.springframework.web.reactive.function.server.RouterFunction; - -import static org.springdoc.core.fn.builders.parameter.Builder.parameterBuilder; -import static org.springdoc.webflux.core.fn.SpringdocRouteBuilder.route; -import static org.springframework.web.reactive.function.server.RequestPredicates.accept; -import static org.springframework.web.reactive.function.server.RequestPredicates.path; -import static org.springframework.web.reactive.function.server.RouterFunctions.nest; -import static test.org.springdoc.api.AbstractSpringDocTest.HANDLER_FUNCTION; - -@Configuration -class BookRouter { - - - @Bean - RouterFunction bookRoute(BookRepository br) { - return route().GET("/books", accept(MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML), HANDLER_FUNCTION, ops -> ops.operationId("findAll").tag("book") - .beanClass(BookRepository.class).beanMethod("findAll")).build() - - .and(route().GET("/books", accept(MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN), HANDLER_FUNCTION, - ops -> ops.operationId("findAll").tag("book").beanClass(BookRepository.class).beanMethod("findAll")).build()) - - .and(route().GET("/books/{author}", HANDLER_FUNCTION, ops -> ops.tag("book") - .beanClass(BookRepository.class).beanMethod("findByAuthor") - .operationId("findByAuthor").tag("book").parameter(parameterBuilder().in(ParameterIn.PATH).name("author"))).build()); - } - - @Bean - RouterFunction routes2() { - return nest(path("/greeter").and(path("/greeter2")), - route().GET("/books", accept(MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML), HANDLER_FUNCTION, getOperation1()).build()) - - .and(route().GET("/books/nest", accept(MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN), HANDLER_FUNCTION, getOperation1()).build()) - - .and(route().GET("/books/nest/{author}", HANDLER_FUNCTION, getOperation2()).build()); - } - - @Bean - RouterFunction routes4() { - return nest(path("/test"), nest(path("/greeter").and(path("/greeter2")), - route().GET("/books", accept(MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML), HANDLER_FUNCTION, getOperation1()).build() - - .and(route().GET("/books", accept(MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN), HANDLER_FUNCTION, getOperation1()).build()) - - .and(route().GET("/books/{author}", HANDLER_FUNCTION, getOperation2()).build()))); - } - - - private Consumer getOperation1() { - return ops -> ops.operationId("findAll").tag("book").beanClass(BookRepository.class).beanMethod("findAll"); - } - - private Consumer getOperation2() { - return ops -> ops.operationId("findAll").tag("book") - .operationId("findByAuthor").parameter(parameterBuilder().name("author").in(ParameterIn.PATH)) - .beanClass(BookRepository.class).beanMethod("findByAuthor"); - } - - - @Component - class BookRepository { - - Flux findByAuthor(String author) { - return Flux.just(new Book("1", "title1", "author1")); - } - - Flux findAll() { - return Flux.just(new Book("2", "title2", "author2")); - } - } - - class Book { - - private String id; - - private String title; - - private String author; - - public Book(String id, String title, String author) { - this.id = id; - this.title = title; - this.author = author; - } - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getTitle() { - return title; - } - - public void setTitle(String title) { - this.title = title; - } - - public String getAuthor() { - return author; - } - - public void setAuthor(String author) { - this.author = author; - } - } - -} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app90/employee/Employee.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app90/employee/Employee.java deleted file mode 100644 index 4b9b98422..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app90/employee/Employee.java +++ /dev/null @@ -1,24 +0,0 @@ -package test.org.springdoc.api.app90.employee; - -public class Employee { - - private String id; - - private String name; - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } -} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app90/employee/EmployeeRepository.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app90/employee/EmployeeRepository.java deleted file mode 100644 index d11166681..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app90/employee/EmployeeRepository.java +++ /dev/null @@ -1,32 +0,0 @@ -package test.org.springdoc.api.app90.employee; - -import java.util.Map; - -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.enums.ParameterIn; -import reactor.core.publisher.Flux; -import reactor.core.publisher.Mono; - -public class EmployeeRepository { - - static Map employeeData; - - static Map employeeAccessData; - - - public Mono findEmployeeById(@Parameter(in = ParameterIn.PATH) String id) { - return Mono.just(employeeData.get(id)); - } - - public Flux findAllEmployees() { - return Flux.fromIterable(employeeData.values()); - } - - public Mono updateEmployee(Employee employee) { - Employee existingEmployee = employeeData.get(employee.getId()); - if (existingEmployee != null) { - existingEmployee.setName(employee.getName()); - } - return Mono.just(existingEmployee); - } -} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app90/employee/EmployeeRouter.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app90/employee/EmployeeRouter.java deleted file mode 100644 index e8ff3af4b..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app90/employee/EmployeeRouter.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * - * - * * - * * * - * * * * Copyright 2019-2020 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.app90.employee; - -import io.swagger.v3.oas.annotations.enums.ParameterIn; -import test.org.springdoc.api.app84.Employee; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.web.reactive.function.server.RouterFunction; -import org.springframework.web.reactive.function.server.ServerResponse; - -import static org.springdoc.core.fn.builders.apiresponse.Builder.responseBuilder; -import static org.springdoc.core.fn.builders.parameter.Builder.parameterBuilder; -import static org.springdoc.webflux.core.fn.SpringdocRouteBuilder.route; -import static test.org.springdoc.api.AbstractSpringDocTest.HANDLER_FUNCTION; - -@Configuration -class EmployeeRouter { - - @Bean - RouterFunction getEmployeeByIdRoute() { - return route().GET("/employees/{id}", HANDLER_FUNCTION, ops -> ops.tag("employee") - .operationId("findEmployeeById").summary("Find purchase order by ID").tags(new String[] { "MyEmployee" }) - .parameter(parameterBuilder().in(ParameterIn.PATH).name("id").description("Employee Id")) - .response(responseBuilder().responseCode("200").description("successful operation").implementation(Employee.class)) - .response(responseBuilder().responseCode("400").description("Invalid Employee ID supplied")) - .response(responseBuilder().responseCode("404").description("Employee not found"))).build(); - } - -} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app90/position/PositionRouter.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app90/position/PositionRouter.java deleted file mode 100644 index 6e38f6dbe..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app90/position/PositionRouter.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * - * - * * - * * * - * * * * Copyright 2019-2020 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.app90.position; - -import io.swagger.v3.oas.annotations.enums.ParameterIn; -import test.org.springdoc.api.app85.entity.Position; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.http.MediaType; -import org.springframework.web.reactive.function.server.RouterFunction; -import org.springframework.web.reactive.function.server.ServerResponse; - -import static org.springdoc.core.fn.builders.apiresponse.Builder.responseBuilder; -import static org.springdoc.core.fn.builders.parameter.Builder.parameterBuilder; -import static org.springdoc.core.fn.builders.requestbody.Builder.requestBodyBuilder; -import static org.springdoc.webflux.core.fn.SpringdocRouteBuilder.route; -import static org.springframework.web.reactive.function.server.RequestPredicates.accept; -import static test.org.springdoc.api.AbstractSpringDocTest.HANDLER_FUNCTION; - -@Configuration -class PositionRouter { - - @Bean - public RouterFunction positionRoute() { - return route().GET("/getAllPositions", accept(MediaType.APPLICATION_JSON), HANDLER_FUNCTION, ops -> ops - .operationId("findAll").description("Get all positions").tags(new String[] { "positions" }) - .response(responseBuilder().responseCode("200").implementationArray(Position.class))).build() - - .and(route().GET("/getPosition/{id}", accept(MediaType.APPLICATION_STREAM_JSON), HANDLER_FUNCTION, ops -> ops - .operationId("findById").description("Find all").tags(new String[] { "positions" }) - .parameter(parameterBuilder().in(ParameterIn.PATH).name("id")) - .response(responseBuilder().responseCode("200").implementation(Position.class))).build()) - - .and(route().POST("/createPosition", accept(MediaType.APPLICATION_JSON), HANDLER_FUNCTION, ops -> ops - .operationId("save").description("Save position").tags(new String[] { "positions" }) - .requestBody(requestBodyBuilder().implementation(Position.class)) - .response(responseBuilder().responseCode("200").implementation(Position.class))).build()) - - .and(route().DELETE("/deletePosition/{id}", accept(MediaType.APPLICATION_JSON), HANDLER_FUNCTION, ops -> ops - .operationId("deleteBy").description("Delete By Id").tags(new String[] { "positions" }) - .parameter(parameterBuilder().in(ParameterIn.PATH).name("id")) - .response(responseBuilder().responseCode("200").content(org.springdoc.core.fn.builders.content.Builder.contentBuilder()))).build()); - } -} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app90/quotes/QuotesRouter.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app90/quotes/QuotesRouter.java deleted file mode 100644 index f8c586fac..000000000 --- a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/app90/quotes/QuotesRouter.java +++ /dev/null @@ -1,130 +0,0 @@ -/* - * - * - * * - * * * - * * * * Copyright 2019-2020 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.app90.quotes; - -import java.math.BigDecimal; -import java.math.MathContext; -import java.time.Instant; - -import io.swagger.v3.oas.annotations.enums.ParameterIn; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.web.reactive.function.server.RouterFunction; -import org.springframework.web.reactive.function.server.ServerResponse; - -import static org.springdoc.core.fn.builders.apiresponse.Builder.responseBuilder; -import static org.springdoc.core.fn.builders.parameter.Builder.parameterBuilder; -import static org.springdoc.core.fn.builders.requestbody.Builder.requestBodyBuilder; -import static org.springdoc.webflux.core.fn.SpringdocRouteBuilder.route; -import static org.springframework.http.MediaType.APPLICATION_JSON; -import static org.springframework.http.MediaType.APPLICATION_STREAM_JSON; -import static org.springframework.http.MediaType.TEXT_PLAIN; -import static org.springframework.web.reactive.function.server.RequestPredicates.accept; -import static org.springframework.web.reactive.function.server.RequestPredicates.contentType; -import static test.org.springdoc.api.AbstractSpringDocTest.HANDLER_FUNCTION; - -@Configuration -class QuotesRouter { - - @Bean - RouterFunction myroute() { - return route().GET("/hello", accept(TEXT_PLAIN), HANDLER_FUNCTION, ops -> ops.tag("quotes") - .operationId("hello").response(responseBuilder().responseCode("200"))).build() - - .and(route().POST("/echo", accept(TEXT_PLAIN).and(contentType(TEXT_PLAIN)), HANDLER_FUNCTION, ops -> ops.tag("quotes") - .operationId("echo") - .requestBody(requestBodyBuilder().implementation(String.class)) - .response(responseBuilder().responseCode("200").implementation(String.class))).build()) - - .and(route().POST("/echo", accept(APPLICATION_JSON).and(contentType(APPLICATION_JSON)), HANDLER_FUNCTION, ops -> ops.tag("quotes") - .operationId("echo") - .requestBody(requestBodyBuilder().implementation(String.class)) - .response(responseBuilder().responseCode("200").implementation(String.class))).build()) - - .and(route().GET("/quotes", accept(APPLICATION_JSON), HANDLER_FUNCTION, ops -> ops.tag("quotes") - .operationId("fetchQuotes") - .parameter(parameterBuilder().in(ParameterIn.QUERY).name("size").implementation(String.class)) - .response(responseBuilder().responseCode("200").implementationArray(Quote.class))).build()) - - .and(route().GET("/quotes", accept(APPLICATION_STREAM_JSON), HANDLER_FUNCTION, ops -> ops.tag("quotes") - .operationId("fetchQuotes") - .response(responseBuilder().responseCode("200").implementation(Quote.class))).build()); - } - - - class Quote { - - private String ticker; - - private BigDecimal price; - - private Instant instant; - - public Quote() { - } - - public Quote(String ticker, BigDecimal price) { - this.ticker = ticker; - this.price = price; - } - - public Quote(String ticker, Double price) { - this(ticker, new BigDecimal(price, new MathContext(2))); - } - - public String getTicker() { - return ticker; - } - - public void setTicker(String ticker) { - this.ticker = ticker; - } - - public BigDecimal getPrice() { - return price; - } - - public void setPrice(BigDecimal price) { - this.price = price; - } - - public Instant getInstant() { - return instant; - } - - public void setInstant(Instant instant) { - this.instant = instant; - } - - @Override - public String toString() { - return "Quote{" + - "ticker='" + ticker + '\'' + - ", price=" + price + - ", instant=" + instant + - '}'; - } - } -} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/AbstractCommonTest.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/AbstractCommonTest.java new file mode 100644 index 000000000..a26b7e6f2 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/AbstractCommonTest.java @@ -0,0 +1,63 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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; + +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.reactive.AutoConfigureWebTestClient; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.context.TestPropertySource; +import org.springframework.test.web.reactive.server.WebTestClient; + +@AutoConfigureWebTestClient(timeout = "3600000") +@ActiveProfiles("test") +@TestPropertySource(properties = "springdoc.api-docs.version=openapi_3_0" ) +public abstract class AbstractCommonTest { + + protected static final Logger LOGGER = LoggerFactory.getLogger(AbstractCommonTest.class); + + @Autowired + protected WebTestClient webTestClient; + + protected String getContent(String fileName) { + try { + Path path = Paths.get(AbstractCommonTest.class.getClassLoader().getResource(fileName).toURI()); + byte[] fileBytes = Files.readAllBytes(path); + return new String(fileBytes, StandardCharsets.UTF_8); + } + catch (Exception e) { + throw new RuntimeException("Failed to read file: " + fileName, e); + } + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/AbstractSpringDocTest.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/AbstractSpringDocTest.java new file mode 100644 index 000000000..3d7c5fef0 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/AbstractSpringDocTest.java @@ -0,0 +1,68 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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; + +import org.junit.jupiter.api.Test; +import org.springdoc.core.utils.Constants; + +import org.springframework.boot.test.autoconfigure.web.reactive.AutoConfigureWebTestClient; +import org.springframework.boot.test.autoconfigure.web.reactive.WebFluxTest; +import org.springframework.test.web.reactive.server.EntityExchangeResult; +import org.springframework.web.reactive.function.server.HandlerFunction; +import org.springframework.web.reactive.function.server.ServerResponse; + +import static org.skyscreamer.jsonassert.JSONAssert.assertEquals; + + +@WebFluxTest +@AutoConfigureWebTestClient(timeout = "3600000") +public abstract class AbstractSpringDocTest extends AbstractCommonTest { + + public static final HandlerFunction HANDLER_FUNCTION = request -> ServerResponse.ok().build(); + + protected String groupName = ""; + + + @Test + void testApp() throws Exception { + String result = null; + try { + EntityExchangeResult getResult = webTestClient.get().uri(Constants.DEFAULT_API_DOCS_URL + groupName).exchange() + .expectStatus().isOk().expectBody().returnResult(); + + result = new String(getResult.getResponseBody()); + String className = getClass().getSimpleName(); + String testNumber = className.replaceAll("[^0-9]", ""); + String expected = getContent("results/3.0.1/app" + testNumber + ".json"); + assertEquals(expected, result, true); + } + catch (java.lang.AssertionError e) { + LOGGER.error(result); + throw e; + } + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app102/InheritedRequestParams.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app102/InheritedRequestParams.java new file mode 100644 index 000000000..834dd9c39 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app102/InheritedRequestParams.java @@ -0,0 +1,44 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app102; + +import io.swagger.v3.oas.annotations.Parameter; +import jakarta.validation.constraints.NotBlank; + +public class InheritedRequestParams extends RequestParams { + @Parameter(description = "parameter from child of RequestParams") + @NotBlank + private String childParam; + + public String getChildParam() { + return childParam; + } + + public void setChildParam(String childParam) { + this.childParam = childParam; + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app102/RequestParams.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app102/RequestParams.java new file mode 100644 index 000000000..cc62d7d89 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app102/RequestParams.java @@ -0,0 +1,148 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app102; + +import java.math.BigInteger; +import java.util.List; +import java.util.Optional; + +import io.swagger.v3.oas.annotations.Parameter; + +import org.springframework.lang.Nullable; + +public class RequestParams { + + @Parameter(description = "string parameter") + private String stringParam; + + @Deprecated + private String stringParam1; + + @Parameter(description = "string parameter2", required = true) + private String stringParam2; + + @Parameter(description = "int parameter") + private int intParam; + + private Optional intParam2; + + @Nullable + private String intParam3; + + private Nested nested; + + private List nestedList; + + public String getStringParam() { + return stringParam; + } + + public void setStringParam(String stringParam) { + this.stringParam = stringParam; + } + + public int getIntParam() { + return intParam; + } + + public void setIntParam(int intParam) { + this.intParam = intParam; + } + + public Optional getIntParam2() { + return intParam2; + } + + public void setIntParam2(Optional intParam2) { + this.intParam2 = intParam2; + } + + @Nullable + public String getIntParam3() { + return intParam3; + } + + public void setIntParam3(@Nullable String intParam3) { + this.intParam3 = intParam3; + } + + public String getStringParam1() { + return stringParam1; + } + + public void setStringParam1(String stringParam1) { + this.stringParam1 = stringParam1; + } + + public String getStringParam2() { + return stringParam2; + } + + public void setStringParam2(String stringParam2) { + this.stringParam2 = stringParam2; + } + + public Nested getNested() { + return nested; + } + + public void setNested(Nested nested) { + this.nested = nested; + } + + public List getNestedList() { + return nestedList; + } + + public void setNestedList(List nestedList) { + this.nestedList = nestedList; + } + + public static class Nested { + private String param1; + + private BigInteger param2; + + @Parameter(description = "nested string parameter") + public String getParam1() { + return param1; + } + + public void setParam1(String param1) { + this.param1 = param1; + } + + @Parameter(description = "nested BigInteger parameter") + public BigInteger getParam2() { + return param2; + } + + public void setParam2(BigInteger param2) { + this.param2 = param2; + } + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app102/SpringDocApp102Test.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app102/SpringDocApp102Test.java new file mode 100644 index 000000000..98d216ef1 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app102/SpringDocApp102Test.java @@ -0,0 +1,40 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app102; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.ComponentScan; + +public class SpringDocApp102Test extends AbstractSpringDocTest { + + @SpringBootApplication + @ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.v30.app102" }) + static class SpringDocTestApp {} + +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app102/TestController.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app102/TestController.java new file mode 100644 index 000000000..4ce1f3a02 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app102/TestController.java @@ -0,0 +1,41 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app102; + +import org.springdoc.core.annotations.ParameterObject; + +import org.springframework.lang.Nullable; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class TestController { + @GetMapping("test") + public void getTest(@RequestParam @Nullable String param, @ParameterObject InheritedRequestParams requestParams) { + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app149/HelloController.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app149/HelloController.java new file mode 100644 index 000000000..a8f86a654 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app149/HelloController.java @@ -0,0 +1,73 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app149; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.ResponseBody; + +/** + * To test the case a user does not use @RestController but puts @Operation on handler methods + * and wants these methods to be exposed. + * + * @author Azige + */ +@Controller +public class HelloController { + + @GetMapping("/hello") + @Operation(responses = @ApiResponse( + responseCode = "200", + description = "OK", + content = @Content(schema = @Schema(implementation = HelloMessage.class)) + )) + public String hello() { + return "forward:/message"; + } + + @GetMapping("/message") + @Operation + @ResponseBody + public HelloMessage message() { + return new HelloMessage("Lucky numbers!", 777); + } + + @GetMapping("/helloModelAndView") + @Operation(responses = @ApiResponse( + responseCode = "200", + description = "OK", + content = @Content(schema = @Schema(implementation = HelloMessage.class)) + )) + public HelloMessage helloModelAndView() { + return null; + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app149/HelloMessage.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app149/HelloMessage.java new file mode 100644 index 000000000..d9f307ab2 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app149/HelloMessage.java @@ -0,0 +1,38 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app149; + +public class HelloMessage { + public String text; + + public int number; + + public HelloMessage(String text, int number) { + this.text = text; + this.number = number; + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app149/HiddenHelloController.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app149/HiddenHelloController.java new file mode 100644 index 000000000..344d88387 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app149/HiddenHelloController.java @@ -0,0 +1,48 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app149; + +import io.swagger.v3.oas.annotations.Operation; + +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * @author bnasslahsen + */ +@RestController +@RequestMapping("/api") +public class HiddenHelloController { + + @Operation(description = "I want here some custom config") + @GetMapping("/{entity}/{id}") + public ResponseEntity getEntity() { + throw new UnsupportedOperationException("the body is not relevant now"); + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app149/SpringDocApp149Test.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app149/SpringDocApp149Test.java new file mode 100644 index 000000000..9df343416 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app149/SpringDocApp149Test.java @@ -0,0 +1,44 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app149; + +import org.springdoc.core.utils.SpringDocUtils; +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.ComponentScan; + +public class SpringDocApp149Test extends AbstractSpringDocTest { + + static { + SpringDocUtils.getConfig().addHiddenRestControllers(HiddenHelloController.class); + } + + @SpringBootApplication + @ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.v30.app149" }) + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app150/HelloRouter.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app150/HelloRouter.java new file mode 100644 index 000000000..f6058f717 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app150/HelloRouter.java @@ -0,0 +1,71 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app150; + +import java.util.function.Consumer; +import java.util.function.Supplier; + +import org.springdoc.core.fn.builders.operation.Builder; +import org.springdoc.webflux.core.fn.SpringdocRouteBuilder; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.reactive.function.server.RequestPredicates; +import org.springframework.web.reactive.function.server.RouterFunction; +import org.springframework.web.reactive.function.server.RouterFunctions; +import org.springframework.web.reactive.function.server.ServerResponse; + +import static org.springframework.web.reactive.function.server.RequestPredicates.path; +import static org.springframework.web.reactive.function.server.RouterFunctions.nest; +import static test.org.springdoc.api.v30.AbstractSpringDocTest.HANDLER_FUNCTION; + +@Configuration +public class HelloRouter { + + @Bean + RouterFunction routeSample() { + Supplier> routerFunctionSupplier = + () -> SpringdocRouteBuilder.route() + .GET("toto", HANDLER_FUNCTION, builder -> builder.operationId("get-user-groups")) + + .POST("/titi", HANDLER_FUNCTION, builder -> builder.operationId("create-user-group-special")).build(); + + Consumer operationsConsumer = builder -> { + }; + + return RouterFunctions.nest(RequestPredicates.path("/users"), nest(path("/test"), nest(path("/greeter"), + SpringdocRouteBuilder.route() + .GET(HANDLER_FUNCTION, builder -> builder.operationId("get-users")) + .POST("/special", HANDLER_FUNCTION, builder -> builder.operationId("create-user-special")) + .nest(path("/groups"), routerFunctionSupplier, operationsConsumer) + .nest(path("/groups2"), routerFunctionSupplier, operationsConsumer) + .nest(path("/greeter3").or(path("/greeter4")), routerFunctionSupplier, operationsConsumer) + .build()))); + + } + +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app150/SpringDocApp150Test.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app150/SpringDocApp150Test.java new file mode 100644 index 000000000..a7db7997d --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app150/SpringDocApp150Test.java @@ -0,0 +1,39 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app150; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.ComponentScan; + +public class SpringDocApp150Test extends AbstractSpringDocTest { + + @SpringBootApplication + @ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.v30.app150" }) + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app151/HelloRouter.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app151/HelloRouter.java new file mode 100644 index 000000000..45360dd8b --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app151/HelloRouter.java @@ -0,0 +1,71 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app151; + +import java.util.function.Consumer; +import java.util.function.Supplier; + +import org.springdoc.core.fn.builders.operation.Builder; +import org.springdoc.webflux.core.fn.SpringdocRouteBuilder; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.reactive.function.server.RequestPredicates; +import org.springframework.web.reactive.function.server.RouterFunction; +import org.springframework.web.reactive.function.server.RouterFunctions; +import org.springframework.web.reactive.function.server.ServerResponse; + +import static org.springframework.web.reactive.function.server.RequestPredicates.path; +import static org.springframework.web.reactive.function.server.RouterFunctions.nest; +import static test.org.springdoc.api.v30.AbstractSpringDocTest.HANDLER_FUNCTION; + +@Configuration +public class HelloRouter { + + @Bean + RouterFunction routeSample() { + Supplier> routerFunctionSupplier = + () -> SpringdocRouteBuilder.route() + .GET("toto", HANDLER_FUNCTION, builder -> builder.operationId("get-user-groups")) + + .POST("/titi", HANDLER_FUNCTION, builder -> builder.operationId("create-user-group-special")).build(); + + Consumer operationsConsumer = builder -> { + }; + + return RouterFunctions.nest(RequestPredicates.path("/users"), nest(path("/test"), nest(path("/greeter"), + SpringdocRouteBuilder.route() + .GET("", HANDLER_FUNCTION, builder -> builder.operationId("get-users")) + .POST("/special", HANDLER_FUNCTION, builder -> builder.operationId("create-user-special")) + .nest(path("/groups"), routerFunctionSupplier, operationsConsumer) + .nest(path("/groups2"), routerFunctionSupplier, operationsConsumer) + .nest(path("/greeter3").or(path("/greeter4")), routerFunctionSupplier, operationsConsumer) + .build()))); + + } + +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app151/SpringDocApp151Test.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app151/SpringDocApp151Test.java new file mode 100644 index 000000000..4e9ddee45 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app151/SpringDocApp151Test.java @@ -0,0 +1,39 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app151; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.ComponentScan; + +public class SpringDocApp151Test extends AbstractSpringDocTest { + + @SpringBootApplication + @ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.v30.app151" }) + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app152/HelloController.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app152/HelloController.java new file mode 100644 index 000000000..8909d3b63 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app152/HelloController.java @@ -0,0 +1,52 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app152; + +import org.reactivestreams.Publisher; +import org.springdoc.core.models.GroupedOpenApi; +import reactor.core.publisher.Mono; + +import org.springframework.context.annotation.Bean; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class HelloController { + + @GetMapping("/persons") + public Publisher persons() { + return Mono.just("OK"); + } + + @Bean + public GroupedOpenApi userOpenApi() { + return GroupedOpenApi.builder() + .group("users") + .packagesToScan("test.org.springdoc.api.v30.app152") + .build(); + } +} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app152/SpringDocApp152Test.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app152/SpringDocApp152Test.java new file mode 100644 index 000000000..2eff5a905 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app152/SpringDocApp152Test.java @@ -0,0 +1,39 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app152; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.ComponentScan; + +public class SpringDocApp152Test extends AbstractSpringDocTest { + + @SpringBootApplication + @ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.v30.app152" }) + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app153/DefaultRequestMappingHandlerMapping.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app153/DefaultRequestMappingHandlerMapping.java new file mode 100644 index 000000000..83e6bc286 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app153/DefaultRequestMappingHandlerMapping.java @@ -0,0 +1,68 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app153; + +import org.springframework.expression.ParserContext; +import org.springframework.expression.spel.standard.SpelExpressionParser; +import org.springframework.expression.spel.support.StandardEvaluationContext; +import org.springframework.util.StringValueResolver; +import org.springframework.web.reactive.result.method.annotation.RequestMappingHandlerMapping; + +public class DefaultRequestMappingHandlerMapping extends RequestMappingHandlerMapping { + + private static final SpelExpressionParser PARSER = new SpelExpressionParser(); + + private static ThreadLocal handlerHolder = new ThreadLocal<>(); + + @Override + public void setEmbeddedValueResolver(StringValueResolver resolver) { + super.setEmbeddedValueResolver(new StringValueResolver() { + @Override + public String resolveStringValue(String strVal) { + Object handler = handlerHolder.get(); + if (handler != null) { + strVal = String.valueOf(PARSER.parseExpression(strVal, ParserContext.TEMPLATE_EXPRESSION) + .getValue(new StandardEvaluationContext(handler))); + } + if (resolver != null) { + strVal = resolver.resolveStringValue(strVal); + } + return strVal; + } + }); + } + + @Override + protected void detectHandlerMethods(Object handler) { + Object handlerObject = (handler instanceof String ? obtainApplicationContext().getBean((String) handler) + : handler); + handlerHolder.set(handlerObject); + super.detectHandlerMethods(handler); + handlerHolder.remove(); + } + +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app153/DefaultWebFluxRegistrations.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app153/DefaultWebFluxRegistrations.java new file mode 100644 index 000000000..982354999 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app153/DefaultWebFluxRegistrations.java @@ -0,0 +1,41 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app153; + +import org.springframework.boot.autoconfigure.web.reactive.WebFluxRegistrations; +import org.springframework.stereotype.Component; +import org.springframework.web.reactive.result.method.annotation.RequestMappingHandlerMapping; + +@Component +public class DefaultWebFluxRegistrations implements WebFluxRegistrations { + + @Override + public RequestMappingHandlerMapping getRequestMappingHandlerMapping() { + return new DefaultRequestMappingHandlerMapping(); + } + +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app153/SpringDocApp153Test.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app153/SpringDocApp153Test.java new file mode 100644 index 000000000..24141c747 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app153/SpringDocApp153Test.java @@ -0,0 +1,39 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app153; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.ComponentScan; + +public class SpringDocApp153Test extends AbstractSpringDocTest { + + @SpringBootApplication + @ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.v30.app153" }) + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app153/TestController.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app153/TestController.java new file mode 100644 index 000000000..fd822d8e5 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app153/TestController.java @@ -0,0 +1,39 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app153; + +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class TestController { + + @PostMapping("/echo") + public String echo(String content) { + return content; + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app184/HelloController.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app184/HelloController.java new file mode 100644 index 000000000..7968f97b6 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app184/HelloController.java @@ -0,0 +1,61 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app184; + + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class HelloController { + + @GetMapping("/globalBeanFiltered") + public String globalBeanFiltered() { + return "globalBeanFiltered"; + } + + @GetMapping("/beanFiltered") + public String beanFiltered() { + return "beanFiltered"; + } + + @GetMapping("/group1Filtered") + public String group1Filtered() { + return "group1Filtered"; + } + + @GetMapping("/group2Filtered") + public String group2Filtered() { + return "group2Filtered"; + } + + @GetMapping("/group3Filtered") + public String group3Filtered() { + return "group3Filtered"; + } + +} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app184/SpringDocApp184Test.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app184/SpringDocApp184Test.java new file mode 100644 index 000000000..050096df8 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app184/SpringDocApp184Test.java @@ -0,0 +1,132 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app184; + +import java.util.Objects; + +import io.swagger.v3.oas.models.parameters.HeaderParameter; +import io.swagger.v3.oas.models.servers.Server; +import org.junit.jupiter.api.Test; +import org.springdoc.core.customizers.GlobalOpenApiCustomizer; +import org.springdoc.core.customizers.GlobalOperationCustomizer; +import org.springdoc.core.customizers.OpenApiCustomizer; +import org.springdoc.core.customizers.OperationCustomizer; +import org.springdoc.core.filters.GlobalOpenApiMethodFilter; +import org.springdoc.core.filters.OpenApiMethodFilter; +import org.springdoc.core.models.GroupedOpenApi; +import org.springdoc.core.utils.Constants; +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.test.context.TestPropertySource; + +@TestPropertySource(properties = { + "springdoc.group-configs[0].group=group1", + "springdoc.group-configs[0].paths-to-exclude=/group1Filtered", +}) +public class SpringDocApp184Test extends AbstractSpringDocTest { + + @Test + void testGroup1() throws Exception { + webTestClient.get().uri(Constants.DEFAULT_API_DOCS_URL + "/group1").exchange() + .expectStatus().isOk() + .expectBody().json(getContent("results/3.0.1/app184-1.json"), true); + } + + @Test + void testGroup2() throws Exception { + webTestClient.get().uri(Constants.DEFAULT_API_DOCS_URL + "/group2").exchange() + .expectStatus().isOk() + .expectBody().json(getContent("results/3.0.1/app184-2.json"), true); + } + + @Test + void testGroup3() throws Exception { + webTestClient.get().uri(Constants.DEFAULT_API_DOCS_URL + "/group3").exchange() + .expectStatus().isOk() + .expectBody().json(getContent("results/3.0.1/app184-3.json"), true); + } + + @SpringBootApplication + @ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.v30.app184" }) + static class SpringDocTestApp { + + @Bean + public GlobalOpenApiCustomizer addUrlGlobalBean() { + return openApi -> openApi.getServers().add(new Server().url("urlGlobalBean")); + } + + @Bean + public OpenApiCustomizer addUrlBean() { + return openApi -> openApi.getServers().add(new Server().url("urlBean")); + } + + @Bean + public GlobalOperationCustomizer addHeaderGlobaBeanl() { + return (operation, handlerMethod) -> operation.addParametersItem(new HeaderParameter().name("headerGlobalBean")); + } + + @Bean + public OperationCustomizer addHeaderBean() { + return (operation, handlerMethod) -> operation.addParametersItem(new HeaderParameter().name("headerBean")); + } + + @Bean + public GlobalOpenApiMethodFilter globalFilterBean() { + return method -> !Objects.equals(method.getName(), "globalBeanFiltered"); + } + + @Bean + public OpenApiMethodFilter filterBean() { + return method -> !Objects.equals(method.getName(), "beanFiltered"); + } + + @Bean + public GroupedOpenApi group2() { + return GroupedOpenApi.builder() + .group("group2") + .addOpenApiCustomizer(openApi -> openApi.getServers().add(new Server().url("urlGroup2"))) + .addOperationCustomizer((operation, handlerMethod) -> operation.addParametersItem(new HeaderParameter().name("headerGroup2"))) + .addOpenApiMethodFilter(method -> !Objects.equals(method.getName(), "group2Filtered")) + .build(); + } + + @Bean + public GroupedOpenApi group3() { + return GroupedOpenApi.builder() + .group("group3") + .addOpenApiCustomizer(openApi -> openApi.getServers().add(new Server().url("urlGroup3"))) + .addOperationCustomizer((operation, handlerMethod) -> operation.addParametersItem(new HeaderParameter().name("headerGroup3"))) + .addOpenApiMethodFilter(method -> !Objects.equals(method.getName(), "group3Filtered")) + .build(); + } + + } + +} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app187/DuplicatedPathController.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app187/DuplicatedPathController.java new file mode 100644 index 000000000..036ff6c30 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app187/DuplicatedPathController.java @@ -0,0 +1,45 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app187; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class DuplicatedPathController { + + @GetMapping("/duplicated") + public String duplicated1() { + return "globalBeanFiltered"; + } + + @GetMapping(value = "/duplicated", params = "filter=params") + public String duplicated2() { + return "beanFiltered"; + } + +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app187/SpringDocApp187Test.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app187/SpringDocApp187Test.java new file mode 100644 index 000000000..9953eac67 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app187/SpringDocApp187Test.java @@ -0,0 +1,62 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app187; + +import org.junit.jupiter.api.Test; +import org.springdoc.core.customizers.RouterOperationCustomizer; +import org.springdoc.core.utils.Constants; +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; + +class SpringDocApp187Test extends AbstractSpringDocTest { + + @Test + void testAddRouterOperationCustomizerBean() { + webTestClient.get().uri(Constants.DEFAULT_API_DOCS_URL).exchange() + .expectStatus().isOk() + .expectBody().json(getContent("results/3.0.1/app187.json"), true); + } + + @SpringBootApplication + @ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.v30.app187" }) + static class SpringDocTestApp { + + @Bean + public RouterOperationCustomizer addRouterOperationCustomizer() { + return (routerOperation, handlerMethod) -> { + if (routerOperation.getParams().length > 0) { + routerOperation.setPath(routerOperation.getPath() + "?" + String.join("&", routerOperation.getParams())); + } + return routerOperation; + }; + } + } + +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app188/OrderDemo.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app188/OrderDemo.java new file mode 100644 index 000000000..c99a1b881 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app188/OrderDemo.java @@ -0,0 +1,67 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app188; + +import io.swagger.v3.oas.models.OpenAPI; +import io.swagger.v3.oas.models.tags.Tag; +import org.springdoc.core.customizers.GlobalOpenApiCustomizer; +import org.springdoc.core.customizers.OpenApiCustomizer; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + + +public class OrderDemo { + + public static class Customizer2 implements OpenApiCustomizer, GlobalOpenApiCustomizer { + public void customise(OpenAPI openApi) { + openApi.addTagsItem(new Tag().name("2")); + } + } + + public static class Customizer3 implements OpenApiCustomizer, GlobalOpenApiCustomizer { + public void customise(OpenAPI openApi) { + openApi.addTagsItem(new Tag().name("3")); + } + } + + public static class Customizer1 implements OpenApiCustomizer, GlobalOpenApiCustomizer { + public void customise(OpenAPI openApi) { + openApi.addTagsItem(new Tag().name("1")); + } + } + + @RestController + public static class MyController { + + @GetMapping("/test") + public String testingMethod() { + return "foo"; + } + } + +} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app188/SpringDocApp188Test.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app188/SpringDocApp188Test.java new file mode 100644 index 000000000..6d15cd802 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app188/SpringDocApp188Test.java @@ -0,0 +1,57 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app188; + +import org.junit.jupiter.api.Test; +import org.springdoc.core.utils.Constants; +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Import; +import org.springframework.test.context.TestPropertySource; + +@TestPropertySource(properties = { "springdoc.group-configs[0].group=mygroup", "springdoc.group-configs[0].paths-to-match=/test" }) +class SpringDocApp188Test extends AbstractSpringDocTest { + + @Test + void testApp1() { + webTestClient.get().uri(Constants.DEFAULT_API_DOCS_URL +"/mygroup").exchange() + .expectStatus().isOk() + .expectBody().json(getContent("results/3.0.1/app188.json"), true); + } + + @SpringBootApplication + @Import({ + OrderDemo.Customizer1.class, + OrderDemo.Customizer2.class, + OrderDemo.Customizer3.class, + }) + @ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.v30.app188" }) + static class SpringDocTestApp {} + +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app189/HelloController.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app189/HelloController.java new file mode 100644 index 000000000..deb1368ae --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app189/HelloController.java @@ -0,0 +1,55 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app189; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; +import reactor.core.publisher.Mono; + +import org.springframework.http.MediaType; +import org.springframework.http.codec.multipart.FilePart; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.bind.annotation.RestController; + + +@RestController +public class HelloController { + + + @Operation(summary = "Parse Resume") + @PostMapping(value = "/parse-resume", produces = { MediaType.APPLICATION_JSON_VALUE }, consumes = { + MediaType.MULTIPART_FORM_DATA_VALUE }) + @ApiResponses({ @ApiResponse(responseCode = "400", description = "Invalid input") }) + public Mono parse( + @RequestPart(name = "resumeFile") @Parameter(description = "Resume file to be parsed", content = @Content(mediaType = MediaType.APPLICATION_OCTET_STREAM_VALUE)) FilePart resumeFile) { + return null; + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app189/SpringDocApp189Test.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app189/SpringDocApp189Test.java new file mode 100644 index 000000000..a1a103533 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app189/SpringDocApp189Test.java @@ -0,0 +1,63 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app189; + +import java.time.Duration; + +import org.json.JSONException; +import org.junit.jupiter.api.Test; +import org.springdoc.core.utils.Constants; +import test.org.springdoc.api.v30.AbstractCommonTest; + +import org.springframework.boot.test.autoconfigure.web.reactive.WebFluxTest; +import org.springframework.test.web.reactive.server.EntityExchangeResult; + +import static org.skyscreamer.jsonassert.JSONAssert.assertEquals; + +@WebFluxTest +public class SpringDocApp189Test extends AbstractCommonTest { + + @Test + public void testWithDifferentLocales() throws Exception { + runTestWithLocale("en-GB"); + runTestWithLocale("de-DE"); + } + private void runTestWithLocale(String locale) throws JSONException { + EntityExchangeResult getResult = webTestClient.mutate().responseTimeout(Duration.ofMinutes(1000)).build() + .get().uri(Constants.DEFAULT_API_DOCS_URL) + .header("Accept-Language", locale) + .exchange() + .expectStatus().isOk().expectBody().returnResult(); + + String result = new String(getResult.getResponseBody()); + String className = getClass().getSimpleName(); + String testNumber = className.replaceAll("[^0-9]", ""); + String expected = getContent("results/3.0.1/app" + testNumber + ".json"); + assertEquals(expected, result, true); + } + +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app189/SpringDocTestApp.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app189/SpringDocTestApp.java new file mode 100644 index 000000000..5cd3219d1 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app189/SpringDocTestApp.java @@ -0,0 +1,61 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app189; + +import io.swagger.v3.oas.models.Components; +import io.swagger.v3.oas.models.OpenAPI; +import io.swagger.v3.oas.models.info.Info; +import io.swagger.v3.oas.models.info.License; +import io.swagger.v3.oas.models.security.SecurityScheme; +import org.springdoc.core.customizers.OpenApiCustomizer; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; + +@SpringBootApplication +@ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.v30.app189" }) +public class SpringDocTestApp { + + @Bean + public OpenAPI customOpenAPI() { + return new OpenAPI() + .components(new Components().addSecuritySchemes("basicScheme", + new SecurityScheme().type(SecurityScheme.Type.HTTP).scheme("basic"))) + .info(new Info().title("Tweet API").version("v0") + .license(new License().name("Apache 2.0").url("http://springdoc.org"))); + } + + @Bean + OpenApiCustomizer serverUrlCustomizer() { + return openApi -> + openApi.getServers().forEach(server -> { + server.setDescription("customized description"); + server.setUrl("https://customized.url"); + }); + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app190/SpringDocApp190Test.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app190/SpringDocApp190Test.java new file mode 100644 index 000000000..31942d4d2 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app190/SpringDocApp190Test.java @@ -0,0 +1,51 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app190; + +import org.junit.jupiter.api.Test; +import org.springdoc.core.utils.Constants; +import test.org.springdoc.api.v30.AbstractCommonTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.test.autoconfigure.web.reactive.WebFluxTest; +import org.springframework.context.annotation.ComponentScan; + +import static org.springdoc.core.utils.Constants.SPRINGDOC_ENABLE_DEFAULT_API_DOCS; + +@WebFluxTest(properties = SPRINGDOC_ENABLE_DEFAULT_API_DOCS+"=false") +public class SpringDocApp190Test extends AbstractCommonTest { + + @SpringBootApplication + @ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.v30.app190" }) + static class SpringDocTestApp {} + + @Test + void test_disable_default_api_docs() throws Exception { + webTestClient.get().uri(Constants.DEFAULT_API_DOCS_URL).exchange() + .expectStatus().isNotFound(); + } +} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app190/SpringDocApp190bisTest.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app190/SpringDocApp190bisTest.java new file mode 100644 index 000000000..de57544e3 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app190/SpringDocApp190bisTest.java @@ -0,0 +1,51 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app190; + +import org.junit.jupiter.api.Test; +import org.springdoc.core.utils.Constants; +import test.org.springdoc.api.v30.AbstractCommonTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.test.autoconfigure.web.reactive.WebFluxTest; +import org.springframework.context.annotation.ComponentScan; + +import static org.springdoc.core.utils.Constants.SPRINGDOC_ENABLE_DEFAULT_API_DOCS; + +@WebFluxTest(properties = SPRINGDOC_ENABLE_DEFAULT_API_DOCS+"=true") +public class SpringDocApp190bisTest extends AbstractCommonTest { + + @SpringBootApplication + @ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.v30.app190" }) + static class SpringDocTestApp {} + + @Test + void test_enable_default_api_docs() throws Exception { + webTestClient.get().uri(Constants.DEFAULT_API_DOCS_URL).exchange() + .expectStatus().isOk(); + } +} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app191/Handler/BaseHandler.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app191/Handler/BaseHandler.java new file mode 100644 index 000000000..1c9738ca5 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app191/Handler/BaseHandler.java @@ -0,0 +1,42 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app191.Handler; + +import reactor.core.publisher.Mono; + +import org.springframework.stereotype.Component; +import org.springframework.web.reactive.function.server.ServerRequest; +import org.springframework.web.reactive.function.server.ServerResponse; + +@Component +public abstract class BaseHandler { + protected abstract Mono apply (ServerRequest serverRequest); + + public Mono handle(ServerRequest serverRequest) { + return this.apply(serverRequest); + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app191/Handler/GetNameHandler.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app191/Handler/GetNameHandler.java new file mode 100644 index 000000000..3a77ca5b9 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app191/Handler/GetNameHandler.java @@ -0,0 +1,45 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app191.Handler; + +import reactor.core.publisher.Mono; + +import org.springframework.http.MediaType; +import org.springframework.stereotype.Component; +import org.springframework.web.reactive.function.server.ServerRequest; +import org.springframework.web.reactive.function.server.ServerResponse; + +@Component +public class GetNameHandler extends BaseHandler{ + @Override + protected Mono apply(ServerRequest serverRequest) { + return ServerResponse.ok() + .contentType(MediaType.APPLICATION_JSON) + .bodyValue("Name API is called"); + } + +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app191/Router/GetNameRouter.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app191/Router/GetNameRouter.java new file mode 100644 index 000000000..d6769ed1d --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app191/Router/GetNameRouter.java @@ -0,0 +1,63 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app191.Router; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import org.springdoc.core.annotations.RouterOperation; +import org.springdoc.core.annotations.RouterOperations; +import test.org.springdoc.api.v30.app191.Handler.GetNameHandler; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.http.MediaType; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.reactive.function.server.RequestPredicates; +import org.springframework.web.reactive.function.server.RouterFunction; +import org.springframework.web.reactive.function.server.RouterFunctions; +import org.springframework.web.reactive.function.server.ServerResponse; + + +@Configuration +public class GetNameRouter { + + @Bean + @RouterOperations( + value = { + @RouterOperation(path = "/v1/name", produces = {MediaType.APPLICATION_JSON_VALUE}, method = RequestMethod.GET, + beanClass = GetNameHandler.class, beanMethod = "handle", operation = @Operation(operationId = "getName", + description = "get name", responses = {@ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = String.class)))}) + ) + }) + + public RouterFunction routerFunction(GetNameHandler getNameHandler) { + return RouterFunctions.route(RequestPredicates.GET("/v1/name"), getNameHandler::handle); + } + +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app191/SpringDocApp191Test.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app191/SpringDocApp191Test.java new file mode 100644 index 000000000..825274e17 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app191/SpringDocApp191Test.java @@ -0,0 +1,39 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app191; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.ComponentScan; + +public class SpringDocApp191Test extends AbstractSpringDocTest { + + @SpringBootApplication + @ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.v30.app191" }) + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app3/SpringDocApp3Test.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app3/SpringDocApp3Test.java new file mode 100644 index 000000000..43ef06a06 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app3/SpringDocApp3Test.java @@ -0,0 +1,34 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app3; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +public class SpringDocApp3Test extends AbstractSpringDocTest { + + +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app3/SpringDocTestApp.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app3/SpringDocTestApp.java new file mode 100644 index 000000000..1108f7841 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app3/SpringDocTestApp.java @@ -0,0 +1,55 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app3; + +import io.swagger.v3.oas.models.Components; +import io.swagger.v3.oas.models.OpenAPI; +import io.swagger.v3.oas.models.info.Info; +import io.swagger.v3.oas.models.info.License; +import io.swagger.v3.oas.models.security.SecurityScheme; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; + +@SpringBootApplication +@ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.v30.app3" }) +public class SpringDocTestApp { + public static void main(String[] args) { + SpringApplication.run(SpringDocTestApp.class, args); + } + + @Bean + public OpenAPI customOpenAPI() { + return new OpenAPI() + .components(new Components().addSecuritySchemes("basicScheme", + new SecurityScheme().type(SecurityScheme.Type.HTTP).scheme("basic"))) + .info(new Info().title("Tweet API").version("v0") + .license(new License().name("Apache 2.0").url("http://springdoc.org"))); + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app3/controller/ExceptionTranslator.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app3/controller/ExceptionTranslator.java new file mode 100644 index 000000000..bc3ae394e --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app3/controller/ExceptionTranslator.java @@ -0,0 +1,58 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app3.controller; + +import test.org.springdoc.api.v30.app3.exception.TweetConflictException; +import test.org.springdoc.api.v30.app3.exception.TweetNotFoundException; +import test.org.springdoc.api.v30.app3.payload.ErrorResponse; + +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.ResponseStatus; +import org.springframework.web.bind.annotation.RestControllerAdvice; + +@RestControllerAdvice +public class ExceptionTranslator { + + + @SuppressWarnings("rawtypes") + @ExceptionHandler(TweetConflictException.class) + @ResponseStatus(HttpStatus.CONFLICT) + public ResponseEntity handleDuplicateKeyException(TweetConflictException ex) { + return ResponseEntity.status(HttpStatus.CONFLICT) + .body(new ErrorResponse("A Tweet with the same text already exists")); + } + + @SuppressWarnings("rawtypes") + @ExceptionHandler(TweetNotFoundException.class) + @ResponseStatus(HttpStatus.NOT_FOUND) + public ResponseEntity handleTweetNotFoundException(TweetNotFoundException ex) { + return ResponseEntity.notFound().build(); + } + +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app3/controller/TweetController.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app3/controller/TweetController.java new file mode 100644 index 000000000..279315459 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app3/controller/TweetController.java @@ -0,0 +1,95 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app3.controller; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; +import jakarta.validation.Valid; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; +import test.org.springdoc.api.v30.app3.dto.TweetDTO; + +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RestController; + +/** + * Created by rajeevkumarsingh on 08/09/17. + */ +@RestController +public class TweetController { + + + @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "get All Tweets") }) + @GetMapping("/tweets") + public Flux getAllTweets() { + return null; + } + + @PostMapping("/tweets") + @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "create Tweets") }) + public Mono createTweets(@Valid @RequestBody TweetDTO tweetDTO) { + return null; + } + + @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "get Tweet By Id"), + @ApiResponse(responseCode = "404", description = "tweet not found") }) + @GetMapping("/tweets/{id}") + public Mono> getTweetById(@PathVariable(value = "id") String tweetId) { + return null; + } + + @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "update Tweet"), + @ApiResponse(responseCode = "404", description = "tweet not found") }) + @PutMapping("/tweets/{id}") + public Mono> updateTweet(@PathVariable(value = "id") String tweetId, + @Valid @RequestBody TweetDTO tweetDTO) { + return null; + } + + @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "delete Tweet"), + @ApiResponse(responseCode = "404", description = "tweet not found") }) + @DeleteMapping("/tweets/{id}") + public Mono> deleteTweet(@PathVariable(value = "id") String tweetId) { + return null; + } + + @Operation(description = "Tweets are Sent to the client as Server Sent Events", responses = { + @ApiResponse(responseCode = "200", description = "stream All Tweets") }) + @GetMapping(value = "/stream/tweets", produces = MediaType.TEXT_EVENT_STREAM_VALUE) + public Flux streamAllTweets() { + return null; + } + +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app3/dto/TweetDTO.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app3/dto/TweetDTO.java new file mode 100644 index 000000000..ccd5ec868 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app3/dto/TweetDTO.java @@ -0,0 +1,80 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app3.dto; + +import java.util.Date; + +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; +import jakarta.validation.constraints.Size; + + +/** + * Created by rajeevkumarsingh on 08/09/17. + */ +public class TweetDTO { + private String id; + + @NotBlank + @Size(max = 140) + private String text; + + @NotNull + private Date createdAt = new Date(); + + public TweetDTO() { + + } + + public TweetDTO(String text) { + this.text = text; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getText() { + return text; + } + + public void setText(String text) { + this.text = text; + } + + public Date getCreatedAt() { + return createdAt; + } + + public void setCreatedAt(Date createdAt) { + this.createdAt = createdAt; + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app3/exception/TweetConflictException.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app3/exception/TweetConflictException.java new file mode 100644 index 000000000..e6f6ff350 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app3/exception/TweetConflictException.java @@ -0,0 +1,42 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app3.exception; + +/** + * Created by rajeevkumarsingh on 22/10/17. + */ +public class TweetConflictException extends RuntimeException { + + /** + * + */ + private static final long serialVersionUID = 1L; + + public TweetConflictException(String tweetId) { + super("Tweet conflict with id " + tweetId); + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app3/exception/TweetNotFoundException.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app3/exception/TweetNotFoundException.java new file mode 100644 index 000000000..185499956 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app3/exception/TweetNotFoundException.java @@ -0,0 +1,42 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app3.exception; + +/** + * Created by rajeevkumarsingh on 22/10/17. + */ +public class TweetNotFoundException extends RuntimeException { + + /** + * + */ + private static final long serialVersionUID = 1L; + + public TweetNotFoundException(String tweetId) { + super("Tweet not found with id " + tweetId); + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app3/payload/ErrorResponse.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app3/payload/ErrorResponse.java new file mode 100644 index 000000000..c2a6b5c0a --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app3/payload/ErrorResponse.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.app3.payload; + +/** + * Created by rajeevkumarsingh on 22/10/17. + */ +public class ErrorResponse { + private String message; + + public ErrorResponse(String message) { + this.message = message; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app39/HelloController.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app39/HelloController.java new file mode 100644 index 000000000..94b645bfd --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app39/HelloController.java @@ -0,0 +1,53 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app39; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.parameters.RequestBody; +import reactor.core.publisher.Mono; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class HelloController { + + @Operation(summary = "test Request") + @RequestBody(description = "test value", required = true, content = @Content(schema = @Schema(implementation = String.class))) + @PostMapping("/test") + public Mono searchEmployee(String test) { + return Mono.empty(); + } + + @GetMapping("/hello") + public Mono hello() { + return Mono.just("hello"); + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app39/SpringDocApp39Test.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app39/SpringDocApp39Test.java new file mode 100644 index 000000000..b7f0a9933 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app39/SpringDocApp39Test.java @@ -0,0 +1,34 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app39; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +public class SpringDocApp39Test extends AbstractSpringDocTest { + + +} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app39/SpringDocTestApp.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app39/SpringDocTestApp.java new file mode 100644 index 000000000..8cbab5977 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app39/SpringDocTestApp.java @@ -0,0 +1,60 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app39; + +import io.swagger.v3.oas.models.Components; +import io.swagger.v3.oas.models.OpenAPI; +import io.swagger.v3.oas.models.media.StringSchema; +import io.swagger.v3.oas.models.parameters.HeaderParameter; +import org.springdoc.core.customizers.OpenApiCustomizer; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; + +@SpringBootApplication +@ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.v30.app39" }) +public class SpringDocTestApp { + + public static void main(String[] args) { + SpringApplication.run(SpringDocTestApp.class, args); + } + + @Bean + public OpenAPI customOpenAPI() { + StringSchema schema = new StringSchema(); + return new OpenAPI() + .components(new Components().addParameters("myGlobalHeader", new HeaderParameter().required(true).name("My-Global-Header").description("My Global Header").schema(schema))); + } + + @Bean + public OpenApiCustomizer customerGlobalHeaderOpenApiCustomizer() { + return openApi -> openApi.getPaths().values().stream().flatMap(pathItem -> pathItem.readOperations().stream()) + .forEach(operation -> operation.addParametersItem(new HeaderParameter().$ref("#/components/parameters/myGlobalHeader"))); + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app4/HelloController.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app4/HelloController.java new file mode 100644 index 000000000..9cd25deeb --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app4/HelloController.java @@ -0,0 +1,55 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app4; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; +import reactor.core.publisher.Mono; + +import org.springframework.http.MediaType; +import org.springframework.http.codec.multipart.FilePart; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.bind.annotation.RestController; + + +@RestController +public class HelloController { + + + @Operation(summary = "Parse Resume") + @PostMapping(value = "/parse-resume", produces = { MediaType.APPLICATION_JSON_VALUE }, consumes = { + MediaType.MULTIPART_FORM_DATA_VALUE }) + @ApiResponses({ @ApiResponse(responseCode = "400", description = "Invalid input") }) + public Mono parse( + @RequestPart(name = "resumeFile") @Parameter(description = "Resume file to be parsed", content = @Content(mediaType = MediaType.APPLICATION_OCTET_STREAM_VALUE)) FilePart resumeFile) { + return null; + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app4/SpringDocApp4Test.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app4/SpringDocApp4Test.java new file mode 100644 index 000000000..d7d58c2b3 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app4/SpringDocApp4Test.java @@ -0,0 +1,34 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app4; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +public class SpringDocApp4Test extends AbstractSpringDocTest { + + +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app4/SpringDocTestApp.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app4/SpringDocTestApp.java new file mode 100644 index 000000000..71565d4e6 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app4/SpringDocTestApp.java @@ -0,0 +1,55 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app4; + +import io.swagger.v3.oas.models.Components; +import io.swagger.v3.oas.models.OpenAPI; +import io.swagger.v3.oas.models.info.Info; +import io.swagger.v3.oas.models.info.License; +import io.swagger.v3.oas.models.security.SecurityScheme; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; + +@SpringBootApplication +@ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.v30.app4" }) +public class SpringDocTestApp { + public static void main(String[] args) { + SpringApplication.run(SpringDocTestApp.class, args); + } + + @Bean + public OpenAPI customOpenAPI() { + return new OpenAPI() + .components(new Components().addSecuritySchemes("basicScheme", + new SecurityScheme().type(SecurityScheme.Type.HTTP).scheme("basic"))) + .info(new Info().title("Tweet API").version("v0") + .license(new License().name("Apache 2.0").url("http://springdoc.org"))); + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app5/HelloController.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app5/HelloController.java new file mode 100644 index 000000000..70b15c62b --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app5/HelloController.java @@ -0,0 +1,51 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app5; + +import reactor.core.publisher.Mono; + +import org.springframework.http.HttpEntity; +import org.springframework.http.MediaType; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class HelloController { + + @PostMapping(value = "/tweets/does-not-work", consumes = MediaType.APPLICATION_JSON_VALUE) + public Mono postNotWorks(@RequestBody Mono tweet) { + return tweet; + } + + @GetMapping("/test") + public Mono> demo2() { + return null; + } + +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app5/SpringDocApp5Test.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app5/SpringDocApp5Test.java new file mode 100644 index 000000000..f81f72341 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app5/SpringDocApp5Test.java @@ -0,0 +1,34 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app5; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +public class SpringDocApp5Test extends AbstractSpringDocTest { + + +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app5/SpringDocTestApp.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app5/SpringDocTestApp.java new file mode 100644 index 000000000..22427a0c6 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app5/SpringDocTestApp.java @@ -0,0 +1,55 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app5; + +import io.swagger.v3.oas.models.Components; +import io.swagger.v3.oas.models.OpenAPI; +import io.swagger.v3.oas.models.info.Info; +import io.swagger.v3.oas.models.info.License; +import io.swagger.v3.oas.models.security.SecurityScheme; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; + +@SpringBootApplication +@ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.v30.app5" }) +public class SpringDocTestApp { + public static void main(String[] args) { + SpringApplication.run(SpringDocTestApp.class, args); + } + + @Bean + public OpenAPI customOpenAPI() { + return new OpenAPI() + .components(new Components().addSecuritySchemes("basicScheme", + new SecurityScheme().type(SecurityScheme.Type.HTTP).scheme("basic"))) + .info(new Info().title("Tweet API").version("v0") + .license(new License().name("Apache 2.0").url("http://springdoc.org"))); + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app5/Tweet.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app5/Tweet.java new file mode 100644 index 000000000..f5450644a --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app5/Tweet.java @@ -0,0 +1,69 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app5; + +import java.util.Date; + +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; +import jakarta.validation.constraints.Size; + +public class Tweet { + private String id; + + @NotBlank + @Size(max = 140) + private String text; + + @NotNull + private Date createdAt = new Date(); + + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getText() { + return text; + } + + public void setText(String text) { + this.text = text; + } + + public Date getCreatedAt() { + return createdAt; + } + + public void setCreatedAt(Date createdAt) { + this.createdAt = createdAt; + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app63/HelloController.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app63/HelloController.java new file mode 100644 index 000000000..ae6e5ee59 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app63/HelloController.java @@ -0,0 +1,39 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app63; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class HelloController { + + @GetMapping("/test") + public void test(String hello) { + } + +} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app63/SpringDocApp63Test.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app63/SpringDocApp63Test.java new file mode 100644 index 000000000..7140f693b --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app63/SpringDocApp63Test.java @@ -0,0 +1,41 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app63; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.test.context.TestPropertySource; + +@TestPropertySource(properties = "springdoc.packagesToScan=hell,hello1, hello.me") +public class SpringDocApp63Test extends AbstractSpringDocTest { + + @SpringBootApplication + @ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.v30.app63" }) + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app63/toto/HelloController2.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app63/toto/HelloController2.java new file mode 100644 index 000000000..4c2554ef0 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app63/toto/HelloController2.java @@ -0,0 +1,39 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app63.toto; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class HelloController2 { + + @GetMapping("/test1") + public void test1(String hello) { + } + +} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app64/HelloController.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app64/HelloController.java new file mode 100644 index 000000000..2da2ac5ef --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app64/HelloController.java @@ -0,0 +1,47 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app64; + +import io.swagger.v3.oas.annotations.Operation; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class HelloController { + + @GetMapping("/v1/test") + public void test1(String hello) { + } + + @GetMapping(value = "/api/balance/abcd") + @Operation(summary = "This is the test endpoint") + public String test2(String from) { + return "This is a fake test"; + } + +} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app64/SpringDocApp64Test.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app64/SpringDocApp64Test.java new file mode 100644 index 000000000..4300db82b --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app64/SpringDocApp64Test.java @@ -0,0 +1,41 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app64; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.test.context.TestPropertySource; + +@TestPropertySource(properties = "springdoc.paths-to-match=/v1, /api/**") +public class SpringDocApp64Test extends AbstractSpringDocTest { + + @SpringBootApplication + @ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.v30.app64" }) + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app65/HelloController.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app65/HelloController.java new file mode 100644 index 000000000..6091dc9fe --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app65/HelloController.java @@ -0,0 +1,47 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app65; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; + +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +@Tag(name = "Health", description = "Health check / ping API") +@RestController +public class HelloController { + + @Operation(summary = "Check server status", description = "Check server status, will return 200 with simple string if alive. Do nothing else.") + @GetMapping(value = { "/ping", "/health", "/" }, produces = MediaType.TEXT_PLAIN_VALUE) + public ResponseEntity ping() { + return ResponseEntity.ok("Healthy"); + } + +} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app65/SpringDocApp65Test.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app65/SpringDocApp65Test.java new file mode 100644 index 000000000..c25015780 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app65/SpringDocApp65Test.java @@ -0,0 +1,39 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app65; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.ComponentScan; + +public class SpringDocApp65Test extends AbstractSpringDocTest { + + @SpringBootApplication + @ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.v30.app65" }) + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app66/SpringDocApp66Test.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app66/SpringDocApp66Test.java new file mode 100644 index 000000000..b77e542a7 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app66/SpringDocApp66Test.java @@ -0,0 +1,44 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app66; + +import org.junit.jupiter.api.Test; +import org.springdoc.core.utils.Constants; +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +public class SpringDocApp66Test extends AbstractSpringDocTest { + + public SpringDocApp66Test() { + this.groupName = "/stream"; + } + + @Test + void testApp2() throws Exception { + webTestClient.get().uri(Constants.DEFAULT_API_DOCS_URL + "streams").exchange() + .expectStatus().isNotFound(); + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app66/SpringDocTestApp.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app66/SpringDocTestApp.java new file mode 100644 index 000000000..5277292f8 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app66/SpringDocTestApp.java @@ -0,0 +1,65 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app66; + +import io.swagger.v3.oas.models.Components; +import io.swagger.v3.oas.models.OpenAPI; +import io.swagger.v3.oas.models.info.Info; +import io.swagger.v3.oas.models.info.License; +import io.swagger.v3.oas.models.security.SecurityScheme; +import org.springdoc.core.models.GroupedOpenApi; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; + +@SpringBootApplication +@ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.v30.app66" }) +public class SpringDocTestApp { + public static void main(String[] args) { + SpringApplication.run(SpringDocTestApp.class, args); + } + + @Bean + public OpenAPI customOpenAPI() { + return new OpenAPI() + .components(new Components().addSecuritySchemes("basicScheme", + new SecurityScheme().type(SecurityScheme.Type.HTTP).scheme("basic"))) + .info(new Info().title("Tweet API").version("v0") + .license(new License().name("Apache 2.0").url("http://springdoc.org"))); + } + + @Bean + public GroupedOpenApi streamOpenApi() { + String[] paths = { "/stream/**" }; + String[] packagedToMatch = { "test.org.springdoc.api.v30.app66" }; + return GroupedOpenApi.builder().group("stream").pathsToMatch(paths) + .build(); + } + +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app66/controller/ExceptionTranslator.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app66/controller/ExceptionTranslator.java new file mode 100644 index 000000000..c76f7da36 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app66/controller/ExceptionTranslator.java @@ -0,0 +1,58 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app66.controller; + +import test.org.springdoc.api.v30.app66.exception.TweetConflictException; +import test.org.springdoc.api.v30.app66.exception.TweetNotFoundException; +import test.org.springdoc.api.v30.app66.payload.ErrorResponse; + +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.ResponseStatus; +import org.springframework.web.bind.annotation.RestControllerAdvice; + +@RestControllerAdvice +public class ExceptionTranslator { + + + @SuppressWarnings("rawtypes") + @ExceptionHandler(TweetConflictException.class) + @ResponseStatus(HttpStatus.CONFLICT) + public ResponseEntity handleDuplicateKeyException(TweetConflictException ex) { + return ResponseEntity.status(HttpStatus.CONFLICT) + .body(new ErrorResponse("A Tweet with the same text already exists")); + } + + @SuppressWarnings("rawtypes") + @ExceptionHandler(TweetNotFoundException.class) + @ResponseStatus(HttpStatus.NOT_FOUND) + public ResponseEntity handleTweetNotFoundException(TweetNotFoundException ex) { + return ResponseEntity.notFound().build(); + } + +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app66/controller/TweetController.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app66/controller/TweetController.java new file mode 100644 index 000000000..b1c2e4dcb --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app66/controller/TweetController.java @@ -0,0 +1,95 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app66.controller; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; +import jakarta.validation.Valid; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; +import test.org.springdoc.api.v30.app66.dto.TweetDTO; + +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RestController; + +/** + * Created by rajeevkumarsingh on 08/09/17. + */ +@RestController +public class TweetController { + + + @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "get All Tweets") }) + @GetMapping("/tweets") + public Flux getAllTweets() { + return null; + } + + @PostMapping("/tweets") + @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "create Tweets") }) + public Mono createTweets(@Valid @RequestBody TweetDTO tweetDTO) { + return null; + } + + @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "get Tweet By Id"), + @ApiResponse(responseCode = "404", description = "tweet not found") }) + @GetMapping("/tweets/{id}") + public Mono> getTweetById(@PathVariable(value = "id") String tweetId) { + return null; + } + + @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "update Tweet"), + @ApiResponse(responseCode = "404", description = "tweet not found") }) + @PutMapping("/tweets/{id}") + public Mono> updateTweet(@PathVariable(value = "id") String tweetId, + @Valid @RequestBody TweetDTO tweetDTO) { + return null; + } + + @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "delete Tweet"), + @ApiResponse(responseCode = "404", description = "tweet not found") }) + @DeleteMapping("/tweets/{id}") + public Mono> deleteTweet(@PathVariable(value = "id") String tweetId) { + return null; + } + + @Operation(description = "Tweets are Sent to the client as Server Sent Events", responses = { + @ApiResponse(responseCode = "200", description = "stream All Tweets") }) + @GetMapping(value = "/stream/tweets", produces = MediaType.TEXT_EVENT_STREAM_VALUE) + public Flux streamAllTweets() { + return null; + } + +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app66/dto/TweetDTO.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app66/dto/TweetDTO.java new file mode 100644 index 000000000..111f7a6b4 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app66/dto/TweetDTO.java @@ -0,0 +1,80 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app66.dto; + +import java.util.Date; + +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; +import jakarta.validation.constraints.Size; + + +/** + * Created by rajeevkumarsingh on 08/09/17. + */ +public class TweetDTO { + private String id; + + @NotBlank + @Size(max = 140) + private String text; + + @NotNull + private Date createdAt = new Date(); + + public TweetDTO() { + + } + + public TweetDTO(String text) { + this.text = text; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getText() { + return text; + } + + public void setText(String text) { + this.text = text; + } + + public Date getCreatedAt() { + return createdAt; + } + + public void setCreatedAt(Date createdAt) { + this.createdAt = createdAt; + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app66/exception/TweetConflictException.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app66/exception/TweetConflictException.java new file mode 100644 index 000000000..cea82f9bc --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app66/exception/TweetConflictException.java @@ -0,0 +1,42 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app66.exception; + +/** + * Created by rajeevkumarsingh on 22/10/17. + */ +public class TweetConflictException extends RuntimeException { + + /** + * + */ + private static final long serialVersionUID = 1L; + + public TweetConflictException(String tweetId) { + super("Tweet conflict with id " + tweetId); + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app66/exception/TweetNotFoundException.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app66/exception/TweetNotFoundException.java new file mode 100644 index 000000000..279a0caa1 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app66/exception/TweetNotFoundException.java @@ -0,0 +1,42 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app66.exception; + +/** + * Created by rajeevkumarsingh on 22/10/17. + */ +public class TweetNotFoundException extends RuntimeException { + + /** + * + */ + private static final long serialVersionUID = 1L; + + public TweetNotFoundException(String tweetId) { + super("Tweet not found with id " + tweetId); + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app66/payload/ErrorResponse.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app66/payload/ErrorResponse.java new file mode 100644 index 000000000..4cd3408e5 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app66/payload/ErrorResponse.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.app66.payload; + +/** + * Created by rajeevkumarsingh on 22/10/17. + */ +public class ErrorResponse { + private String message; + + public ErrorResponse(String message) { + this.message = message; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app67/HelloController.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app67/HelloController.java new file mode 100644 index 000000000..61016b603 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app67/HelloController.java @@ -0,0 +1,41 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app67; + +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequestMapping("/api") +public class HelloController { + + @RequestMapping + public String test() { + return "ok"; + } + +} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app67/SpringDocApp67Test.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app67/SpringDocApp67Test.java new file mode 100644 index 000000000..5b24e7d1e --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app67/SpringDocApp67Test.java @@ -0,0 +1,61 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app67; + +import org.junit.jupiter.api.Test; +import org.springdoc.core.utils.Constants; +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.ComponentScan; + +public class SpringDocApp67Test extends AbstractSpringDocTest { + + @Test + void testApp() { + webTestClient.get().uri(Constants.DEFAULT_API_DOCS_URL + groupName).exchange().expectStatus().isOk().expectBody() + .jsonPath("$.openapi").isEqualTo("3.0.1") + .jsonPath("$.paths./api.get.tags[0]").isEqualTo("hello-controller") + .jsonPath("$.paths./api.get.responses.200.content.['*/*'].schema.type").isEqualTo("string") + .jsonPath("$.paths./api.post.tags[0]").isEqualTo("hello-controller") + .jsonPath("$.paths./api.post.responses.200.content.['*/*'].schema.type").isEqualTo("string") + .jsonPath("$.paths./api.put.tags[0]").isEqualTo("hello-controller") + .jsonPath("$.paths./api.put.responses.200.content.['*/*'].schema.type").isEqualTo("string") + .jsonPath("$.paths./api.patch.tags[0]").isEqualTo("hello-controller") + .jsonPath("$.paths./api.patch.responses.200.content.['*/*'].schema.type").isEqualTo("string") + .jsonPath("$.paths./api.delete.tags[0]").isEqualTo("hello-controller") + .jsonPath("$.paths./api.delete.responses.200.content.['*/*'].schema.type").isEqualTo("string") + .jsonPath("$.paths./api.options.tags[0]").isEqualTo("hello-controller") + .jsonPath("$.paths./api.options.responses.200.content.['*/*'].schema.type").isEqualTo("string") + .jsonPath("$.paths./api.head.tags[0]").isEqualTo("hello-controller") + .jsonPath("$.paths./api.head.responses.200.content.['*/*'].schema.type").isEqualTo("string"); + } + + @SpringBootApplication + @ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.v30.app67" }) + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app68/SpringDocApp68Test.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app68/SpringDocApp68Test.java new file mode 100644 index 000000000..5cbfc84f9 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app68/SpringDocApp68Test.java @@ -0,0 +1,64 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app68; + +import io.swagger.v3.oas.models.Components; +import io.swagger.v3.oas.models.OpenAPI; +import io.swagger.v3.oas.models.info.Info; +import io.swagger.v3.oas.models.info.License; +import io.swagger.v3.oas.models.security.SecurityScheme; +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.test.context.TestPropertySource; + +@TestPropertySource(properties = { + "springdoc.group-configs[0].group=stream", + "springdoc.group-configs[0].pathsToMatch=/stream/**" +}) +public class SpringDocApp68Test extends AbstractSpringDocTest { + + public SpringDocApp68Test() { + this.groupName = "/stream"; + } + + + @SpringBootApplication + @ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.v30.app68" }) + static class SpringDocTestApp { + @Bean + public OpenAPI customOpenAPI() { + return new OpenAPI() + .components(new Components().addSecuritySchemes("basicScheme", + new SecurityScheme().type(SecurityScheme.Type.HTTP).scheme("basic"))) + .info(new Info().title("Tweet API").version("v0") + .license(new License().name("Apache 2.0").url("http://springdoc.org"))); + } + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app68/controller/ExceptionTranslator.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app68/controller/ExceptionTranslator.java new file mode 100644 index 000000000..96b395e06 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app68/controller/ExceptionTranslator.java @@ -0,0 +1,58 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app68.controller; + +import test.org.springdoc.api.v30.app68.exception.TweetConflictException; +import test.org.springdoc.api.v30.app68.exception.TweetNotFoundException; +import test.org.springdoc.api.v30.app68.payload.ErrorResponse; + +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.ResponseStatus; +import org.springframework.web.bind.annotation.RestControllerAdvice; + +@RestControllerAdvice +public class ExceptionTranslator { + + + @SuppressWarnings("rawtypes") + @ExceptionHandler(TweetConflictException.class) + @ResponseStatus(HttpStatus.CONFLICT) + public ResponseEntity handleDuplicateKeyException(TweetConflictException ex) { + return ResponseEntity.status(HttpStatus.CONFLICT) + .body(new ErrorResponse("A Tweet with the same text already exists")); + } + + @SuppressWarnings("rawtypes") + @ExceptionHandler(TweetNotFoundException.class) + @ResponseStatus(HttpStatus.NOT_FOUND) + public ResponseEntity handleTweetNotFoundException(TweetNotFoundException ex) { + return ResponseEntity.notFound().build(); + } + +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app68/controller/TweetController.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app68/controller/TweetController.java new file mode 100644 index 000000000..37ea7b5e4 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app68/controller/TweetController.java @@ -0,0 +1,95 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app68.controller; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; +import jakarta.validation.Valid; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; +import test.org.springdoc.api.v30.app68.dto.TweetDTO; + +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RestController; + +/** + * Created by rajeevkumarsingh on 08/09/17. + */ +@RestController +public class TweetController { + + + @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "get All Tweets") }) + @GetMapping("/tweets") + public Flux getAllTweets() { + return null; + } + + @PostMapping("/tweets") + @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "create Tweets") }) + public Mono createTweets(@Valid @RequestBody TweetDTO tweetDTO) { + return null; + } + + @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "get Tweet By Id"), + @ApiResponse(responseCode = "404", description = "tweet not found") }) + @GetMapping("/tweets/{id}") + public Mono> getTweetById(@PathVariable(value = "id") String tweetId) { + return null; + } + + @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "update Tweet"), + @ApiResponse(responseCode = "404", description = "tweet not found") }) + @PutMapping("/tweets/{id}") + public Mono> updateTweet(@PathVariable(value = "id") String tweetId, + @Valid @RequestBody TweetDTO tweetDTO) { + return null; + } + + @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "delete Tweet"), + @ApiResponse(responseCode = "404", description = "tweet not found") }) + @DeleteMapping("/tweets/{id}") + public Mono> deleteTweet(@PathVariable(value = "id") String tweetId) { + return null; + } + + @Operation(description = "Tweets are Sent to the client as Server Sent Events", responses = { + @ApiResponse(responseCode = "200", description = "stream All Tweets") }) + @GetMapping(value = "/stream/tweets", produces = MediaType.TEXT_EVENT_STREAM_VALUE) + public Flux streamAllTweets() { + return null; + } + +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app68/dto/TweetDTO.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app68/dto/TweetDTO.java new file mode 100644 index 000000000..24b7f4aa5 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app68/dto/TweetDTO.java @@ -0,0 +1,80 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app68.dto; + +import java.util.Date; + +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; +import jakarta.validation.constraints.Size; + + +/** + * Created by rajeevkumarsingh on 08/09/17. + */ +public class TweetDTO { + private String id; + + @NotBlank + @Size(max = 140) + private String text; + + @NotNull + private Date createdAt = new Date(); + + public TweetDTO() { + + } + + public TweetDTO(String text) { + this.text = text; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getText() { + return text; + } + + public void setText(String text) { + this.text = text; + } + + public Date getCreatedAt() { + return createdAt; + } + + public void setCreatedAt(Date createdAt) { + this.createdAt = createdAt; + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app68/exception/TweetConflictException.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app68/exception/TweetConflictException.java new file mode 100644 index 000000000..740d92163 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app68/exception/TweetConflictException.java @@ -0,0 +1,42 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app68.exception; + +/** + * Created by rajeevkumarsingh on 22/10/17. + */ +public class TweetConflictException extends RuntimeException { + + /** + * + */ + private static final long serialVersionUID = 1L; + + public TweetConflictException(String tweetId) { + super("Tweet conflict with id " + tweetId); + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app68/exception/TweetNotFoundException.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app68/exception/TweetNotFoundException.java new file mode 100644 index 000000000..1cc0d8fae --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app68/exception/TweetNotFoundException.java @@ -0,0 +1,42 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app68.exception; + +/** + * Created by rajeevkumarsingh on 22/10/17. + */ +public class TweetNotFoundException extends RuntimeException { + + /** + * + */ + private static final long serialVersionUID = 1L; + + public TweetNotFoundException(String tweetId) { + super("Tweet not found with id " + tweetId); + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app68/payload/ErrorResponse.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app68/payload/ErrorResponse.java new file mode 100644 index 000000000..d52834bab --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app68/payload/ErrorResponse.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.app68.payload; + +/** + * Created by rajeevkumarsingh on 22/10/17. + */ +public class ErrorResponse { + private String message; + + public ErrorResponse(String message) { + this.message = message; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app69/RoutingConfiguration.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app69/RoutingConfiguration.java new file mode 100644 index 000000000..b3f18e1a2 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app69/RoutingConfiguration.java @@ -0,0 +1,62 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app69; + +import org.springdoc.core.annotations.RouterOperation; +import org.springdoc.core.annotations.RouterOperations; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.http.MediaType; +import org.springframework.web.reactive.function.server.RouterFunction; +import org.springframework.web.reactive.function.server.ServerResponse; + +import static org.springframework.web.reactive.function.server.RequestPredicates.DELETE; +import static org.springframework.web.reactive.function.server.RequestPredicates.GET; +import static org.springframework.web.reactive.function.server.RequestPredicates.POST; +import static org.springframework.web.reactive.function.server.RequestPredicates.PUT; +import static org.springframework.web.reactive.function.server.RequestPredicates.accept; +import static org.springframework.web.reactive.function.server.RouterFunctions.route; + +@Configuration +public class RoutingConfiguration { + + @Bean + @RouterOperations({ @RouterOperation(path = "/api/user/index", beanClass = UserRepository.class, beanMethod = "getAllUsers"), + @RouterOperation(path = "/api/user/{id}", beanClass = UserRepository.class, beanMethod = "getUserById"), + @RouterOperation(path = "/api/user/post", beanClass = UserRepository.class, beanMethod = "saveUser"), + @RouterOperation(path = "/api/user/put/{id}", beanClass = UserRepository.class, beanMethod = "putUser"), + @RouterOperation(path = "/api/user/delete/{id}", beanClass = UserRepository.class, beanMethod = "deleteUser") }) + public RouterFunction monoRouterFunction(UserHandler userHandler) { + return route(GET("/api/user/index").and(accept(MediaType.APPLICATION_JSON)), userHandler::getAll) + .andRoute(GET("/api/user/{id}").and(accept(MediaType.APPLICATION_JSON)), userHandler::getUser) + .andRoute(POST("/api/user/post").and(accept(MediaType.APPLICATION_JSON)), userHandler::postUser) + .andRoute(PUT("/api/user/put/{id}").and(accept(MediaType.APPLICATION_JSON)), userHandler::putUser) + .andRoute(DELETE("/api/user/delete/{id}").and(accept(MediaType.APPLICATION_JSON)), userHandler::deleteUser); + } + +} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app69/SpringDocApp69Test.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app69/SpringDocApp69Test.java new file mode 100644 index 000000000..9025c3564 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app69/SpringDocApp69Test.java @@ -0,0 +1,39 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app69; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.ComponentScan; + +public class SpringDocApp69Test extends AbstractSpringDocTest { + + @SpringBootApplication + @ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.v30.app69" }) + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app69/User.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app69/User.java new file mode 100644 index 000000000..79ed3d4be --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app69/User.java @@ -0,0 +1,85 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app69; + +public class User { + private long id; + + private String firstname; + + private String lastname; + + private int age; + + public User() { + } + + public User(long id, String firstname, String lastname, int age) { + this.id = id; + this.firstname = firstname; + this.lastname = lastname; + this.age = age; + } + + public long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getFirstname() { + return firstname; + } + + public void setFirstname(String firstname) { + this.firstname = firstname; + } + + public String getLastname() { + return lastname; + } + + public void setLastname(String lastname) { + this.lastname = lastname; + } + + public int getAge() { + return age; + } + + public void setAge(int age) { + this.age = age; + } + + @Override + public String toString() { + String info = String.format("id = %d, firstname = %s, lastname = %s, age = %d", id, firstname, lastname, age); + return info; + } +} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app69/UserHandler.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app69/UserHandler.java new file mode 100644 index 000000000..f77f6e480 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app69/UserHandler.java @@ -0,0 +1,119 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app69; + +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +import org.springframework.http.MediaType; +import org.springframework.stereotype.Component; +import org.springframework.web.reactive.function.server.ServerRequest; +import org.springframework.web.reactive.function.server.ServerResponse; + +import static org.springframework.web.reactive.function.BodyInserters.fromObject; + +@Component +public class UserHandler { + + private final UserRepository customerRepository; + + public UserHandler(UserRepository repository) { + this.customerRepository = repository; + } + + /** + * GET ALL Users + */ + public Mono getAll(ServerRequest request) { + // fetch all customers from repository + Flux customers = customerRepository.getAllUsers(); + + // build response + return ServerResponse.ok().contentType(MediaType.APPLICATION_JSON).body(customers, User.class); + } + + /** + * GET a User by ID + */ + public Mono getUser(ServerRequest request) { + // parse path-variable + long customerId = Long.valueOf(request.queryParam("id").get()); + + // build notFound response + Mono notFound = ServerResponse.notFound().build(); + + // get customer from repository + Mono customerMono = customerRepository.getUserById(customerId); + + // build response + return customerMono + .flatMap(customer -> ServerResponse.ok().contentType(MediaType.APPLICATION_JSON).body(fromObject(customer))) + .switchIfEmpty(notFound); + } + + /** + * POST a User + */ + public Mono postUser(ServerRequest request) { + Mono customer = request.bodyToMono(User.class); + return ServerResponse.ok().build(customerRepository.saveUser(customer)); + } + + /** + * PUT a User + */ + public Mono putUser(ServerRequest request) { + // parse id from path-variable + long customerId = Long.valueOf(request.pathVariable("id")); + + // get customer data from request object + Mono customer = request.bodyToMono(User.class); + + // get customer from repository + Mono responseMono = customerRepository.putUser(customerId, customer); + + // build response + return responseMono + .flatMap(cust -> ServerResponse.ok().contentType(MediaType.APPLICATION_JSON).body(fromObject(cust))); + } + + /** + * DELETE a User + */ + public Mono deleteUser(ServerRequest request) { + // parse id from path-variable + long customerId = Long.valueOf(request.pathVariable("id")); + + // get customer from repository + Mono responseMono = customerRepository.deleteUser(customerId); + + // build response + return responseMono + .flatMap(strMono -> ServerResponse.ok().contentType(MediaType.TEXT_PLAIN).body(fromObject(strMono))); + } + +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app69/UserRepository.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app69/UserRepository.java new file mode 100644 index 000000000..caf6e26a2 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app69/UserRepository.java @@ -0,0 +1,51 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app69; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.enums.ParameterIn; +import io.swagger.v3.oas.annotations.parameters.RequestBody; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +public interface UserRepository { + + public Mono getUserById(@Parameter(in = ParameterIn.PATH, description = "The user Id") Long id); + + @Operation(description = "get all the users") + public Flux getAllUsers(); + + @Operation(description = "get all the users by firstname") + public Flux getAllUsers(String firstname); + + public Mono saveUser(Mono user); + + public Mono putUser(@Parameter(in = ParameterIn.PATH) Long id, @RequestBody Mono user); + + public Mono deleteUser(@Parameter(in = ParameterIn.PATH) Long id); +} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app69/UserRepositoryImpl.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app69/UserRepositoryImpl.java new file mode 100644 index 000000000..b94fc6cf5 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app69/UserRepositoryImpl.java @@ -0,0 +1,98 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app69; + +import java.util.HashMap; +import java.util.Map; + +import jakarta.annotation.PostConstruct; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +import org.springframework.stereotype.Repository; + +@Repository +public class UserRepositoryImpl implements UserRepository { + private Map users = new HashMap(); + + @PostConstruct + public void init() throws Exception { + users.put(Long.valueOf(1), new User(1, "Jack", "Smith", 20)); + users.put(Long.valueOf(2), new User(2, "Peter", "Johnson", 25)); + } + + @Override + public Mono getUserById(Long id) { + return Mono.just(users.get(id)); + } + + @Override + public Flux getAllUsers() { + return Flux.fromIterable(this.users.values()); + } + + @Override + public Flux getAllUsers(String firstname) { + return Flux.fromIterable(this.users.values().stream().filter(user -> user.getFirstname().equals(firstname)).toList()); + } + + @Override + public Mono saveUser(Mono monoUser) { + Mono userMono = monoUser.doOnNext(user -> { + // do post + users.put(user.getId(), user); + + // log on console + System.out.println("########### POST:" + user); + }); + + return userMono.then(); + } + + @Override + public Mono putUser(Long id, Mono monoUser) { + Mono userMono = monoUser.doOnNext(user -> { + // reset user.Id + user.setId(id); + + // do put + users.put(id, user); + + // log on console + System.out.println("########### PUT:" + user); + }); + + return userMono; + } + + @Override + public Mono deleteUser(Long id) { + // delete processing + users.remove(id); + return Mono.just("Delete Succesfully!"); + } +} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app70/Coffee.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app70/Coffee.java new file mode 100644 index 000000000..b41fd1c8b --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app70/Coffee.java @@ -0,0 +1,86 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app70; + +import java.util.Objects; + +public class Coffee { + + private String id; + + private String name; + + public Coffee() { + } + + public Coffee(String name) { + this.name = name; + } + + public Coffee(String id, String name) { + this.id = id; + this.name = name; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Coffee coffee = (Coffee) o; + return Objects.equals(id, coffee.id) && + Objects.equals(name, coffee.name); + } + + @Override + public int hashCode() { + return Objects.hash(id, name); + } + + @Override + public String toString() { + return "Coffee{" + + "id='" + id + '\'' + + ", name='" + name + '\'' + + '}'; + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app70/CoffeeOrder.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app70/CoffeeOrder.java new file mode 100644 index 000000000..bb886f679 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app70/CoffeeOrder.java @@ -0,0 +1,74 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app70; + +import java.time.Instant; +import java.util.Objects; + +public class CoffeeOrder { + private String coffeeId; + + private Instant whenOrdered; + + public CoffeeOrder() { + } + + public CoffeeOrder(String coffeeId, Instant whenOrdered) { + this.coffeeId = coffeeId; + this.whenOrdered = whenOrdered; + } + + public String getCoffeeId() { + return coffeeId; + } + + public Instant getWhenOrdered() { + return whenOrdered; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + CoffeeOrder that = (CoffeeOrder) o; + return Objects.equals(coffeeId, that.coffeeId) && + Objects.equals(whenOrdered, that.whenOrdered); + } + + @Override + public int hashCode() { + return Objects.hash(coffeeId, whenOrdered); + } + + @Override + public String toString() { + return "CoffeeOrder{" + + "coffeeId='" + coffeeId + '\'' + + ", whenOrdered=" + whenOrdered + + '}'; + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app70/CoffeeRepository.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app70/CoffeeRepository.java new file mode 100644 index 000000000..246507904 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app70/CoffeeRepository.java @@ -0,0 +1,52 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app70; + +import org.reactivestreams.Publisher; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +import org.springframework.stereotype.Repository; + +@Repository +public class CoffeeRepository { + Flux deleteAll() { + return null; + } + + Mono findById(String id) { + return null; + } + + Publisher save(Coffee coffee) { + return null; + } + + Flux findAll() { + return null; + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app70/CoffeeService.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app70/CoffeeService.java new file mode 100644 index 000000000..2a8d90faa --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app70/CoffeeService.java @@ -0,0 +1,60 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app70; + +import java.time.Duration; +import java.time.Instant; + +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.enums.ParameterIn; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +import org.springframework.stereotype.Service; + +@Service +public class CoffeeService { + private final CoffeeRepository repo; + + public CoffeeService(CoffeeRepository repo) { + this.repo = repo; + } + + Flux getAllCoffees() { + return repo.findAll(); + } + + Mono getCoffeeById(@Parameter(in = ParameterIn.PATH) String id) { + return repo.findById(id); + } + + Flux getOrdersForCoffeeById(@Parameter(in = ParameterIn.PATH) String id) { + return Flux.interval(Duration.ofSeconds(1)) + .onBackpressureDrop() + .map(i -> new CoffeeOrder(id, Instant.now())); + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app70/RouteConfig.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app70/RouteConfig.java new file mode 100644 index 000000000..967752aab --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app70/RouteConfig.java @@ -0,0 +1,76 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app70; + +import org.springdoc.core.annotations.RouterOperation; +import org.springdoc.core.annotations.RouterOperations; +import reactor.core.publisher.Mono; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.http.MediaType; +import org.springframework.web.reactive.function.server.RouterFunction; +import org.springframework.web.reactive.function.server.ServerRequest; +import org.springframework.web.reactive.function.server.ServerResponse; + +import static org.springframework.web.reactive.function.server.RequestPredicates.GET; +import static org.springframework.web.reactive.function.server.RouterFunctions.route; + +@Configuration +public class RouteConfig { + private final CoffeeService service; + + public RouteConfig(CoffeeService service) { + this.service = service; + } + + @Bean + @RouterOperations({ @RouterOperation(path = "/coffees", beanClass = CoffeeService.class, beanMethod = "getAllCoffees"), + @RouterOperation(path = "/coffees/{id}", beanClass = CoffeeService.class, beanMethod = "getCoffeeById"), + @RouterOperation(path = "/coffees/{id}/orders", beanClass = CoffeeService.class, beanMethod = "getOrdersForCoffeeById") }) + RouterFunction routerFunction() { + return route(GET("/coffees"), this::all) + .andRoute(GET("/coffees/{id}"), this::byId) + .andRoute(GET("/coffees/{id}/orders"), this::orders); + } + + private Mono all(ServerRequest req) { + return ServerResponse.ok() + .body(service.getAllCoffees(), Coffee.class); + } + + private Mono byId(ServerRequest req) { + return ServerResponse.ok() + .body(service.getCoffeeById(req.pathVariable("id")), Coffee.class); + } + + private Mono orders(ServerRequest req) { + return ServerResponse.ok() + .contentType(MediaType.TEXT_EVENT_STREAM) + .body(service.getOrdersForCoffeeById(req.pathVariable("id")), CoffeeOrder.class); + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app70/SpringDocApp70Test.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app70/SpringDocApp70Test.java new file mode 100644 index 000000000..86f9863ba --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app70/SpringDocApp70Test.java @@ -0,0 +1,39 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app70; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.ComponentScan; + +public class SpringDocApp70Test extends AbstractSpringDocTest { + + @SpringBootApplication + @ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.v30.app70" }) + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app71/Employee.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app71/Employee.java new file mode 100644 index 000000000..94f6fdf4c --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app71/Employee.java @@ -0,0 +1,50 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app71; + +public class Employee { + + private String id; + + private String name; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app71/EmployeeFunctionalConfig.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app71/EmployeeFunctionalConfig.java new file mode 100644 index 000000000..012c9ee0a --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app71/EmployeeFunctionalConfig.java @@ -0,0 +1,108 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app71; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.enums.ParameterIn; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import org.springdoc.core.annotations.RouterOperation; +import org.springdoc.core.annotations.RouterOperations; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.http.MediaType; +import org.springframework.web.reactive.function.BodyExtractors; +import org.springframework.web.reactive.function.server.RouterFunction; +import org.springframework.web.reactive.function.server.ServerResponse; + +import static org.springframework.web.reactive.function.server.RequestPredicates.GET; +import static org.springframework.web.reactive.function.server.RequestPredicates.POST; +import static org.springframework.web.reactive.function.server.RequestPredicates.accept; +import static org.springframework.web.reactive.function.server.RouterFunctions.route; +import static org.springframework.web.reactive.function.server.ServerResponse.ok; + +@Configuration +public class EmployeeFunctionalConfig { + + + @Bean + EmployeeRepository employeeRepository() { + return new EmployeeRepository(); + } + + @Bean + @RouterOperation(beanClass = EmployeeRepository.class, beanMethod = "findAllEmployees") + RouterFunction getAllEmployeesRoute() { + return route(GET("/employees").and(accept(MediaType.APPLICATION_JSON)), + req -> ok().body( + employeeRepository().findAllEmployees(), Employee.class)); + } + + @Bean + @RouterOperation(operation = @Operation(operationId = "findEmployeeById", summary = "Find purchase order by ID", tags = { "MyEmployee" }, + parameters = { @Parameter(in = ParameterIn.PATH, name = "id", description = "Employee Id") }, + responses = { @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(schema = @Schema(implementation = Employee.class))), + @ApiResponse(responseCode = "400", description = "Invalid Employee ID supplied"), + @ApiResponse(responseCode = "404", description = "Employee not found") })) + RouterFunction getEmployeeByIdRoute() { + return route(GET("/employees/{id}"), + req -> ok().body( + employeeRepository().findEmployeeById(req.pathVariable("id")), Employee.class)); + } + + + @Bean + @RouterOperation(beanClass = EmployeeRepository.class, beanMethod = "updateEmployee") + RouterFunction updateEmployeeRoute() { + return route(POST("/employees/update").and(accept(MediaType.APPLICATION_XML)), + req -> req.body(BodyExtractors.toMono(Employee.class)) + .doOnNext(employeeRepository()::updateEmployee) + .then(ok().build())); + } + + @Bean + @RouterOperations({ @RouterOperation(path = "/employees-composed/update", beanClass = EmployeeRepository.class, beanMethod = "updateEmployee"), + @RouterOperation(path = "/employees-composed/{id}", beanClass = EmployeeRepository.class, beanMethod = "findEmployeeById"), + @RouterOperation(path = "/employees-composed", beanClass = EmployeeRepository.class, beanMethod = "findAllEmployees") }) + RouterFunction composedRoutes() { + return + route(GET("/employees-composed"), + req -> ok().body( + employeeRepository().findAllEmployees(), Employee.class)) + .and(route(GET("/employees-composed/{id}"), + req -> ok().body( + employeeRepository().findEmployeeById(req.pathVariable("id")), Employee.class))) + .and(route(POST("/employees-composed/update"), + req -> req.body(BodyExtractors.toMono(Employee.class)) + .doOnNext(employeeRepository()::updateEmployee) + .then(ok().build()))); + } + +} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app71/EmployeeRepository.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app71/EmployeeRepository.java new file mode 100644 index 000000000..37794c834 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app71/EmployeeRepository.java @@ -0,0 +1,58 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app71; + +import java.util.Map; + +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.enums.ParameterIn; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +public class EmployeeRepository { + + static Map employeeData; + + static Map employeeAccessData; + + + public Mono findEmployeeById(@Parameter(in = ParameterIn.PATH) String id) { + return Mono.just(employeeData.get(id)); + } + + public Flux findAllEmployees() { + return Flux.fromIterable(employeeData.values()); + } + + public Mono updateEmployee(Employee employee) { + Employee existingEmployee = employeeData.get(employee.getId()); + if (existingEmployee != null) { + existingEmployee.setName(employee.getName()); + } + return Mono.just(existingEmployee); + } +} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app71/SpringDocApp71Test.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app71/SpringDocApp71Test.java new file mode 100644 index 000000000..8472bf4e6 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app71/SpringDocApp71Test.java @@ -0,0 +1,39 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app71; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.ComponentScan; + +public class SpringDocApp71Test extends AbstractSpringDocTest { + + @SpringBootApplication + @ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.v30.app71" }) + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app72/SpringDocApp72Test.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app72/SpringDocApp72Test.java new file mode 100644 index 000000000..fbb07bf80 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app72/SpringDocApp72Test.java @@ -0,0 +1,39 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app72; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.ComponentScan; + +public class SpringDocApp72Test extends AbstractSpringDocTest { + + @SpringBootApplication + @ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.v30.app72" }) + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app72/controller/PersonRouter.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app72/controller/PersonRouter.java new file mode 100644 index 000000000..07141a60d --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app72/controller/PersonRouter.java @@ -0,0 +1,62 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app72.controller; + +import org.springdoc.core.annotations.RouterOperation; +import org.springdoc.core.annotations.RouterOperations; +import test.org.springdoc.api.v30.app72.handler.PersonHandler; +import test.org.springdoc.api.v30.app72.service.PersonService; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.http.MediaType; +import org.springframework.web.reactive.function.server.RouterFunction; +import org.springframework.web.reactive.function.server.RouterFunctions; +import org.springframework.web.reactive.function.server.ServerResponse; + +import static org.springframework.web.reactive.function.server.RequestPredicates.DELETE; +import static org.springframework.web.reactive.function.server.RequestPredicates.GET; +import static org.springframework.web.reactive.function.server.RequestPredicates.POST; +import static org.springframework.web.reactive.function.server.RequestPredicates.accept; + +@Configuration +public class PersonRouter { + + @RouterOperations({ @RouterOperation(path = "/getAllPersons", beanClass = PersonService.class, beanMethod = "getAll"), + @RouterOperation(path = "/getPerson/{id}", beanClass = PersonService.class, beanMethod = "getById"), + @RouterOperation(path = "/createPerson", beanClass = PersonService.class, beanMethod = "save"), + @RouterOperation(path = "/deletePerson/{id}", beanClass = PersonService.class, beanMethod = "delete") }) + @Bean + public RouterFunction personRoute(PersonHandler handler) { + return RouterFunctions + .route(GET("/getAllPersons").and(accept(MediaType.APPLICATION_JSON)), handler::findAll) + .andRoute(GET("/getPerson/{id}").and(accept(MediaType.APPLICATION_STREAM_JSON)), handler::findById) + .andRoute(POST("/createPerson").and(accept(MediaType.APPLICATION_JSON)), handler::save) + .andRoute(DELETE("/deletePerson/{id}").and(accept(MediaType.APPLICATION_JSON)), handler::delete); + } + +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app72/controller/PositionRouter.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app72/controller/PositionRouter.java new file mode 100644 index 000000000..3fc4a10ca --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app72/controller/PositionRouter.java @@ -0,0 +1,74 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app72.controller; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.enums.ParameterIn; +import io.swagger.v3.oas.annotations.media.ArraySchema; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.parameters.RequestBody; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import org.springdoc.core.annotations.RouterOperation; +import org.springdoc.core.annotations.RouterOperations; +import test.org.springdoc.api.v30.app72.entity.Position; +import test.org.springdoc.api.v30.app72.handler.PositionHandler; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.http.MediaType; +import org.springframework.web.reactive.function.server.RouterFunction; +import org.springframework.web.reactive.function.server.RouterFunctions; +import org.springframework.web.reactive.function.server.ServerResponse; + +import static org.springframework.web.reactive.function.server.RequestPredicates.DELETE; +import static org.springframework.web.reactive.function.server.RequestPredicates.GET; +import static org.springframework.web.reactive.function.server.RequestPredicates.POST; +import static org.springframework.web.reactive.function.server.RequestPredicates.accept; + +@Configuration +public class PositionRouter { + + @Bean + @RouterOperations({ @RouterOperation(path = "/getAllPositions", operation = @Operation(description = "Get all positions", operationId = "findAll", tags = "positions", + responses = @ApiResponse(responseCode = "200", content = @Content(array = @ArraySchema(schema = @Schema(implementation = Position.class)))))), + @RouterOperation(path = "/getPosition/{id}", operation = @Operation(description = "Find all", operationId = "findById", tags = "positions", parameters = @Parameter(name = "id", in = ParameterIn.PATH), + responses = @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = Position.class))))), + @RouterOperation(path = "/createPosition", operation = @Operation(description = "Save position", operationId = "save", tags = "positions", requestBody = @RequestBody(content = @Content(schema = @Schema(implementation = Position.class))), + responses = @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = Position.class))))), + @RouterOperation(path = "/deletePosition/{id}", operation = @Operation(description = "Delete By Id", operationId = "deleteBy", tags = "positions", parameters = @Parameter(name = "id", in = ParameterIn.PATH), + responses = @ApiResponse(responseCode = "200", content = @Content))) }) + public RouterFunction positionRoute(PositionHandler handler) { + return RouterFunctions + .route(GET("/getAllPositions").and(accept(MediaType.APPLICATION_JSON)), handler::findAll) + .andRoute(GET("/getPosition/{id}").and(accept(MediaType.APPLICATION_STREAM_JSON)), handler::findById) + .andRoute(POST("/createPosition").and(accept(MediaType.APPLICATION_JSON)), handler::save) + .andRoute(DELETE("/deletePosition/{id}").and(accept(MediaType.APPLICATION_JSON)), handler::delete); + } + +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app72/entity/Person.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app72/entity/Person.java new file mode 100644 index 000000000..9432f84a7 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app72/entity/Person.java @@ -0,0 +1,100 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app72.entity; + +public class Person { + + private String id; + + private Sex sex; + + private String firstName; + + private String lastName; + + private String age; + + private String interests; + + private String email; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public Sex getSex() { + return sex; + } + + public void setSex(Sex sex) { + this.sex = sex; + } + + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } + + public String getAge() { + return age; + } + + public void setAge(String age) { + this.age = age; + } + + public String getInterests() { + return interests; + } + + public void setInterests(String interests) { + this.interests = interests; + } + + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app72/entity/Position.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app72/entity/Position.java new file mode 100644 index 000000000..06cea5c94 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app72/entity/Position.java @@ -0,0 +1,80 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app72.entity; + +import java.util.Date; + +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; +import jakarta.validation.constraints.Size; + + +public class Position { + + private String id; + + @NotBlank + @Size(max = 140) + private String positionName; + + private String description; + + @NotNull + private Date createdAt = new Date(); + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getPositionName() { + return positionName; + } + + public void setPositionName(String positionName) { + this.positionName = positionName; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public Date getCreatedAt() { + return createdAt; + } + + public void setCreatedAt(Date createdAt) { + this.createdAt = createdAt; + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app72/entity/Sex.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app72/entity/Sex.java new file mode 100644 index 000000000..d2361ae1d --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app72/entity/Sex.java @@ -0,0 +1,31 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app72.entity; + +public enum Sex { + MAN, WOMEN +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app72/exception/PositionNotFoundException.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app72/exception/PositionNotFoundException.java new file mode 100644 index 000000000..9a63bb3d3 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app72/exception/PositionNotFoundException.java @@ -0,0 +1,34 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app72.exception; + +public class PositionNotFoundException extends RuntimeException { + + public PositionNotFoundException(String positionId) { + super("Position not found with id " + positionId); + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app72/handler/PersonHandler.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app72/handler/PersonHandler.java new file mode 100644 index 000000000..da05a3575 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app72/handler/PersonHandler.java @@ -0,0 +1,78 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app72.handler; + +import reactor.core.publisher.Mono; +import test.org.springdoc.api.v30.app72.entity.Person; +import test.org.springdoc.api.v30.app72.service.PersonService; + +import org.springframework.http.MediaType; +import org.springframework.stereotype.Component; +import org.springframework.web.reactive.function.BodyInserters; +import org.springframework.web.reactive.function.server.ServerRequest; +import org.springframework.web.reactive.function.server.ServerResponse; + +import static org.springframework.web.reactive.function.server.ServerResponse.ok; + +@Component +@SuppressWarnings({ "deprecared", "unchecked" }) +public class PersonHandler { + + private final PersonService personService; + + public PersonHandler(PersonService personService) { + this.personService = personService; + } + + public Mono findById(ServerRequest request) { + String id = request.pathVariable("id"); + return ok() + .contentType(MediaType.APPLICATION_JSON) + .body(personService.getById(id), Person.class); + } + + public Mono findAll(ServerRequest request) { + return ok() + .contentType(MediaType.APPLICATION_JSON) + .body(personService.getAll(), Person.class); + } + + public Mono save(ServerRequest request) { + final Mono person = request.bodyToMono(Person.class); + return ok() + .contentType(MediaType.APPLICATION_JSON) + .body(BodyInserters.fromPublisher(person.flatMap(personService::save), Person.class)); + } + + public Mono delete(ServerRequest request) { + String id = request.pathVariable("id"); + return ok() + .contentType(MediaType.APPLICATION_JSON) + .body(personService.delete(id), Void.class); + } + +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app72/handler/PositionHandler.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app72/handler/PositionHandler.java new file mode 100644 index 000000000..96f389b2f --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app72/handler/PositionHandler.java @@ -0,0 +1,56 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app72.handler; + +import reactor.core.publisher.Mono; + +import org.springframework.stereotype.Component; +import org.springframework.web.reactive.function.server.ServerRequest; +import org.springframework.web.reactive.function.server.ServerResponse; + +@Component +public class PositionHandler { + + + public Mono findById(ServerRequest request) { + String id = request.pathVariable("id"); + return null; + } + + public Mono findAll(ServerRequest request) { + return null; + } + + public Mono save(ServerRequest request) { + return null; + } + + public Mono delete(ServerRequest request) { + return null; + } + +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app72/payload/ErrorResponse.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app72/payload/ErrorResponse.java new file mode 100644 index 000000000..c6c467852 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app72/payload/ErrorResponse.java @@ -0,0 +1,45 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app72.payload; + +public class ErrorResponse { + + private String message; + + public ErrorResponse(String message) { + this.message = message; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app72/service/PersonService.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app72/service/PersonService.java new file mode 100644 index 000000000..b0b0595cf --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app72/service/PersonService.java @@ -0,0 +1,65 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app72.service; + +import java.util.Objects; + +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.enums.ParameterIn; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; +import test.org.springdoc.api.v30.app72.entity.Person; + +import org.springframework.stereotype.Service; + +@Service +public class PersonService { + + public Flux getAll() { + return null; + } + + public Mono getById(@Parameter(in = ParameterIn.PATH) final String id) { + return null; + } + + public Mono update(@Parameter(in = ParameterIn.PATH) final String id, final Person person) { + return null; + } + + public Mono save(final Person person) { + return null; + } + + public Mono delete(@Parameter(in = ParameterIn.PATH) final String id) { + final Mono dbPerson = getById(id); + if (Objects.isNull(dbPerson)) { + return Mono.empty(); + } + return null; + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app73/Quote.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app73/Quote.java new file mode 100644 index 000000000..b7c761c0b --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app73/Quote.java @@ -0,0 +1,88 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app73; + + +import java.math.BigDecimal; +import java.math.MathContext; +import java.time.Instant; + +public class Quote { + + private static final MathContext MATH_CONTEXT = new MathContext(2); + + private String ticker; + + private BigDecimal price; + + private Instant instant; + + public Quote() { + } + + public Quote(String ticker, BigDecimal price) { + this.ticker = ticker; + this.price = price; + } + + public Quote(String ticker, Double price) { + this(ticker, new BigDecimal(price, MATH_CONTEXT)); + } + + public String getTicker() { + return ticker; + } + + public void setTicker(String ticker) { + this.ticker = ticker; + } + + public BigDecimal getPrice() { + return price; + } + + public void setPrice(BigDecimal price) { + this.price = price; + } + + public Instant getInstant() { + return instant; + } + + public void setInstant(Instant instant) { + this.instant = instant; + } + + @Override + public String toString() { + return "Quote{" + + "ticker='" + ticker + '\'' + + ", price=" + price + + ", instant=" + instant + + '}'; + } +} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app73/QuoteGenerator.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app73/QuoteGenerator.java new file mode 100644 index 000000000..e42386616 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app73/QuoteGenerator.java @@ -0,0 +1,95 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app73; + + +import java.math.BigDecimal; +import java.math.MathContext; +import java.time.Duration; +import java.time.Instant; +import java.util.ArrayList; +import java.util.List; +import java.util.Random; + +import reactor.core.publisher.Flux; + +import org.springframework.stereotype.Component; + +@Component +public class QuoteGenerator { + + private final MathContext mathContext = new MathContext(2); + + private final Random random = new Random(); + + private final List prices = new ArrayList<>(); + + /** + * Bootstraps the generator with tickers and initial prices + */ + public QuoteGenerator() { + this.prices.add(new Quote("CTXS", 82.26)); + this.prices.add(new Quote("DELL", 63.74)); + this.prices.add(new Quote("GOOG", 847.24)); + this.prices.add(new Quote("MSFT", 65.11)); + this.prices.add(new Quote("ORCL", 45.71)); + this.prices.add(new Quote("RHT", 84.29)); + this.prices.add(new Quote("VMW", 92.21)); + } + + + public Flux fetchQuoteStream(Duration period) { + + // We want to emit quotes with a specific period; + // to do so, we create a Flux.interval + return Flux.interval(period) + // In case of back-pressure, drop events + .onBackpressureDrop() + // For each tick, generate a list of quotes + .map(this::generateQuotes) + // "flatten" that List into a Flux + .flatMapIterable(quotes -> quotes) + .log("io.spring.workshop.stockquotes"); + } + + /* + * Create quotes for all tickers at a single instant. + */ + private List generateQuotes(long interval) { + final Instant instant = Instant.now(); + return prices.stream() + .map(baseQuote -> { + BigDecimal priceChange = baseQuote.getPrice() + .multiply(new BigDecimal(0.05 * this.random.nextDouble()), this.mathContext); + Quote result = new Quote(baseQuote.getTicker(), baseQuote.getPrice().add(priceChange)); + result.setInstant(instant); + return result; + }) + .toList(); + } + +} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app73/QuoteHandler.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app73/QuoteHandler.java new file mode 100644 index 000000000..a4b9cd91b --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app73/QuoteHandler.java @@ -0,0 +1,72 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app73; + + +import java.time.Duration; + +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +import org.springframework.http.MediaType; +import org.springframework.stereotype.Component; +import org.springframework.web.reactive.function.BodyInserters; +import org.springframework.web.reactive.function.server.ServerRequest; +import org.springframework.web.reactive.function.server.ServerResponse; + +@Component +public class QuoteHandler { + + private final Flux quoteStream; + + public QuoteHandler(QuoteGenerator quoteGenerator) { + this.quoteStream = quoteGenerator.fetchQuoteStream(Duration.ofMillis(1000)).share(); + } + + public Mono hello(ServerRequest request) { + return ServerResponse.ok().contentType(MediaType.TEXT_PLAIN) + .body(BodyInserters.fromObject("Hello Spring!")); + } + + public Mono echo(ServerRequest request) { + return ServerResponse.ok().contentType(MediaType.TEXT_PLAIN) + .body(request.bodyToMono(String.class), String.class); + } + + public Mono streamQuotes(ServerRequest request) { + return ServerResponse.ok() + .contentType(MediaType.APPLICATION_STREAM_JSON) + .body(this.quoteStream, Quote.class); + } + + public Mono fetchQuotes(ServerRequest request) { + int size = Integer.parseInt(request.queryParam("size").orElse("10")); + return ServerResponse.ok() + .contentType(MediaType.APPLICATION_JSON) + .body(this.quoteStream.take(size), Quote.class); + } +} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app73/QuoteRouter.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app73/QuoteRouter.java new file mode 100644 index 000000000..c7a08b747 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app73/QuoteRouter.java @@ -0,0 +1,79 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app73; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.enums.ParameterIn; +import io.swagger.v3.oas.annotations.media.ArraySchema; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.parameters.RequestBody; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import org.springdoc.core.annotations.RouterOperation; +import org.springdoc.core.annotations.RouterOperations; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.reactive.function.server.RouterFunction; +import org.springframework.web.reactive.function.server.RouterFunctions; +import org.springframework.web.reactive.function.server.ServerResponse; + +import static org.springframework.http.MediaType.APPLICATION_JSON; +import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE; +import static org.springframework.http.MediaType.APPLICATION_STREAM_JSON; +import static org.springframework.http.MediaType.APPLICATION_STREAM_JSON_VALUE; +import static org.springframework.http.MediaType.TEXT_PLAIN; +import static org.springframework.http.MediaType.TEXT_PLAIN_VALUE; +import static org.springframework.web.reactive.function.server.RequestPredicates.GET; +import static org.springframework.web.reactive.function.server.RequestPredicates.POST; +import static org.springframework.web.reactive.function.server.RequestPredicates.accept; +import static org.springframework.web.reactive.function.server.RequestPredicates.contentType; + +@Configuration +public class QuoteRouter { + + @RouterOperations({ + @RouterOperation(path = "/hello", operation = @Operation(operationId = "hello", responses = @ApiResponse(responseCode = "200"))), + @RouterOperation(path = "/echo", produces = TEXT_PLAIN_VALUE, operation = @Operation(operationId = "echo", requestBody = @RequestBody(content = @Content(schema = @Schema(type = "string"))), + responses = @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(type = "string"))))), + @RouterOperation(path = "/echo", produces = APPLICATION_JSON_VALUE, operation = @Operation(operationId = "echo", requestBody = @RequestBody(content = @Content(schema = @Schema(type = "string"))), + responses = @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(type = "string"))))), + @RouterOperation(path = "/quotes", produces = APPLICATION_JSON_VALUE, operation = @Operation(operationId = "fetchQuotes", parameters = @Parameter(name = "size", in = ParameterIn.QUERY, schema = @Schema(type = "string")), + responses = @ApiResponse(responseCode = "200", content = @Content(array = @ArraySchema(schema = @Schema(implementation = Quote.class)))))), + @RouterOperation(path = "/quotes", produces = APPLICATION_STREAM_JSON_VALUE, operation = @Operation(operationId = "fetchQuotes", + responses = @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = Quote.class))))) }) + @Bean + public RouterFunction route(QuoteHandler quoteHandler) { + return RouterFunctions + .route(GET("/hello").and(accept(TEXT_PLAIN)), quoteHandler::hello) + .andRoute(POST("/echo").and(accept(TEXT_PLAIN).and(contentType(TEXT_PLAIN))), quoteHandler::echo) + .andRoute(POST("/echo").and(accept(APPLICATION_JSON).and(contentType(APPLICATION_JSON))), quoteHandler::echo) + .andRoute(GET("/quotes").and(accept(APPLICATION_JSON)), quoteHandler::fetchQuotes) + .andRoute(GET("/quotes").and(accept(APPLICATION_STREAM_JSON)), quoteHandler::streamQuotes); + } +} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app73/SpringDocApp73Test.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app73/SpringDocApp73Test.java new file mode 100644 index 000000000..9a3af3463 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app73/SpringDocApp73Test.java @@ -0,0 +1,39 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app73; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.ComponentScan; + +public class SpringDocApp73Test extends AbstractSpringDocTest { + + @SpringBootApplication + @ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.v30.app73" }) + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app74/Book.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app74/Book.java new file mode 100644 index 000000000..b70349944 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app74/Book.java @@ -0,0 +1,66 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app74; + +public class Book { + + private String id; + + private String title; + + private String author; + + public Book(String id, String title, String author) { + this.id = id; + this.title = title; + this.author = author; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getAuthor() { + return author; + } + + public void setAuthor(String author) { + this.author = author; + } +} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app74/BookRepository.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app74/BookRepository.java new file mode 100644 index 000000000..1e832101b --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app74/BookRepository.java @@ -0,0 +1,44 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app74; + +import reactor.core.publisher.Flux; + +import org.springframework.stereotype.Component; + +@Component +public class BookRepository { + + + Flux findByAuthor(String author) { + return Flux.just(new Book("1", "title1", "author1")); + } + + Flux findAll() { + return Flux.just(new Book("2", "title2", "author2")); + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app74/BookRouter.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app74/BookRouter.java new file mode 100644 index 000000000..40776a7a5 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app74/BookRouter.java @@ -0,0 +1,61 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app74; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.enums.ParameterIn; +import org.springdoc.core.annotations.RouterOperation; +import org.springdoc.core.annotations.RouterOperations; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.http.MediaType; +import org.springframework.web.reactive.function.server.RouterFunction; + +import static org.springframework.web.reactive.function.server.RequestPredicates.GET; +import static org.springframework.web.reactive.function.server.RequestPredicates.accept; +import static org.springframework.web.reactive.function.server.RouterFunctions.route; +import static org.springframework.web.reactive.function.server.ServerResponse.ok; + +@Configuration +class BookRouter { + + @Bean + @RouterOperations({ + @RouterOperation(path = "/books", produces = { MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE }, beanClass = BookRepository.class, beanMethod = "findAll"), + @RouterOperation(path = "/books", produces = { MediaType.TEXT_PLAIN_VALUE, MediaType.APPLICATION_XML_VALUE }, beanClass = BookRepository.class, beanMethod = "findAll"), + @RouterOperation(path = "/books/{author}", beanClass = BookRepository.class, beanMethod = "findByAuthor", + operation = @Operation(operationId = "findByAuthor" + , parameters = { @Parameter(in = ParameterIn.PATH, name = "author") })) }) + RouterFunction routes(BookRepository br) { + return + route(GET("/books").and(accept(MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML)), req -> ok().body(br.findAll(), Book.class)) + .and(route(GET("/books").and(accept(MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN)), req -> ok().body(br.findAll(), Book.class))) + .andRoute(GET("/books/{author}"), req -> ok().body(br.findByAuthor(req.pathVariable("author")), Book.class)); + } +} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app74/SpringDocApp74Test.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app74/SpringDocApp74Test.java new file mode 100644 index 000000000..685b2a9af --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app74/SpringDocApp74Test.java @@ -0,0 +1,39 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app74; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.ComponentScan; + +public class SpringDocApp74Test extends AbstractSpringDocTest { + + @SpringBootApplication + @ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.v30.app74" }) + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app75/Post.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app75/Post.java new file mode 100644 index 000000000..b94b392df --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app75/Post.java @@ -0,0 +1,79 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app75; + +import java.time.LocalDateTime; + +public class Post { + + private String id; + + private String title; + + private String content; + + private LocalDateTime createdDate; + + public Post(String id, String title, String content) { + this.id = id; + this.title = title; + this.content = content; + this.createdDate = LocalDateTime.now(); + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } + + public LocalDateTime getCreatedDate() { + return createdDate; + } + + public void setCreatedDate(LocalDateTime createdDate) { + this.createdDate = createdDate; + } +} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app75/PostHandler.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app75/PostHandler.java new file mode 100644 index 000000000..57d03263a --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app75/PostHandler.java @@ -0,0 +1,83 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app75; + + +import java.net.URI; + +import reactor.core.publisher.Mono; + +import org.springframework.stereotype.Component; +import org.springframework.web.reactive.function.server.ServerRequest; +import org.springframework.web.reactive.function.server.ServerResponse; + +@Component +class PostHandler { + + private final PostRepository posts; + + public PostHandler(PostRepository posts) { + this.posts = posts; + } + + public Mono all(ServerRequest req) { + return ServerResponse.ok().body(this.posts.findAll(), Post.class); + } + + public Mono create(ServerRequest req) { + return req.bodyToMono(Post.class) + .flatMap(post -> this.posts.save(post)) + .flatMap(p -> ServerResponse.created(URI.create("/posts/" + p.getId())).build()); + } + + public Mono get(ServerRequest req) { + return this.posts.findById(req.pathVariable("id")) + .flatMap(post -> ServerResponse.ok().body(Mono.just(post), Post.class)) + .switchIfEmpty(ServerResponse.notFound().build()); + } + + public Mono update(ServerRequest req) { + + return Mono + .zip( + (data) -> { + Post p = (Post) data[0]; + Post p2 = (Post) data[1]; + p.setTitle(p2.getTitle()); + p.setContent(p2.getContent()); + return p; + }, + this.posts.findById(req.pathVariable("id")), + req.bodyToMono(Post.class) + ) + .cast(Post.class) + .flatMap(post -> this.posts.save(post)) + .flatMap(post -> ServerResponse.noContent().build()); + + } + +} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app75/PostRepository.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app75/PostRepository.java new file mode 100644 index 000000000..80d6bf261 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app75/PostRepository.java @@ -0,0 +1,53 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app75; + +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +import org.springframework.stereotype.Component; + +@Component +public class PostRepository { + + public Flux findByAuthor(String author) { + return Flux.just(new Post("1", "title1", "author1")); + } + + public Flux findAll() { + return Flux.just(new Post("2", "title2", "author2")); + } + + public Mono findById(String id) { + return Mono.just(new Post("3", "title2", "author2")); + } + + public Mono save(Post post) { + return Mono.just(new Post("4", "title2", "author2")); + } + +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app75/PostRouter.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app75/PostRouter.java new file mode 100644 index 000000000..a748b4419 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app75/PostRouter.java @@ -0,0 +1,73 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app75; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.enums.ParameterIn; +import io.swagger.v3.oas.annotations.media.ArraySchema; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.parameters.RequestBody; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import org.springdoc.core.annotations.RouterOperation; +import org.springdoc.core.annotations.RouterOperations; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.reactive.function.server.RouterFunction; +import org.springframework.web.reactive.function.server.ServerResponse; + +import static org.springframework.web.reactive.function.server.RequestPredicates.GET; +import static org.springframework.web.reactive.function.server.RequestPredicates.POST; +import static org.springframework.web.reactive.function.server.RequestPredicates.PUT; +import static org.springframework.web.reactive.function.server.RequestPredicates.queryParam; +import static org.springframework.web.reactive.function.server.RouterFunctions.route; + +@Configuration +class PostRouter { + + @RouterOperations({ @RouterOperation(path = "/posts", method = RequestMethod.GET, headers = { "x-header1=test1", "x-header2=test2" }, operation = @Operation(operationId = "all", + parameters = { @Parameter(name = "key", description = "sample description"), @Parameter(name = "test", description = "sample desc") }, + responses = @ApiResponse(responseCode = "200", content = @Content(array = @ArraySchema(schema = @Schema(implementation = Post.class)))))), + @RouterOperation(path = "/posts", method = RequestMethod.POST, operation = @Operation(operationId = "create", + requestBody = @RequestBody(content = @Content(schema = @Schema(implementation = Post.class))), responses = @ApiResponse(responseCode = "201"))), + @RouterOperation(path = "/posts/{id}", method = RequestMethod.GET, operation = @Operation(operationId = "get", + parameters = @Parameter(name = "id", in = ParameterIn.PATH), + responses = @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = Post.class))))), + @RouterOperation(path = "/posts/{id}", method = RequestMethod.PUT, operation = @Operation(operationId = "update", + parameters = @Parameter(name = "id", in = ParameterIn.PATH), + responses = @ApiResponse(responseCode = "202", content = @Content(schema = @Schema(implementation = Post.class))))) }) + @Bean + public RouterFunction routes(PostHandler postController) { + return route(GET("/posts").and(queryParam("key", "value")), postController::all) + .andRoute(POST("/posts"), postController::create) + .andRoute(GET("/posts/{id}"), postController::get) + .andRoute(PUT("/posts/{id}"), postController::update); + } +} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app75/SpringDocApp75Test.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app75/SpringDocApp75Test.java new file mode 100644 index 000000000..949d572af --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app75/SpringDocApp75Test.java @@ -0,0 +1,39 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app75; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.ComponentScan; + +public class SpringDocApp75Test extends AbstractSpringDocTest { + + @SpringBootApplication + @ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.v30.app75" }) + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app78/HelloController.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app78/HelloController.java new file mode 100644 index 000000000..5d8939aad --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app78/HelloController.java @@ -0,0 +1,63 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app78; + +import java.io.File; +import java.io.IOException; +import java.nio.file.Path; +import java.nio.file.Paths; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.media.Content; +import reactor.core.publisher.Flux; + +import org.springframework.http.MediaType; +import org.springframework.http.codec.multipart.FilePart; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class HelloController { + + + @PostMapping(value = "/files", produces = { MediaType.APPLICATION_JSON_VALUE }, consumes = { MediaType.MULTIPART_FORM_DATA_VALUE }) + @Operation(summary = "files") + public Flux handleFileUpload( + @RequestPart("files") @Parameter(description = "files", + content = @Content(mediaType = MediaType.APPLICATION_OCTET_STREAM_VALUE)) + Flux filePartFux) throws IOException { + File tmp = File.createTempFile("tmp", ""); + return filePartFux.flatMap(filePart -> { + Path path = Paths.get(tmp.toString() + filePart.filename()); + System.out.println(path); + return filePart.transferTo(path); + }); + } + +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app78/SpringDocApp78Test.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app78/SpringDocApp78Test.java new file mode 100644 index 000000000..979cd2a83 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app78/SpringDocApp78Test.java @@ -0,0 +1,39 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app78; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.ComponentScan; + +public class SpringDocApp78Test extends AbstractSpringDocTest { + + @SpringBootApplication + @ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.v30.app78" }) + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app79/BaseClientModel.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app79/BaseClientModel.java new file mode 100644 index 000000000..ed6ecddd5 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app79/BaseClientModel.java @@ -0,0 +1,34 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app79; + +import com.fasterxml.jackson.annotation.JsonProperty; + +public abstract class BaseClientModel { + @JsonProperty("id") + int id; +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app79/BaseController.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app79/BaseController.java new file mode 100644 index 000000000..8c365769a --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app79/BaseController.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.app79; + +import java.util.List; + +import reactor.core.publisher.Mono; + +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; + +public abstract class BaseController { + @GetMapping("/test1") + Mono> get1() { + return null; + } + + @GetMapping("/test2") + Mono>> get2() { + return null; + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app79/SpecificClientModel.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app79/SpecificClientModel.java new file mode 100644 index 000000000..915cd7fb1 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app79/SpecificClientModel.java @@ -0,0 +1,36 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app79; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.v3.oas.annotations.media.Schema; + +public class SpecificClientModel extends BaseClientModel { + @JsonProperty("name") + @Schema(title = "my title", pattern = "this is it", example = "this is example") + String name; +} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app79/SpecificController.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app79/SpecificController.java new file mode 100644 index 000000000..e4ebcc15c --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app79/SpecificController.java @@ -0,0 +1,32 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app79; + +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class SpecificController extends BaseController {} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app79/SpringDocApp79Test.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app79/SpringDocApp79Test.java new file mode 100644 index 000000000..2121c333f --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app79/SpringDocApp79Test.java @@ -0,0 +1,39 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app79; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.ComponentScan; + +public class SpringDocApp79Test extends AbstractSpringDocTest { + + @SpringBootApplication + @ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.v30.app79" }) + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app80/Book.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app80/Book.java new file mode 100644 index 000000000..a88884953 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app80/Book.java @@ -0,0 +1,66 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app80; + +public class Book { + + private String id; + + private String title; + + private String author; + + public Book(String id, String title, String author) { + this.id = id; + this.title = title; + this.author = author; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getAuthor() { + return author; + } + + public void setAuthor(String author) { + this.author = author; + } +} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app80/BookRepository.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app80/BookRepository.java new file mode 100644 index 000000000..b9ff1e510 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app80/BookRepository.java @@ -0,0 +1,44 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app80; + +import reactor.core.publisher.Flux; + +import org.springframework.stereotype.Component; + +@Component +public class BookRepository { + + + Flux findByAuthor(String author) { + return Flux.just(new Book("1", "title1", "author1")); + } + + Flux findAll() { + return Flux.just(new Book("2", "title2", "author2")); + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app80/BookRouter.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app80/BookRouter.java new file mode 100644 index 000000000..1bc5cece7 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app80/BookRouter.java @@ -0,0 +1,113 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app80; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.enums.ParameterIn; +import org.springdoc.core.annotations.RouterOperation; +import org.springdoc.core.annotations.RouterOperations; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.http.MediaType; +import org.springframework.web.reactive.function.server.RouterFunction; + +import static org.springframework.web.reactive.function.server.RequestPredicates.GET; +import static org.springframework.web.reactive.function.server.RequestPredicates.accept; +import static org.springframework.web.reactive.function.server.RequestPredicates.path; +import static org.springframework.web.reactive.function.server.RouterFunctions.nest; +import static org.springframework.web.reactive.function.server.RouterFunctions.route; +import static org.springframework.web.reactive.function.server.ServerResponse.ok; + +@Configuration +class BookRouter { + + @Bean + @RouterOperations({ + @RouterOperation(path = "/greeter/greeter2/books", produces = { MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE }, beanClass = BookRepository.class, beanMethod = "findAll"), + @RouterOperation(path = "/greeter/greeter2/books", produces = { MediaType.TEXT_PLAIN_VALUE, MediaType.APPLICATION_XML_VALUE }, beanClass = BookRepository.class, beanMethod = "findAll"), + @RouterOperation(path = "/greeter/greeter2/books/{author}", beanClass = BookRepository.class, beanMethod = "findByAuthor", + operation = @Operation(operationId = "findByAuthor" + , parameters = { @Parameter(in = ParameterIn.PATH, name = "author") })) }) + RouterFunction routes(BookRepository br) { + return + nest(path("/greeter").and(path("/greeter2")), + route(GET("/books").and(accept(MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML)), req -> ok().body(br.findAll(), Book.class)) + .and(route(GET("/books").and(accept(MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN)), req -> ok().body(br.findAll(), Book.class))) + .andRoute(GET("/books/{author}"), req -> ok().body(br.findByAuthor(req.pathVariable("author")), Book.class))); + } + + @Bean + @RouterOperations({ + @RouterOperation(path = "/books", produces = { MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE }, beanClass = BookRepository.class, beanMethod = "findAll"), + @RouterOperation(path = "/books/{author}", beanClass = BookRepository.class, beanMethod = "findByAuthor", + operation = @Operation(operationId = "findByAuthor" + , parameters = { @Parameter(in = ParameterIn.PATH, name = "author") })) }) + RouterFunction routes1(BookRepository br) { + return + nest(accept(MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML), + route(GET("/books"), req -> ok().body(br.findAll(), Book.class)) + .andRoute(GET("/books/{author}"), req -> ok().body(br.findByAuthor(req.pathVariable("author")), Book.class))); + } + + @Bean + @RouterOperations({ + @RouterOperation(path = "/greeter/books", produces = { MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE }, beanClass = BookRepository.class, beanMethod = "findAll"), + @RouterOperation(path = "/greeter/books", produces = { MediaType.TEXT_PLAIN_VALUE, MediaType.APPLICATION_XML_VALUE }, beanClass = BookRepository.class, beanMethod = "findAll"), + @RouterOperation(path = "/greeter/books/{author}", beanClass = BookRepository.class, beanMethod = "findByAuthor", + operation = @Operation(operationId = "findByAuthor" + , parameters = { @Parameter(in = ParameterIn.PATH, name = "author") })), + @RouterOperation(path = "/greeter2/books", produces = { MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE }, beanClass = BookRepository.class, beanMethod = "findAll"), + @RouterOperation(path = "/greeter2/books", produces = { MediaType.TEXT_PLAIN_VALUE, MediaType.APPLICATION_XML_VALUE }, beanClass = BookRepository.class, beanMethod = "findAll"), + @RouterOperation(path = "/greeter2/books/{author}", beanClass = BookRepository.class, beanMethod = "findByAuthor", + operation = @Operation(operationId = "findByAuthor" + , parameters = { @Parameter(in = ParameterIn.PATH, name = "author") })) }) + RouterFunction routes3(BookRepository br) { + return + nest(path("/greeter").or(path("/greeter2")), + route(GET("/books").and(accept(MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML)), req -> ok().body(br.findAll(), Book.class)) + .and(route(GET("/books").and(accept(MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN)), req -> ok().body(br.findAll(), Book.class))) + .andRoute(GET("/books/{author}"), req -> ok().body(br.findByAuthor(req.pathVariable("author")), Book.class))); + } + + @Bean + @RouterOperations({ + @RouterOperation(path = "/test/greeter/greeter2/books", produces = { MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE }, beanClass = BookRepository.class, beanMethod = "findAll"), + @RouterOperation(path = "/test/greeter/greeter2/books", produces = { MediaType.TEXT_PLAIN_VALUE, MediaType.APPLICATION_XML_VALUE }, beanClass = BookRepository.class, beanMethod = "findAll"), + @RouterOperation(path = "/test/greeter/greeter2/books/{author}", beanClass = BookRepository.class, beanMethod = "findByAuthor", + operation = @Operation(operationId = "findByAuthor" + , parameters = { @Parameter(in = ParameterIn.PATH, name = "author") })) }) + RouterFunction routes4(BookRepository br) { + return + nest(path("/test"), + nest(path("/greeter").and(path("/greeter2")), + route(GET("/books").and(accept(MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML)), req -> ok().body(br.findAll(), Book.class)) + .and(route(GET("/books").and(accept(MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN)), req -> ok().body(br.findAll(), Book.class))) + .andRoute(GET("/books/{author}"), req -> ok().body(br.findByAuthor(req.pathVariable("author")), Book.class)))); + } +} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app80/SpringDocApp80Test.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app80/SpringDocApp80Test.java new file mode 100644 index 000000000..438a706ad --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app80/SpringDocApp80Test.java @@ -0,0 +1,39 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app80; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.ComponentScan; + +public class SpringDocApp80Test extends AbstractSpringDocTest { + + @SpringBootApplication + @ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.v30.app80" }) + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app81/OperationIdController.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app81/OperationIdController.java new file mode 100644 index 000000000..d3cb04bdf --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app81/OperationIdController.java @@ -0,0 +1,58 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app81; + +import reactor.core.publisher.Mono; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class OperationIdController { + + @GetMapping(path = "/test_0") // gets operationId opIdTest_3 + public Mono opIdTest() { + return null; + } + + @GetMapping(path = "/test_1") // gets operationId opIdTest_2 + public Mono opIdTest(@RequestParam String param) { + return null; + } + + @GetMapping(path = "/test_2") // gets operationId opIdTest_1 + public Mono opIdTest(@RequestParam Integer param) { + return null; + } + + @GetMapping(path = "/test_3") // gets operationId opIdTest + public Mono opIdTest(@RequestParam Boolean param) { + return null; + } + +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app81/SpringDocApp81Test.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app81/SpringDocApp81Test.java new file mode 100644 index 000000000..bf7969153 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app81/SpringDocApp81Test.java @@ -0,0 +1,95 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app81; + +import java.net.URI; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.Comparator; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.concurrent.ThreadLocalRandom; + +import org.junit.jupiter.api.RepeatedTest; +import org.springdoc.webflux.api.OpenApiWebfluxResource; +import test.org.springdoc.api.v30.AbstractCommonTest; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.test.autoconfigure.web.reactive.WebFluxTest; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.http.server.reactive.ServerHttpRequest; +import org.springframework.web.method.HandlerMethod; +import org.springframework.web.reactive.result.method.RequestMappingInfo; +import org.springframework.web.reactive.result.method.RequestMappingInfoHandlerMapping; + +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; +import static org.skyscreamer.jsonassert.JSONAssert.assertEquals; +import static org.springdoc.core.utils.Constants.SPRINGDOC_CACHE_DISABLED; + + +/** + * Tests deterministic creation of operationIds + */ +@WebFluxTest(properties = SPRINGDOC_CACHE_DISABLED + "=true") +public class SpringDocApp81Test extends AbstractCommonTest { + + @Autowired + OpenApiWebfluxResource resource; + + @Autowired + RequestMappingInfoHandlerMapping mappingInfoHandlerMapping; + + @RepeatedTest(10) + public void shouldGenerateOperationIdsDeterministically() throws Exception { + shuffleSpringHandlerMethods(); + + ServerHttpRequest request = mock(ServerHttpRequest.class); + when(request.getURI()).thenReturn(URI.create("http://localhost")); + + String expected = getContent("results/3.0.1/app81.json"); + byte[] openApiBytes =resource.openapiJson(request, "", Locale.US).block(); + String openApi = new String(openApiBytes, StandardCharsets.UTF_8); // for UTF-8 encoding String openApi = resource.openapiJson(request, "", Locale.US).block(); + assertEquals(expected, openApi, true); + } + + private void shuffleSpringHandlerMethods() { + Map handlerMethods = mappingInfoHandlerMapping.getHandlerMethods(); + List> collect = new ArrayList<>(handlerMethods.entrySet()); + collect.sort(Comparator.comparing(a -> ThreadLocalRandom.current().nextBoolean() ? -1 : 1)); + + collect.forEach(e -> mappingInfoHandlerMapping.unregisterMapping(e.getKey())); + collect.forEach(e -> mappingInfoHandlerMapping.registerMapping(e.getKey(), e.getValue().getBean(), e.getValue().getMethod())); + } + + @SpringBootApplication + @ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.v30.app81" }) + static class SpringDocTestApp { + } + +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app82/RoutingConfiguration.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app82/RoutingConfiguration.java new file mode 100644 index 000000000..0fc04f75f --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app82/RoutingConfiguration.java @@ -0,0 +1,65 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app82; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.reactive.function.server.RouterFunction; +import org.springframework.web.reactive.function.server.ServerResponse; + +import static org.springdoc.core.fn.builders.operation.Builder.operationBuilder; +import static org.springdoc.core.utils.Constants.OPERATION_ATTRIBUTE; +import static org.springframework.http.MediaType.APPLICATION_JSON; +import static org.springframework.web.reactive.function.server.RequestPredicates.DELETE; +import static org.springframework.web.reactive.function.server.RequestPredicates.GET; +import static org.springframework.web.reactive.function.server.RequestPredicates.POST; +import static org.springframework.web.reactive.function.server.RequestPredicates.PUT; +import static org.springframework.web.reactive.function.server.RequestPredicates.accept; +import static org.springframework.web.reactive.function.server.RouterFunctions.route; + +@Configuration +public class RoutingConfiguration { + + @Bean + public RouterFunction monoRouterFunction(UserHandler userHandler) { + return route(GET("/api/user/index").and(accept(APPLICATION_JSON)), userHandler::getAll) + .withAttribute(OPERATION_ATTRIBUTE, operationBuilder().beanClass(UserRepository.class).beanMethod("getAllUsers")) + + .and(route(GET("/api/user/{id}").and(accept(APPLICATION_JSON)), userHandler::getUser) + .withAttribute(OPERATION_ATTRIBUTE, operationBuilder().beanClass(UserRepository.class).beanMethod("getUserById"))) + + .and(route(POST("/api/user/post").and(accept(APPLICATION_JSON)), userHandler::postUser) + .withAttribute(OPERATION_ATTRIBUTE, operationBuilder().beanClass(UserRepository.class).beanMethod("saveUser"))) + + .and(route(PUT("/api/user/put").and(accept(APPLICATION_JSON)), userHandler::putUser) + .withAttribute(OPERATION_ATTRIBUTE, operationBuilder().beanClass(UserRepository.class).beanMethod("putUser"))) + + .and(route(DELETE("/api/user/delete/{id}").and(accept(APPLICATION_JSON)), userHandler::deleteUser) + .withAttribute(OPERATION_ATTRIBUTE, operationBuilder().beanClass(UserRepository.class).beanMethod("deleteUser"))); + } + +} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app82/SpringDocApp82Test.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app82/SpringDocApp82Test.java new file mode 100644 index 000000000..9886a28b9 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app82/SpringDocApp82Test.java @@ -0,0 +1,39 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app82; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.ComponentScan; + +public class SpringDocApp82Test extends AbstractSpringDocTest { + + @SpringBootApplication + @ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.v30.app82" }) + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app82/User.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app82/User.java new file mode 100644 index 000000000..aaf36bb74 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app82/User.java @@ -0,0 +1,85 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app82; + +public class User { + private long id; + + private String firstname; + + private String lastname; + + private int age; + + public User() { + } + + public User(long id, String firstname, String lastname, int age) { + this.id = id; + this.firstname = firstname; + this.lastname = lastname; + this.age = age; + } + + public long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getFirstname() { + return firstname; + } + + public void setFirstname(String firstname) { + this.firstname = firstname; + } + + public String getLastname() { + return lastname; + } + + public void setLastname(String lastname) { + this.lastname = lastname; + } + + public int getAge() { + return age; + } + + public void setAge(int age) { + this.age = age; + } + + @Override + public String toString() { + String info = String.format("id = %d, firstname = %s, lastname = %s, age = %d", id, firstname, lastname, age); + return info; + } +} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app82/UserHandler.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app82/UserHandler.java new file mode 100644 index 000000000..f12c82944 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app82/UserHandler.java @@ -0,0 +1,119 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app82; + +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +import org.springframework.http.MediaType; +import org.springframework.stereotype.Component; +import org.springframework.web.reactive.function.server.ServerRequest; +import org.springframework.web.reactive.function.server.ServerResponse; + +import static org.springframework.web.reactive.function.BodyInserters.fromObject; + +@Component +public class UserHandler { + + private final UserRepository customerRepository; + + public UserHandler(UserRepository repository) { + this.customerRepository = repository; + } + + /** + * GET ALL Users + */ + public Mono getAll(ServerRequest request) { + // fetch all customers from repository + Flux customers = customerRepository.getAllUsers(); + + // build response + return ServerResponse.ok().contentType(MediaType.APPLICATION_JSON).body(customers, User.class); + } + + /** + * GET a User by ID + */ + public Mono getUser(ServerRequest request) { + // parse path-variable + long customerId = Long.valueOf(request.queryParam("id").get()); + + // build notFound response + Mono notFound = ServerResponse.notFound().build(); + + // get customer from repository + Mono customerMono = customerRepository.getUserById(customerId); + + // build response + return customerMono + .flatMap(customer -> ServerResponse.ok().contentType(MediaType.APPLICATION_JSON).body(fromObject(customer))) + .switchIfEmpty(notFound); + } + + /** + * POST a User + */ + public Mono postUser(ServerRequest request) { + Mono customer = request.bodyToMono(User.class); + return ServerResponse.ok().build(customerRepository.saveUser(customer)); + } + + /** + * PUT a User + */ + public Mono putUser(ServerRequest request) { + // parse id from path-variable + long customerId = Long.valueOf(request.pathVariable("id")); + + // get customer data from request object + Mono customer = request.bodyToMono(User.class); + + // get customer from repository + Mono responseMono = customerRepository.putUser(customerId, customer); + + // build response + return responseMono + .flatMap(cust -> ServerResponse.ok().contentType(MediaType.APPLICATION_JSON).body(fromObject(cust))); + } + + /** + * DELETE a User + */ + public Mono deleteUser(ServerRequest request) { + // parse id from path-variable + long customerId = Long.valueOf(request.pathVariable("id")); + + // get customer from repository + Mono responseMono = customerRepository.deleteUser(customerId); + + // build response + return responseMono + .flatMap(strMono -> ServerResponse.ok().contentType(MediaType.TEXT_PLAIN).body(fromObject(strMono))); + } + +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app82/UserRepository.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app82/UserRepository.java new file mode 100644 index 000000000..497d298e9 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app82/UserRepository.java @@ -0,0 +1,51 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app82; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.enums.ParameterIn; +import io.swagger.v3.oas.annotations.parameters.RequestBody; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +public interface UserRepository { + + public Mono getUserById(@Parameter(in = ParameterIn.PATH, description = "The user Id") Long id); + + @Operation(description = "get all the users") + public Flux getAllUsers(); + + @Operation(description = "get all the users by firstname") + public Flux getAllUsers(String firstname); + + public Mono saveUser(Mono user); + + public Mono putUser(@Parameter(in = ParameterIn.QUERY) Long id, @RequestBody Mono user); + + public Mono deleteUser(@Parameter(in = ParameterIn.PATH) Long id); +} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app82/UserRepositoryImpl.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app82/UserRepositoryImpl.java new file mode 100644 index 000000000..356831926 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app82/UserRepositoryImpl.java @@ -0,0 +1,98 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app82; + +import java.util.HashMap; +import java.util.Map; + +import jakarta.annotation.PostConstruct; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +import org.springframework.stereotype.Repository; + +@Repository +public class UserRepositoryImpl implements UserRepository { + private Map users = new HashMap(); + + @PostConstruct + public void init() throws Exception { + users.put(Long.valueOf(1), new User(1, "Jack", "Smith", 20)); + users.put(Long.valueOf(2), new User(2, "Peter", "Johnson", 25)); + } + + @Override + public Mono getUserById(Long id) { + return Mono.just(users.get(id)); + } + + @Override + public Flux getAllUsers() { + return Flux.fromIterable(this.users.values()); + } + + @Override + public Flux getAllUsers(String firstname) { + return Flux.fromIterable(this.users.values().stream().filter(user -> user.getFirstname().equals(firstname)).toList()); + } + + @Override + public Mono saveUser(Mono monoUser) { + Mono userMono = monoUser.doOnNext(user -> { + // do post + users.put(user.getId(), user); + + // log on console + System.out.println("########### POST:" + user); + }); + + return userMono.then(); + } + + @Override + public Mono putUser(Long id, Mono monoUser) { + Mono userMono = monoUser.doOnNext(user -> { + // reset user.Id + user.setId(id); + + // do put + users.put(id, user); + + // log on console + System.out.println("########### PUT:" + user); + }); + + return userMono; + } + + @Override + public Mono deleteUser(Long id) { + // delete processing + users.remove(id); + return Mono.just("Delete Succesfully!"); + } +} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app83/Coffee.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app83/Coffee.java new file mode 100644 index 000000000..e9b7bc829 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app83/Coffee.java @@ -0,0 +1,86 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app83; + +import java.util.Objects; + +public class Coffee { + + private String id; + + private String name; + + public Coffee() { + } + + public Coffee(String name) { + this.name = name; + } + + public Coffee(String id, String name) { + this.id = id; + this.name = name; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Coffee coffee = (Coffee) o; + return Objects.equals(id, coffee.id) && + Objects.equals(name, coffee.name); + } + + @Override + public int hashCode() { + return Objects.hash(id, name); + } + + @Override + public String toString() { + return "Coffee{" + + "id='" + id + '\'' + + ", name='" + name + '\'' + + '}'; + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app83/CoffeeOrder.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app83/CoffeeOrder.java new file mode 100644 index 000000000..764b98a22 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app83/CoffeeOrder.java @@ -0,0 +1,74 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app83; + +import java.time.Instant; +import java.util.Objects; + +public class CoffeeOrder { + private String coffeeId; + + private Instant whenOrdered; + + public CoffeeOrder() { + } + + public CoffeeOrder(String coffeeId, Instant whenOrdered) { + this.coffeeId = coffeeId; + this.whenOrdered = whenOrdered; + } + + public String getCoffeeId() { + return coffeeId; + } + + public Instant getWhenOrdered() { + return whenOrdered; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + CoffeeOrder that = (CoffeeOrder) o; + return Objects.equals(coffeeId, that.coffeeId) && + Objects.equals(whenOrdered, that.whenOrdered); + } + + @Override + public int hashCode() { + return Objects.hash(coffeeId, whenOrdered); + } + + @Override + public String toString() { + return "CoffeeOrder{" + + "coffeeId='" + coffeeId + '\'' + + ", whenOrdered=" + whenOrdered + + '}'; + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app83/CoffeeRepository.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app83/CoffeeRepository.java new file mode 100644 index 000000000..c3ed2e077 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app83/CoffeeRepository.java @@ -0,0 +1,52 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app83; + +import org.reactivestreams.Publisher; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +import org.springframework.stereotype.Repository; + +@Repository +public class CoffeeRepository { + Flux deleteAll() { + return null; + } + + Mono findById(String id) { + return null; + } + + Publisher save(Coffee coffee) { + return null; + } + + Flux findAll() { + return null; + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app83/CoffeeService.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app83/CoffeeService.java new file mode 100644 index 000000000..a355a1e82 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app83/CoffeeService.java @@ -0,0 +1,60 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app83; + +import java.time.Duration; +import java.time.Instant; + +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.enums.ParameterIn; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +import org.springframework.stereotype.Service; + +@Service +public class CoffeeService { + private final CoffeeRepository repo; + + public CoffeeService(CoffeeRepository repo) { + this.repo = repo; + } + + Flux getAllCoffees() { + return repo.findAll(); + } + + Mono getCoffeeById(@Parameter(in = ParameterIn.PATH) String id) { + return repo.findById(id); + } + + Flux getOrdersForCoffeeById(@Parameter(in = ParameterIn.PATH) String id) { + return Flux.interval(Duration.ofSeconds(1)) + .onBackpressureDrop() + .map(i -> new CoffeeOrder(id, Instant.now())); + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app83/RouteConfig.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app83/RouteConfig.java new file mode 100644 index 000000000..442697e9e --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app83/RouteConfig.java @@ -0,0 +1,78 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app83; + +import reactor.core.publisher.Mono; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.http.MediaType; +import org.springframework.web.reactive.function.server.RouterFunction; +import org.springframework.web.reactive.function.server.ServerRequest; +import org.springframework.web.reactive.function.server.ServerResponse; + +import static org.springdoc.core.fn.builders.operation.Builder.operationBuilder; +import static org.springdoc.core.utils.Constants.OPERATION_ATTRIBUTE; +import static org.springframework.web.reactive.function.server.RequestPredicates.GET; +import static org.springframework.web.reactive.function.server.RouterFunctions.route; + +@Configuration +public class RouteConfig { + private final CoffeeService service; + + public RouteConfig(CoffeeService service) { + this.service = service; + } + + @Bean + RouterFunction routerFunction() { + return route(GET("/coffees"), this::all) + .withAttribute(OPERATION_ATTRIBUTE, operationBuilder().beanClass(CoffeeService.class).beanMethod("getAllCoffees")) + + .and(route(GET("/coffees/{id}"), this::byId) + .withAttribute(OPERATION_ATTRIBUTE, operationBuilder().beanClass(CoffeeService.class).beanMethod("getCoffeeById"))) + + .and(route(GET("/coffees/{id}/orders"), this::orders) + .withAttribute(OPERATION_ATTRIBUTE, operationBuilder().beanClass(CoffeeService.class).beanMethod("getOrdersForCoffeeById"))); + } + + private Mono all(ServerRequest req) { + return ServerResponse.ok() + .body(service.getAllCoffees(), Coffee.class); + } + + private Mono byId(ServerRequest req) { + return ServerResponse.ok() + .body(service.getCoffeeById(req.pathVariable("id")), Coffee.class); + } + + private Mono orders(ServerRequest req) { + return ServerResponse.ok() + .contentType(MediaType.TEXT_EVENT_STREAM) + .body(service.getOrdersForCoffeeById(req.pathVariable("id")), CoffeeOrder.class); + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app83/SpringDocApp83Test.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app83/SpringDocApp83Test.java new file mode 100644 index 000000000..37d91fa96 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app83/SpringDocApp83Test.java @@ -0,0 +1,39 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app83; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.ComponentScan; + +public class SpringDocApp83Test extends AbstractSpringDocTest { + + @SpringBootApplication + @ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.v30.app83" }) + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app84/Employee.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app84/Employee.java new file mode 100644 index 000000000..1f44e346d --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app84/Employee.java @@ -0,0 +1,50 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app84; + +public class Employee { + + private String id; + + private String name; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app84/EmployeeFunctionalConfig.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app84/EmployeeFunctionalConfig.java new file mode 100644 index 000000000..536e16769 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app84/EmployeeFunctionalConfig.java @@ -0,0 +1,107 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app84; + +import io.swagger.v3.oas.annotations.enums.ParameterIn; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.http.MediaType; +import org.springframework.web.reactive.function.BodyExtractors; +import org.springframework.web.reactive.function.server.RouterFunction; +import org.springframework.web.reactive.function.server.ServerResponse; + +import static org.springdoc.core.fn.builders.apiresponse.Builder.responseBuilder; +import static org.springdoc.core.fn.builders.operation.Builder.operationBuilder; +import static org.springdoc.core.fn.builders.parameter.Builder.parameterBuilder; +import static org.springdoc.core.utils.Constants.OPERATION_ATTRIBUTE; +import static org.springframework.web.reactive.function.server.RequestPredicates.GET; +import static org.springframework.web.reactive.function.server.RequestPredicates.POST; +import static org.springframework.web.reactive.function.server.RequestPredicates.accept; +import static org.springframework.web.reactive.function.server.RouterFunctions.route; +import static org.springframework.web.reactive.function.server.ServerResponse.ok; + +@Configuration +public class EmployeeFunctionalConfig { + + + @Bean + EmployeeRepository employeeRepository() { + return new EmployeeRepository(); + } + + @Bean + RouterFunction getAllEmployeesRoute() { + return route(GET("/employees").and(accept(MediaType.APPLICATION_JSON)), + req -> ok().body( + employeeRepository().findAllEmployees(), Employee.class)) + .withAttribute(OPERATION_ATTRIBUTE, operationBuilder().beanClass(EmployeeRepository.class).beanMethod("findAllEmployees")); + } + + @Bean + RouterFunction getEmployeeByIdRoute() { + return route(GET("/employees/{id}"), + req -> ok().body( + employeeRepository().findEmployeeById(req.pathVariable("id")), Employee.class)) + .withAttribute(OPERATION_ATTRIBUTE, + operationBuilder().operationId("findEmployeeById").summary("Find purchase order by ID").tags(new String[] { "MyEmployee" }) + .parameter(parameterBuilder().in(ParameterIn.PATH).name("id").description("Employee Id")) + .response(responseBuilder().responseCode("200").description("successful operation").implementation(Employee.class)) + .response(responseBuilder().responseCode("400").description("Invalid Employee ID supplied")) + .response(responseBuilder().responseCode("404").description("Employee not found"))); + } + + + @Bean + RouterFunction updateEmployeeRoute() { + return route(POST("/employees/update").and(accept(MediaType.APPLICATION_XML)), + req -> req.body(BodyExtractors.toMono(Employee.class)) + .doOnNext(employeeRepository()::updateEmployee) + .then(ok().build())) + .withAttribute(OPERATION_ATTRIBUTE, operationBuilder().beanClass(EmployeeRepository.class).beanMethod("updateEmployee")); + } + + @Bean + RouterFunction composedRoutes() { + return + route(GET("/employees-composed"), + req -> ok().body( + employeeRepository().findAllEmployees(), Employee.class)) + .withAttribute(OPERATION_ATTRIBUTE, operationBuilder().beanClass(EmployeeRepository.class).beanMethod("findAllEmployees")) + + .and(route(GET("/employees-composed/{id}"), req -> ok().body( + employeeRepository().findEmployeeById(req.pathVariable("id")), Employee.class)) + .withAttribute(OPERATION_ATTRIBUTE, operationBuilder().beanClass(EmployeeRepository.class).beanMethod("findEmployeeById"))) + + .and(route(POST("/employees-composed/update"), + req -> req.body(BodyExtractors.toMono(Employee.class)) + .doOnNext(employeeRepository()::updateEmployee) + .then(ok().build())) + .withAttribute(OPERATION_ATTRIBUTE, operationBuilder().beanClass(EmployeeRepository.class).beanMethod("updateEmployee"))); + } + +} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app84/EmployeeRepository.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app84/EmployeeRepository.java new file mode 100644 index 000000000..dcd40506e --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app84/EmployeeRepository.java @@ -0,0 +1,58 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app84; + +import java.util.Map; + +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.enums.ParameterIn; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +public class EmployeeRepository { + + static Map employeeData; + + static Map employeeAccessData; + + + public Mono findEmployeeById(@Parameter(in = ParameterIn.PATH) String id) { + return Mono.just(employeeData.get(id)); + } + + public Flux findAllEmployees() { + return Flux.fromIterable(employeeData.values()); + } + + public Mono updateEmployee(Employee employee) { + Employee existingEmployee = employeeData.get(employee.getId()); + if (existingEmployee != null) { + existingEmployee.setName(employee.getName()); + } + return Mono.just(existingEmployee); + } +} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app84/SpringDocApp84Test.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app84/SpringDocApp84Test.java new file mode 100644 index 000000000..e77f4f055 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app84/SpringDocApp84Test.java @@ -0,0 +1,39 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app84; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.ComponentScan; + +public class SpringDocApp84Test extends AbstractSpringDocTest { + + @SpringBootApplication + @ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.v30.app84" }) + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app85/SpringDocApp85Test.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app85/SpringDocApp85Test.java new file mode 100644 index 000000000..980c78a60 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app85/SpringDocApp85Test.java @@ -0,0 +1,39 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app85; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.ComponentScan; + +public class SpringDocApp85Test extends AbstractSpringDocTest { + + @SpringBootApplication + @ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.v30.app85" }) + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app85/controller/PersonRouter.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app85/controller/PersonRouter.java new file mode 100644 index 000000000..885847b06 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app85/controller/PersonRouter.java @@ -0,0 +1,65 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app85.controller; + +import test.org.springdoc.api.v30.app85.handler.PersonHandler; +import test.org.springdoc.api.v30.app85.service.PersonService; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.http.MediaType; +import org.springframework.web.reactive.function.server.RouterFunction; +import org.springframework.web.reactive.function.server.ServerResponse; + +import static org.springdoc.core.fn.builders.operation.Builder.operationBuilder; +import static org.springdoc.core.utils.Constants.OPERATION_ATTRIBUTE; +import static org.springframework.web.reactive.function.server.RequestPredicates.DELETE; +import static org.springframework.web.reactive.function.server.RequestPredicates.GET; +import static org.springframework.web.reactive.function.server.RequestPredicates.POST; +import static org.springframework.web.reactive.function.server.RequestPredicates.accept; +import static org.springframework.web.reactive.function.server.RouterFunctions.route; + + +@Configuration +public class PersonRouter { + + @Bean + public RouterFunction personRoute(PersonHandler handler) { + return route(GET("/getAllPersons").and(accept(MediaType.APPLICATION_JSON)), handler::findAll) + .withAttribute(OPERATION_ATTRIBUTE, operationBuilder().beanClass(PersonService.class).beanMethod("getAll")) + + .and(route(GET("/getPerson/{id}").and(accept(MediaType.APPLICATION_STREAM_JSON)), handler::findById) + .withAttribute(OPERATION_ATTRIBUTE, operationBuilder().beanClass(PersonService.class).beanMethod("getById"))) + + .and(route(POST("/createPerson").and(accept(MediaType.APPLICATION_JSON)), handler::save) + .withAttribute(OPERATION_ATTRIBUTE, operationBuilder().beanClass(PersonService.class).beanMethod("save"))) + + .and(route(DELETE("/deletePerson/{id}").and(accept(MediaType.APPLICATION_JSON)), handler::delete) + .withAttribute(OPERATION_ATTRIBUTE, operationBuilder().beanClass(PersonService.class).beanMethod("delete"))); + } + +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app85/controller/PositionRouter.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app85/controller/PositionRouter.java new file mode 100644 index 000000000..c8109ed48 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app85/controller/PositionRouter.java @@ -0,0 +1,79 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app85.controller; + +import io.swagger.v3.oas.annotations.enums.ParameterIn; +import test.org.springdoc.api.v30.app85.entity.Position; +import test.org.springdoc.api.v30.app85.handler.PositionHandler; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.http.MediaType; +import org.springframework.web.reactive.function.server.RouterFunction; +import org.springframework.web.reactive.function.server.ServerResponse; + +import static org.springdoc.core.fn.builders.apiresponse.Builder.responseBuilder; +import static org.springdoc.core.fn.builders.content.Builder.contentBuilder; +import static org.springdoc.core.fn.builders.operation.Builder.operationBuilder; +import static org.springdoc.core.fn.builders.parameter.Builder.parameterBuilder; +import static org.springdoc.core.fn.builders.requestbody.Builder.requestBodyBuilder; +import static org.springdoc.core.utils.Constants.OPERATION_ATTRIBUTE; +import static org.springframework.web.reactive.function.server.RequestPredicates.DELETE; +import static org.springframework.web.reactive.function.server.RequestPredicates.GET; +import static org.springframework.web.reactive.function.server.RequestPredicates.POST; +import static org.springframework.web.reactive.function.server.RequestPredicates.accept; +import static org.springframework.web.reactive.function.server.RouterFunctions.route; + +@Configuration +public class PositionRouter { + + @Bean + public RouterFunction positionRoute(PositionHandler handler) { + return route(GET("/getAllPositions").and(accept(MediaType.APPLICATION_JSON)), handler::findAll) + .withAttribute(OPERATION_ATTRIBUTE, operationBuilder().operationId("findAll").description("Get all positions").tags(new String[] { "positions" }) + .response(responseBuilder().responseCode("200").implementationArray(Position.class))) + + .and(route(GET("/getPosition/{id}").and(accept(MediaType.APPLICATION_STREAM_JSON)), handler::findById) + .withAttribute(OPERATION_ATTRIBUTE, + operationBuilder().operationId("findById").description("Find all").tags(new String[] { "positions" }) + .parameter(parameterBuilder().in(ParameterIn.PATH).name("id")) + .response(responseBuilder().responseCode("200").implementation(Position.class)))) + + .and(route(POST("/createPosition").and(accept(MediaType.APPLICATION_JSON)), handler::save) + .withAttribute(OPERATION_ATTRIBUTE, + operationBuilder().operationId("save").description("Save position").tags(new String[] { "positions" }) + .requestBody(requestBodyBuilder().implementation(Position.class)) + .response(responseBuilder().responseCode("200").implementation(Position.class)))) + + .and(route(DELETE("/deletePosition/{id}").and(accept(MediaType.APPLICATION_JSON)), handler::delete) + .withAttribute(OPERATION_ATTRIBUTE, + operationBuilder().operationId("deleteBy").description("Delete By Id").tags(new String[] { "positions" }) + .parameter(parameterBuilder().in(ParameterIn.PATH).name("id")) + .response(responseBuilder().responseCode("200").content(contentBuilder())))); + } + +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app85/entity/Person.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app85/entity/Person.java new file mode 100644 index 000000000..4e1b8d515 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app85/entity/Person.java @@ -0,0 +1,100 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app85.entity; + +public class Person { + + private String id; + + private Sex sex; + + private String firstName; + + private String lastName; + + private String age; + + private String interests; + + private String email; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public Sex getSex() { + return sex; + } + + public void setSex(Sex sex) { + this.sex = sex; + } + + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } + + public String getAge() { + return age; + } + + public void setAge(String age) { + this.age = age; + } + + public String getInterests() { + return interests; + } + + public void setInterests(String interests) { + this.interests = interests; + } + + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app85/entity/Position.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app85/entity/Position.java new file mode 100644 index 000000000..0276e08de --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app85/entity/Position.java @@ -0,0 +1,80 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app85.entity; + +import java.util.Date; + +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; +import jakarta.validation.constraints.Size; + + +public class Position { + + private String id; + + @NotBlank + @Size(max = 140) + private String positionName; + + private String description; + + @NotNull + private Date createdAt = new Date(); + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getPositionName() { + return positionName; + } + + public void setPositionName(String positionName) { + this.positionName = positionName; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public Date getCreatedAt() { + return createdAt; + } + + public void setCreatedAt(Date createdAt) { + this.createdAt = createdAt; + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app85/entity/Sex.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app85/entity/Sex.java new file mode 100644 index 000000000..557232491 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app85/entity/Sex.java @@ -0,0 +1,31 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app85.entity; + +public enum Sex { + MAN, WOMEN +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app85/exception/PositionNotFoundException.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app85/exception/PositionNotFoundException.java new file mode 100644 index 000000000..acc067a6a --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app85/exception/PositionNotFoundException.java @@ -0,0 +1,34 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app85.exception; + +public class PositionNotFoundException extends RuntimeException { + + public PositionNotFoundException(String positionId) { + super("Position not found with id " + positionId); + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app85/handler/PersonHandler.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app85/handler/PersonHandler.java new file mode 100644 index 000000000..d93bb28bf --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app85/handler/PersonHandler.java @@ -0,0 +1,78 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app85.handler; + +import reactor.core.publisher.Mono; +import test.org.springdoc.api.v30.app85.entity.Person; +import test.org.springdoc.api.v30.app85.service.PersonService; + +import org.springframework.http.MediaType; +import org.springframework.stereotype.Component; +import org.springframework.web.reactive.function.BodyInserters; +import org.springframework.web.reactive.function.server.ServerRequest; +import org.springframework.web.reactive.function.server.ServerResponse; + +import static org.springframework.web.reactive.function.server.ServerResponse.ok; + +@Component +@SuppressWarnings({ "deprecared", "unchecked" }) +public class PersonHandler { + + private final PersonService personService; + + public PersonHandler(PersonService personService) { + this.personService = personService; + } + + public Mono findById(ServerRequest request) { + String id = request.pathVariable("id"); + return ok() + .contentType(MediaType.APPLICATION_JSON) + .body(personService.getById(id), Person.class); + } + + public Mono findAll(ServerRequest request) { + return ok() + .contentType(MediaType.APPLICATION_JSON) + .body(personService.getAll(), Person.class); + } + + public Mono save(ServerRequest request) { + final Mono person = request.bodyToMono(Person.class); + return ok() + .contentType(MediaType.APPLICATION_JSON) + .body(BodyInserters.fromPublisher(person.flatMap(personService::save), Person.class)); + } + + public Mono delete(ServerRequest request) { + String id = request.pathVariable("id"); + return ok() + .contentType(MediaType.APPLICATION_JSON) + .body(personService.delete(id), Void.class); + } + +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app85/handler/PositionHandler.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app85/handler/PositionHandler.java new file mode 100644 index 000000000..fe619ac24 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app85/handler/PositionHandler.java @@ -0,0 +1,56 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app85.handler; + +import reactor.core.publisher.Mono; + +import org.springframework.stereotype.Component; +import org.springframework.web.reactive.function.server.ServerRequest; +import org.springframework.web.reactive.function.server.ServerResponse; + +@Component +public class PositionHandler { + + + public Mono findById(ServerRequest request) { + String id = request.pathVariable("id"); + return null; + } + + public Mono findAll(ServerRequest request) { + return null; + } + + public Mono save(ServerRequest request) { + return null; + } + + public Mono delete(ServerRequest request) { + return null; + } + +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app85/payload/ErrorResponse.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app85/payload/ErrorResponse.java new file mode 100644 index 000000000..5627b175f --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app85/payload/ErrorResponse.java @@ -0,0 +1,45 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app85.payload; + +public class ErrorResponse { + + private String message; + + public ErrorResponse(String message) { + this.message = message; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app85/service/PersonService.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app85/service/PersonService.java new file mode 100644 index 000000000..43128c7a2 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app85/service/PersonService.java @@ -0,0 +1,65 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app85.service; + +import java.util.Objects; + +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.enums.ParameterIn; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; +import test.org.springdoc.api.v30.app85.entity.Person; + +import org.springframework.stereotype.Service; + +@Service +public class PersonService { + + public Flux getAll() { + return null; + } + + public Mono getById(@Parameter(in = ParameterIn.PATH) final String id) { + return null; + } + + public Mono update(@Parameter(in = ParameterIn.PATH) final String id, final Person person) { + return null; + } + + public Mono save(final Person person) { + return null; + } + + public Mono delete(@Parameter(in = ParameterIn.PATH) final String id) { + final Mono dbPerson = getById(id); + if (Objects.isNull(dbPerson)) { + return Mono.empty(); + } + return null; + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app86/Quote.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app86/Quote.java new file mode 100644 index 000000000..8094b5b6e --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app86/Quote.java @@ -0,0 +1,88 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app86; + + +import java.math.BigDecimal; +import java.math.MathContext; +import java.time.Instant; + +public class Quote { + + private static final MathContext MATH_CONTEXT = new MathContext(2); + + private String ticker; + + private BigDecimal price; + + private Instant instant; + + public Quote() { + } + + public Quote(String ticker, BigDecimal price) { + this.ticker = ticker; + this.price = price; + } + + public Quote(String ticker, Double price) { + this(ticker, new BigDecimal(price, MATH_CONTEXT)); + } + + public String getTicker() { + return ticker; + } + + public void setTicker(String ticker) { + this.ticker = ticker; + } + + public BigDecimal getPrice() { + return price; + } + + public void setPrice(BigDecimal price) { + this.price = price; + } + + public Instant getInstant() { + return instant; + } + + public void setInstant(Instant instant) { + this.instant = instant; + } + + @Override + public String toString() { + return "Quote{" + + "ticker='" + ticker + '\'' + + ", price=" + price + + ", instant=" + instant + + '}'; + } +} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app86/QuoteGenerator.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app86/QuoteGenerator.java new file mode 100644 index 000000000..5238ccaa7 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app86/QuoteGenerator.java @@ -0,0 +1,95 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app86; + + +import java.math.BigDecimal; +import java.math.MathContext; +import java.time.Duration; +import java.time.Instant; +import java.util.ArrayList; +import java.util.List; +import java.util.Random; + +import reactor.core.publisher.Flux; + +import org.springframework.stereotype.Component; + +@Component +public class QuoteGenerator { + + private final MathContext mathContext = new MathContext(2); + + private final Random random = new Random(); + + private final List prices = new ArrayList<>(); + + /** + * Bootstraps the generator with tickers and initial prices + */ + public QuoteGenerator() { + this.prices.add(new Quote("CTXS", 82.26)); + this.prices.add(new Quote("DELL", 63.74)); + this.prices.add(new Quote("GOOG", 847.24)); + this.prices.add(new Quote("MSFT", 65.11)); + this.prices.add(new Quote("ORCL", 45.71)); + this.prices.add(new Quote("RHT", 84.29)); + this.prices.add(new Quote("VMW", 92.21)); + } + + + public Flux fetchQuoteStream(Duration period) { + + // We want to emit quotes with a specific period; + // to do so, we create a Flux.interval + return Flux.interval(period) + // In case of back-pressure, drop events + .onBackpressureDrop() + // For each tick, generate a list of quotes + .map(this::generateQuotes) + // "flatten" that List into a Flux + .flatMapIterable(quotes -> quotes) + .log("io.spring.workshop.stockquotes"); + } + + /* + * Create quotes for all tickers at a single instant. + */ + private List generateQuotes(long interval) { + final Instant instant = Instant.now(); + return prices.stream() + .map(baseQuote -> { + BigDecimal priceChange = baseQuote.getPrice() + .multiply(new BigDecimal(0.05 * this.random.nextDouble()), this.mathContext); + Quote result = new Quote(baseQuote.getTicker(), baseQuote.getPrice().add(priceChange)); + result.setInstant(instant); + return result; + }) + .toList(); + } + +} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app86/QuoteHandler.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app86/QuoteHandler.java new file mode 100644 index 000000000..73478b09d --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app86/QuoteHandler.java @@ -0,0 +1,72 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app86; + + +import java.time.Duration; + +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +import org.springframework.http.MediaType; +import org.springframework.stereotype.Component; +import org.springframework.web.reactive.function.BodyInserters; +import org.springframework.web.reactive.function.server.ServerRequest; +import org.springframework.web.reactive.function.server.ServerResponse; + +@Component +public class QuoteHandler { + + private final Flux quoteStream; + + public QuoteHandler(QuoteGenerator quoteGenerator) { + this.quoteStream = quoteGenerator.fetchQuoteStream(Duration.ofMillis(1000)).share(); + } + + public Mono hello(ServerRequest request) { + return ServerResponse.ok().contentType(MediaType.TEXT_PLAIN) + .body(BodyInserters.fromObject("Hello Spring!")); + } + + public Mono echo(ServerRequest request) { + return ServerResponse.ok().contentType(MediaType.TEXT_PLAIN) + .body(request.bodyToMono(String.class), String.class); + } + + public Mono streamQuotes(ServerRequest request) { + return ServerResponse.ok() + .contentType(MediaType.APPLICATION_STREAM_JSON) + .body(this.quoteStream, Quote.class); + } + + public Mono fetchQuotes(ServerRequest request) { + int size = Integer.parseInt(request.queryParam("size").orElse("10")); + return ServerResponse.ok() + .contentType(MediaType.APPLICATION_JSON) + .body(this.quoteStream.take(size), Quote.class); + } +} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app86/QuoteRouter.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app86/QuoteRouter.java new file mode 100644 index 000000000..bcaaf61bf --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app86/QuoteRouter.java @@ -0,0 +1,79 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app86; + +import io.swagger.v3.oas.annotations.enums.ParameterIn; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.reactive.function.server.RouterFunction; +import org.springframework.web.reactive.function.server.ServerResponse; + +import static org.springdoc.core.fn.builders.apiresponse.Builder.responseBuilder; +import static org.springdoc.core.fn.builders.operation.Builder.operationBuilder; +import static org.springdoc.core.fn.builders.parameter.Builder.parameterBuilder; +import static org.springdoc.core.fn.builders.requestbody.Builder.requestBodyBuilder; +import static org.springdoc.core.utils.Constants.OPERATION_ATTRIBUTE; +import static org.springframework.http.MediaType.APPLICATION_JSON; +import static org.springframework.http.MediaType.APPLICATION_STREAM_JSON; +import static org.springframework.http.MediaType.TEXT_PLAIN; +import static org.springframework.web.reactive.function.server.RequestPredicates.GET; +import static org.springframework.web.reactive.function.server.RequestPredicates.POST; +import static org.springframework.web.reactive.function.server.RequestPredicates.accept; +import static org.springframework.web.reactive.function.server.RequestPredicates.contentType; +import static org.springframework.web.reactive.function.server.RouterFunctions.route; + +@Configuration +public class QuoteRouter { + + @Bean + public RouterFunction myroute(QuoteHandler quoteHandler) { + return route(GET("/hello").and(accept(TEXT_PLAIN)), quoteHandler::hello) + .withAttribute(OPERATION_ATTRIBUTE, operationBuilder().operationId("hello").response(responseBuilder().responseCode("200"))) + + .and(route(POST("/echo").and(accept(TEXT_PLAIN).and(contentType(TEXT_PLAIN))), quoteHandler::echo) + .withAttribute(OPERATION_ATTRIBUTE, operationBuilder().operationId("echo") + .requestBody(requestBodyBuilder().implementation(String.class)) + .response(responseBuilder().responseCode("200").implementation(String.class)))) + + .and(route(POST("/echo").and(accept(APPLICATION_JSON).and(contentType(APPLICATION_JSON))), quoteHandler::echo) + .withAttribute(OPERATION_ATTRIBUTE, operationBuilder().operationId("echo") + .requestBody(requestBodyBuilder().implementation(String.class)) + .response(responseBuilder().responseCode("200").implementation(String.class))) + ) + + .and(route(GET("/quotes").and(accept(APPLICATION_JSON)), quoteHandler::fetchQuotes) + .withAttribute(OPERATION_ATTRIBUTE, operationBuilder().operationId("fetchQuotes") + .parameter(parameterBuilder().in(ParameterIn.QUERY).name("size").implementation(String.class)) + .response(responseBuilder().responseCode("200").implementationArray(Quote.class)))) + + .and(route(GET("/quotes").and(accept(APPLICATION_STREAM_JSON)), quoteHandler::streamQuotes) + .withAttribute(OPERATION_ATTRIBUTE, operationBuilder().operationId("fetchQuotes") + .response(responseBuilder().responseCode("200").implementation(Quote.class)))); + } + +} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app86/SpringDocApp86Test.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app86/SpringDocApp86Test.java new file mode 100644 index 000000000..07ef2e96d --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app86/SpringDocApp86Test.java @@ -0,0 +1,39 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app86; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.ComponentScan; + +public class SpringDocApp86Test extends AbstractSpringDocTest { + + @SpringBootApplication + @ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.v30.app86" }) + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app87/Book.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app87/Book.java new file mode 100644 index 000000000..a092666db --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app87/Book.java @@ -0,0 +1,66 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app87; + +public class Book { + + private String id; + + private String title; + + private String author; + + public Book(String id, String title, String author) { + this.id = id; + this.title = title; + this.author = author; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getAuthor() { + return author; + } + + public void setAuthor(String author) { + this.author = author; + } +} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app87/BookRepository.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app87/BookRepository.java new file mode 100644 index 000000000..4203eaf7d --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app87/BookRepository.java @@ -0,0 +1,44 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app87; + +import reactor.core.publisher.Flux; + +import org.springframework.stereotype.Component; + +@Component +public class BookRepository { + + + Flux findByAuthor(String author) { + return Flux.just(new Book("1", "title1", "author1")); + } + + Flux findAll() { + return Flux.just(new Book("2", "title2", "author2")); + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app87/BookRouter.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app87/BookRouter.java new file mode 100644 index 000000000..9468ab6ce --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app87/BookRouter.java @@ -0,0 +1,60 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app87; + +import io.swagger.v3.oas.annotations.enums.ParameterIn; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.http.MediaType; +import org.springframework.web.reactive.function.server.RouterFunction; + +import static org.springdoc.core.fn.builders.operation.Builder.operationBuilder; +import static org.springdoc.core.fn.builders.parameter.Builder.parameterBuilder; +import static org.springdoc.core.utils.Constants.OPERATION_ATTRIBUTE; +import static org.springframework.web.reactive.function.server.RequestPredicates.GET; +import static org.springframework.web.reactive.function.server.RequestPredicates.accept; +import static org.springframework.web.reactive.function.server.RouterFunctions.route; +import static org.springframework.web.reactive.function.server.ServerResponse.ok; + +@Configuration +class BookRouter { + + @Bean + RouterFunction routes(BookRepository br) { + return route(GET("/books").and(accept(MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML)), req -> ok().body(br.findAll(), Book.class)) + .withAttribute(OPERATION_ATTRIBUTE, operationBuilder().beanClass(BookRepository.class).beanMethod("findAll")) + + .and(route(GET("/books").and(accept(MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN)), req -> ok().body(br.findAll(), Book.class)) + .withAttribute(OPERATION_ATTRIBUTE, operationBuilder().beanClass(BookRepository.class).beanMethod("findAll"))) + + .and(route(GET("/books/{author}"), req -> ok().body(br.findByAuthor(req.pathVariable("author")), Book.class)) + .withAttribute(OPERATION_ATTRIBUTE, operationBuilder() + .beanClass(BookRepository.class).beanMethod("findByAuthor") + .operationId("findByAuthor").parameter(parameterBuilder().in(ParameterIn.PATH).name("author")))); + } +} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app87/SpringDocApp87Test.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app87/SpringDocApp87Test.java new file mode 100644 index 000000000..16e2190f5 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app87/SpringDocApp87Test.java @@ -0,0 +1,39 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app87; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.ComponentScan; + +public class SpringDocApp87Test extends AbstractSpringDocTest { + + @SpringBootApplication + @ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.v30.app87" }) + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app88/Post.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app88/Post.java new file mode 100644 index 000000000..f4a356ebb --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app88/Post.java @@ -0,0 +1,79 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app88; + +import java.time.LocalDateTime; + +public class Post { + + private String id; + + private String title; + + private String content; + + private LocalDateTime createdDate; + + public Post(String id, String title, String content) { + this.id = id; + this.title = title; + this.content = content; + this.createdDate = LocalDateTime.now(); + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } + + public LocalDateTime getCreatedDate() { + return createdDate; + } + + public void setCreatedDate(LocalDateTime createdDate) { + this.createdDate = createdDate; + } +} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app88/PostHandler.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app88/PostHandler.java new file mode 100644 index 000000000..a88c70129 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app88/PostHandler.java @@ -0,0 +1,83 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app88; + + +import java.net.URI; + +import reactor.core.publisher.Mono; + +import org.springframework.stereotype.Component; +import org.springframework.web.reactive.function.server.ServerRequest; +import org.springframework.web.reactive.function.server.ServerResponse; + +@Component +class PostHandler { + + private final PostRepository posts; + + public PostHandler(PostRepository posts) { + this.posts = posts; + } + + public Mono all(ServerRequest req) { + return ServerResponse.ok().body(this.posts.findAll(), Post.class); + } + + public Mono create(ServerRequest req) { + return req.bodyToMono(Post.class) + .flatMap(post -> this.posts.save(post)) + .flatMap(p -> ServerResponse.created(URI.create("/posts/" + p.getId())).build()); + } + + public Mono get(ServerRequest req) { + return this.posts.findById(req.pathVariable("id")) + .flatMap(post -> ServerResponse.ok().body(Mono.just(post), Post.class)) + .switchIfEmpty(ServerResponse.notFound().build()); + } + + public Mono update(ServerRequest req) { + + return Mono + .zip( + (data) -> { + Post p = (Post) data[0]; + Post p2 = (Post) data[1]; + p.setTitle(p2.getTitle()); + p.setContent(p2.getContent()); + return p; + }, + this.posts.findById(req.pathVariable("id")), + req.bodyToMono(Post.class) + ) + .cast(Post.class) + .flatMap(post -> this.posts.save(post)) + .flatMap(post -> ServerResponse.noContent().build()); + + } + +} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app88/PostRepository.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app88/PostRepository.java new file mode 100644 index 000000000..91559d109 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app88/PostRepository.java @@ -0,0 +1,53 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app88; + +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +import org.springframework.stereotype.Component; + +@Component +public class PostRepository { + + public Flux findByAuthor(String author) { + return Flux.just(new Post("1", "title1", "author1")); + } + + public Flux findAll() { + return Flux.just(new Post("2", "title2", "author2")); + } + + public Mono findById(String id) { + return Mono.just(new Post("3", "title2", "author2")); + } + + public Mono save(Post post) { + return Mono.just(new Post("4", "title2", "author2")); + } + +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app88/PostRouter.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app88/PostRouter.java new file mode 100644 index 000000000..1cbb475ab --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app88/PostRouter.java @@ -0,0 +1,77 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app88; + +import io.swagger.v3.oas.annotations.enums.ParameterIn; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.reactive.function.server.RouterFunction; +import org.springframework.web.reactive.function.server.ServerResponse; + +import static org.springdoc.core.fn.builders.apiresponse.Builder.responseBuilder; +import static org.springdoc.core.fn.builders.operation.Builder.operationBuilder; +import static org.springdoc.core.fn.builders.parameter.Builder.parameterBuilder; +import static org.springdoc.core.fn.builders.requestbody.Builder.requestBodyBuilder; +import static org.springdoc.core.utils.Constants.OPERATION_ATTRIBUTE; +import static org.springframework.web.reactive.function.server.RequestPredicates.GET; +import static org.springframework.web.reactive.function.server.RequestPredicates.POST; +import static org.springframework.web.reactive.function.server.RequestPredicates.PUT; +import static org.springframework.web.reactive.function.server.RequestPredicates.queryParam; +import static org.springframework.web.reactive.function.server.RouterFunctions.route; + +@Configuration +class PostRouter { + + @Bean + public RouterFunction routes(PostHandler postController) { + return route(GET("/posts").and(queryParam("key", "value")), postController::all) + .withAttribute(OPERATION_ATTRIBUTE, + operationBuilder().operationId("all") + .parameter(parameterBuilder().name("key").description("sample description")) + .parameter(parameterBuilder().name("test").description("sample desc")) + .response(responseBuilder().responseCode("200").implementationArray(Post.class))) + + .and(route(POST("/posts"), postController::create) + .withAttribute(OPERATION_ATTRIBUTE, + operationBuilder().operationId("create") + .requestBody(requestBodyBuilder().implementation(Post.class)) + .response(responseBuilder().responseCode("201")))) + + .and(route(GET("/posts/{id}"), postController::get) + .withAttribute(OPERATION_ATTRIBUTE, + operationBuilder().operationId("get") + .parameter(parameterBuilder().in(ParameterIn.PATH).name("id")) + .response(responseBuilder().responseCode("200").implementation(Post.class)))) + + .and(route(PUT("/posts/{id}"), postController::update) + .withAttribute(OPERATION_ATTRIBUTE, + operationBuilder().operationId("update") + .parameter(parameterBuilder().in(ParameterIn.PATH).name("id")) + .response(responseBuilder().responseCode("202").implementation(Post.class)))); + } +} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app88/SpringDocApp88Test.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app88/SpringDocApp88Test.java new file mode 100644 index 000000000..6d4362639 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app88/SpringDocApp88Test.java @@ -0,0 +1,39 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app88; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.ComponentScan; + +public class SpringDocApp88Test extends AbstractSpringDocTest { + + @SpringBootApplication + @ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.v30.app88" }) + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app89/Book.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app89/Book.java new file mode 100644 index 000000000..b7ae26b03 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app89/Book.java @@ -0,0 +1,66 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app89; + +public class Book { + + private String id; + + private String title; + + private String author; + + public Book(String id, String title, String author) { + this.id = id; + this.title = title; + this.author = author; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getAuthor() { + return author; + } + + public void setAuthor(String author) { + this.author = author; + } +} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app89/BookRepository.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app89/BookRepository.java new file mode 100644 index 000000000..f6a90043c --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app89/BookRepository.java @@ -0,0 +1,44 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app89; + +import reactor.core.publisher.Flux; + +import org.springframework.stereotype.Component; + +@Component +public class BookRepository { + + + Flux findByAuthor(String author) { + return Flux.just(new Book("1", "title1", "author1")); + } + + Flux findAll() { + return Flux.just(new Book("2", "title2", "author2")); + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app89/BookRouter.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app89/BookRouter.java new file mode 100644 index 000000000..a61aa59fe --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app89/BookRouter.java @@ -0,0 +1,109 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app89; + +import io.swagger.v3.oas.annotations.enums.ParameterIn; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.http.MediaType; +import org.springframework.web.reactive.function.server.RouterFunction; + +import static org.springdoc.core.fn.builders.operation.Builder.operationBuilder; +import static org.springdoc.core.fn.builders.parameter.Builder.parameterBuilder; +import static org.springdoc.core.utils.Constants.OPERATION_ATTRIBUTE; +import static org.springframework.web.reactive.function.server.RequestPredicates.GET; +import static org.springframework.web.reactive.function.server.RequestPredicates.accept; +import static org.springframework.web.reactive.function.server.RequestPredicates.path; +import static org.springframework.web.reactive.function.server.RouterFunctions.nest; +import static org.springframework.web.reactive.function.server.RouterFunctions.route; +import static org.springframework.web.reactive.function.server.ServerResponse.ok; + +@Configuration +class BookRouter { + + @Bean + RouterFunction routes(BookRepository br) { + return nest(path("/greeter").and(path("/greeter2")), + route(GET("/books").and(accept(MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML)), req -> ok().body(br.findAll(), Book.class)) + .withAttribute(OPERATION_ATTRIBUTE, getFindAll()) + + .and(route(GET("/books").and(accept(MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN)), req -> ok().body(br.findAll(), Book.class)) + .withAttribute(OPERATION_ATTRIBUTE, getFindAll())) + + .and(route(GET("/books/{author}"), req -> ok().body(br.findByAuthor(req.pathVariable("author")), Book.class)) + .withAttribute(OPERATION_ATTRIBUTE, getRouterAttribute())) + ); + } + + @Bean + RouterFunction routes1(BookRepository br) { + return nest(accept(MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML), + route(GET("/books"), req -> ok().body(br.findAll(), Book.class)) + .withAttribute(OPERATION_ATTRIBUTE, getFindAll()) + + .and(route(GET("/books/{author}"), req -> ok().body(br.findByAuthor(req.pathVariable("author")), Book.class)) + .withAttribute(OPERATION_ATTRIBUTE, getRouterAttribute()))); + } + + @Bean + RouterFunction routes3(BookRepository br) { + return nest(path("/greeter").or(path("/greeter2")), + route(GET("/books").and(accept(MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML)), req -> ok().body(br.findAll(), Book.class)) + .withAttribute(OPERATION_ATTRIBUTE, getFindAll()) + + + .and(route(GET("/books").and(accept(MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN)), req -> ok().body(br.findAll(), Book.class)) + .withAttribute(OPERATION_ATTRIBUTE, getFindAll())) + + .and(route(GET("/books/{author}"), req -> ok().body(br.findByAuthor(req.pathVariable("author")), Book.class)) + .withAttribute(OPERATION_ATTRIBUTE, getRouterAttribute()))); + } + + @Bean + RouterFunction routes4(BookRepository br) { + return nest(path("/test"), nest(path("/greeter").and(path("/greeter2")), + route(GET("/books").and(accept(MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML)), req -> ok().body(br.findAll(), Book.class)) + .withAttribute(OPERATION_ATTRIBUTE, getFindAll()) + + .and(route(GET("/books").and(accept(MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN)), req -> ok().body(br.findAll(), Book.class)) + .withAttribute(OPERATION_ATTRIBUTE, getFindAll())) + + .and(route(GET("/books/{author}"), req -> ok().body(br.findByAuthor(req.pathVariable("author")), Book.class)) + .withAttribute(OPERATION_ATTRIBUTE, getRouterAttribute())))); + } + + private org.springdoc.core.fn.builders.operation.Builder getFindAll() { + return operationBuilder().beanClass(BookRepository.class).beanMethod("findAll"); + } + + private org.springdoc.core.fn.builders.operation.Builder getRouterAttribute() { + return operationBuilder() + .operationId("findByAuthor").parameter(parameterBuilder().name("author").in(ParameterIn.PATH)) + .beanClass(BookRepository.class).beanMethod("findByAuthor"); + } +} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app89/SpringDocApp89Test.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app89/SpringDocApp89Test.java new file mode 100644 index 000000000..817e4fbf2 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app89/SpringDocApp89Test.java @@ -0,0 +1,39 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app89; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.ComponentScan; + +public class SpringDocApp89Test extends AbstractSpringDocTest { + + @SpringBootApplication + @ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.v30.app89" }) + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app90/HelloRouter.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app90/HelloRouter.java new file mode 100644 index 000000000..8c600dca7 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app90/HelloRouter.java @@ -0,0 +1,52 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app90; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.reactive.function.server.RouterFunction; + +import static org.springdoc.core.fn.builders.apiresponse.Builder.responseBuilder; +import static org.springdoc.core.fn.builders.parameter.Builder.parameterBuilder; +import static org.springdoc.webflux.core.fn.SpringdocRouteBuilder.route; +import static test.org.springdoc.api.v30.AbstractSpringDocTest.HANDLER_FUNCTION; + +@Configuration +class HelloRouter { + + @Bean + RouterFunction routes() { + return route().GET("/foo", HANDLER_FUNCTION, ops -> ops + .operationId("hello") + .parameter(parameterBuilder().name("key1").description("My key1 description")) + .parameter(parameterBuilder().name("key2").description("My key2 description")) + .response(responseBuilder().responseCode("200").description("This is normal response description")) + .response(responseBuilder().responseCode("404").description("This is another response description")) + ).build(); + } + +} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app90/SpringDocApp90Test.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app90/SpringDocApp90Test.java new file mode 100644 index 000000000..41b3ce03a --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app90/SpringDocApp90Test.java @@ -0,0 +1,39 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app90; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.ComponentScan; + +public class SpringDocApp90Test extends AbstractSpringDocTest { + + @SpringBootApplication + @ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.v30.app90" }) + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app90/book/BookRouter.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app90/book/BookRouter.java new file mode 100644 index 000000000..e5bda3d5a --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app90/book/BookRouter.java @@ -0,0 +1,147 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app90.book; + +import java.util.function.Consumer; + +import io.swagger.v3.oas.annotations.enums.ParameterIn; +import reactor.core.publisher.Flux; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.http.MediaType; +import org.springframework.stereotype.Component; +import org.springframework.web.reactive.function.server.RouterFunction; + +import static org.springdoc.core.fn.builders.parameter.Builder.parameterBuilder; +import static org.springdoc.webflux.core.fn.SpringdocRouteBuilder.route; +import static org.springframework.web.reactive.function.server.RequestPredicates.accept; +import static org.springframework.web.reactive.function.server.RequestPredicates.path; +import static org.springframework.web.reactive.function.server.RouterFunctions.nest; +import static test.org.springdoc.api.v30.AbstractSpringDocTest.HANDLER_FUNCTION; + +@Configuration +class BookRouter { + + + @Bean + RouterFunction bookRoute(BookRepository br) { + return route().GET("/books", accept(MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML), HANDLER_FUNCTION, ops -> ops.operationId("findAll").tag("book") + .beanClass(BookRepository.class).beanMethod("findAll")).build() + + .and(route().GET("/books", accept(MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN), HANDLER_FUNCTION, + ops -> ops.operationId("findAll").tag("book").beanClass(BookRepository.class).beanMethod("findAll")).build()) + + .and(route().GET("/books/{author}", HANDLER_FUNCTION, ops -> ops.tag("book") + .beanClass(BookRepository.class).beanMethod("findByAuthor") + .operationId("findByAuthor").tag("book").parameter(parameterBuilder().in(ParameterIn.PATH).name("author"))).build()); + } + + @Bean + RouterFunction routes2() { + return nest(path("/greeter").and(path("/greeter2")), + route().GET("/books", accept(MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML), HANDLER_FUNCTION, getOperation1()).build()) + + .and(route().GET("/books/nest", accept(MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN), HANDLER_FUNCTION, getOperation1()).build()) + + .and(route().GET("/books/nest/{author}", HANDLER_FUNCTION, getOperation2()).build()); + } + + @Bean + RouterFunction routes4() { + return nest(path("/test"), nest(path("/greeter").and(path("/greeter2")), + route().GET("/books", accept(MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML), HANDLER_FUNCTION, getOperation1()).build() + + .and(route().GET("/books", accept(MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN), HANDLER_FUNCTION, getOperation1()).build()) + + .and(route().GET("/books/{author}", HANDLER_FUNCTION, getOperation2()).build()))); + } + + + private Consumer getOperation1() { + return ops -> ops.operationId("findAll").tag("book").beanClass(BookRepository.class).beanMethod("findAll"); + } + + private Consumer getOperation2() { + return ops -> ops.operationId("findAll").tag("book") + .operationId("findByAuthor").parameter(parameterBuilder().name("author").in(ParameterIn.PATH)) + .beanClass(BookRepository.class).beanMethod("findByAuthor"); + } + + + @Component + class BookRepository { + + Flux findByAuthor(String author) { + return Flux.just(new Book("1", "title1", "author1")); + } + + Flux findAll() { + return Flux.just(new Book("2", "title2", "author2")); + } + } + + class Book { + + private String id; + + private String title; + + private String author; + + public Book(String id, String title, String author) { + this.id = id; + this.title = title; + this.author = author; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getAuthor() { + return author; + } + + public void setAuthor(String author) { + this.author = author; + } + } + +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app90/employee/Employee.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app90/employee/Employee.java new file mode 100644 index 000000000..9e1f09071 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app90/employee/Employee.java @@ -0,0 +1,50 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app90.employee; + +public class Employee { + + private String id; + + private String name; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app90/employee/EmployeeRepository.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app90/employee/EmployeeRepository.java new file mode 100644 index 000000000..9fc792d0b --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app90/employee/EmployeeRepository.java @@ -0,0 +1,58 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app90.employee; + +import java.util.Map; + +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.enums.ParameterIn; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +public class EmployeeRepository { + + static Map employeeData; + + static Map employeeAccessData; + + + public Mono findEmployeeById(@Parameter(in = ParameterIn.PATH) String id) { + return Mono.just(employeeData.get(id)); + } + + public Flux findAllEmployees() { + return Flux.fromIterable(employeeData.values()); + } + + public Mono updateEmployee(Employee employee) { + Employee existingEmployee = employeeData.get(employee.getId()); + if (existingEmployee != null) { + existingEmployee.setName(employee.getName()); + } + return Mono.just(existingEmployee); + } +} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app90/employee/EmployeeRouter.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app90/employee/EmployeeRouter.java new file mode 100644 index 000000000..5b156b17c --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app90/employee/EmployeeRouter.java @@ -0,0 +1,55 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app90.employee; + +import io.swagger.v3.oas.annotations.enums.ParameterIn; +import test.org.springdoc.api.v30.app84.Employee; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.reactive.function.server.RouterFunction; +import org.springframework.web.reactive.function.server.ServerResponse; + +import static org.springdoc.core.fn.builders.apiresponse.Builder.responseBuilder; +import static org.springdoc.core.fn.builders.parameter.Builder.parameterBuilder; +import static org.springdoc.webflux.core.fn.SpringdocRouteBuilder.route; +import static test.org.springdoc.api.v30.AbstractSpringDocTest.HANDLER_FUNCTION; + +@Configuration +class EmployeeRouter { + + @Bean + RouterFunction getEmployeeByIdRoute() { + return route().GET("/employees/{id}", HANDLER_FUNCTION, ops -> ops.tag("employee") + .operationId("findEmployeeById").summary("Find purchase order by ID").tags(new String[] { "MyEmployee" }) + .parameter(parameterBuilder().in(ParameterIn.PATH).name("id").description("Employee Id")) + .response(responseBuilder().responseCode("200").description("successful operation").implementation(Employee.class)) + .response(responseBuilder().responseCode("400").description("Invalid Employee ID supplied")) + .response(responseBuilder().responseCode("404").description("Employee not found"))).build(); + } + +} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app90/position/PositionRouter.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app90/position/PositionRouter.java new file mode 100644 index 000000000..624202706 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app90/position/PositionRouter.java @@ -0,0 +1,69 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app90.position; + +import io.swagger.v3.oas.annotations.enums.ParameterIn; +import test.org.springdoc.api.v30.app85.entity.Position; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.http.MediaType; +import org.springframework.web.reactive.function.server.RouterFunction; +import org.springframework.web.reactive.function.server.ServerResponse; + +import static org.springdoc.core.fn.builders.apiresponse.Builder.responseBuilder; +import static org.springdoc.core.fn.builders.parameter.Builder.parameterBuilder; +import static org.springdoc.core.fn.builders.requestbody.Builder.requestBodyBuilder; +import static org.springdoc.webflux.core.fn.SpringdocRouteBuilder.route; +import static org.springframework.web.reactive.function.server.RequestPredicates.accept; +import static test.org.springdoc.api.v30.AbstractSpringDocTest.HANDLER_FUNCTION; + +@Configuration +class PositionRouter { + + @Bean + public RouterFunction positionRoute() { + return route().GET("/getAllPositions", accept(MediaType.APPLICATION_JSON), HANDLER_FUNCTION, ops -> ops + .operationId("findAll").description("Get all positions").tags(new String[] { "positions" }) + .response(responseBuilder().responseCode("200").implementationArray(Position.class))).build() + + .and(route().GET("/getPosition/{id}", accept(MediaType.APPLICATION_STREAM_JSON), HANDLER_FUNCTION, ops -> ops + .operationId("findById").description("Find all").tags(new String[] { "positions" }) + .parameter(parameterBuilder().in(ParameterIn.PATH).name("id")) + .response(responseBuilder().responseCode("200").implementation(Position.class))).build()) + + .and(route().POST("/createPosition", accept(MediaType.APPLICATION_JSON), HANDLER_FUNCTION, ops -> ops + .operationId("save").description("Save position").tags(new String[] { "positions" }) + .requestBody(requestBodyBuilder().implementation(Position.class)) + .response(responseBuilder().responseCode("200").implementation(Position.class))).build()) + + .and(route().DELETE("/deletePosition/{id}", accept(MediaType.APPLICATION_JSON), HANDLER_FUNCTION, ops -> ops + .operationId("deleteBy").description("Delete By Id").tags(new String[] { "positions" }) + .parameter(parameterBuilder().in(ParameterIn.PATH).name("id")) + .response(responseBuilder().responseCode("200").content(org.springdoc.core.fn.builders.content.Builder.contentBuilder()))).build()); + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app90/quotes/QuotesRouter.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app90/quotes/QuotesRouter.java new file mode 100644 index 000000000..540573836 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v30/app90/quotes/QuotesRouter.java @@ -0,0 +1,133 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app90.quotes; + +import java.math.BigDecimal; +import java.math.MathContext; +import java.time.Instant; + +import io.swagger.v3.oas.annotations.enums.ParameterIn; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.reactive.function.server.RouterFunction; +import org.springframework.web.reactive.function.server.ServerResponse; + +import static org.springdoc.core.fn.builders.apiresponse.Builder.responseBuilder; +import static org.springdoc.core.fn.builders.parameter.Builder.parameterBuilder; +import static org.springdoc.core.fn.builders.requestbody.Builder.requestBodyBuilder; +import static org.springdoc.webflux.core.fn.SpringdocRouteBuilder.route; +import static org.springframework.http.MediaType.APPLICATION_JSON; +import static org.springframework.http.MediaType.APPLICATION_STREAM_JSON; +import static org.springframework.http.MediaType.TEXT_PLAIN; +import static org.springframework.web.reactive.function.server.RequestPredicates.accept; +import static org.springframework.web.reactive.function.server.RequestPredicates.contentType; +import static test.org.springdoc.api.v30.AbstractSpringDocTest.HANDLER_FUNCTION; + +@Configuration +class QuotesRouter { + + @Bean + RouterFunction myroute() { + return route().GET("/hello", accept(TEXT_PLAIN), HANDLER_FUNCTION, ops -> ops.tag("quotes") + .operationId("hello").response(responseBuilder().responseCode("200"))).build() + + .and(route().POST("/echo", accept(TEXT_PLAIN).and(contentType(TEXT_PLAIN)), HANDLER_FUNCTION, ops -> ops.tag("quotes") + .operationId("echo") + .requestBody(requestBodyBuilder().implementation(String.class)) + .response(responseBuilder().responseCode("200").implementation(String.class))).build()) + + .and(route().POST("/echo", accept(APPLICATION_JSON).and(contentType(APPLICATION_JSON)), HANDLER_FUNCTION, ops -> ops.tag("quotes") + .operationId("echo") + .requestBody(requestBodyBuilder().implementation(String.class)) + .response(responseBuilder().responseCode("200").implementation(String.class))).build()) + + .and(route().GET("/quotes", accept(APPLICATION_JSON), HANDLER_FUNCTION, ops -> ops.tag("quotes") + .operationId("fetchQuotes") + .parameter(parameterBuilder().in(ParameterIn.QUERY).name("size").implementation(String.class)) + .response(responseBuilder().responseCode("200").implementationArray(Quote.class))).build()) + + .and(route().GET("/quotes", accept(APPLICATION_STREAM_JSON), HANDLER_FUNCTION, ops -> ops.tag("quotes") + .operationId("fetchQuotes") + .response(responseBuilder().responseCode("200").implementation(Quote.class))).build()); + } + + + class Quote { + + private String ticker; + + private BigDecimal price; + + private Instant instant; + + public Quote() { + } + + public Quote(String ticker, BigDecimal price) { + this.ticker = ticker; + this.price = price; + } + + public Quote(String ticker, Double price) { + this(ticker, new BigDecimal(price, new MathContext(2))); + } + + public String getTicker() { + return ticker; + } + + public void setTicker(String ticker) { + this.ticker = ticker; + } + + public BigDecimal getPrice() { + return price; + } + + public void setPrice(BigDecimal price) { + this.price = price; + } + + public Instant getInstant() { + return instant; + } + + public void setInstant(Instant instant) { + this.instant = instant; + } + + @Override + public String toString() { + return "Quote{" + + "ticker='" + ticker + '\'' + + ", price=" + price + + ", instant=" + instant + + '}'; + } + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/AbstractCommonTest.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/AbstractCommonTest.java new file mode 100644 index 000000000..4dedd2868 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/AbstractCommonTest.java @@ -0,0 +1,61 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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; + +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.reactive.AutoConfigureWebTestClient; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.web.reactive.server.WebTestClient; + +@AutoConfigureWebTestClient(timeout = "3600000") +@ActiveProfiles("test") +public abstract class AbstractCommonTest { + + protected static final Logger LOGGER = LoggerFactory.getLogger(AbstractCommonTest.class); + + @Autowired + protected WebTestClient webTestClient; + + protected String getContent(String fileName) { + try { + Path path = Paths.get(AbstractCommonTest.class.getClassLoader().getResource(fileName).toURI()); + byte[] fileBytes = Files.readAllBytes(path); + return new String(fileBytes, StandardCharsets.UTF_8); + } + catch (Exception e) { + throw new RuntimeException("Failed to read file: " + fileName, e); + } + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/AbstractSpringDocTest.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/AbstractSpringDocTest.java new file mode 100644 index 000000000..ccbc9f1aa --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/AbstractSpringDocTest.java @@ -0,0 +1,68 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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; + +import org.junit.jupiter.api.Test; +import org.springdoc.core.utils.Constants; + +import org.springframework.boot.test.autoconfigure.web.reactive.AutoConfigureWebTestClient; +import org.springframework.boot.test.autoconfigure.web.reactive.WebFluxTest; +import org.springframework.test.web.reactive.server.EntityExchangeResult; +import org.springframework.web.reactive.function.server.HandlerFunction; +import org.springframework.web.reactive.function.server.ServerResponse; + +import static org.skyscreamer.jsonassert.JSONAssert.assertEquals; + + +@WebFluxTest +@AutoConfigureWebTestClient(timeout = "3600000") +public abstract class AbstractSpringDocTest extends AbstractCommonTest { + + public static final HandlerFunction HANDLER_FUNCTION = request -> ServerResponse.ok().build(); + + protected String groupName = ""; + + + @Test + void testApp() throws Exception { + String result = null; + try { + EntityExchangeResult getResult = webTestClient.get().uri(Constants.DEFAULT_API_DOCS_URL + groupName).exchange() + .expectStatus().isOk().expectBody().returnResult(); + + result = new String(getResult.getResponseBody()); + String className = getClass().getSimpleName(); + String testNumber = className.replaceAll("[^0-9]", ""); + String expected = getContent("results/3.1.0/app" + testNumber + ".json"); + assertEquals(expected, result, true); + } + catch (AssertionError e) { + LOGGER.error(result); + throw e; + } + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app102/InheritedRequestParams.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app102/InheritedRequestParams.java new file mode 100644 index 000000000..88b425548 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app102/InheritedRequestParams.java @@ -0,0 +1,44 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app102; + +import io.swagger.v3.oas.annotations.Parameter; +import jakarta.validation.constraints.NotBlank; + +public class InheritedRequestParams extends RequestParams { + @Parameter(description = "parameter from child of RequestParams") + @NotBlank + private String childParam; + + public String getChildParam() { + return childParam; + } + + public void setChildParam(String childParam) { + this.childParam = childParam; + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app102/RequestParams.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app102/RequestParams.java new file mode 100644 index 000000000..b61503109 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app102/RequestParams.java @@ -0,0 +1,148 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app102; + +import java.math.BigInteger; +import java.util.List; +import java.util.Optional; + +import io.swagger.v3.oas.annotations.Parameter; + +import org.springframework.lang.Nullable; + +public class RequestParams { + + @Parameter(description = "string parameter") + private String stringParam; + + @Deprecated + private String stringParam1; + + @Parameter(description = "string parameter2", required = true) + private String stringParam2; + + @Parameter(description = "int parameter") + private int intParam; + + private Optional intParam2; + + @Nullable + private String intParam3; + + private Nested nested; + + private List nestedList; + + public String getStringParam() { + return stringParam; + } + + public void setStringParam(String stringParam) { + this.stringParam = stringParam; + } + + public int getIntParam() { + return intParam; + } + + public void setIntParam(int intParam) { + this.intParam = intParam; + } + + public Optional getIntParam2() { + return intParam2; + } + + public void setIntParam2(Optional intParam2) { + this.intParam2 = intParam2; + } + + @Nullable + public String getIntParam3() { + return intParam3; + } + + public void setIntParam3(@Nullable String intParam3) { + this.intParam3 = intParam3; + } + + public String getStringParam1() { + return stringParam1; + } + + public void setStringParam1(String stringParam1) { + this.stringParam1 = stringParam1; + } + + public String getStringParam2() { + return stringParam2; + } + + public void setStringParam2(String stringParam2) { + this.stringParam2 = stringParam2; + } + + public Nested getNested() { + return nested; + } + + public void setNested(Nested nested) { + this.nested = nested; + } + + public List getNestedList() { + return nestedList; + } + + public void setNestedList(List nestedList) { + this.nestedList = nestedList; + } + + public static class Nested { + private String param1; + + private BigInteger param2; + + @Parameter(description = "nested string parameter") + public String getParam1() { + return param1; + } + + public void setParam1(String param1) { + this.param1 = param1; + } + + @Parameter(description = "nested BigInteger parameter") + public BigInteger getParam2() { + return param2; + } + + public void setParam2(BigInteger param2) { + this.param2 = param2; + } + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app102/SpringDocApp102Test.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app102/SpringDocApp102Test.java new file mode 100644 index 000000000..76f9d6881 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app102/SpringDocApp102Test.java @@ -0,0 +1,40 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app102; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.ComponentScan; + +public class SpringDocApp102Test extends AbstractSpringDocTest { + + @SpringBootApplication + @ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.v31.app102" }) + static class SpringDocTestApp {} + +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app102/TestController.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app102/TestController.java new file mode 100644 index 000000000..c17cdc175 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app102/TestController.java @@ -0,0 +1,41 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app102; + +import org.springdoc.core.annotations.ParameterObject; + +import org.springframework.lang.Nullable; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class TestController { + @GetMapping("test") + public void getTest(@RequestParam @Nullable String param, @ParameterObject InheritedRequestParams requestParams) { + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app149/HelloController.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app149/HelloController.java new file mode 100644 index 000000000..70ac492cd --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app149/HelloController.java @@ -0,0 +1,73 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app149; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.ResponseBody; + +/** + * To test the case a user does not use @RestController but puts @Operation on handler methods + * and wants these methods to be exposed. + * + * @author Azige + */ +@Controller +public class HelloController { + + @GetMapping("/hello") + @Operation(responses = @ApiResponse( + responseCode = "200", + description = "OK", + content = @Content(schema = @Schema(implementation = HelloMessage.class)) + )) + public String hello() { + return "forward:/message"; + } + + @GetMapping("/message") + @Operation + @ResponseBody + public HelloMessage message() { + return new HelloMessage("Lucky numbers!", 777); + } + + @GetMapping("/helloModelAndView") + @Operation(responses = @ApiResponse( + responseCode = "200", + description = "OK", + content = @Content(schema = @Schema(implementation = HelloMessage.class)) + )) + public HelloMessage helloModelAndView() { + return null; + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app149/HelloMessage.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app149/HelloMessage.java new file mode 100644 index 000000000..53af43a16 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app149/HelloMessage.java @@ -0,0 +1,38 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app149; + +public class HelloMessage { + public String text; + + public int number; + + public HelloMessage(String text, int number) { + this.text = text; + this.number = number; + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app149/HiddenHelloController.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app149/HiddenHelloController.java new file mode 100644 index 000000000..fd57a0465 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app149/HiddenHelloController.java @@ -0,0 +1,48 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app149; + +import io.swagger.v3.oas.annotations.Operation; + +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * @author bnasslahsen + */ +@RestController +@RequestMapping("/api") +public class HiddenHelloController { + + @Operation(description = "I want here some custom config") + @GetMapping("/{entity}/{id}") + public ResponseEntity getEntity() { + throw new UnsupportedOperationException("the body is not relevant now"); + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app149/SpringDocApp149Test.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app149/SpringDocApp149Test.java new file mode 100644 index 000000000..f560c4379 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app149/SpringDocApp149Test.java @@ -0,0 +1,44 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app149; + +import org.springdoc.core.utils.SpringDocUtils; +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.ComponentScan; + +public class SpringDocApp149Test extends AbstractSpringDocTest { + + static { + SpringDocUtils.getConfig().addHiddenRestControllers(HiddenHelloController.class); + } + + @SpringBootApplication + @ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.v31.app149" }) + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app150/HelloRouter.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app150/HelloRouter.java new file mode 100644 index 000000000..089a2beaa --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app150/HelloRouter.java @@ -0,0 +1,71 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app150; + +import java.util.function.Consumer; +import java.util.function.Supplier; + +import org.springdoc.core.fn.builders.operation.Builder; +import org.springdoc.webflux.core.fn.SpringdocRouteBuilder; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.reactive.function.server.RequestPredicates; +import org.springframework.web.reactive.function.server.RouterFunction; +import org.springframework.web.reactive.function.server.RouterFunctions; +import org.springframework.web.reactive.function.server.ServerResponse; + +import static org.springframework.web.reactive.function.server.RequestPredicates.path; +import static org.springframework.web.reactive.function.server.RouterFunctions.nest; +import static test.org.springdoc.api.v30.AbstractSpringDocTest.HANDLER_FUNCTION; + +@Configuration +public class HelloRouter { + + @Bean + RouterFunction routeSample() { + Supplier> routerFunctionSupplier = + () -> SpringdocRouteBuilder.route() + .GET("toto", HANDLER_FUNCTION, builder -> builder.operationId("get-user-groups")) + + .POST("/titi", HANDLER_FUNCTION, builder -> builder.operationId("create-user-group-special")).build(); + + Consumer operationsConsumer = builder -> { + }; + + return RouterFunctions.nest(RequestPredicates.path("/users"), nest(path("/test"), nest(path("/greeter"), + SpringdocRouteBuilder.route() + .GET(HANDLER_FUNCTION, builder -> builder.operationId("get-users")) + .POST("/special", HANDLER_FUNCTION, builder -> builder.operationId("create-user-special")) + .nest(path("/groups"), routerFunctionSupplier, operationsConsumer) + .nest(path("/groups2"), routerFunctionSupplier, operationsConsumer) + .nest(path("/greeter3").or(path("/greeter4")), routerFunctionSupplier, operationsConsumer) + .build()))); + + } + +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app150/SpringDocApp150Test.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app150/SpringDocApp150Test.java new file mode 100644 index 000000000..ad6d6429d --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app150/SpringDocApp150Test.java @@ -0,0 +1,39 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app150; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.ComponentScan; + +public class SpringDocApp150Test extends AbstractSpringDocTest { + + @SpringBootApplication + @ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.v31.app150" }) + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app151/HelloRouter.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app151/HelloRouter.java new file mode 100644 index 000000000..e5205f610 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app151/HelloRouter.java @@ -0,0 +1,71 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app151; + +import java.util.function.Consumer; +import java.util.function.Supplier; + +import org.springdoc.core.fn.builders.operation.Builder; +import org.springdoc.webflux.core.fn.SpringdocRouteBuilder; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.reactive.function.server.RequestPredicates; +import org.springframework.web.reactive.function.server.RouterFunction; +import org.springframework.web.reactive.function.server.RouterFunctions; +import org.springframework.web.reactive.function.server.ServerResponse; + +import static org.springframework.web.reactive.function.server.RequestPredicates.path; +import static org.springframework.web.reactive.function.server.RouterFunctions.nest; +import static test.org.springdoc.api.v30.AbstractSpringDocTest.HANDLER_FUNCTION; + +@Configuration +public class HelloRouter { + + @Bean + RouterFunction routeSample() { + Supplier> routerFunctionSupplier = + () -> SpringdocRouteBuilder.route() + .GET("toto", HANDLER_FUNCTION, builder -> builder.operationId("get-user-groups")) + + .POST("/titi", HANDLER_FUNCTION, builder -> builder.operationId("create-user-group-special")).build(); + + Consumer operationsConsumer = builder -> { + }; + + return RouterFunctions.nest(RequestPredicates.path("/users"), nest(path("/test"), nest(path("/greeter"), + SpringdocRouteBuilder.route() + .GET("", HANDLER_FUNCTION, builder -> builder.operationId("get-users")) + .POST("/special", HANDLER_FUNCTION, builder -> builder.operationId("create-user-special")) + .nest(path("/groups"), routerFunctionSupplier, operationsConsumer) + .nest(path("/groups2"), routerFunctionSupplier, operationsConsumer) + .nest(path("/greeter3").or(path("/greeter4")), routerFunctionSupplier, operationsConsumer) + .build()))); + + } + +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app151/SpringDocApp151Test.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app151/SpringDocApp151Test.java new file mode 100644 index 000000000..9ce852f90 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app151/SpringDocApp151Test.java @@ -0,0 +1,39 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app151; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.ComponentScan; + +public class SpringDocApp151Test extends AbstractSpringDocTest { + + @SpringBootApplication + @ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.v31.app151" }) + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app152/HelloController.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app152/HelloController.java new file mode 100644 index 000000000..2d1165465 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app152/HelloController.java @@ -0,0 +1,52 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app152; + +import org.reactivestreams.Publisher; +import org.springdoc.core.models.GroupedOpenApi; +import reactor.core.publisher.Mono; + +import org.springframework.context.annotation.Bean; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class HelloController { + + @GetMapping("/persons") + public Publisher persons() { + return Mono.just("OK"); + } + + @Bean + public GroupedOpenApi userOpenApi() { + return GroupedOpenApi.builder() + .group("users") + .packagesToScan("test.org.springdoc.api.v31.app152") + .build(); + } +} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app152/SpringDocApp152Test.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app152/SpringDocApp152Test.java new file mode 100644 index 000000000..f028a5e63 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app152/SpringDocApp152Test.java @@ -0,0 +1,39 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app152; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.ComponentScan; + +public class SpringDocApp152Test extends AbstractSpringDocTest { + + @SpringBootApplication + @ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.v31.app152" }) + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app153/DefaultRequestMappingHandlerMapping.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app153/DefaultRequestMappingHandlerMapping.java new file mode 100644 index 000000000..263c27b00 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app153/DefaultRequestMappingHandlerMapping.java @@ -0,0 +1,68 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app153; + +import org.springframework.expression.ParserContext; +import org.springframework.expression.spel.standard.SpelExpressionParser; +import org.springframework.expression.spel.support.StandardEvaluationContext; +import org.springframework.util.StringValueResolver; +import org.springframework.web.reactive.result.method.annotation.RequestMappingHandlerMapping; + +public class DefaultRequestMappingHandlerMapping extends RequestMappingHandlerMapping { + + private static final SpelExpressionParser PARSER = new SpelExpressionParser(); + + private static ThreadLocal handlerHolder = new ThreadLocal<>(); + + @Override + public void setEmbeddedValueResolver(StringValueResolver resolver) { + super.setEmbeddedValueResolver(new StringValueResolver() { + @Override + public String resolveStringValue(String strVal) { + Object handler = handlerHolder.get(); + if (handler != null) { + strVal = String.valueOf(PARSER.parseExpression(strVal, ParserContext.TEMPLATE_EXPRESSION) + .getValue(new StandardEvaluationContext(handler))); + } + if (resolver != null) { + strVal = resolver.resolveStringValue(strVal); + } + return strVal; + } + }); + } + + @Override + protected void detectHandlerMethods(Object handler) { + Object handlerObject = (handler instanceof String ? obtainApplicationContext().getBean((String) handler) + : handler); + handlerHolder.set(handlerObject); + super.detectHandlerMethods(handler); + handlerHolder.remove(); + } + +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app153/DefaultWebFluxRegistrations.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app153/DefaultWebFluxRegistrations.java new file mode 100644 index 000000000..951011841 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app153/DefaultWebFluxRegistrations.java @@ -0,0 +1,41 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app153; + +import org.springframework.boot.autoconfigure.web.reactive.WebFluxRegistrations; +import org.springframework.stereotype.Component; +import org.springframework.web.reactive.result.method.annotation.RequestMappingHandlerMapping; + +@Component +public class DefaultWebFluxRegistrations implements WebFluxRegistrations { + + @Override + public RequestMappingHandlerMapping getRequestMappingHandlerMapping() { + return new DefaultRequestMappingHandlerMapping(); + } + +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app153/SpringDocApp153Test.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app153/SpringDocApp153Test.java new file mode 100644 index 000000000..657bb1d0f --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app153/SpringDocApp153Test.java @@ -0,0 +1,39 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app153; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.ComponentScan; + +public class SpringDocApp153Test extends AbstractSpringDocTest { + + @SpringBootApplication + @ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.v31.app153" }) + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app153/TestController.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app153/TestController.java new file mode 100644 index 000000000..1a52abcca --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app153/TestController.java @@ -0,0 +1,39 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app153; + +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class TestController { + + @PostMapping("/echo") + public String echo(String content) { + return content; + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app184/HelloController.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app184/HelloController.java new file mode 100644 index 000000000..3c6739705 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app184/HelloController.java @@ -0,0 +1,61 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app184; + + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class HelloController { + + @GetMapping("/globalBeanFiltered") + public String globalBeanFiltered() { + return "globalBeanFiltered"; + } + + @GetMapping("/beanFiltered") + public String beanFiltered() { + return "beanFiltered"; + } + + @GetMapping("/group1Filtered") + public String group1Filtered() { + return "group1Filtered"; + } + + @GetMapping("/group2Filtered") + public String group2Filtered() { + return "group2Filtered"; + } + + @GetMapping("/group3Filtered") + public String group3Filtered() { + return "group3Filtered"; + } + +} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app184/SpringDocApp184Test.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app184/SpringDocApp184Test.java new file mode 100644 index 000000000..0da571075 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app184/SpringDocApp184Test.java @@ -0,0 +1,132 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app184; + +import java.util.Objects; + +import io.swagger.v3.oas.models.parameters.HeaderParameter; +import io.swagger.v3.oas.models.servers.Server; +import org.junit.jupiter.api.Test; +import org.springdoc.core.customizers.GlobalOpenApiCustomizer; +import org.springdoc.core.customizers.GlobalOperationCustomizer; +import org.springdoc.core.customizers.OpenApiCustomizer; +import org.springdoc.core.customizers.OperationCustomizer; +import org.springdoc.core.filters.GlobalOpenApiMethodFilter; +import org.springdoc.core.filters.OpenApiMethodFilter; +import org.springdoc.core.models.GroupedOpenApi; +import org.springdoc.core.utils.Constants; +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.test.context.TestPropertySource; + +@TestPropertySource(properties = { + "springdoc.group-configs[0].group=group1", + "springdoc.group-configs[0].paths-to-exclude=/group1Filtered", +}) +public class SpringDocApp184Test extends AbstractSpringDocTest { + + @Test + void testGroup1() throws Exception { + webTestClient.get().uri(Constants.DEFAULT_API_DOCS_URL + "/group1").exchange() + .expectStatus().isOk() + .expectBody().json(getContent("results/3.1.0/app184-1.json"), true); + } + + @Test + void testGroup2() throws Exception { + webTestClient.get().uri(Constants.DEFAULT_API_DOCS_URL + "/group2").exchange() + .expectStatus().isOk() + .expectBody().json(getContent("results/3.1.0/app184-2.json"), true); + } + + @Test + void testGroup3() throws Exception { + webTestClient.get().uri(Constants.DEFAULT_API_DOCS_URL + "/group3").exchange() + .expectStatus().isOk() + .expectBody().json(getContent("results/3.1.0/app184-3.json"), true); + } + + @SpringBootApplication + @ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.v31.app184" }) + static class SpringDocTestApp { + + @Bean + public GlobalOpenApiCustomizer addUrlGlobalBean() { + return openApi -> openApi.getServers().add(new Server().url("urlGlobalBean")); + } + + @Bean + public OpenApiCustomizer addUrlBean() { + return openApi -> openApi.getServers().add(new Server().url("urlBean")); + } + + @Bean + public GlobalOperationCustomizer addHeaderGlobaBeanl() { + return (operation, handlerMethod) -> operation.addParametersItem(new HeaderParameter().name("headerGlobalBean")); + } + + @Bean + public OperationCustomizer addHeaderBean() { + return (operation, handlerMethod) -> operation.addParametersItem(new HeaderParameter().name("headerBean")); + } + + @Bean + public GlobalOpenApiMethodFilter globalFilterBean() { + return method -> !Objects.equals(method.getName(), "globalBeanFiltered"); + } + + @Bean + public OpenApiMethodFilter filterBean() { + return method -> !Objects.equals(method.getName(), "beanFiltered"); + } + + @Bean + public GroupedOpenApi group2() { + return GroupedOpenApi.builder() + .group("group2") + .addOpenApiCustomizer(openApi -> openApi.getServers().add(new Server().url("urlGroup2"))) + .addOperationCustomizer((operation, handlerMethod) -> operation.addParametersItem(new HeaderParameter().name("headerGroup2"))) + .addOpenApiMethodFilter(method -> !Objects.equals(method.getName(), "group2Filtered")) + .build(); + } + + @Bean + public GroupedOpenApi group3() { + return GroupedOpenApi.builder() + .group("group3") + .addOpenApiCustomizer(openApi -> openApi.getServers().add(new Server().url("urlGroup3"))) + .addOperationCustomizer((operation, handlerMethod) -> operation.addParametersItem(new HeaderParameter().name("headerGroup3"))) + .addOpenApiMethodFilter(method -> !Objects.equals(method.getName(), "group3Filtered")) + .build(); + } + + } + +} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app187/DuplicatedPathController.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app187/DuplicatedPathController.java new file mode 100644 index 000000000..82f0b0abd --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app187/DuplicatedPathController.java @@ -0,0 +1,45 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app187; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class DuplicatedPathController { + + @GetMapping("/duplicated") + public String duplicated1() { + return "globalBeanFiltered"; + } + + @GetMapping(value = "/duplicated", params = "filter=params") + public String duplicated2() { + return "beanFiltered"; + } + +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app187/SpringDocApp187Test.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app187/SpringDocApp187Test.java new file mode 100644 index 000000000..f8134dbfc --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app187/SpringDocApp187Test.java @@ -0,0 +1,62 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app187; + +import org.junit.jupiter.api.Test; +import org.springdoc.core.customizers.RouterOperationCustomizer; +import org.springdoc.core.utils.Constants; +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; + +class SpringDocApp187Test extends AbstractSpringDocTest { + + @Test + void testAddRouterOperationCustomizerBean() { + webTestClient.get().uri(Constants.DEFAULT_API_DOCS_URL).exchange() + .expectStatus().isOk() + .expectBody().json(getContent("results/3.1.0/app187.json"), true); + } + + @SpringBootApplication + @ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.v31.app187" }) + static class SpringDocTestApp { + + @Bean + public RouterOperationCustomizer addRouterOperationCustomizer() { + return (routerOperation, handlerMethod) -> { + if (routerOperation.getParams().length > 0) { + routerOperation.setPath(routerOperation.getPath() + "?" + String.join("&", routerOperation.getParams())); + } + return routerOperation; + }; + } + } + +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app188/OrderDemo.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app188/OrderDemo.java new file mode 100644 index 000000000..ff9cac779 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app188/OrderDemo.java @@ -0,0 +1,67 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app188; + +import io.swagger.v3.oas.models.OpenAPI; +import io.swagger.v3.oas.models.tags.Tag; +import org.springdoc.core.customizers.GlobalOpenApiCustomizer; +import org.springdoc.core.customizers.OpenApiCustomizer; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + + +public class OrderDemo { + + public static class Customizer2 implements OpenApiCustomizer, GlobalOpenApiCustomizer { + public void customise(OpenAPI openApi) { + openApi.addTagsItem(new Tag().name("2")); + } + } + + public static class Customizer3 implements OpenApiCustomizer, GlobalOpenApiCustomizer { + public void customise(OpenAPI openApi) { + openApi.addTagsItem(new Tag().name("3")); + } + } + + public static class Customizer1 implements OpenApiCustomizer, GlobalOpenApiCustomizer { + public void customise(OpenAPI openApi) { + openApi.addTagsItem(new Tag().name("1")); + } + } + + @RestController + public static class MyController { + + @GetMapping("/test") + public String testingMethod() { + return "foo"; + } + } + +} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app188/SpringDocApp188Test.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app188/SpringDocApp188Test.java new file mode 100644 index 000000000..21f9ccb97 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app188/SpringDocApp188Test.java @@ -0,0 +1,57 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app188; + +import org.junit.jupiter.api.Test; +import org.springdoc.core.utils.Constants; +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Import; +import org.springframework.test.context.TestPropertySource; + +@TestPropertySource(properties = { "springdoc.group-configs[0].group=mygroup", "springdoc.group-configs[0].paths-to-match=/test" }) +class SpringDocApp188Test extends AbstractSpringDocTest { + + @Test + void testApp1() { + webTestClient.get().uri(Constants.DEFAULT_API_DOCS_URL +"/mygroup").exchange() + .expectStatus().isOk() + .expectBody().json(getContent("results/3.1.0/app188.json"), true); + } + + @SpringBootApplication + @Import({ + OrderDemo.Customizer1.class, + OrderDemo.Customizer2.class, + OrderDemo.Customizer3.class, + }) + @ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.v31.app188" }) + static class SpringDocTestApp {} + +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app189/HelloController.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app189/HelloController.java new file mode 100644 index 000000000..34aa72d3d --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app189/HelloController.java @@ -0,0 +1,55 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app189; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; +import reactor.core.publisher.Mono; + +import org.springframework.http.MediaType; +import org.springframework.http.codec.multipart.FilePart; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.bind.annotation.RestController; + + +@RestController +public class HelloController { + + + @Operation(summary = "Parse Resume") + @PostMapping(value = "/parse-resume", produces = { MediaType.APPLICATION_JSON_VALUE }, consumes = { + MediaType.MULTIPART_FORM_DATA_VALUE }) + @ApiResponses({ @ApiResponse(responseCode = "400", description = "Invalid input") }) + public Mono parse( + @RequestPart(name = "resumeFile") @Parameter(description = "Resume file to be parsed", content = @Content(mediaType = MediaType.APPLICATION_OCTET_STREAM_VALUE)) FilePart resumeFile) { + return null; + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app189/SpringDocApp189Test.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app189/SpringDocApp189Test.java new file mode 100644 index 000000000..336fdf706 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app189/SpringDocApp189Test.java @@ -0,0 +1,63 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app189; + +import java.time.Duration; + +import org.json.JSONException; +import org.junit.jupiter.api.Test; +import org.springdoc.core.utils.Constants; +import test.org.springdoc.api.v31.AbstractCommonTest; + +import org.springframework.boot.test.autoconfigure.web.reactive.WebFluxTest; +import org.springframework.test.web.reactive.server.EntityExchangeResult; + +import static org.skyscreamer.jsonassert.JSONAssert.assertEquals; + +@WebFluxTest +public class SpringDocApp189Test extends AbstractCommonTest { + + @Test + public void testWithDifferentLocales() throws Exception { + runTestWithLocale("en-GB"); + runTestWithLocale("de-DE"); + } + private void runTestWithLocale(String locale) throws JSONException { + EntityExchangeResult getResult = webTestClient.mutate().responseTimeout(Duration.ofMinutes(1000)).build() + .get().uri(Constants.DEFAULT_API_DOCS_URL) + .header("Accept-Language", locale) + .exchange() + .expectStatus().isOk().expectBody().returnResult(); + + String result = new String(getResult.getResponseBody()); + String className = getClass().getSimpleName(); + String testNumber = className.replaceAll("[^0-9]", ""); + String expected = getContent("results/3.1.0/app" + testNumber + ".json"); + assertEquals(expected, result, true); + } + +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app189/SpringDocTestApp.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app189/SpringDocTestApp.java new file mode 100644 index 000000000..87bf1adb0 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app189/SpringDocTestApp.java @@ -0,0 +1,61 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app189; + +import io.swagger.v3.oas.models.Components; +import io.swagger.v3.oas.models.OpenAPI; +import io.swagger.v3.oas.models.info.Info; +import io.swagger.v3.oas.models.info.License; +import io.swagger.v3.oas.models.security.SecurityScheme; +import org.springdoc.core.customizers.OpenApiCustomizer; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; + +@SpringBootApplication +@ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.v31.app189" }) +public class SpringDocTestApp { + + @Bean + public OpenAPI customOpenAPI() { + return new OpenAPI() + .components(new Components().addSecuritySchemes("basicScheme", + new SecurityScheme().type(SecurityScheme.Type.HTTP).scheme("basic"))) + .info(new Info().title("Tweet API").version("v0") + .license(new License().name("Apache 2.0").url("http://springdoc.org"))); + } + + @Bean + OpenApiCustomizer serverUrlCustomizer() { + return openApi -> + openApi.getServers().forEach(server -> { + server.setDescription("customized description"); + server.setUrl("https://customized.url"); + }); + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app190/SpringDocApp190Test.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app190/SpringDocApp190Test.java new file mode 100644 index 000000000..8993213cc --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app190/SpringDocApp190Test.java @@ -0,0 +1,51 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app190; + +import org.junit.jupiter.api.Test; +import org.springdoc.core.utils.Constants; +import test.org.springdoc.api.v31.AbstractCommonTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.test.autoconfigure.web.reactive.WebFluxTest; +import org.springframework.context.annotation.ComponentScan; + +import static org.springdoc.core.utils.Constants.SPRINGDOC_ENABLE_DEFAULT_API_DOCS; + +@WebFluxTest(properties = SPRINGDOC_ENABLE_DEFAULT_API_DOCS+"=false") +public class SpringDocApp190Test extends AbstractCommonTest { + + @SpringBootApplication + @ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.v31.app190" }) + static class SpringDocTestApp {} + + @Test + void test_disable_default_api_docs() throws Exception { + webTestClient.get().uri(Constants.DEFAULT_API_DOCS_URL).exchange() + .expectStatus().isNotFound(); + } +} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app190/SpringDocApp190bisTest.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app190/SpringDocApp190bisTest.java new file mode 100644 index 000000000..2a36670ea --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app190/SpringDocApp190bisTest.java @@ -0,0 +1,51 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app190; + +import org.junit.jupiter.api.Test; +import org.springdoc.core.utils.Constants; +import test.org.springdoc.api.v31.AbstractCommonTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.test.autoconfigure.web.reactive.WebFluxTest; +import org.springframework.context.annotation.ComponentScan; + +import static org.springdoc.core.utils.Constants.SPRINGDOC_ENABLE_DEFAULT_API_DOCS; + +@WebFluxTest(properties = SPRINGDOC_ENABLE_DEFAULT_API_DOCS+"=true") +public class SpringDocApp190bisTest extends AbstractCommonTest { + + @SpringBootApplication + @ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.v31.app190" }) + static class SpringDocTestApp {} + + @Test + void test_enable_default_api_docs() throws Exception { + webTestClient.get().uri(Constants.DEFAULT_API_DOCS_URL).exchange() + .expectStatus().isOk(); + } +} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app191/Handler/BaseHandler.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app191/Handler/BaseHandler.java new file mode 100644 index 000000000..7f268fe74 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app191/Handler/BaseHandler.java @@ -0,0 +1,42 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app191.Handler; + +import reactor.core.publisher.Mono; + +import org.springframework.stereotype.Component; +import org.springframework.web.reactive.function.server.ServerRequest; +import org.springframework.web.reactive.function.server.ServerResponse; + +@Component +public abstract class BaseHandler { + protected abstract Mono apply (ServerRequest serverRequest); + + public Mono handle(ServerRequest serverRequest) { + return this.apply(serverRequest); + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app191/Handler/GetNameHandler.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app191/Handler/GetNameHandler.java new file mode 100644 index 000000000..0c7800d96 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app191/Handler/GetNameHandler.java @@ -0,0 +1,45 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app191.Handler; + +import reactor.core.publisher.Mono; + +import org.springframework.http.MediaType; +import org.springframework.stereotype.Component; +import org.springframework.web.reactive.function.server.ServerRequest; +import org.springframework.web.reactive.function.server.ServerResponse; + +@Component +public class GetNameHandler extends BaseHandler { + @Override + protected Mono apply(ServerRequest serverRequest) { + return ServerResponse.ok() + .contentType(MediaType.APPLICATION_JSON) + .bodyValue("Name API is called"); + } + +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app191/Router/GetNameRouter.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app191/Router/GetNameRouter.java new file mode 100644 index 000000000..aea9a759d --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app191/Router/GetNameRouter.java @@ -0,0 +1,63 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app191.Router; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import org.springdoc.core.annotations.RouterOperation; +import org.springdoc.core.annotations.RouterOperations; +import test.org.springdoc.api.v31.app191.Handler.GetNameHandler; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.http.MediaType; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.reactive.function.server.RequestPredicates; +import org.springframework.web.reactive.function.server.RouterFunction; +import org.springframework.web.reactive.function.server.RouterFunctions; +import org.springframework.web.reactive.function.server.ServerResponse; + + +@Configuration +public class GetNameRouter { + + @Bean + @RouterOperations( + value = { + @RouterOperation(path = "/v1/name", produces = {MediaType.APPLICATION_JSON_VALUE}, method = RequestMethod.GET, + beanClass = GetNameHandler.class, beanMethod = "handle", operation = @Operation(operationId = "getName", + description = "get name", responses = {@ApiResponse(responseCode = "200", description = "OK", content = @Content(schema = @Schema(implementation = String.class)))}) + ) + }) + + public RouterFunction routerFunction(GetNameHandler getNameHandler) { + return RouterFunctions.route(RequestPredicates.GET("/v1/name"), getNameHandler::handle); + } + +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app191/SpringDocApp191Test.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app191/SpringDocApp191Test.java new file mode 100644 index 000000000..c0fab9bc1 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app191/SpringDocApp191Test.java @@ -0,0 +1,39 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app191; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.ComponentScan; + +public class SpringDocApp191Test extends AbstractSpringDocTest { + + @SpringBootApplication + @ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.v31.app191" }) + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app3/SpringDocApp3Test.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app3/SpringDocApp3Test.java new file mode 100644 index 000000000..f25576fc3 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app3/SpringDocApp3Test.java @@ -0,0 +1,34 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app3; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +public class SpringDocApp3Test extends AbstractSpringDocTest { + + +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app3/SpringDocTestApp.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app3/SpringDocTestApp.java new file mode 100644 index 000000000..1b4b32a40 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app3/SpringDocTestApp.java @@ -0,0 +1,55 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app3; + +import io.swagger.v3.oas.models.Components; +import io.swagger.v3.oas.models.OpenAPI; +import io.swagger.v3.oas.models.info.Info; +import io.swagger.v3.oas.models.info.License; +import io.swagger.v3.oas.models.security.SecurityScheme; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; + +@SpringBootApplication +@ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.v31.app3" }) +public class SpringDocTestApp { + public static void main(String[] args) { + SpringApplication.run(SpringDocTestApp.class, args); + } + + @Bean + public OpenAPI customOpenAPI() { + return new OpenAPI() + .components(new Components().addSecuritySchemes("basicScheme", + new SecurityScheme().type(SecurityScheme.Type.HTTP).scheme("basic"))) + .info(new Info().title("Tweet API").version("v0") + .license(new License().name("Apache 2.0").url("http://springdoc.org"))); + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app3/controller/ExceptionTranslator.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app3/controller/ExceptionTranslator.java new file mode 100644 index 000000000..6cc23a4ed --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app3/controller/ExceptionTranslator.java @@ -0,0 +1,58 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app3.controller; + +import test.org.springdoc.api.v31.app3.exception.TweetConflictException; +import test.org.springdoc.api.v31.app3.exception.TweetNotFoundException; +import test.org.springdoc.api.v31.app3.payload.ErrorResponse; + +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.ResponseStatus; +import org.springframework.web.bind.annotation.RestControllerAdvice; + +@RestControllerAdvice +public class ExceptionTranslator { + + + @SuppressWarnings("rawtypes") + @ExceptionHandler(TweetConflictException.class) + @ResponseStatus(HttpStatus.CONFLICT) + public ResponseEntity handleDuplicateKeyException(TweetConflictException ex) { + return ResponseEntity.status(HttpStatus.CONFLICT) + .body(new ErrorResponse("A Tweet with the same text already exists")); + } + + @SuppressWarnings("rawtypes") + @ExceptionHandler(TweetNotFoundException.class) + @ResponseStatus(HttpStatus.NOT_FOUND) + public ResponseEntity handleTweetNotFoundException(TweetNotFoundException ex) { + return ResponseEntity.notFound().build(); + } + +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app3/controller/TweetController.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app3/controller/TweetController.java new file mode 100644 index 000000000..13183418b --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app3/controller/TweetController.java @@ -0,0 +1,95 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app3.controller; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; +import jakarta.validation.Valid; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; +import test.org.springdoc.api.v31.app3.dto.TweetDTO; + +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RestController; + +/** + * Created by rajeevkumarsingh on 08/09/17. + */ +@RestController +public class TweetController { + + + @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "get All Tweets") }) + @GetMapping("/tweets") + public Flux getAllTweets() { + return null; + } + + @PostMapping("/tweets") + @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "create Tweets") }) + public Mono createTweets(@Valid @RequestBody TweetDTO tweetDTO) { + return null; + } + + @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "get Tweet By Id"), + @ApiResponse(responseCode = "404", description = "tweet not found") }) + @GetMapping("/tweets/{id}") + public Mono> getTweetById(@PathVariable(value = "id") String tweetId) { + return null; + } + + @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "update Tweet"), + @ApiResponse(responseCode = "404", description = "tweet not found") }) + @PutMapping("/tweets/{id}") + public Mono> updateTweet(@PathVariable(value = "id") String tweetId, + @Valid @RequestBody TweetDTO tweetDTO) { + return null; + } + + @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "delete Tweet"), + @ApiResponse(responseCode = "404", description = "tweet not found") }) + @DeleteMapping("/tweets/{id}") + public Mono> deleteTweet(@PathVariable(value = "id") String tweetId) { + return null; + } + + @Operation(description = "Tweets are Sent to the client as Server Sent Events", responses = { + @ApiResponse(responseCode = "200", description = "stream All Tweets") }) + @GetMapping(value = "/stream/tweets", produces = MediaType.TEXT_EVENT_STREAM_VALUE) + public Flux streamAllTweets() { + return null; + } + +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app3/dto/TweetDTO.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app3/dto/TweetDTO.java new file mode 100644 index 000000000..42e8d1b44 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app3/dto/TweetDTO.java @@ -0,0 +1,80 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app3.dto; + +import java.util.Date; + +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; +import jakarta.validation.constraints.Size; + + +/** + * Created by rajeevkumarsingh on 08/09/17. + */ +public class TweetDTO { + private String id; + + @NotBlank + @Size(max = 140) + private String text; + + @NotNull + private Date createdAt = new Date(); + + public TweetDTO() { + + } + + public TweetDTO(String text) { + this.text = text; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getText() { + return text; + } + + public void setText(String text) { + this.text = text; + } + + public Date getCreatedAt() { + return createdAt; + } + + public void setCreatedAt(Date createdAt) { + this.createdAt = createdAt; + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app3/exception/TweetConflictException.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app3/exception/TweetConflictException.java new file mode 100644 index 000000000..dc15ac266 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app3/exception/TweetConflictException.java @@ -0,0 +1,42 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app3.exception; + +/** + * Created by rajeevkumarsingh on 22/10/17. + */ +public class TweetConflictException extends RuntimeException { + + /** + * + */ + private static final long serialVersionUID = 1L; + + public TweetConflictException(String tweetId) { + super("Tweet conflict with id " + tweetId); + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app3/exception/TweetNotFoundException.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app3/exception/TweetNotFoundException.java new file mode 100644 index 000000000..03fc75d75 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app3/exception/TweetNotFoundException.java @@ -0,0 +1,42 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app3.exception; + +/** + * Created by rajeevkumarsingh on 22/10/17. + */ +public class TweetNotFoundException extends RuntimeException { + + /** + * + */ + private static final long serialVersionUID = 1L; + + public TweetNotFoundException(String tweetId) { + super("Tweet not found with id " + tweetId); + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app3/payload/ErrorResponse.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app3/payload/ErrorResponse.java new file mode 100644 index 000000000..81ad86fc2 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app3/payload/ErrorResponse.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.app3.payload; + +/** + * Created by rajeevkumarsingh on 22/10/17. + */ +public class ErrorResponse { + private String message; + + public ErrorResponse(String message) { + this.message = message; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app39/HelloController.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app39/HelloController.java new file mode 100644 index 000000000..3e78d20a7 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app39/HelloController.java @@ -0,0 +1,53 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app39; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.parameters.RequestBody; +import reactor.core.publisher.Mono; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class HelloController { + + @Operation(summary = "test Request") + @RequestBody(description = "test value", required = true, content = @Content(schema = @Schema(implementation = String.class))) + @PostMapping("/test") + public Mono searchEmployee(String test) { + return Mono.empty(); + } + + @GetMapping("/hello") + public Mono hello() { + return Mono.just("hello"); + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app39/SpringDocApp39Test.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app39/SpringDocApp39Test.java new file mode 100644 index 000000000..5e698e493 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app39/SpringDocApp39Test.java @@ -0,0 +1,34 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app39; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +public class SpringDocApp39Test extends AbstractSpringDocTest { + + +} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app39/SpringDocTestApp.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app39/SpringDocTestApp.java new file mode 100644 index 000000000..4103f7c00 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app39/SpringDocTestApp.java @@ -0,0 +1,60 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app39; + +import io.swagger.v3.oas.models.Components; +import io.swagger.v3.oas.models.OpenAPI; +import io.swagger.v3.oas.models.media.StringSchema; +import io.swagger.v3.oas.models.parameters.HeaderParameter; +import org.springdoc.core.customizers.OpenApiCustomizer; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; + +@SpringBootApplication +@ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.v31.app39" }) +public class SpringDocTestApp { + + public static void main(String[] args) { + SpringApplication.run(SpringDocTestApp.class, args); + } + + @Bean + public OpenAPI customOpenAPI() { + StringSchema schema = new StringSchema(); + return new OpenAPI() + .components(new Components().addParameters("myGlobalHeader", new HeaderParameter().required(true).name("My-Global-Header").description("My Global Header").schema(schema))); + } + + @Bean + public OpenApiCustomizer customerGlobalHeaderOpenApiCustomizer() { + return openApi -> openApi.getPaths().values().stream().flatMap(pathItem -> pathItem.readOperations().stream()) + .forEach(operation -> operation.addParametersItem(new HeaderParameter().$ref("#/components/parameters/myGlobalHeader"))); + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app4/HelloController.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app4/HelloController.java new file mode 100644 index 000000000..a4a32610f --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app4/HelloController.java @@ -0,0 +1,55 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app4; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; +import reactor.core.publisher.Mono; + +import org.springframework.http.MediaType; +import org.springframework.http.codec.multipart.FilePart; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.bind.annotation.RestController; + + +@RestController +public class HelloController { + + + @Operation(summary = "Parse Resume") + @PostMapping(value = "/parse-resume", produces = { MediaType.APPLICATION_JSON_VALUE }, consumes = { + MediaType.MULTIPART_FORM_DATA_VALUE }) + @ApiResponses({ @ApiResponse(responseCode = "400", description = "Invalid input") }) + public Mono parse( + @RequestPart(name = "resumeFile") @Parameter(description = "Resume file to be parsed", content = @Content(mediaType = MediaType.APPLICATION_OCTET_STREAM_VALUE)) FilePart resumeFile) { + return null; + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app4/SpringDocApp4Test.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app4/SpringDocApp4Test.java new file mode 100644 index 000000000..8fb628b21 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app4/SpringDocApp4Test.java @@ -0,0 +1,34 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app4; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +public class SpringDocApp4Test extends AbstractSpringDocTest { + + +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app4/SpringDocTestApp.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app4/SpringDocTestApp.java new file mode 100644 index 000000000..5b3a6e03e --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app4/SpringDocTestApp.java @@ -0,0 +1,55 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app4; + +import io.swagger.v3.oas.models.Components; +import io.swagger.v3.oas.models.OpenAPI; +import io.swagger.v3.oas.models.info.Info; +import io.swagger.v3.oas.models.info.License; +import io.swagger.v3.oas.models.security.SecurityScheme; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; + +@SpringBootApplication +@ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.v31.app4" }) +public class SpringDocTestApp { + public static void main(String[] args) { + SpringApplication.run(SpringDocTestApp.class, args); + } + + @Bean + public OpenAPI customOpenAPI() { + return new OpenAPI() + .components(new Components().addSecuritySchemes("basicScheme", + new SecurityScheme().type(SecurityScheme.Type.HTTP).scheme("basic"))) + .info(new Info().title("Tweet API").version("v0") + .license(new License().name("Apache 2.0").url("http://springdoc.org"))); + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app5/HelloController.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app5/HelloController.java new file mode 100644 index 000000000..844888235 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app5/HelloController.java @@ -0,0 +1,51 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app5; + +import reactor.core.publisher.Mono; + +import org.springframework.http.HttpEntity; +import org.springframework.http.MediaType; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class HelloController { + + @PostMapping(value = "/tweets/does-not-work", consumes = MediaType.APPLICATION_JSON_VALUE) + public Mono postNotWorks(@RequestBody Mono tweet) { + return tweet; + } + + @GetMapping("/test") + public Mono> demo2() { + return null; + } + +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app5/SpringDocApp5Test.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app5/SpringDocApp5Test.java new file mode 100644 index 000000000..b6b390e6e --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app5/SpringDocApp5Test.java @@ -0,0 +1,34 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app5; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +public class SpringDocApp5Test extends AbstractSpringDocTest { + + +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app5/SpringDocTestApp.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app5/SpringDocTestApp.java new file mode 100644 index 000000000..a5fb689ae --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app5/SpringDocTestApp.java @@ -0,0 +1,55 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app5; + +import io.swagger.v3.oas.models.Components; +import io.swagger.v3.oas.models.OpenAPI; +import io.swagger.v3.oas.models.info.Info; +import io.swagger.v3.oas.models.info.License; +import io.swagger.v3.oas.models.security.SecurityScheme; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; + +@SpringBootApplication +@ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.v31.app5" }) +public class SpringDocTestApp { + public static void main(String[] args) { + SpringApplication.run(SpringDocTestApp.class, args); + } + + @Bean + public OpenAPI customOpenAPI() { + return new OpenAPI() + .components(new Components().addSecuritySchemes("basicScheme", + new SecurityScheme().type(SecurityScheme.Type.HTTP).scheme("basic"))) + .info(new Info().title("Tweet API").version("v0") + .license(new License().name("Apache 2.0").url("http://springdoc.org"))); + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app5/Tweet.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app5/Tweet.java new file mode 100644 index 000000000..b81c56339 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app5/Tweet.java @@ -0,0 +1,69 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app5; + +import java.util.Date; + +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; +import jakarta.validation.constraints.Size; + +public class Tweet { + private String id; + + @NotBlank + @Size(max = 140) + private String text; + + @NotNull + private Date createdAt = new Date(); + + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getText() { + return text; + } + + public void setText(String text) { + this.text = text; + } + + public Date getCreatedAt() { + return createdAt; + } + + public void setCreatedAt(Date createdAt) { + this.createdAt = createdAt; + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app63/HelloController.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app63/HelloController.java new file mode 100644 index 000000000..2fe0962de --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app63/HelloController.java @@ -0,0 +1,39 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app63; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class HelloController { + + @GetMapping("/test") + public void test(String hello) { + } + +} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app63/SpringDocApp63Test.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app63/SpringDocApp63Test.java new file mode 100644 index 000000000..4bdcc8732 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app63/SpringDocApp63Test.java @@ -0,0 +1,41 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app63; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.test.context.TestPropertySource; + +@TestPropertySource(properties = "springdoc.packagesToScan=hell,hello1, hello.me") +public class SpringDocApp63Test extends AbstractSpringDocTest { + + @SpringBootApplication + @ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.v31.app63" }) + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app63/toto/HelloController2.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app63/toto/HelloController2.java new file mode 100644 index 000000000..9b8c3ee0b --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app63/toto/HelloController2.java @@ -0,0 +1,39 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app63.toto; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class HelloController2 { + + @GetMapping("/test1") + public void test1(String hello) { + } + +} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app64/HelloController.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app64/HelloController.java new file mode 100644 index 000000000..8f280bafb --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app64/HelloController.java @@ -0,0 +1,47 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app64; + +import io.swagger.v3.oas.annotations.Operation; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class HelloController { + + @GetMapping("/v1/test") + public void test1(String hello) { + } + + @GetMapping(value = "/api/balance/abcd") + @Operation(summary = "This is the test endpoint") + public String test2(String from) { + return "This is a fake test"; + } + +} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app64/SpringDocApp64Test.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app64/SpringDocApp64Test.java new file mode 100644 index 000000000..a40756d95 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app64/SpringDocApp64Test.java @@ -0,0 +1,41 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app64; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.test.context.TestPropertySource; + +@TestPropertySource(properties = "springdoc.paths-to-match=/v1, /api/**") +public class SpringDocApp64Test extends AbstractSpringDocTest { + + @SpringBootApplication + @ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.v31.app64" }) + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app65/HelloController.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app65/HelloController.java new file mode 100644 index 000000000..67a705d26 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app65/HelloController.java @@ -0,0 +1,47 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app65; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; + +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +@Tag(name = "Health", description = "Health check / ping API") +@RestController +public class HelloController { + + @Operation(summary = "Check server status", description = "Check server status, will return 200 with simple string if alive. Do nothing else.") + @GetMapping(value = { "/ping", "/health", "/" }, produces = MediaType.TEXT_PLAIN_VALUE) + public ResponseEntity ping() { + return ResponseEntity.ok("Healthy"); + } + +} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app65/SpringDocApp65Test.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app65/SpringDocApp65Test.java new file mode 100644 index 000000000..22e127867 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app65/SpringDocApp65Test.java @@ -0,0 +1,39 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app65; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.ComponentScan; + +public class SpringDocApp65Test extends AbstractSpringDocTest { + + @SpringBootApplication + @ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.v31.app65" }) + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app66/SpringDocApp66Test.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app66/SpringDocApp66Test.java new file mode 100644 index 000000000..1da8f5f23 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app66/SpringDocApp66Test.java @@ -0,0 +1,44 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app66; + +import org.junit.jupiter.api.Test; +import org.springdoc.core.utils.Constants; +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +public class SpringDocApp66Test extends AbstractSpringDocTest { + + public SpringDocApp66Test() { + this.groupName = "/stream"; + } + + @Test + void testApp2() throws Exception { + webTestClient.get().uri(Constants.DEFAULT_API_DOCS_URL + "streams").exchange() + .expectStatus().isNotFound(); + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app66/SpringDocTestApp.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app66/SpringDocTestApp.java new file mode 100644 index 000000000..88ccee7c7 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app66/SpringDocTestApp.java @@ -0,0 +1,65 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app66; + +import io.swagger.v3.oas.models.Components; +import io.swagger.v3.oas.models.OpenAPI; +import io.swagger.v3.oas.models.info.Info; +import io.swagger.v3.oas.models.info.License; +import io.swagger.v3.oas.models.security.SecurityScheme; +import org.springdoc.core.models.GroupedOpenApi; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; + +@SpringBootApplication +@ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.v31.app66" }) +public class SpringDocTestApp { + public static void main(String[] args) { + SpringApplication.run(SpringDocTestApp.class, args); + } + + @Bean + public OpenAPI customOpenAPI() { + return new OpenAPI() + .components(new Components().addSecuritySchemes("basicScheme", + new SecurityScheme().type(SecurityScheme.Type.HTTP).scheme("basic"))) + .info(new Info().title("Tweet API").version("v0") + .license(new License().name("Apache 2.0").url("http://springdoc.org"))); + } + + @Bean + public GroupedOpenApi streamOpenApi() { + String[] paths = { "/stream/**" }; + String[] packagedToMatch = { "test.org.springdoc.api.v31.app66" }; + return GroupedOpenApi.builder().group("stream").pathsToMatch(paths) + .build(); + } + +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app66/controller/ExceptionTranslator.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app66/controller/ExceptionTranslator.java new file mode 100644 index 000000000..3ff39c52f --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app66/controller/ExceptionTranslator.java @@ -0,0 +1,58 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app66.controller; + +import test.org.springdoc.api.v31.app66.exception.TweetConflictException; +import test.org.springdoc.api.v31.app66.exception.TweetNotFoundException; +import test.org.springdoc.api.v31.app66.payload.ErrorResponse; + +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.ResponseStatus; +import org.springframework.web.bind.annotation.RestControllerAdvice; + +@RestControllerAdvice +public class ExceptionTranslator { + + + @SuppressWarnings("rawtypes") + @ExceptionHandler(TweetConflictException.class) + @ResponseStatus(HttpStatus.CONFLICT) + public ResponseEntity handleDuplicateKeyException(TweetConflictException ex) { + return ResponseEntity.status(HttpStatus.CONFLICT) + .body(new ErrorResponse("A Tweet with the same text already exists")); + } + + @SuppressWarnings("rawtypes") + @ExceptionHandler(TweetNotFoundException.class) + @ResponseStatus(HttpStatus.NOT_FOUND) + public ResponseEntity handleTweetNotFoundException(TweetNotFoundException ex) { + return ResponseEntity.notFound().build(); + } + +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app66/controller/TweetController.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app66/controller/TweetController.java new file mode 100644 index 000000000..545e9b8b7 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app66/controller/TweetController.java @@ -0,0 +1,95 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app66.controller; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; +import jakarta.validation.Valid; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; +import test.org.springdoc.api.v31.app66.dto.TweetDTO; + +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RestController; + +/** + * Created by rajeevkumarsingh on 08/09/17. + */ +@RestController +public class TweetController { + + + @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "get All Tweets") }) + @GetMapping("/tweets") + public Flux getAllTweets() { + return null; + } + + @PostMapping("/tweets") + @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "create Tweets") }) + public Mono createTweets(@Valid @RequestBody TweetDTO tweetDTO) { + return null; + } + + @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "get Tweet By Id"), + @ApiResponse(responseCode = "404", description = "tweet not found") }) + @GetMapping("/tweets/{id}") + public Mono> getTweetById(@PathVariable(value = "id") String tweetId) { + return null; + } + + @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "update Tweet"), + @ApiResponse(responseCode = "404", description = "tweet not found") }) + @PutMapping("/tweets/{id}") + public Mono> updateTweet(@PathVariable(value = "id") String tweetId, + @Valid @RequestBody TweetDTO tweetDTO) { + return null; + } + + @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "delete Tweet"), + @ApiResponse(responseCode = "404", description = "tweet not found") }) + @DeleteMapping("/tweets/{id}") + public Mono> deleteTweet(@PathVariable(value = "id") String tweetId) { + return null; + } + + @Operation(description = "Tweets are Sent to the client as Server Sent Events", responses = { + @ApiResponse(responseCode = "200", description = "stream All Tweets") }) + @GetMapping(value = "/stream/tweets", produces = MediaType.TEXT_EVENT_STREAM_VALUE) + public Flux streamAllTweets() { + return null; + } + +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app66/dto/TweetDTO.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app66/dto/TweetDTO.java new file mode 100644 index 000000000..1b2647fbe --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app66/dto/TweetDTO.java @@ -0,0 +1,80 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app66.dto; + +import java.util.Date; + +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; +import jakarta.validation.constraints.Size; + + +/** + * Created by rajeevkumarsingh on 08/09/17. + */ +public class TweetDTO { + private String id; + + @NotBlank + @Size(max = 140) + private String text; + + @NotNull + private Date createdAt = new Date(); + + public TweetDTO() { + + } + + public TweetDTO(String text) { + this.text = text; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getText() { + return text; + } + + public void setText(String text) { + this.text = text; + } + + public Date getCreatedAt() { + return createdAt; + } + + public void setCreatedAt(Date createdAt) { + this.createdAt = createdAt; + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app66/exception/TweetConflictException.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app66/exception/TweetConflictException.java new file mode 100644 index 000000000..20215d668 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app66/exception/TweetConflictException.java @@ -0,0 +1,42 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app66.exception; + +/** + * Created by rajeevkumarsingh on 22/10/17. + */ +public class TweetConflictException extends RuntimeException { + + /** + * + */ + private static final long serialVersionUID = 1L; + + public TweetConflictException(String tweetId) { + super("Tweet conflict with id " + tweetId); + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app66/exception/TweetNotFoundException.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app66/exception/TweetNotFoundException.java new file mode 100644 index 000000000..be6085474 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app66/exception/TweetNotFoundException.java @@ -0,0 +1,42 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app66.exception; + +/** + * Created by rajeevkumarsingh on 22/10/17. + */ +public class TweetNotFoundException extends RuntimeException { + + /** + * + */ + private static final long serialVersionUID = 1L; + + public TweetNotFoundException(String tweetId) { + super("Tweet not found with id " + tweetId); + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app66/payload/ErrorResponse.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app66/payload/ErrorResponse.java new file mode 100644 index 000000000..bdcc3212f --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app66/payload/ErrorResponse.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.app66.payload; + +/** + * Created by rajeevkumarsingh on 22/10/17. + */ +public class ErrorResponse { + private String message; + + public ErrorResponse(String message) { + this.message = message; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app67/HelloController.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app67/HelloController.java new file mode 100644 index 000000000..5fac5246b --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app67/HelloController.java @@ -0,0 +1,41 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app67; + +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequestMapping("/api") +public class HelloController { + + @RequestMapping + public String test() { + return "ok"; + } + +} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app67/SpringDocApp67Test.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app67/SpringDocApp67Test.java new file mode 100644 index 000000000..e1e853125 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app67/SpringDocApp67Test.java @@ -0,0 +1,61 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app67; + +import org.junit.jupiter.api.Test; +import org.springdoc.core.utils.Constants; +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.ComponentScan; + +public class SpringDocApp67Test extends AbstractSpringDocTest { + + @Test + void testApp() { + webTestClient.get().uri(Constants.DEFAULT_API_DOCS_URL + groupName).exchange().expectStatus().isOk().expectBody() + .jsonPath("$.openapi").isEqualTo("3.1.0") + .jsonPath("$.paths./api.get.tags[0]").isEqualTo("hello-controller") + .jsonPath("$.paths./api.get.responses.200.content.['*/*'].schema.type").isEqualTo("string") + .jsonPath("$.paths./api.post.tags[0]").isEqualTo("hello-controller") + .jsonPath("$.paths./api.post.responses.200.content.['*/*'].schema.type").isEqualTo("string") + .jsonPath("$.paths./api.put.tags[0]").isEqualTo("hello-controller") + .jsonPath("$.paths./api.put.responses.200.content.['*/*'].schema.type").isEqualTo("string") + .jsonPath("$.paths./api.patch.tags[0]").isEqualTo("hello-controller") + .jsonPath("$.paths./api.patch.responses.200.content.['*/*'].schema.type").isEqualTo("string") + .jsonPath("$.paths./api.delete.tags[0]").isEqualTo("hello-controller") + .jsonPath("$.paths./api.delete.responses.200.content.['*/*'].schema.type").isEqualTo("string") + .jsonPath("$.paths./api.options.tags[0]").isEqualTo("hello-controller") + .jsonPath("$.paths./api.options.responses.200.content.['*/*'].schema.type").isEqualTo("string") + .jsonPath("$.paths./api.head.tags[0]").isEqualTo("hello-controller") + .jsonPath("$.paths./api.head.responses.200.content.['*/*'].schema.type").isEqualTo("string"); + } + + @SpringBootApplication + @ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.v31.app67" }) + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app68/SpringDocApp68Test.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app68/SpringDocApp68Test.java new file mode 100644 index 000000000..5f373000c --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app68/SpringDocApp68Test.java @@ -0,0 +1,64 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app68; + +import io.swagger.v3.oas.models.Components; +import io.swagger.v3.oas.models.OpenAPI; +import io.swagger.v3.oas.models.info.Info; +import io.swagger.v3.oas.models.info.License; +import io.swagger.v3.oas.models.security.SecurityScheme; +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.test.context.TestPropertySource; + +@TestPropertySource(properties = { + "springdoc.group-configs[0].group=stream", + "springdoc.group-configs[0].pathsToMatch=/stream/**" +}) +public class SpringDocApp68Test extends AbstractSpringDocTest { + + public SpringDocApp68Test() { + this.groupName = "/stream"; + } + + + @SpringBootApplication + @ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.v31.app68" }) + static class SpringDocTestApp { + @Bean + public OpenAPI customOpenAPI() { + return new OpenAPI() + .components(new Components().addSecuritySchemes("basicScheme", + new SecurityScheme().type(SecurityScheme.Type.HTTP).scheme("basic"))) + .info(new Info().title("Tweet API").version("v0") + .license(new License().name("Apache 2.0").url("http://springdoc.org"))); + } + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app68/controller/ExceptionTranslator.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app68/controller/ExceptionTranslator.java new file mode 100644 index 000000000..f4cf8792c --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app68/controller/ExceptionTranslator.java @@ -0,0 +1,58 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app68.controller; + +import test.org.springdoc.api.v31.app68.exception.TweetConflictException; +import test.org.springdoc.api.v31.app68.exception.TweetNotFoundException; +import test.org.springdoc.api.v31.app68.payload.ErrorResponse; + +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.ResponseStatus; +import org.springframework.web.bind.annotation.RestControllerAdvice; + +@RestControllerAdvice +public class ExceptionTranslator { + + + @SuppressWarnings("rawtypes") + @ExceptionHandler(TweetConflictException.class) + @ResponseStatus(HttpStatus.CONFLICT) + public ResponseEntity handleDuplicateKeyException(TweetConflictException ex) { + return ResponseEntity.status(HttpStatus.CONFLICT) + .body(new ErrorResponse("A Tweet with the same text already exists")); + } + + @SuppressWarnings("rawtypes") + @ExceptionHandler(TweetNotFoundException.class) + @ResponseStatus(HttpStatus.NOT_FOUND) + public ResponseEntity handleTweetNotFoundException(TweetNotFoundException ex) { + return ResponseEntity.notFound().build(); + } + +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app68/controller/TweetController.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app68/controller/TweetController.java new file mode 100644 index 000000000..9b2aa9765 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app68/controller/TweetController.java @@ -0,0 +1,95 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app68.controller; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; +import jakarta.validation.Valid; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; +import test.org.springdoc.api.v31.app68.dto.TweetDTO; + +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RestController; + +/** + * Created by rajeevkumarsingh on 08/09/17. + */ +@RestController +public class TweetController { + + + @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "get All Tweets") }) + @GetMapping("/tweets") + public Flux getAllTweets() { + return null; + } + + @PostMapping("/tweets") + @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "create Tweets") }) + public Mono createTweets(@Valid @RequestBody TweetDTO tweetDTO) { + return null; + } + + @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "get Tweet By Id"), + @ApiResponse(responseCode = "404", description = "tweet not found") }) + @GetMapping("/tweets/{id}") + public Mono> getTweetById(@PathVariable(value = "id") String tweetId) { + return null; + } + + @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "update Tweet"), + @ApiResponse(responseCode = "404", description = "tweet not found") }) + @PutMapping("/tweets/{id}") + public Mono> updateTweet(@PathVariable(value = "id") String tweetId, + @Valid @RequestBody TweetDTO tweetDTO) { + return null; + } + + @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "delete Tweet"), + @ApiResponse(responseCode = "404", description = "tweet not found") }) + @DeleteMapping("/tweets/{id}") + public Mono> deleteTweet(@PathVariable(value = "id") String tweetId) { + return null; + } + + @Operation(description = "Tweets are Sent to the client as Server Sent Events", responses = { + @ApiResponse(responseCode = "200", description = "stream All Tweets") }) + @GetMapping(value = "/stream/tweets", produces = MediaType.TEXT_EVENT_STREAM_VALUE) + public Flux streamAllTweets() { + return null; + } + +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app68/dto/TweetDTO.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app68/dto/TweetDTO.java new file mode 100644 index 000000000..34e4a2721 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app68/dto/TweetDTO.java @@ -0,0 +1,80 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app68.dto; + +import java.util.Date; + +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; +import jakarta.validation.constraints.Size; + + +/** + * Created by rajeevkumarsingh on 08/09/17. + */ +public class TweetDTO { + private String id; + + @NotBlank + @Size(max = 140) + private String text; + + @NotNull + private Date createdAt = new Date(); + + public TweetDTO() { + + } + + public TweetDTO(String text) { + this.text = text; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getText() { + return text; + } + + public void setText(String text) { + this.text = text; + } + + public Date getCreatedAt() { + return createdAt; + } + + public void setCreatedAt(Date createdAt) { + this.createdAt = createdAt; + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app68/exception/TweetConflictException.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app68/exception/TweetConflictException.java new file mode 100644 index 000000000..bd07eb40f --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app68/exception/TweetConflictException.java @@ -0,0 +1,42 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app68.exception; + +/** + * Created by rajeevkumarsingh on 22/10/17. + */ +public class TweetConflictException extends RuntimeException { + + /** + * + */ + private static final long serialVersionUID = 1L; + + public TweetConflictException(String tweetId) { + super("Tweet conflict with id " + tweetId); + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app68/exception/TweetNotFoundException.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app68/exception/TweetNotFoundException.java new file mode 100644 index 000000000..c22a909bd --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app68/exception/TweetNotFoundException.java @@ -0,0 +1,42 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app68.exception; + +/** + * Created by rajeevkumarsingh on 22/10/17. + */ +public class TweetNotFoundException extends RuntimeException { + + /** + * + */ + private static final long serialVersionUID = 1L; + + public TweetNotFoundException(String tweetId) { + super("Tweet not found with id " + tweetId); + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app68/payload/ErrorResponse.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app68/payload/ErrorResponse.java new file mode 100644 index 000000000..8ca3b42f9 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app68/payload/ErrorResponse.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.app68.payload; + +/** + * Created by rajeevkumarsingh on 22/10/17. + */ +public class ErrorResponse { + private String message; + + public ErrorResponse(String message) { + this.message = message; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app69/RoutingConfiguration.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app69/RoutingConfiguration.java new file mode 100644 index 000000000..e8be3704f --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app69/RoutingConfiguration.java @@ -0,0 +1,62 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app69; + +import org.springdoc.core.annotations.RouterOperation; +import org.springdoc.core.annotations.RouterOperations; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.http.MediaType; +import org.springframework.web.reactive.function.server.RouterFunction; +import org.springframework.web.reactive.function.server.ServerResponse; + +import static org.springframework.web.reactive.function.server.RequestPredicates.DELETE; +import static org.springframework.web.reactive.function.server.RequestPredicates.GET; +import static org.springframework.web.reactive.function.server.RequestPredicates.POST; +import static org.springframework.web.reactive.function.server.RequestPredicates.PUT; +import static org.springframework.web.reactive.function.server.RequestPredicates.accept; +import static org.springframework.web.reactive.function.server.RouterFunctions.route; + +@Configuration +public class RoutingConfiguration { + + @Bean + @RouterOperations({ @RouterOperation(path = "/api/user/index", beanClass = UserRepository.class, beanMethod = "getAllUsers"), + @RouterOperation(path = "/api/user/{id}", beanClass = UserRepository.class, beanMethod = "getUserById"), + @RouterOperation(path = "/api/user/post", beanClass = UserRepository.class, beanMethod = "saveUser"), + @RouterOperation(path = "/api/user/put/{id}", beanClass = UserRepository.class, beanMethod = "putUser"), + @RouterOperation(path = "/api/user/delete/{id}", beanClass = UserRepository.class, beanMethod = "deleteUser") }) + public RouterFunction monoRouterFunction(UserHandler userHandler) { + return route(GET("/api/user/index").and(accept(MediaType.APPLICATION_JSON)), userHandler::getAll) + .andRoute(GET("/api/user/{id}").and(accept(MediaType.APPLICATION_JSON)), userHandler::getUser) + .andRoute(POST("/api/user/post").and(accept(MediaType.APPLICATION_JSON)), userHandler::postUser) + .andRoute(PUT("/api/user/put/{id}").and(accept(MediaType.APPLICATION_JSON)), userHandler::putUser) + .andRoute(DELETE("/api/user/delete/{id}").and(accept(MediaType.APPLICATION_JSON)), userHandler::deleteUser); + } + +} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app69/SpringDocApp69Test.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app69/SpringDocApp69Test.java new file mode 100644 index 000000000..a67a07077 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app69/SpringDocApp69Test.java @@ -0,0 +1,39 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app69; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.ComponentScan; + +public class SpringDocApp69Test extends AbstractSpringDocTest { + + @SpringBootApplication + @ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.v31.app69" }) + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app69/User.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app69/User.java new file mode 100644 index 000000000..5fc8425fe --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app69/User.java @@ -0,0 +1,85 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app69; + +public class User { + private long id; + + private String firstname; + + private String lastname; + + private int age; + + public User() { + } + + public User(long id, String firstname, String lastname, int age) { + this.id = id; + this.firstname = firstname; + this.lastname = lastname; + this.age = age; + } + + public long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getFirstname() { + return firstname; + } + + public void setFirstname(String firstname) { + this.firstname = firstname; + } + + public String getLastname() { + return lastname; + } + + public void setLastname(String lastname) { + this.lastname = lastname; + } + + public int getAge() { + return age; + } + + public void setAge(int age) { + this.age = age; + } + + @Override + public String toString() { + String info = String.format("id = %d, firstname = %s, lastname = %s, age = %d", id, firstname, lastname, age); + return info; + } +} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app69/UserHandler.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app69/UserHandler.java new file mode 100644 index 000000000..bf3798557 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app69/UserHandler.java @@ -0,0 +1,119 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app69; + +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +import org.springframework.http.MediaType; +import org.springframework.stereotype.Component; +import org.springframework.web.reactive.function.server.ServerRequest; +import org.springframework.web.reactive.function.server.ServerResponse; + +import static org.springframework.web.reactive.function.BodyInserters.fromObject; + +@Component +public class UserHandler { + + private final UserRepository customerRepository; + + public UserHandler(UserRepository repository) { + this.customerRepository = repository; + } + + /** + * GET ALL Users + */ + public Mono getAll(ServerRequest request) { + // fetch all customers from repository + Flux customers = customerRepository.getAllUsers(); + + // build response + return ServerResponse.ok().contentType(MediaType.APPLICATION_JSON).body(customers, User.class); + } + + /** + * GET a User by ID + */ + public Mono getUser(ServerRequest request) { + // parse path-variable + long customerId = Long.valueOf(request.queryParam("id").get()); + + // build notFound response + Mono notFound = ServerResponse.notFound().build(); + + // get customer from repository + Mono customerMono = customerRepository.getUserById(customerId); + + // build response + return customerMono + .flatMap(customer -> ServerResponse.ok().contentType(MediaType.APPLICATION_JSON).body(fromObject(customer))) + .switchIfEmpty(notFound); + } + + /** + * POST a User + */ + public Mono postUser(ServerRequest request) { + Mono customer = request.bodyToMono(User.class); + return ServerResponse.ok().build(customerRepository.saveUser(customer)); + } + + /** + * PUT a User + */ + public Mono putUser(ServerRequest request) { + // parse id from path-variable + long customerId = Long.valueOf(request.pathVariable("id")); + + // get customer data from request object + Mono customer = request.bodyToMono(User.class); + + // get customer from repository + Mono responseMono = customerRepository.putUser(customerId, customer); + + // build response + return responseMono + .flatMap(cust -> ServerResponse.ok().contentType(MediaType.APPLICATION_JSON).body(fromObject(cust))); + } + + /** + * DELETE a User + */ + public Mono deleteUser(ServerRequest request) { + // parse id from path-variable + long customerId = Long.valueOf(request.pathVariable("id")); + + // get customer from repository + Mono responseMono = customerRepository.deleteUser(customerId); + + // build response + return responseMono + .flatMap(strMono -> ServerResponse.ok().contentType(MediaType.TEXT_PLAIN).body(fromObject(strMono))); + } + +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app69/UserRepository.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app69/UserRepository.java new file mode 100644 index 000000000..9aca62c39 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app69/UserRepository.java @@ -0,0 +1,51 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app69; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.enums.ParameterIn; +import io.swagger.v3.oas.annotations.parameters.RequestBody; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +public interface UserRepository { + + public Mono getUserById(@Parameter(in = ParameterIn.PATH, description = "The user Id") Long id); + + @Operation(description = "get all the users") + public Flux getAllUsers(); + + @Operation(description = "get all the users by firstname") + public Flux getAllUsers(String firstname); + + public Mono saveUser(Mono user); + + public Mono putUser(@Parameter(in = ParameterIn.PATH) Long id, @RequestBody Mono user); + + public Mono deleteUser(@Parameter(in = ParameterIn.PATH) Long id); +} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app69/UserRepositoryImpl.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app69/UserRepositoryImpl.java new file mode 100644 index 000000000..cda571b61 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app69/UserRepositoryImpl.java @@ -0,0 +1,98 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app69; + +import java.util.HashMap; +import java.util.Map; + +import jakarta.annotation.PostConstruct; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +import org.springframework.stereotype.Repository; + +@Repository +public class UserRepositoryImpl implements UserRepository { + private Map users = new HashMap(); + + @PostConstruct + public void init() throws Exception { + users.put(Long.valueOf(1), new User(1, "Jack", "Smith", 20)); + users.put(Long.valueOf(2), new User(2, "Peter", "Johnson", 25)); + } + + @Override + public Mono getUserById(Long id) { + return Mono.just(users.get(id)); + } + + @Override + public Flux getAllUsers() { + return Flux.fromIterable(this.users.values()); + } + + @Override + public Flux getAllUsers(String firstname) { + return Flux.fromIterable(this.users.values().stream().filter(user -> user.getFirstname().equals(firstname)).toList()); + } + + @Override + public Mono saveUser(Mono monoUser) { + Mono userMono = monoUser.doOnNext(user -> { + // do post + users.put(user.getId(), user); + + // log on console + System.out.println("########### POST:" + user); + }); + + return userMono.then(); + } + + @Override + public Mono putUser(Long id, Mono monoUser) { + Mono userMono = monoUser.doOnNext(user -> { + // reset user.Id + user.setId(id); + + // do put + users.put(id, user); + + // log on console + System.out.println("########### PUT:" + user); + }); + + return userMono; + } + + @Override + public Mono deleteUser(Long id) { + // delete processing + users.remove(id); + return Mono.just("Delete Succesfully!"); + } +} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app70/Coffee.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app70/Coffee.java new file mode 100644 index 000000000..91528daec --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app70/Coffee.java @@ -0,0 +1,86 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app70; + +import java.util.Objects; + +public class Coffee { + + private String id; + + private String name; + + public Coffee() { + } + + public Coffee(String name) { + this.name = name; + } + + public Coffee(String id, String name) { + this.id = id; + this.name = name; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Coffee coffee = (Coffee) o; + return Objects.equals(id, coffee.id) && + Objects.equals(name, coffee.name); + } + + @Override + public int hashCode() { + return Objects.hash(id, name); + } + + @Override + public String toString() { + return "Coffee{" + + "id='" + id + '\'' + + ", name='" + name + '\'' + + '}'; + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app70/CoffeeOrder.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app70/CoffeeOrder.java new file mode 100644 index 000000000..f11aa8d4a --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app70/CoffeeOrder.java @@ -0,0 +1,74 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app70; + +import java.time.Instant; +import java.util.Objects; + +public class CoffeeOrder { + private String coffeeId; + + private Instant whenOrdered; + + public CoffeeOrder() { + } + + public CoffeeOrder(String coffeeId, Instant whenOrdered) { + this.coffeeId = coffeeId; + this.whenOrdered = whenOrdered; + } + + public String getCoffeeId() { + return coffeeId; + } + + public Instant getWhenOrdered() { + return whenOrdered; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + CoffeeOrder that = (CoffeeOrder) o; + return Objects.equals(coffeeId, that.coffeeId) && + Objects.equals(whenOrdered, that.whenOrdered); + } + + @Override + public int hashCode() { + return Objects.hash(coffeeId, whenOrdered); + } + + @Override + public String toString() { + return "CoffeeOrder{" + + "coffeeId='" + coffeeId + '\'' + + ", whenOrdered=" + whenOrdered + + '}'; + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app70/CoffeeRepository.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app70/CoffeeRepository.java new file mode 100644 index 000000000..8a8da0ea7 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app70/CoffeeRepository.java @@ -0,0 +1,52 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app70; + +import org.reactivestreams.Publisher; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +import org.springframework.stereotype.Repository; + +@Repository +public class CoffeeRepository { + Flux deleteAll() { + return null; + } + + Mono findById(String id) { + return null; + } + + Publisher save(Coffee coffee) { + return null; + } + + Flux findAll() { + return null; + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app70/CoffeeService.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app70/CoffeeService.java new file mode 100644 index 000000000..634622c20 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app70/CoffeeService.java @@ -0,0 +1,60 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app70; + +import java.time.Duration; +import java.time.Instant; + +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.enums.ParameterIn; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +import org.springframework.stereotype.Service; + +@Service +public class CoffeeService { + private final CoffeeRepository repo; + + public CoffeeService(CoffeeRepository repo) { + this.repo = repo; + } + + Flux getAllCoffees() { + return repo.findAll(); + } + + Mono getCoffeeById(@Parameter(in = ParameterIn.PATH) String id) { + return repo.findById(id); + } + + Flux getOrdersForCoffeeById(@Parameter(in = ParameterIn.PATH) String id) { + return Flux.interval(Duration.ofSeconds(1)) + .onBackpressureDrop() + .map(i -> new CoffeeOrder(id, Instant.now())); + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app70/RouteConfig.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app70/RouteConfig.java new file mode 100644 index 000000000..a444b8144 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app70/RouteConfig.java @@ -0,0 +1,76 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app70; + +import org.springdoc.core.annotations.RouterOperation; +import org.springdoc.core.annotations.RouterOperations; +import reactor.core.publisher.Mono; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.http.MediaType; +import org.springframework.web.reactive.function.server.RouterFunction; +import org.springframework.web.reactive.function.server.ServerRequest; +import org.springframework.web.reactive.function.server.ServerResponse; + +import static org.springframework.web.reactive.function.server.RequestPredicates.GET; +import static org.springframework.web.reactive.function.server.RouterFunctions.route; + +@Configuration +public class RouteConfig { + private final CoffeeService service; + + public RouteConfig(CoffeeService service) { + this.service = service; + } + + @Bean + @RouterOperations({ @RouterOperation(path = "/coffees", beanClass = CoffeeService.class, beanMethod = "getAllCoffees"), + @RouterOperation(path = "/coffees/{id}", beanClass = CoffeeService.class, beanMethod = "getCoffeeById"), + @RouterOperation(path = "/coffees/{id}/orders", beanClass = CoffeeService.class, beanMethod = "getOrdersForCoffeeById") }) + RouterFunction routerFunction() { + return route(GET("/coffees"), this::all) + .andRoute(GET("/coffees/{id}"), this::byId) + .andRoute(GET("/coffees/{id}/orders"), this::orders); + } + + private Mono all(ServerRequest req) { + return ServerResponse.ok() + .body(service.getAllCoffees(), Coffee.class); + } + + private Mono byId(ServerRequest req) { + return ServerResponse.ok() + .body(service.getCoffeeById(req.pathVariable("id")), Coffee.class); + } + + private Mono orders(ServerRequest req) { + return ServerResponse.ok() + .contentType(MediaType.TEXT_EVENT_STREAM) + .body(service.getOrdersForCoffeeById(req.pathVariable("id")), CoffeeOrder.class); + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app70/SpringDocApp70Test.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app70/SpringDocApp70Test.java new file mode 100644 index 000000000..9490d82a1 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app70/SpringDocApp70Test.java @@ -0,0 +1,39 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app70; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.ComponentScan; + +public class SpringDocApp70Test extends AbstractSpringDocTest { + + @SpringBootApplication + @ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.v31.app70" }) + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app71/Employee.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app71/Employee.java new file mode 100644 index 000000000..44f0e2c81 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app71/Employee.java @@ -0,0 +1,50 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app71; + +public class Employee { + + private String id; + + private String name; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app71/EmployeeFunctionalConfig.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app71/EmployeeFunctionalConfig.java new file mode 100644 index 000000000..f07d94e1a --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app71/EmployeeFunctionalConfig.java @@ -0,0 +1,108 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app71; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.enums.ParameterIn; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import org.springdoc.core.annotations.RouterOperation; +import org.springdoc.core.annotations.RouterOperations; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.http.MediaType; +import org.springframework.web.reactive.function.BodyExtractors; +import org.springframework.web.reactive.function.server.RouterFunction; +import org.springframework.web.reactive.function.server.ServerResponse; + +import static org.springframework.web.reactive.function.server.RequestPredicates.GET; +import static org.springframework.web.reactive.function.server.RequestPredicates.POST; +import static org.springframework.web.reactive.function.server.RequestPredicates.accept; +import static org.springframework.web.reactive.function.server.RouterFunctions.route; +import static org.springframework.web.reactive.function.server.ServerResponse.ok; + +@Configuration +public class EmployeeFunctionalConfig { + + + @Bean + EmployeeRepository employeeRepository() { + return new EmployeeRepository(); + } + + @Bean + @RouterOperation(beanClass = EmployeeRepository.class, beanMethod = "findAllEmployees") + RouterFunction getAllEmployeesRoute() { + return route(GET("/employees").and(accept(MediaType.APPLICATION_JSON)), + req -> ok().body( + employeeRepository().findAllEmployees(), Employee.class)); + } + + @Bean + @RouterOperation(operation = @Operation(operationId = "findEmployeeById", summary = "Find purchase order by ID", tags = { "MyEmployee" }, + parameters = { @Parameter(in = ParameterIn.PATH, name = "id", description = "Employee Id") }, + responses = { @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(schema = @Schema(implementation = Employee.class))), + @ApiResponse(responseCode = "400", description = "Invalid Employee ID supplied"), + @ApiResponse(responseCode = "404", description = "Employee not found") })) + RouterFunction getEmployeeByIdRoute() { + return route(GET("/employees/{id}"), + req -> ok().body( + employeeRepository().findEmployeeById(req.pathVariable("id")), Employee.class)); + } + + + @Bean + @RouterOperation(beanClass = EmployeeRepository.class, beanMethod = "updateEmployee") + RouterFunction updateEmployeeRoute() { + return route(POST("/employees/update").and(accept(MediaType.APPLICATION_XML)), + req -> req.body(BodyExtractors.toMono(Employee.class)) + .doOnNext(employeeRepository()::updateEmployee) + .then(ok().build())); + } + + @Bean + @RouterOperations({ @RouterOperation(path = "/employees-composed/update", beanClass = EmployeeRepository.class, beanMethod = "updateEmployee"), + @RouterOperation(path = "/employees-composed/{id}", beanClass = EmployeeRepository.class, beanMethod = "findEmployeeById"), + @RouterOperation(path = "/employees-composed", beanClass = EmployeeRepository.class, beanMethod = "findAllEmployees") }) + RouterFunction composedRoutes() { + return + route(GET("/employees-composed"), + req -> ok().body( + employeeRepository().findAllEmployees(), Employee.class)) + .and(route(GET("/employees-composed/{id}"), + req -> ok().body( + employeeRepository().findEmployeeById(req.pathVariable("id")), Employee.class))) + .and(route(POST("/employees-composed/update"), + req -> req.body(BodyExtractors.toMono(Employee.class)) + .doOnNext(employeeRepository()::updateEmployee) + .then(ok().build()))); + } + +} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app71/EmployeeRepository.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app71/EmployeeRepository.java new file mode 100644 index 000000000..0a9cbfbf4 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app71/EmployeeRepository.java @@ -0,0 +1,58 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app71; + +import java.util.Map; + +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.enums.ParameterIn; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +public class EmployeeRepository { + + static Map employeeData; + + static Map employeeAccessData; + + + public Mono findEmployeeById(@Parameter(in = ParameterIn.PATH) String id) { + return Mono.just(employeeData.get(id)); + } + + public Flux findAllEmployees() { + return Flux.fromIterable(employeeData.values()); + } + + public Mono updateEmployee(Employee employee) { + Employee existingEmployee = employeeData.get(employee.getId()); + if (existingEmployee != null) { + existingEmployee.setName(employee.getName()); + } + return Mono.just(existingEmployee); + } +} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app71/SpringDocApp71Test.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app71/SpringDocApp71Test.java new file mode 100644 index 000000000..14e5f47c9 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app71/SpringDocApp71Test.java @@ -0,0 +1,39 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app71; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.ComponentScan; + +public class SpringDocApp71Test extends AbstractSpringDocTest { + + @SpringBootApplication + @ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.v31.app71" }) + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app72/SpringDocApp72Test.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app72/SpringDocApp72Test.java new file mode 100644 index 000000000..b38f5e05b --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app72/SpringDocApp72Test.java @@ -0,0 +1,39 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app72; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.ComponentScan; + +public class SpringDocApp72Test extends AbstractSpringDocTest { + + @SpringBootApplication + @ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.v31.app72" }) + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app72/controller/PersonRouter.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app72/controller/PersonRouter.java new file mode 100644 index 000000000..a316dfb3e --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app72/controller/PersonRouter.java @@ -0,0 +1,62 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app72.controller; + +import org.springdoc.core.annotations.RouterOperation; +import org.springdoc.core.annotations.RouterOperations; +import test.org.springdoc.api.v31.app72.handler.PersonHandler; +import test.org.springdoc.api.v31.app72.service.PersonService; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.http.MediaType; +import org.springframework.web.reactive.function.server.RouterFunction; +import org.springframework.web.reactive.function.server.RouterFunctions; +import org.springframework.web.reactive.function.server.ServerResponse; + +import static org.springframework.web.reactive.function.server.RequestPredicates.DELETE; +import static org.springframework.web.reactive.function.server.RequestPredicates.GET; +import static org.springframework.web.reactive.function.server.RequestPredicates.POST; +import static org.springframework.web.reactive.function.server.RequestPredicates.accept; + +@Configuration +public class PersonRouter { + + @RouterOperations({ @RouterOperation(path = "/getAllPersons", beanClass = PersonService.class, beanMethod = "getAll"), + @RouterOperation(path = "/getPerson/{id}", beanClass = PersonService.class, beanMethod = "getById"), + @RouterOperation(path = "/createPerson", beanClass = PersonService.class, beanMethod = "save"), + @RouterOperation(path = "/deletePerson/{id}", beanClass = PersonService.class, beanMethod = "delete") }) + @Bean + public RouterFunction personRoute(PersonHandler handler) { + return RouterFunctions + .route(GET("/getAllPersons").and(accept(MediaType.APPLICATION_JSON)), handler::findAll) + .andRoute(GET("/getPerson/{id}").and(accept(MediaType.APPLICATION_STREAM_JSON)), handler::findById) + .andRoute(POST("/createPerson").and(accept(MediaType.APPLICATION_JSON)), handler::save) + .andRoute(DELETE("/deletePerson/{id}").and(accept(MediaType.APPLICATION_JSON)), handler::delete); + } + +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app72/controller/PositionRouter.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app72/controller/PositionRouter.java new file mode 100644 index 000000000..3392f7da5 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app72/controller/PositionRouter.java @@ -0,0 +1,74 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app72.controller; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.enums.ParameterIn; +import io.swagger.v3.oas.annotations.media.ArraySchema; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.parameters.RequestBody; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import org.springdoc.core.annotations.RouterOperation; +import org.springdoc.core.annotations.RouterOperations; +import test.org.springdoc.api.v31.app72.entity.Position; +import test.org.springdoc.api.v31.app72.handler.PositionHandler; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.http.MediaType; +import org.springframework.web.reactive.function.server.RouterFunction; +import org.springframework.web.reactive.function.server.RouterFunctions; +import org.springframework.web.reactive.function.server.ServerResponse; + +import static org.springframework.web.reactive.function.server.RequestPredicates.DELETE; +import static org.springframework.web.reactive.function.server.RequestPredicates.GET; +import static org.springframework.web.reactive.function.server.RequestPredicates.POST; +import static org.springframework.web.reactive.function.server.RequestPredicates.accept; + +@Configuration +public class PositionRouter { + + @Bean + @RouterOperations({ @RouterOperation(path = "/getAllPositions", operation = @Operation(description = "Get all positions", operationId = "findAll", tags = "positions", + responses = @ApiResponse(responseCode = "200", content = @Content(array = @ArraySchema(schema = @Schema(implementation = Position.class)))))), + @RouterOperation(path = "/getPosition/{id}", operation = @Operation(description = "Find all", operationId = "findById", tags = "positions", parameters = @Parameter(name = "id", in = ParameterIn.PATH), + responses = @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = Position.class))))), + @RouterOperation(path = "/createPosition", operation = @Operation(description = "Save position", operationId = "save", tags = "positions", requestBody = @RequestBody(content = @Content(schema = @Schema(implementation = Position.class))), + responses = @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = Position.class))))), + @RouterOperation(path = "/deletePosition/{id}", operation = @Operation(description = "Delete By Id", operationId = "deleteBy", tags = "positions", parameters = @Parameter(name = "id", in = ParameterIn.PATH), + responses = @ApiResponse(responseCode = "200", content = @Content))) }) + public RouterFunction positionRoute(PositionHandler handler) { + return RouterFunctions + .route(GET("/getAllPositions").and(accept(MediaType.APPLICATION_JSON)), handler::findAll) + .andRoute(GET("/getPosition/{id}").and(accept(MediaType.APPLICATION_STREAM_JSON)), handler::findById) + .andRoute(POST("/createPosition").and(accept(MediaType.APPLICATION_JSON)), handler::save) + .andRoute(DELETE("/deletePosition/{id}").and(accept(MediaType.APPLICATION_JSON)), handler::delete); + } + +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app72/entity/Person.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app72/entity/Person.java new file mode 100644 index 000000000..56312cdca --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app72/entity/Person.java @@ -0,0 +1,100 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app72.entity; + +public class Person { + + private String id; + + private Sex sex; + + private String firstName; + + private String lastName; + + private String age; + + private String interests; + + private String email; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public Sex getSex() { + return sex; + } + + public void setSex(Sex sex) { + this.sex = sex; + } + + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } + + public String getAge() { + return age; + } + + public void setAge(String age) { + this.age = age; + } + + public String getInterests() { + return interests; + } + + public void setInterests(String interests) { + this.interests = interests; + } + + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app72/entity/Position.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app72/entity/Position.java new file mode 100644 index 000000000..f0352f835 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app72/entity/Position.java @@ -0,0 +1,80 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app72.entity; + +import java.util.Date; + +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; +import jakarta.validation.constraints.Size; + + +public class Position { + + private String id; + + @NotBlank + @Size(max = 140) + private String positionName; + + private String description; + + @NotNull + private Date createdAt = new Date(); + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getPositionName() { + return positionName; + } + + public void setPositionName(String positionName) { + this.positionName = positionName; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public Date getCreatedAt() { + return createdAt; + } + + public void setCreatedAt(Date createdAt) { + this.createdAt = createdAt; + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app72/entity/Sex.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app72/entity/Sex.java new file mode 100644 index 000000000..7012f44ff --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app72/entity/Sex.java @@ -0,0 +1,31 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app72.entity; + +public enum Sex { + MAN, WOMEN +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app72/exception/PositionNotFoundException.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app72/exception/PositionNotFoundException.java new file mode 100644 index 000000000..34ed831f7 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app72/exception/PositionNotFoundException.java @@ -0,0 +1,34 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app72.exception; + +public class PositionNotFoundException extends RuntimeException { + + public PositionNotFoundException(String positionId) { + super("Position not found with id " + positionId); + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app72/handler/PersonHandler.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app72/handler/PersonHandler.java new file mode 100644 index 000000000..aa692d001 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app72/handler/PersonHandler.java @@ -0,0 +1,78 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app72.handler; + +import reactor.core.publisher.Mono; +import test.org.springdoc.api.v31.app72.entity.Person; +import test.org.springdoc.api.v31.app72.service.PersonService; + +import org.springframework.http.MediaType; +import org.springframework.stereotype.Component; +import org.springframework.web.reactive.function.BodyInserters; +import org.springframework.web.reactive.function.server.ServerRequest; +import org.springframework.web.reactive.function.server.ServerResponse; + +import static org.springframework.web.reactive.function.server.ServerResponse.ok; + +@Component +@SuppressWarnings({ "deprecared", "unchecked" }) +public class PersonHandler { + + private final PersonService personService; + + public PersonHandler(PersonService personService) { + this.personService = personService; + } + + public Mono findById(ServerRequest request) { + String id = request.pathVariable("id"); + return ok() + .contentType(MediaType.APPLICATION_JSON) + .body(personService.getById(id), Person.class); + } + + public Mono findAll(ServerRequest request) { + return ok() + .contentType(MediaType.APPLICATION_JSON) + .body(personService.getAll(), Person.class); + } + + public Mono save(ServerRequest request) { + final Mono person = request.bodyToMono(Person.class); + return ok() + .contentType(MediaType.APPLICATION_JSON) + .body(BodyInserters.fromPublisher(person.flatMap(personService::save), Person.class)); + } + + public Mono delete(ServerRequest request) { + String id = request.pathVariable("id"); + return ok() + .contentType(MediaType.APPLICATION_JSON) + .body(personService.delete(id), Void.class); + } + +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app72/handler/PositionHandler.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app72/handler/PositionHandler.java new file mode 100644 index 000000000..71e4f584a --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app72/handler/PositionHandler.java @@ -0,0 +1,56 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app72.handler; + +import reactor.core.publisher.Mono; + +import org.springframework.stereotype.Component; +import org.springframework.web.reactive.function.server.ServerRequest; +import org.springframework.web.reactive.function.server.ServerResponse; + +@Component +public class PositionHandler { + + + public Mono findById(ServerRequest request) { + String id = request.pathVariable("id"); + return null; + } + + public Mono findAll(ServerRequest request) { + return null; + } + + public Mono save(ServerRequest request) { + return null; + } + + public Mono delete(ServerRequest request) { + return null; + } + +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app72/payload/ErrorResponse.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app72/payload/ErrorResponse.java new file mode 100644 index 000000000..7c6b5ab47 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app72/payload/ErrorResponse.java @@ -0,0 +1,45 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app72.payload; + +public class ErrorResponse { + + private String message; + + public ErrorResponse(String message) { + this.message = message; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app72/service/PersonService.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app72/service/PersonService.java new file mode 100644 index 000000000..774467db8 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app72/service/PersonService.java @@ -0,0 +1,65 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app72.service; + +import java.util.Objects; + +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.enums.ParameterIn; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; +import test.org.springdoc.api.v31.app72.entity.Person; + +import org.springframework.stereotype.Service; + +@Service +public class PersonService { + + public Flux getAll() { + return null; + } + + public Mono getById(@Parameter(in = ParameterIn.PATH) final String id) { + return null; + } + + public Mono update(@Parameter(in = ParameterIn.PATH) final String id, final Person person) { + return null; + } + + public Mono save(final Person person) { + return null; + } + + public Mono delete(@Parameter(in = ParameterIn.PATH) final String id) { + final Mono dbPerson = getById(id); + if (Objects.isNull(dbPerson)) { + return Mono.empty(); + } + return null; + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app73/Quote.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app73/Quote.java new file mode 100644 index 000000000..6f2f76ed4 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app73/Quote.java @@ -0,0 +1,88 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app73; + + +import java.math.BigDecimal; +import java.math.MathContext; +import java.time.Instant; + +public class Quote { + + private static final MathContext MATH_CONTEXT = new MathContext(2); + + private String ticker; + + private BigDecimal price; + + private Instant instant; + + public Quote() { + } + + public Quote(String ticker, BigDecimal price) { + this.ticker = ticker; + this.price = price; + } + + public Quote(String ticker, Double price) { + this(ticker, new BigDecimal(price, MATH_CONTEXT)); + } + + public String getTicker() { + return ticker; + } + + public void setTicker(String ticker) { + this.ticker = ticker; + } + + public BigDecimal getPrice() { + return price; + } + + public void setPrice(BigDecimal price) { + this.price = price; + } + + public Instant getInstant() { + return instant; + } + + public void setInstant(Instant instant) { + this.instant = instant; + } + + @Override + public String toString() { + return "Quote{" + + "ticker='" + ticker + '\'' + + ", price=" + price + + ", instant=" + instant + + '}'; + } +} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app73/QuoteGenerator.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app73/QuoteGenerator.java new file mode 100644 index 000000000..02b9ae3b4 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app73/QuoteGenerator.java @@ -0,0 +1,95 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app73; + + +import java.math.BigDecimal; +import java.math.MathContext; +import java.time.Duration; +import java.time.Instant; +import java.util.ArrayList; +import java.util.List; +import java.util.Random; + +import reactor.core.publisher.Flux; + +import org.springframework.stereotype.Component; + +@Component +public class QuoteGenerator { + + private final MathContext mathContext = new MathContext(2); + + private final Random random = new Random(); + + private final List prices = new ArrayList<>(); + + /** + * Bootstraps the generator with tickers and initial prices + */ + public QuoteGenerator() { + this.prices.add(new Quote("CTXS", 82.26)); + this.prices.add(new Quote("DELL", 63.74)); + this.prices.add(new Quote("GOOG", 847.24)); + this.prices.add(new Quote("MSFT", 65.11)); + this.prices.add(new Quote("ORCL", 45.71)); + this.prices.add(new Quote("RHT", 84.29)); + this.prices.add(new Quote("VMW", 92.21)); + } + + + public Flux fetchQuoteStream(Duration period) { + + // We want to emit quotes with a specific period; + // to do so, we create a Flux.interval + return Flux.interval(period) + // In case of back-pressure, drop events + .onBackpressureDrop() + // For each tick, generate a list of quotes + .map(this::generateQuotes) + // "flatten" that List into a Flux + .flatMapIterable(quotes -> quotes) + .log("io.spring.workshop.stockquotes"); + } + + /* + * Create quotes for all tickers at a single instant. + */ + private List generateQuotes(long interval) { + final Instant instant = Instant.now(); + return prices.stream() + .map(baseQuote -> { + BigDecimal priceChange = baseQuote.getPrice() + .multiply(new BigDecimal(0.05 * this.random.nextDouble()), this.mathContext); + Quote result = new Quote(baseQuote.getTicker(), baseQuote.getPrice().add(priceChange)); + result.setInstant(instant); + return result; + }) + .toList(); + } + +} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app73/QuoteHandler.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app73/QuoteHandler.java new file mode 100644 index 000000000..a1ed9bda2 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app73/QuoteHandler.java @@ -0,0 +1,72 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app73; + + +import java.time.Duration; + +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +import org.springframework.http.MediaType; +import org.springframework.stereotype.Component; +import org.springframework.web.reactive.function.BodyInserters; +import org.springframework.web.reactive.function.server.ServerRequest; +import org.springframework.web.reactive.function.server.ServerResponse; + +@Component +public class QuoteHandler { + + private final Flux quoteStream; + + public QuoteHandler(QuoteGenerator quoteGenerator) { + this.quoteStream = quoteGenerator.fetchQuoteStream(Duration.ofMillis(1000)).share(); + } + + public Mono hello(ServerRequest request) { + return ServerResponse.ok().contentType(MediaType.TEXT_PLAIN) + .body(BodyInserters.fromObject("Hello Spring!")); + } + + public Mono echo(ServerRequest request) { + return ServerResponse.ok().contentType(MediaType.TEXT_PLAIN) + .body(request.bodyToMono(String.class), String.class); + } + + public Mono streamQuotes(ServerRequest request) { + return ServerResponse.ok() + .contentType(MediaType.APPLICATION_STREAM_JSON) + .body(this.quoteStream, Quote.class); + } + + public Mono fetchQuotes(ServerRequest request) { + int size = Integer.parseInt(request.queryParam("size").orElse("10")); + return ServerResponse.ok() + .contentType(MediaType.APPLICATION_JSON) + .body(this.quoteStream.take(size), Quote.class); + } +} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app73/QuoteRouter.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app73/QuoteRouter.java new file mode 100644 index 000000000..cb5d1075c --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app73/QuoteRouter.java @@ -0,0 +1,79 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app73; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.enums.ParameterIn; +import io.swagger.v3.oas.annotations.media.ArraySchema; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.parameters.RequestBody; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import org.springdoc.core.annotations.RouterOperation; +import org.springdoc.core.annotations.RouterOperations; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.reactive.function.server.RouterFunction; +import org.springframework.web.reactive.function.server.RouterFunctions; +import org.springframework.web.reactive.function.server.ServerResponse; + +import static org.springframework.http.MediaType.APPLICATION_JSON; +import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE; +import static org.springframework.http.MediaType.APPLICATION_STREAM_JSON; +import static org.springframework.http.MediaType.APPLICATION_STREAM_JSON_VALUE; +import static org.springframework.http.MediaType.TEXT_PLAIN; +import static org.springframework.http.MediaType.TEXT_PLAIN_VALUE; +import static org.springframework.web.reactive.function.server.RequestPredicates.GET; +import static org.springframework.web.reactive.function.server.RequestPredicates.POST; +import static org.springframework.web.reactive.function.server.RequestPredicates.accept; +import static org.springframework.web.reactive.function.server.RequestPredicates.contentType; + +@Configuration +public class QuoteRouter { + + @RouterOperations({ + @RouterOperation(path = "/hello", operation = @Operation(operationId = "hello", responses = @ApiResponse(responseCode = "200"))), + @RouterOperation(path = "/echo", produces = TEXT_PLAIN_VALUE, operation = @Operation(operationId = "echo", requestBody = @RequestBody(content = @Content(schema = @Schema(type = "string"))), + responses = @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(type = "string"))))), + @RouterOperation(path = "/echo", produces = APPLICATION_JSON_VALUE, operation = @Operation(operationId = "echo", requestBody = @RequestBody(content = @Content(schema = @Schema(type = "string"))), + responses = @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(type = "string"))))), + @RouterOperation(path = "/quotes", produces = APPLICATION_JSON_VALUE, operation = @Operation(operationId = "fetchQuotes", parameters = @Parameter(name = "size", in = ParameterIn.QUERY, schema = @Schema(type = "string")), + responses = @ApiResponse(responseCode = "200", content = @Content(array = @ArraySchema(schema = @Schema(implementation = Quote.class)))))), + @RouterOperation(path = "/quotes", produces = APPLICATION_STREAM_JSON_VALUE, operation = @Operation(operationId = "fetchQuotes", + responses = @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = Quote.class))))) }) + @Bean + public RouterFunction route(QuoteHandler quoteHandler) { + return RouterFunctions + .route(GET("/hello").and(accept(TEXT_PLAIN)), quoteHandler::hello) + .andRoute(POST("/echo").and(accept(TEXT_PLAIN).and(contentType(TEXT_PLAIN))), quoteHandler::echo) + .andRoute(POST("/echo").and(accept(APPLICATION_JSON).and(contentType(APPLICATION_JSON))), quoteHandler::echo) + .andRoute(GET("/quotes").and(accept(APPLICATION_JSON)), quoteHandler::fetchQuotes) + .andRoute(GET("/quotes").and(accept(APPLICATION_STREAM_JSON)), quoteHandler::streamQuotes); + } +} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app73/SpringDocApp73Test.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app73/SpringDocApp73Test.java new file mode 100644 index 000000000..e9b1091f6 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app73/SpringDocApp73Test.java @@ -0,0 +1,39 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app73; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.ComponentScan; + +public class SpringDocApp73Test extends AbstractSpringDocTest { + + @SpringBootApplication + @ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.v31.app73" }) + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app74/Book.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app74/Book.java new file mode 100644 index 000000000..f34b933e3 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app74/Book.java @@ -0,0 +1,66 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app74; + +public class Book { + + private String id; + + private String title; + + private String author; + + public Book(String id, String title, String author) { + this.id = id; + this.title = title; + this.author = author; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getAuthor() { + return author; + } + + public void setAuthor(String author) { + this.author = author; + } +} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app74/BookRepository.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app74/BookRepository.java new file mode 100644 index 000000000..28ed1dae5 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app74/BookRepository.java @@ -0,0 +1,44 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app74; + +import reactor.core.publisher.Flux; + +import org.springframework.stereotype.Component; + +@Component +public class BookRepository { + + + Flux findByAuthor(String author) { + return Flux.just(new Book("1", "title1", "author1")); + } + + Flux findAll() { + return Flux.just(new Book("2", "title2", "author2")); + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app74/BookRouter.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app74/BookRouter.java new file mode 100644 index 000000000..3972dbf20 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app74/BookRouter.java @@ -0,0 +1,61 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app74; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.enums.ParameterIn; +import org.springdoc.core.annotations.RouterOperation; +import org.springdoc.core.annotations.RouterOperations; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.http.MediaType; +import org.springframework.web.reactive.function.server.RouterFunction; + +import static org.springframework.web.reactive.function.server.RequestPredicates.GET; +import static org.springframework.web.reactive.function.server.RequestPredicates.accept; +import static org.springframework.web.reactive.function.server.RouterFunctions.route; +import static org.springframework.web.reactive.function.server.ServerResponse.ok; + +@Configuration +class BookRouter { + + @Bean + @RouterOperations({ + @RouterOperation(path = "/books", produces = { MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE }, beanClass = BookRepository.class, beanMethod = "findAll"), + @RouterOperation(path = "/books", produces = { MediaType.TEXT_PLAIN_VALUE, MediaType.APPLICATION_XML_VALUE }, beanClass = BookRepository.class, beanMethod = "findAll"), + @RouterOperation(path = "/books/{author}", beanClass = BookRepository.class, beanMethod = "findByAuthor", + operation = @Operation(operationId = "findByAuthor" + , parameters = { @Parameter(in = ParameterIn.PATH, name = "author") })) }) + RouterFunction routes(BookRepository br) { + return + route(GET("/books").and(accept(MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML)), req -> ok().body(br.findAll(), Book.class)) + .and(route(GET("/books").and(accept(MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN)), req -> ok().body(br.findAll(), Book.class))) + .andRoute(GET("/books/{author}"), req -> ok().body(br.findByAuthor(req.pathVariable("author")), Book.class)); + } +} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app74/SpringDocApp74Test.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app74/SpringDocApp74Test.java new file mode 100644 index 000000000..c552b6b7b --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app74/SpringDocApp74Test.java @@ -0,0 +1,39 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app74; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.ComponentScan; + +public class SpringDocApp74Test extends AbstractSpringDocTest { + + @SpringBootApplication + @ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.v31.app74" }) + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app75/Post.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app75/Post.java new file mode 100644 index 000000000..57a855854 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app75/Post.java @@ -0,0 +1,79 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app75; + +import java.time.LocalDateTime; + +public class Post { + + private String id; + + private String title; + + private String content; + + private LocalDateTime createdDate; + + public Post(String id, String title, String content) { + this.id = id; + this.title = title; + this.content = content; + this.createdDate = LocalDateTime.now(); + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } + + public LocalDateTime getCreatedDate() { + return createdDate; + } + + public void setCreatedDate(LocalDateTime createdDate) { + this.createdDate = createdDate; + } +} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app75/PostHandler.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app75/PostHandler.java new file mode 100644 index 000000000..025d6855f --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app75/PostHandler.java @@ -0,0 +1,83 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app75; + + +import java.net.URI; + +import reactor.core.publisher.Mono; + +import org.springframework.stereotype.Component; +import org.springframework.web.reactive.function.server.ServerRequest; +import org.springframework.web.reactive.function.server.ServerResponse; + +@Component +class PostHandler { + + private final PostRepository posts; + + public PostHandler(PostRepository posts) { + this.posts = posts; + } + + public Mono all(ServerRequest req) { + return ServerResponse.ok().body(this.posts.findAll(), Post.class); + } + + public Mono create(ServerRequest req) { + return req.bodyToMono(Post.class) + .flatMap(post -> this.posts.save(post)) + .flatMap(p -> ServerResponse.created(URI.create("/posts/" + p.getId())).build()); + } + + public Mono get(ServerRequest req) { + return this.posts.findById(req.pathVariable("id")) + .flatMap(post -> ServerResponse.ok().body(Mono.just(post), Post.class)) + .switchIfEmpty(ServerResponse.notFound().build()); + } + + public Mono update(ServerRequest req) { + + return Mono + .zip( + (data) -> { + Post p = (Post) data[0]; + Post p2 = (Post) data[1]; + p.setTitle(p2.getTitle()); + p.setContent(p2.getContent()); + return p; + }, + this.posts.findById(req.pathVariable("id")), + req.bodyToMono(Post.class) + ) + .cast(Post.class) + .flatMap(post -> this.posts.save(post)) + .flatMap(post -> ServerResponse.noContent().build()); + + } + +} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app75/PostRepository.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app75/PostRepository.java new file mode 100644 index 000000000..dffdcf460 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app75/PostRepository.java @@ -0,0 +1,53 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app75; + +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +import org.springframework.stereotype.Component; + +@Component +public class PostRepository { + + public Flux findByAuthor(String author) { + return Flux.just(new Post("1", "title1", "author1")); + } + + public Flux findAll() { + return Flux.just(new Post("2", "title2", "author2")); + } + + public Mono findById(String id) { + return Mono.just(new Post("3", "title2", "author2")); + } + + public Mono save(Post post) { + return Mono.just(new Post("4", "title2", "author2")); + } + +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app75/PostRouter.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app75/PostRouter.java new file mode 100644 index 000000000..5d44ba674 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app75/PostRouter.java @@ -0,0 +1,73 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app75; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.enums.ParameterIn; +import io.swagger.v3.oas.annotations.media.ArraySchema; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.parameters.RequestBody; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import org.springdoc.core.annotations.RouterOperation; +import org.springdoc.core.annotations.RouterOperations; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.reactive.function.server.RouterFunction; +import org.springframework.web.reactive.function.server.ServerResponse; + +import static org.springframework.web.reactive.function.server.RequestPredicates.GET; +import static org.springframework.web.reactive.function.server.RequestPredicates.POST; +import static org.springframework.web.reactive.function.server.RequestPredicates.PUT; +import static org.springframework.web.reactive.function.server.RequestPredicates.queryParam; +import static org.springframework.web.reactive.function.server.RouterFunctions.route; + +@Configuration +class PostRouter { + + @RouterOperations({ @RouterOperation(path = "/posts", method = RequestMethod.GET, headers = { "x-header1=test1", "x-header2=test2" }, operation = @Operation(operationId = "all", + parameters = { @Parameter(name = "key", description = "sample description"), @Parameter(name = "test", description = "sample desc") }, + responses = @ApiResponse(responseCode = "200", content = @Content(array = @ArraySchema(schema = @Schema(implementation = Post.class)))))), + @RouterOperation(path = "/posts", method = RequestMethod.POST, operation = @Operation(operationId = "create", + requestBody = @RequestBody(content = @Content(schema = @Schema(implementation = Post.class))), responses = @ApiResponse(responseCode = "201"))), + @RouterOperation(path = "/posts/{id}", method = RequestMethod.GET, operation = @Operation(operationId = "get", + parameters = @Parameter(name = "id", in = ParameterIn.PATH), + responses = @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = Post.class))))), + @RouterOperation(path = "/posts/{id}", method = RequestMethod.PUT, operation = @Operation(operationId = "update", + parameters = @Parameter(name = "id", in = ParameterIn.PATH), + responses = @ApiResponse(responseCode = "202", content = @Content(schema = @Schema(implementation = Post.class))))) }) + @Bean + public RouterFunction routes(PostHandler postController) { + return route(GET("/posts").and(queryParam("key", "value")), postController::all) + .andRoute(POST("/posts"), postController::create) + .andRoute(GET("/posts/{id}"), postController::get) + .andRoute(PUT("/posts/{id}"), postController::update); + } +} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app75/SpringDocApp75Test.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app75/SpringDocApp75Test.java new file mode 100644 index 000000000..b6aec57b2 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app75/SpringDocApp75Test.java @@ -0,0 +1,39 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app75; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.ComponentScan; + +public class SpringDocApp75Test extends AbstractSpringDocTest { + + @SpringBootApplication + @ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.v31.app75" }) + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app78/HelloController.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app78/HelloController.java new file mode 100644 index 000000000..1e1d4b94e --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app78/HelloController.java @@ -0,0 +1,63 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app78; + +import java.io.File; +import java.io.IOException; +import java.nio.file.Path; +import java.nio.file.Paths; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.media.Content; +import reactor.core.publisher.Flux; + +import org.springframework.http.MediaType; +import org.springframework.http.codec.multipart.FilePart; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class HelloController { + + + @PostMapping(value = "/files", produces = { MediaType.APPLICATION_JSON_VALUE }, consumes = { MediaType.MULTIPART_FORM_DATA_VALUE }) + @Operation(summary = "files") + public Flux handleFileUpload( + @RequestPart("files") @Parameter(description = "files", + content = @Content(mediaType = MediaType.APPLICATION_OCTET_STREAM_VALUE)) + Flux filePartFux) throws IOException { + File tmp = File.createTempFile("tmp", ""); + return filePartFux.flatMap(filePart -> { + Path path = Paths.get(tmp.toString() + filePart.filename()); + System.out.println(path); + return filePart.transferTo(path); + }); + } + +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app78/SpringDocApp78Test.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app78/SpringDocApp78Test.java new file mode 100644 index 000000000..00d8254cb --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app78/SpringDocApp78Test.java @@ -0,0 +1,39 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app78; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.ComponentScan; + +public class SpringDocApp78Test extends AbstractSpringDocTest { + + @SpringBootApplication + @ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.v31.app78" }) + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app79/BaseClientModel.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app79/BaseClientModel.java new file mode 100644 index 000000000..13689311f --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app79/BaseClientModel.java @@ -0,0 +1,34 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app79; + +import com.fasterxml.jackson.annotation.JsonProperty; + +public abstract class BaseClientModel { + @JsonProperty("id") + int id; +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app79/BaseController.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app79/BaseController.java new file mode 100644 index 000000000..0983898c8 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app79/BaseController.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.app79; + +import java.util.List; + +import reactor.core.publisher.Mono; + +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; + +public abstract class BaseController { + @GetMapping("/test1") + Mono> get1() { + return null; + } + + @GetMapping("/test2") + Mono>> get2() { + return null; + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app79/SpecificClientModel.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app79/SpecificClientModel.java new file mode 100644 index 000000000..4ba0312a2 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app79/SpecificClientModel.java @@ -0,0 +1,36 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app79; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.v3.oas.annotations.media.Schema; + +public class SpecificClientModel extends BaseClientModel { + @JsonProperty("name") + @Schema(title = "my title", pattern = "this is it", example = "this is example") + String name; +} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app79/SpecificController.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app79/SpecificController.java new file mode 100644 index 000000000..93a576e65 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app79/SpecificController.java @@ -0,0 +1,32 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app79; + +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class SpecificController extends BaseController {} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app79/SpringDocApp79Test.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app79/SpringDocApp79Test.java new file mode 100644 index 000000000..0bddb87b4 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app79/SpringDocApp79Test.java @@ -0,0 +1,39 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app79; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.ComponentScan; + +public class SpringDocApp79Test extends AbstractSpringDocTest { + + @SpringBootApplication + @ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.v31.app79" }) + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app80/Book.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app80/Book.java new file mode 100644 index 000000000..1f94a1bf8 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app80/Book.java @@ -0,0 +1,66 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app80; + +public class Book { + + private String id; + + private String title; + + private String author; + + public Book(String id, String title, String author) { + this.id = id; + this.title = title; + this.author = author; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getAuthor() { + return author; + } + + public void setAuthor(String author) { + this.author = author; + } +} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app80/BookRepository.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app80/BookRepository.java new file mode 100644 index 000000000..d131758a7 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app80/BookRepository.java @@ -0,0 +1,44 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app80; + +import reactor.core.publisher.Flux; + +import org.springframework.stereotype.Component; + +@Component +public class BookRepository { + + + Flux findByAuthor(String author) { + return Flux.just(new Book("1", "title1", "author1")); + } + + Flux findAll() { + return Flux.just(new Book("2", "title2", "author2")); + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app80/BookRouter.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app80/BookRouter.java new file mode 100644 index 000000000..20b47ae98 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app80/BookRouter.java @@ -0,0 +1,113 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app80; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.enums.ParameterIn; +import org.springdoc.core.annotations.RouterOperation; +import org.springdoc.core.annotations.RouterOperations; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.http.MediaType; +import org.springframework.web.reactive.function.server.RouterFunction; + +import static org.springframework.web.reactive.function.server.RequestPredicates.GET; +import static org.springframework.web.reactive.function.server.RequestPredicates.accept; +import static org.springframework.web.reactive.function.server.RequestPredicates.path; +import static org.springframework.web.reactive.function.server.RouterFunctions.nest; +import static org.springframework.web.reactive.function.server.RouterFunctions.route; +import static org.springframework.web.reactive.function.server.ServerResponse.ok; + +@Configuration +class BookRouter { + + @Bean + @RouterOperations({ + @RouterOperation(path = "/greeter/greeter2/books", produces = { MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE }, beanClass = BookRepository.class, beanMethod = "findAll"), + @RouterOperation(path = "/greeter/greeter2/books", produces = { MediaType.TEXT_PLAIN_VALUE, MediaType.APPLICATION_XML_VALUE }, beanClass = BookRepository.class, beanMethod = "findAll"), + @RouterOperation(path = "/greeter/greeter2/books/{author}", beanClass = BookRepository.class, beanMethod = "findByAuthor", + operation = @Operation(operationId = "findByAuthor" + , parameters = { @Parameter(in = ParameterIn.PATH, name = "author") })) }) + RouterFunction routes(BookRepository br) { + return + nest(path("/greeter").and(path("/greeter2")), + route(GET("/books").and(accept(MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML)), req -> ok().body(br.findAll(), Book.class)) + .and(route(GET("/books").and(accept(MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN)), req -> ok().body(br.findAll(), Book.class))) + .andRoute(GET("/books/{author}"), req -> ok().body(br.findByAuthor(req.pathVariable("author")), Book.class))); + } + + @Bean + @RouterOperations({ + @RouterOperation(path = "/books", produces = { MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE }, beanClass = BookRepository.class, beanMethod = "findAll"), + @RouterOperation(path = "/books/{author}", beanClass = BookRepository.class, beanMethod = "findByAuthor", + operation = @Operation(operationId = "findByAuthor" + , parameters = { @Parameter(in = ParameterIn.PATH, name = "author") })) }) + RouterFunction routes1(BookRepository br) { + return + nest(accept(MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML), + route(GET("/books"), req -> ok().body(br.findAll(), Book.class)) + .andRoute(GET("/books/{author}"), req -> ok().body(br.findByAuthor(req.pathVariable("author")), Book.class))); + } + + @Bean + @RouterOperations({ + @RouterOperation(path = "/greeter/books", produces = { MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE }, beanClass = BookRepository.class, beanMethod = "findAll"), + @RouterOperation(path = "/greeter/books", produces = { MediaType.TEXT_PLAIN_VALUE, MediaType.APPLICATION_XML_VALUE }, beanClass = BookRepository.class, beanMethod = "findAll"), + @RouterOperation(path = "/greeter/books/{author}", beanClass = BookRepository.class, beanMethod = "findByAuthor", + operation = @Operation(operationId = "findByAuthor" + , parameters = { @Parameter(in = ParameterIn.PATH, name = "author") })), + @RouterOperation(path = "/greeter2/books", produces = { MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE }, beanClass = BookRepository.class, beanMethod = "findAll"), + @RouterOperation(path = "/greeter2/books", produces = { MediaType.TEXT_PLAIN_VALUE, MediaType.APPLICATION_XML_VALUE }, beanClass = BookRepository.class, beanMethod = "findAll"), + @RouterOperation(path = "/greeter2/books/{author}", beanClass = BookRepository.class, beanMethod = "findByAuthor", + operation = @Operation(operationId = "findByAuthor" + , parameters = { @Parameter(in = ParameterIn.PATH, name = "author") })) }) + RouterFunction routes3(BookRepository br) { + return + nest(path("/greeter").or(path("/greeter2")), + route(GET("/books").and(accept(MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML)), req -> ok().body(br.findAll(), Book.class)) + .and(route(GET("/books").and(accept(MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN)), req -> ok().body(br.findAll(), Book.class))) + .andRoute(GET("/books/{author}"), req -> ok().body(br.findByAuthor(req.pathVariable("author")), Book.class))); + } + + @Bean + @RouterOperations({ + @RouterOperation(path = "/test/greeter/greeter2/books", produces = { MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE }, beanClass = BookRepository.class, beanMethod = "findAll"), + @RouterOperation(path = "/test/greeter/greeter2/books", produces = { MediaType.TEXT_PLAIN_VALUE, MediaType.APPLICATION_XML_VALUE }, beanClass = BookRepository.class, beanMethod = "findAll"), + @RouterOperation(path = "/test/greeter/greeter2/books/{author}", beanClass = BookRepository.class, beanMethod = "findByAuthor", + operation = @Operation(operationId = "findByAuthor" + , parameters = { @Parameter(in = ParameterIn.PATH, name = "author") })) }) + RouterFunction routes4(BookRepository br) { + return + nest(path("/test"), + nest(path("/greeter").and(path("/greeter2")), + route(GET("/books").and(accept(MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML)), req -> ok().body(br.findAll(), Book.class)) + .and(route(GET("/books").and(accept(MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN)), req -> ok().body(br.findAll(), Book.class))) + .andRoute(GET("/books/{author}"), req -> ok().body(br.findByAuthor(req.pathVariable("author")), Book.class)))); + } +} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app80/SpringDocApp80Test.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app80/SpringDocApp80Test.java new file mode 100644 index 000000000..83913761f --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app80/SpringDocApp80Test.java @@ -0,0 +1,39 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app80; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.ComponentScan; + +public class SpringDocApp80Test extends AbstractSpringDocTest { + + @SpringBootApplication + @ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.v31.app80" }) + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app81/OperationIdController.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app81/OperationIdController.java new file mode 100644 index 000000000..970a3c675 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app81/OperationIdController.java @@ -0,0 +1,58 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app81; + +import reactor.core.publisher.Mono; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class OperationIdController { + + @GetMapping(path = "/test_0") // gets operationId opIdTest_3 + public Mono opIdTest() { + return null; + } + + @GetMapping(path = "/test_1") // gets operationId opIdTest_2 + public Mono opIdTest(@RequestParam String param) { + return null; + } + + @GetMapping(path = "/test_2") // gets operationId opIdTest_1 + public Mono opIdTest(@RequestParam Integer param) { + return null; + } + + @GetMapping(path = "/test_3") // gets operationId opIdTest + public Mono opIdTest(@RequestParam Boolean param) { + return null; + } + +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app81/SpringDocApp81Test.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app81/SpringDocApp81Test.java new file mode 100644 index 000000000..a43f23f47 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app81/SpringDocApp81Test.java @@ -0,0 +1,95 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app81; + +import java.net.URI; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.Comparator; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.concurrent.ThreadLocalRandom; + +import org.junit.jupiter.api.RepeatedTest; +import org.springdoc.webflux.api.OpenApiWebfluxResource; +import test.org.springdoc.api.v31.AbstractCommonTest; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.test.autoconfigure.web.reactive.WebFluxTest; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.http.server.reactive.ServerHttpRequest; +import org.springframework.web.method.HandlerMethod; +import org.springframework.web.reactive.result.method.RequestMappingInfo; +import org.springframework.web.reactive.result.method.RequestMappingInfoHandlerMapping; + +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; +import static org.skyscreamer.jsonassert.JSONAssert.assertEquals; +import static org.springdoc.core.utils.Constants.SPRINGDOC_CACHE_DISABLED; + + +/** + * Tests deterministic creation of operationIds + */ +@WebFluxTest(properties = SPRINGDOC_CACHE_DISABLED + "=true") +public class SpringDocApp81Test extends AbstractCommonTest { + + @Autowired + OpenApiWebfluxResource resource; + + @Autowired + RequestMappingInfoHandlerMapping mappingInfoHandlerMapping; + + @RepeatedTest(10) + public void shouldGenerateOperationIdsDeterministically() throws Exception { + shuffleSpringHandlerMethods(); + + ServerHttpRequest request = mock(ServerHttpRequest.class); + when(request.getURI()).thenReturn(URI.create("http://localhost")); + + String expected = getContent("results/3.1.0/app81.json"); + byte[] openApiBytes =resource.openapiJson(request, "", Locale.US).block(); + String openApi = new String(openApiBytes, StandardCharsets.UTF_8); // for UTF-8 encoding String openApi = resource.openapiJson(request, "", Locale.US).block(); + assertEquals(expected, openApi, true); + } + + private void shuffleSpringHandlerMethods() { + Map handlerMethods = mappingInfoHandlerMapping.getHandlerMethods(); + List> collect = new ArrayList<>(handlerMethods.entrySet()); + collect.sort(Comparator.comparing(a -> ThreadLocalRandom.current().nextBoolean() ? -1 : 1)); + + collect.forEach(e -> mappingInfoHandlerMapping.unregisterMapping(e.getKey())); + collect.forEach(e -> mappingInfoHandlerMapping.registerMapping(e.getKey(), e.getValue().getBean(), e.getValue().getMethod())); + } + + @SpringBootApplication + @ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.v31.app81" }) + static class SpringDocTestApp { + } + +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app82/RoutingConfiguration.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app82/RoutingConfiguration.java new file mode 100644 index 000000000..18ae01da5 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app82/RoutingConfiguration.java @@ -0,0 +1,65 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app82; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.reactive.function.server.RouterFunction; +import org.springframework.web.reactive.function.server.ServerResponse; + +import static org.springdoc.core.fn.builders.operation.Builder.operationBuilder; +import static org.springdoc.core.utils.Constants.OPERATION_ATTRIBUTE; +import static org.springframework.http.MediaType.APPLICATION_JSON; +import static org.springframework.web.reactive.function.server.RequestPredicates.DELETE; +import static org.springframework.web.reactive.function.server.RequestPredicates.GET; +import static org.springframework.web.reactive.function.server.RequestPredicates.POST; +import static org.springframework.web.reactive.function.server.RequestPredicates.PUT; +import static org.springframework.web.reactive.function.server.RequestPredicates.accept; +import static org.springframework.web.reactive.function.server.RouterFunctions.route; + +@Configuration +public class RoutingConfiguration { + + @Bean + public RouterFunction monoRouterFunction(UserHandler userHandler) { + return route(GET("/api/user/index").and(accept(APPLICATION_JSON)), userHandler::getAll) + .withAttribute(OPERATION_ATTRIBUTE, operationBuilder().beanClass(UserRepository.class).beanMethod("getAllUsers")) + + .and(route(GET("/api/user/{id}").and(accept(APPLICATION_JSON)), userHandler::getUser) + .withAttribute(OPERATION_ATTRIBUTE, operationBuilder().beanClass(UserRepository.class).beanMethod("getUserById"))) + + .and(route(POST("/api/user/post").and(accept(APPLICATION_JSON)), userHandler::postUser) + .withAttribute(OPERATION_ATTRIBUTE, operationBuilder().beanClass(UserRepository.class).beanMethod("saveUser"))) + + .and(route(PUT("/api/user/put").and(accept(APPLICATION_JSON)), userHandler::putUser) + .withAttribute(OPERATION_ATTRIBUTE, operationBuilder().beanClass(UserRepository.class).beanMethod("putUser"))) + + .and(route(DELETE("/api/user/delete/{id}").and(accept(APPLICATION_JSON)), userHandler::deleteUser) + .withAttribute(OPERATION_ATTRIBUTE, operationBuilder().beanClass(UserRepository.class).beanMethod("deleteUser"))); + } + +} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app82/SpringDocApp82Test.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app82/SpringDocApp82Test.java new file mode 100644 index 000000000..3b50d1577 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app82/SpringDocApp82Test.java @@ -0,0 +1,39 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app82; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.ComponentScan; + +public class SpringDocApp82Test extends AbstractSpringDocTest { + + @SpringBootApplication + @ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.v31.app82" }) + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app82/User.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app82/User.java new file mode 100644 index 000000000..21e5f1030 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app82/User.java @@ -0,0 +1,85 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app82; + +public class User { + private long id; + + private String firstname; + + private String lastname; + + private int age; + + public User() { + } + + public User(long id, String firstname, String lastname, int age) { + this.id = id; + this.firstname = firstname; + this.lastname = lastname; + this.age = age; + } + + public long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getFirstname() { + return firstname; + } + + public void setFirstname(String firstname) { + this.firstname = firstname; + } + + public String getLastname() { + return lastname; + } + + public void setLastname(String lastname) { + this.lastname = lastname; + } + + public int getAge() { + return age; + } + + public void setAge(int age) { + this.age = age; + } + + @Override + public String toString() { + String info = String.format("id = %d, firstname = %s, lastname = %s, age = %d", id, firstname, lastname, age); + return info; + } +} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app82/UserHandler.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app82/UserHandler.java new file mode 100644 index 000000000..a7bf08de9 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app82/UserHandler.java @@ -0,0 +1,119 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app82; + +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +import org.springframework.http.MediaType; +import org.springframework.stereotype.Component; +import org.springframework.web.reactive.function.server.ServerRequest; +import org.springframework.web.reactive.function.server.ServerResponse; + +import static org.springframework.web.reactive.function.BodyInserters.fromObject; + +@Component +public class UserHandler { + + private final UserRepository customerRepository; + + public UserHandler(UserRepository repository) { + this.customerRepository = repository; + } + + /** + * GET ALL Users + */ + public Mono getAll(ServerRequest request) { + // fetch all customers from repository + Flux customers = customerRepository.getAllUsers(); + + // build response + return ServerResponse.ok().contentType(MediaType.APPLICATION_JSON).body(customers, User.class); + } + + /** + * GET a User by ID + */ + public Mono getUser(ServerRequest request) { + // parse path-variable + long customerId = Long.valueOf(request.queryParam("id").get()); + + // build notFound response + Mono notFound = ServerResponse.notFound().build(); + + // get customer from repository + Mono customerMono = customerRepository.getUserById(customerId); + + // build response + return customerMono + .flatMap(customer -> ServerResponse.ok().contentType(MediaType.APPLICATION_JSON).body(fromObject(customer))) + .switchIfEmpty(notFound); + } + + /** + * POST a User + */ + public Mono postUser(ServerRequest request) { + Mono customer = request.bodyToMono(User.class); + return ServerResponse.ok().build(customerRepository.saveUser(customer)); + } + + /** + * PUT a User + */ + public Mono putUser(ServerRequest request) { + // parse id from path-variable + long customerId = Long.valueOf(request.pathVariable("id")); + + // get customer data from request object + Mono customer = request.bodyToMono(User.class); + + // get customer from repository + Mono responseMono = customerRepository.putUser(customerId, customer); + + // build response + return responseMono + .flatMap(cust -> ServerResponse.ok().contentType(MediaType.APPLICATION_JSON).body(fromObject(cust))); + } + + /** + * DELETE a User + */ + public Mono deleteUser(ServerRequest request) { + // parse id from path-variable + long customerId = Long.valueOf(request.pathVariable("id")); + + // get customer from repository + Mono responseMono = customerRepository.deleteUser(customerId); + + // build response + return responseMono + .flatMap(strMono -> ServerResponse.ok().contentType(MediaType.TEXT_PLAIN).body(fromObject(strMono))); + } + +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app82/UserRepository.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app82/UserRepository.java new file mode 100644 index 000000000..1458d3587 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app82/UserRepository.java @@ -0,0 +1,51 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app82; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.enums.ParameterIn; +import io.swagger.v3.oas.annotations.parameters.RequestBody; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +public interface UserRepository { + + public Mono getUserById(@Parameter(in = ParameterIn.PATH, description = "The user Id") Long id); + + @Operation(description = "get all the users") + public Flux getAllUsers(); + + @Operation(description = "get all the users by firstname") + public Flux getAllUsers(String firstname); + + public Mono saveUser(Mono user); + + public Mono putUser(@Parameter(in = ParameterIn.QUERY) Long id, @RequestBody Mono user); + + public Mono deleteUser(@Parameter(in = ParameterIn.PATH) Long id); +} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app82/UserRepositoryImpl.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app82/UserRepositoryImpl.java new file mode 100644 index 000000000..c3fd23499 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app82/UserRepositoryImpl.java @@ -0,0 +1,98 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app82; + +import java.util.HashMap; +import java.util.Map; + +import jakarta.annotation.PostConstruct; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +import org.springframework.stereotype.Repository; + +@Repository +public class UserRepositoryImpl implements UserRepository { + private Map users = new HashMap(); + + @PostConstruct + public void init() throws Exception { + users.put(Long.valueOf(1), new User(1, "Jack", "Smith", 20)); + users.put(Long.valueOf(2), new User(2, "Peter", "Johnson", 25)); + } + + @Override + public Mono getUserById(Long id) { + return Mono.just(users.get(id)); + } + + @Override + public Flux getAllUsers() { + return Flux.fromIterable(this.users.values()); + } + + @Override + public Flux getAllUsers(String firstname) { + return Flux.fromIterable(this.users.values().stream().filter(user -> user.getFirstname().equals(firstname)).toList()); + } + + @Override + public Mono saveUser(Mono monoUser) { + Mono userMono = monoUser.doOnNext(user -> { + // do post + users.put(user.getId(), user); + + // log on console + System.out.println("########### POST:" + user); + }); + + return userMono.then(); + } + + @Override + public Mono putUser(Long id, Mono monoUser) { + Mono userMono = monoUser.doOnNext(user -> { + // reset user.Id + user.setId(id); + + // do put + users.put(id, user); + + // log on console + System.out.println("########### PUT:" + user); + }); + + return userMono; + } + + @Override + public Mono deleteUser(Long id) { + // delete processing + users.remove(id); + return Mono.just("Delete Succesfully!"); + } +} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app83/Coffee.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app83/Coffee.java new file mode 100644 index 000000000..d4f1c29f4 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app83/Coffee.java @@ -0,0 +1,86 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app83; + +import java.util.Objects; + +public class Coffee { + + private String id; + + private String name; + + public Coffee() { + } + + public Coffee(String name) { + this.name = name; + } + + public Coffee(String id, String name) { + this.id = id; + this.name = name; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Coffee coffee = (Coffee) o; + return Objects.equals(id, coffee.id) && + Objects.equals(name, coffee.name); + } + + @Override + public int hashCode() { + return Objects.hash(id, name); + } + + @Override + public String toString() { + return "Coffee{" + + "id='" + id + '\'' + + ", name='" + name + '\'' + + '}'; + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app83/CoffeeOrder.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app83/CoffeeOrder.java new file mode 100644 index 000000000..b7b8b3a2b --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app83/CoffeeOrder.java @@ -0,0 +1,74 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app83; + +import java.time.Instant; +import java.util.Objects; + +public class CoffeeOrder { + private String coffeeId; + + private Instant whenOrdered; + + public CoffeeOrder() { + } + + public CoffeeOrder(String coffeeId, Instant whenOrdered) { + this.coffeeId = coffeeId; + this.whenOrdered = whenOrdered; + } + + public String getCoffeeId() { + return coffeeId; + } + + public Instant getWhenOrdered() { + return whenOrdered; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + CoffeeOrder that = (CoffeeOrder) o; + return Objects.equals(coffeeId, that.coffeeId) && + Objects.equals(whenOrdered, that.whenOrdered); + } + + @Override + public int hashCode() { + return Objects.hash(coffeeId, whenOrdered); + } + + @Override + public String toString() { + return "CoffeeOrder{" + + "coffeeId='" + coffeeId + '\'' + + ", whenOrdered=" + whenOrdered + + '}'; + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app83/CoffeeRepository.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app83/CoffeeRepository.java new file mode 100644 index 000000000..ac84cff75 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app83/CoffeeRepository.java @@ -0,0 +1,52 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app83; + +import org.reactivestreams.Publisher; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +import org.springframework.stereotype.Repository; + +@Repository +public class CoffeeRepository { + Flux deleteAll() { + return null; + } + + Mono findById(String id) { + return null; + } + + Publisher save(Coffee coffee) { + return null; + } + + Flux findAll() { + return null; + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app83/CoffeeService.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app83/CoffeeService.java new file mode 100644 index 000000000..bd03c970b --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app83/CoffeeService.java @@ -0,0 +1,60 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app83; + +import java.time.Duration; +import java.time.Instant; + +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.enums.ParameterIn; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +import org.springframework.stereotype.Service; + +@Service +public class CoffeeService { + private final CoffeeRepository repo; + + public CoffeeService(CoffeeRepository repo) { + this.repo = repo; + } + + Flux getAllCoffees() { + return repo.findAll(); + } + + Mono getCoffeeById(@Parameter(in = ParameterIn.PATH) String id) { + return repo.findById(id); + } + + Flux getOrdersForCoffeeById(@Parameter(in = ParameterIn.PATH) String id) { + return Flux.interval(Duration.ofSeconds(1)) + .onBackpressureDrop() + .map(i -> new CoffeeOrder(id, Instant.now())); + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app83/RouteConfig.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app83/RouteConfig.java new file mode 100644 index 000000000..17456d03e --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app83/RouteConfig.java @@ -0,0 +1,78 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app83; + +import reactor.core.publisher.Mono; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.http.MediaType; +import org.springframework.web.reactive.function.server.RouterFunction; +import org.springframework.web.reactive.function.server.ServerRequest; +import org.springframework.web.reactive.function.server.ServerResponse; + +import static org.springdoc.core.fn.builders.operation.Builder.operationBuilder; +import static org.springdoc.core.utils.Constants.OPERATION_ATTRIBUTE; +import static org.springframework.web.reactive.function.server.RequestPredicates.GET; +import static org.springframework.web.reactive.function.server.RouterFunctions.route; + +@Configuration +public class RouteConfig { + private final CoffeeService service; + + public RouteConfig(CoffeeService service) { + this.service = service; + } + + @Bean + RouterFunction routerFunction() { + return route(GET("/coffees"), this::all) + .withAttribute(OPERATION_ATTRIBUTE, operationBuilder().beanClass(CoffeeService.class).beanMethod("getAllCoffees")) + + .and(route(GET("/coffees/{id}"), this::byId) + .withAttribute(OPERATION_ATTRIBUTE, operationBuilder().beanClass(CoffeeService.class).beanMethod("getCoffeeById"))) + + .and(route(GET("/coffees/{id}/orders"), this::orders) + .withAttribute(OPERATION_ATTRIBUTE, operationBuilder().beanClass(CoffeeService.class).beanMethod("getOrdersForCoffeeById"))); + } + + private Mono all(ServerRequest req) { + return ServerResponse.ok() + .body(service.getAllCoffees(), Coffee.class); + } + + private Mono byId(ServerRequest req) { + return ServerResponse.ok() + .body(service.getCoffeeById(req.pathVariable("id")), Coffee.class); + } + + private Mono orders(ServerRequest req) { + return ServerResponse.ok() + .contentType(MediaType.TEXT_EVENT_STREAM) + .body(service.getOrdersForCoffeeById(req.pathVariable("id")), CoffeeOrder.class); + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app83/SpringDocApp83Test.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app83/SpringDocApp83Test.java new file mode 100644 index 000000000..b04caeadc --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app83/SpringDocApp83Test.java @@ -0,0 +1,39 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app83; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.ComponentScan; + +public class SpringDocApp83Test extends AbstractSpringDocTest { + + @SpringBootApplication + @ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.v31.app83" }) + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app84/Employee.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app84/Employee.java new file mode 100644 index 000000000..361429fd4 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app84/Employee.java @@ -0,0 +1,50 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app84; + +public class Employee { + + private String id; + + private String name; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app84/EmployeeFunctionalConfig.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app84/EmployeeFunctionalConfig.java new file mode 100644 index 000000000..e088107ae --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app84/EmployeeFunctionalConfig.java @@ -0,0 +1,107 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app84; + +import io.swagger.v3.oas.annotations.enums.ParameterIn; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.http.MediaType; +import org.springframework.web.reactive.function.BodyExtractors; +import org.springframework.web.reactive.function.server.RouterFunction; +import org.springframework.web.reactive.function.server.ServerResponse; + +import static org.springdoc.core.fn.builders.apiresponse.Builder.responseBuilder; +import static org.springdoc.core.fn.builders.operation.Builder.operationBuilder; +import static org.springdoc.core.fn.builders.parameter.Builder.parameterBuilder; +import static org.springdoc.core.utils.Constants.OPERATION_ATTRIBUTE; +import static org.springframework.web.reactive.function.server.RequestPredicates.GET; +import static org.springframework.web.reactive.function.server.RequestPredicates.POST; +import static org.springframework.web.reactive.function.server.RequestPredicates.accept; +import static org.springframework.web.reactive.function.server.RouterFunctions.route; +import static org.springframework.web.reactive.function.server.ServerResponse.ok; + +@Configuration +public class EmployeeFunctionalConfig { + + + @Bean + EmployeeRepository employeeRepository() { + return new EmployeeRepository(); + } + + @Bean + RouterFunction getAllEmployeesRoute() { + return route(GET("/employees").and(accept(MediaType.APPLICATION_JSON)), + req -> ok().body( + employeeRepository().findAllEmployees(), Employee.class)) + .withAttribute(OPERATION_ATTRIBUTE, operationBuilder().beanClass(EmployeeRepository.class).beanMethod("findAllEmployees")); + } + + @Bean + RouterFunction getEmployeeByIdRoute() { + return route(GET("/employees/{id}"), + req -> ok().body( + employeeRepository().findEmployeeById(req.pathVariable("id")), Employee.class)) + .withAttribute(OPERATION_ATTRIBUTE, + operationBuilder().operationId("findEmployeeById").summary("Find purchase order by ID").tags(new String[] { "MyEmployee" }) + .parameter(parameterBuilder().in(ParameterIn.PATH).name("id").description("Employee Id")) + .response(responseBuilder().responseCode("200").description("successful operation").implementation(Employee.class)) + .response(responseBuilder().responseCode("400").description("Invalid Employee ID supplied")) + .response(responseBuilder().responseCode("404").description("Employee not found"))); + } + + + @Bean + RouterFunction updateEmployeeRoute() { + return route(POST("/employees/update").and(accept(MediaType.APPLICATION_XML)), + req -> req.body(BodyExtractors.toMono(Employee.class)) + .doOnNext(employeeRepository()::updateEmployee) + .then(ok().build())) + .withAttribute(OPERATION_ATTRIBUTE, operationBuilder().beanClass(EmployeeRepository.class).beanMethod("updateEmployee")); + } + + @Bean + RouterFunction composedRoutes() { + return + route(GET("/employees-composed"), + req -> ok().body( + employeeRepository().findAllEmployees(), Employee.class)) + .withAttribute(OPERATION_ATTRIBUTE, operationBuilder().beanClass(EmployeeRepository.class).beanMethod("findAllEmployees")) + + .and(route(GET("/employees-composed/{id}"), req -> ok().body( + employeeRepository().findEmployeeById(req.pathVariable("id")), Employee.class)) + .withAttribute(OPERATION_ATTRIBUTE, operationBuilder().beanClass(EmployeeRepository.class).beanMethod("findEmployeeById"))) + + .and(route(POST("/employees-composed/update"), + req -> req.body(BodyExtractors.toMono(Employee.class)) + .doOnNext(employeeRepository()::updateEmployee) + .then(ok().build())) + .withAttribute(OPERATION_ATTRIBUTE, operationBuilder().beanClass(EmployeeRepository.class).beanMethod("updateEmployee"))); + } + +} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app84/EmployeeRepository.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app84/EmployeeRepository.java new file mode 100644 index 000000000..e5df0b3bf --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app84/EmployeeRepository.java @@ -0,0 +1,58 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app84; + +import java.util.Map; + +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.enums.ParameterIn; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +public class EmployeeRepository { + + static Map employeeData; + + static Map employeeAccessData; + + + public Mono findEmployeeById(@Parameter(in = ParameterIn.PATH) String id) { + return Mono.just(employeeData.get(id)); + } + + public Flux findAllEmployees() { + return Flux.fromIterable(employeeData.values()); + } + + public Mono updateEmployee(Employee employee) { + Employee existingEmployee = employeeData.get(employee.getId()); + if (existingEmployee != null) { + existingEmployee.setName(employee.getName()); + } + return Mono.just(existingEmployee); + } +} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app84/SpringDocApp84Test.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app84/SpringDocApp84Test.java new file mode 100644 index 000000000..83992cf71 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app84/SpringDocApp84Test.java @@ -0,0 +1,39 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app84; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.ComponentScan; + +public class SpringDocApp84Test extends AbstractSpringDocTest { + + @SpringBootApplication + @ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.v31.app84" }) + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app85/SpringDocApp85Test.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app85/SpringDocApp85Test.java new file mode 100644 index 000000000..fdcd07744 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app85/SpringDocApp85Test.java @@ -0,0 +1,39 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app85; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.ComponentScan; + +public class SpringDocApp85Test extends AbstractSpringDocTest { + + @SpringBootApplication + @ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.v31.app85" }) + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app85/controller/PersonRouter.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app85/controller/PersonRouter.java new file mode 100644 index 000000000..e082b3030 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app85/controller/PersonRouter.java @@ -0,0 +1,65 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app85.controller; + +import test.org.springdoc.api.v31.app85.handler.PersonHandler; +import test.org.springdoc.api.v31.app85.service.PersonService; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.http.MediaType; +import org.springframework.web.reactive.function.server.RouterFunction; +import org.springframework.web.reactive.function.server.ServerResponse; + +import static org.springdoc.core.fn.builders.operation.Builder.operationBuilder; +import static org.springdoc.core.utils.Constants.OPERATION_ATTRIBUTE; +import static org.springframework.web.reactive.function.server.RequestPredicates.DELETE; +import static org.springframework.web.reactive.function.server.RequestPredicates.GET; +import static org.springframework.web.reactive.function.server.RequestPredicates.POST; +import static org.springframework.web.reactive.function.server.RequestPredicates.accept; +import static org.springframework.web.reactive.function.server.RouterFunctions.route; + + +@Configuration +public class PersonRouter { + + @Bean + public RouterFunction personRoute(PersonHandler handler) { + return route(GET("/getAllPersons").and(accept(MediaType.APPLICATION_JSON)), handler::findAll) + .withAttribute(OPERATION_ATTRIBUTE, operationBuilder().beanClass(PersonService.class).beanMethod("getAll")) + + .and(route(GET("/getPerson/{id}").and(accept(MediaType.APPLICATION_STREAM_JSON)), handler::findById) + .withAttribute(OPERATION_ATTRIBUTE, operationBuilder().beanClass(PersonService.class).beanMethod("getById"))) + + .and(route(POST("/createPerson").and(accept(MediaType.APPLICATION_JSON)), handler::save) + .withAttribute(OPERATION_ATTRIBUTE, operationBuilder().beanClass(PersonService.class).beanMethod("save"))) + + .and(route(DELETE("/deletePerson/{id}").and(accept(MediaType.APPLICATION_JSON)), handler::delete) + .withAttribute(OPERATION_ATTRIBUTE, operationBuilder().beanClass(PersonService.class).beanMethod("delete"))); + } + +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app85/controller/PositionRouter.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app85/controller/PositionRouter.java new file mode 100644 index 000000000..94bacc458 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app85/controller/PositionRouter.java @@ -0,0 +1,79 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app85.controller; + +import io.swagger.v3.oas.annotations.enums.ParameterIn; +import test.org.springdoc.api.v31.app85.entity.Position; +import test.org.springdoc.api.v31.app85.handler.PositionHandler; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.http.MediaType; +import org.springframework.web.reactive.function.server.RouterFunction; +import org.springframework.web.reactive.function.server.ServerResponse; + +import static org.springdoc.core.fn.builders.apiresponse.Builder.responseBuilder; +import static org.springdoc.core.fn.builders.content.Builder.contentBuilder; +import static org.springdoc.core.fn.builders.operation.Builder.operationBuilder; +import static org.springdoc.core.fn.builders.parameter.Builder.parameterBuilder; +import static org.springdoc.core.fn.builders.requestbody.Builder.requestBodyBuilder; +import static org.springdoc.core.utils.Constants.OPERATION_ATTRIBUTE; +import static org.springframework.web.reactive.function.server.RequestPredicates.DELETE; +import static org.springframework.web.reactive.function.server.RequestPredicates.GET; +import static org.springframework.web.reactive.function.server.RequestPredicates.POST; +import static org.springframework.web.reactive.function.server.RequestPredicates.accept; +import static org.springframework.web.reactive.function.server.RouterFunctions.route; + +@Configuration +public class PositionRouter { + + @Bean + public RouterFunction positionRoute(PositionHandler handler) { + return route(GET("/getAllPositions").and(accept(MediaType.APPLICATION_JSON)), handler::findAll) + .withAttribute(OPERATION_ATTRIBUTE, operationBuilder().operationId("findAll").description("Get all positions").tags(new String[] { "positions" }) + .response(responseBuilder().responseCode("200").implementationArray(Position.class))) + + .and(route(GET("/getPosition/{id}").and(accept(MediaType.APPLICATION_STREAM_JSON)), handler::findById) + .withAttribute(OPERATION_ATTRIBUTE, + operationBuilder().operationId("findById").description("Find all").tags(new String[] { "positions" }) + .parameter(parameterBuilder().in(ParameterIn.PATH).name("id")) + .response(responseBuilder().responseCode("200").implementation(Position.class)))) + + .and(route(POST("/createPosition").and(accept(MediaType.APPLICATION_JSON)), handler::save) + .withAttribute(OPERATION_ATTRIBUTE, + operationBuilder().operationId("save").description("Save position").tags(new String[] { "positions" }) + .requestBody(requestBodyBuilder().implementation(Position.class)) + .response(responseBuilder().responseCode("200").implementation(Position.class)))) + + .and(route(DELETE("/deletePosition/{id}").and(accept(MediaType.APPLICATION_JSON)), handler::delete) + .withAttribute(OPERATION_ATTRIBUTE, + operationBuilder().operationId("deleteBy").description("Delete By Id").tags(new String[] { "positions" }) + .parameter(parameterBuilder().in(ParameterIn.PATH).name("id")) + .response(responseBuilder().responseCode("200").content(contentBuilder())))); + } + +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app85/entity/Person.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app85/entity/Person.java new file mode 100644 index 000000000..8db511b33 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app85/entity/Person.java @@ -0,0 +1,100 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app85.entity; + +public class Person { + + private String id; + + private Sex sex; + + private String firstName; + + private String lastName; + + private String age; + + private String interests; + + private String email; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public Sex getSex() { + return sex; + } + + public void setSex(Sex sex) { + this.sex = sex; + } + + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } + + public String getAge() { + return age; + } + + public void setAge(String age) { + this.age = age; + } + + public String getInterests() { + return interests; + } + + public void setInterests(String interests) { + this.interests = interests; + } + + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app85/entity/Position.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app85/entity/Position.java new file mode 100644 index 000000000..97cef62db --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app85/entity/Position.java @@ -0,0 +1,80 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app85.entity; + +import java.util.Date; + +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; +import jakarta.validation.constraints.Size; + + +public class Position { + + private String id; + + @NotBlank + @Size(max = 140) + private String positionName; + + private String description; + + @NotNull + private Date createdAt = new Date(); + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getPositionName() { + return positionName; + } + + public void setPositionName(String positionName) { + this.positionName = positionName; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public Date getCreatedAt() { + return createdAt; + } + + public void setCreatedAt(Date createdAt) { + this.createdAt = createdAt; + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app85/entity/Sex.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app85/entity/Sex.java new file mode 100644 index 000000000..aaeb1c76d --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app85/entity/Sex.java @@ -0,0 +1,31 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app85.entity; + +public enum Sex { + MAN, WOMEN +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app85/exception/PositionNotFoundException.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app85/exception/PositionNotFoundException.java new file mode 100644 index 000000000..2cc56aadb --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app85/exception/PositionNotFoundException.java @@ -0,0 +1,34 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app85.exception; + +public class PositionNotFoundException extends RuntimeException { + + public PositionNotFoundException(String positionId) { + super("Position not found with id " + positionId); + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app85/handler/PersonHandler.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app85/handler/PersonHandler.java new file mode 100644 index 000000000..70d331b0f --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app85/handler/PersonHandler.java @@ -0,0 +1,78 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app85.handler; + +import reactor.core.publisher.Mono; +import test.org.springdoc.api.v31.app85.entity.Person; +import test.org.springdoc.api.v31.app85.service.PersonService; + +import org.springframework.http.MediaType; +import org.springframework.stereotype.Component; +import org.springframework.web.reactive.function.BodyInserters; +import org.springframework.web.reactive.function.server.ServerRequest; +import org.springframework.web.reactive.function.server.ServerResponse; + +import static org.springframework.web.reactive.function.server.ServerResponse.ok; + +@Component +@SuppressWarnings({ "deprecared", "unchecked" }) +public class PersonHandler { + + private final PersonService personService; + + public PersonHandler(PersonService personService) { + this.personService = personService; + } + + public Mono findById(ServerRequest request) { + String id = request.pathVariable("id"); + return ok() + .contentType(MediaType.APPLICATION_JSON) + .body(personService.getById(id), Person.class); + } + + public Mono findAll(ServerRequest request) { + return ok() + .contentType(MediaType.APPLICATION_JSON) + .body(personService.getAll(), Person.class); + } + + public Mono save(ServerRequest request) { + final Mono person = request.bodyToMono(Person.class); + return ok() + .contentType(MediaType.APPLICATION_JSON) + .body(BodyInserters.fromPublisher(person.flatMap(personService::save), Person.class)); + } + + public Mono delete(ServerRequest request) { + String id = request.pathVariable("id"); + return ok() + .contentType(MediaType.APPLICATION_JSON) + .body(personService.delete(id), Void.class); + } + +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app85/handler/PositionHandler.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app85/handler/PositionHandler.java new file mode 100644 index 000000000..4dc35e2f0 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app85/handler/PositionHandler.java @@ -0,0 +1,56 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app85.handler; + +import reactor.core.publisher.Mono; + +import org.springframework.stereotype.Component; +import org.springframework.web.reactive.function.server.ServerRequest; +import org.springframework.web.reactive.function.server.ServerResponse; + +@Component +public class PositionHandler { + + + public Mono findById(ServerRequest request) { + String id = request.pathVariable("id"); + return null; + } + + public Mono findAll(ServerRequest request) { + return null; + } + + public Mono save(ServerRequest request) { + return null; + } + + public Mono delete(ServerRequest request) { + return null; + } + +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app85/payload/ErrorResponse.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app85/payload/ErrorResponse.java new file mode 100644 index 000000000..6fd7db683 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app85/payload/ErrorResponse.java @@ -0,0 +1,45 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app85.payload; + +public class ErrorResponse { + + private String message; + + public ErrorResponse(String message) { + this.message = message; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app85/service/PersonService.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app85/service/PersonService.java new file mode 100644 index 000000000..0e503e317 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app85/service/PersonService.java @@ -0,0 +1,65 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app85.service; + +import java.util.Objects; + +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.enums.ParameterIn; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; +import test.org.springdoc.api.v31.app85.entity.Person; + +import org.springframework.stereotype.Service; + +@Service +public class PersonService { + + public Flux getAll() { + return null; + } + + public Mono getById(@Parameter(in = ParameterIn.PATH) final String id) { + return null; + } + + public Mono update(@Parameter(in = ParameterIn.PATH) final String id, final Person person) { + return null; + } + + public Mono save(final Person person) { + return null; + } + + public Mono delete(@Parameter(in = ParameterIn.PATH) final String id) { + final Mono dbPerson = getById(id); + if (Objects.isNull(dbPerson)) { + return Mono.empty(); + } + return null; + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app86/Quote.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app86/Quote.java new file mode 100644 index 000000000..263b995af --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app86/Quote.java @@ -0,0 +1,88 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app86; + + +import java.math.BigDecimal; +import java.math.MathContext; +import java.time.Instant; + +public class Quote { + + private static final MathContext MATH_CONTEXT = new MathContext(2); + + private String ticker; + + private BigDecimal price; + + private Instant instant; + + public Quote() { + } + + public Quote(String ticker, BigDecimal price) { + this.ticker = ticker; + this.price = price; + } + + public Quote(String ticker, Double price) { + this(ticker, new BigDecimal(price, MATH_CONTEXT)); + } + + public String getTicker() { + return ticker; + } + + public void setTicker(String ticker) { + this.ticker = ticker; + } + + public BigDecimal getPrice() { + return price; + } + + public void setPrice(BigDecimal price) { + this.price = price; + } + + public Instant getInstant() { + return instant; + } + + public void setInstant(Instant instant) { + this.instant = instant; + } + + @Override + public String toString() { + return "Quote{" + + "ticker='" + ticker + '\'' + + ", price=" + price + + ", instant=" + instant + + '}'; + } +} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app86/QuoteGenerator.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app86/QuoteGenerator.java new file mode 100644 index 000000000..9470bdf8c --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app86/QuoteGenerator.java @@ -0,0 +1,95 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app86; + + +import java.math.BigDecimal; +import java.math.MathContext; +import java.time.Duration; +import java.time.Instant; +import java.util.ArrayList; +import java.util.List; +import java.util.Random; + +import reactor.core.publisher.Flux; + +import org.springframework.stereotype.Component; + +@Component +public class QuoteGenerator { + + private final MathContext mathContext = new MathContext(2); + + private final Random random = new Random(); + + private final List prices = new ArrayList<>(); + + /** + * Bootstraps the generator with tickers and initial prices + */ + public QuoteGenerator() { + this.prices.add(new Quote("CTXS", 82.26)); + this.prices.add(new Quote("DELL", 63.74)); + this.prices.add(new Quote("GOOG", 847.24)); + this.prices.add(new Quote("MSFT", 65.11)); + this.prices.add(new Quote("ORCL", 45.71)); + this.prices.add(new Quote("RHT", 84.29)); + this.prices.add(new Quote("VMW", 92.21)); + } + + + public Flux fetchQuoteStream(Duration period) { + + // We want to emit quotes with a specific period; + // to do so, we create a Flux.interval + return Flux.interval(period) + // In case of back-pressure, drop events + .onBackpressureDrop() + // For each tick, generate a list of quotes + .map(this::generateQuotes) + // "flatten" that List into a Flux + .flatMapIterable(quotes -> quotes) + .log("io.spring.workshop.stockquotes"); + } + + /* + * Create quotes for all tickers at a single instant. + */ + private List generateQuotes(long interval) { + final Instant instant = Instant.now(); + return prices.stream() + .map(baseQuote -> { + BigDecimal priceChange = baseQuote.getPrice() + .multiply(new BigDecimal(0.05 * this.random.nextDouble()), this.mathContext); + Quote result = new Quote(baseQuote.getTicker(), baseQuote.getPrice().add(priceChange)); + result.setInstant(instant); + return result; + }) + .toList(); + } + +} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app86/QuoteHandler.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app86/QuoteHandler.java new file mode 100644 index 000000000..16d3ba359 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app86/QuoteHandler.java @@ -0,0 +1,72 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app86; + + +import java.time.Duration; + +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +import org.springframework.http.MediaType; +import org.springframework.stereotype.Component; +import org.springframework.web.reactive.function.BodyInserters; +import org.springframework.web.reactive.function.server.ServerRequest; +import org.springframework.web.reactive.function.server.ServerResponse; + +@Component +public class QuoteHandler { + + private final Flux quoteStream; + + public QuoteHandler(QuoteGenerator quoteGenerator) { + this.quoteStream = quoteGenerator.fetchQuoteStream(Duration.ofMillis(1000)).share(); + } + + public Mono hello(ServerRequest request) { + return ServerResponse.ok().contentType(MediaType.TEXT_PLAIN) + .body(BodyInserters.fromObject("Hello Spring!")); + } + + public Mono echo(ServerRequest request) { + return ServerResponse.ok().contentType(MediaType.TEXT_PLAIN) + .body(request.bodyToMono(String.class), String.class); + } + + public Mono streamQuotes(ServerRequest request) { + return ServerResponse.ok() + .contentType(MediaType.APPLICATION_STREAM_JSON) + .body(this.quoteStream, Quote.class); + } + + public Mono fetchQuotes(ServerRequest request) { + int size = Integer.parseInt(request.queryParam("size").orElse("10")); + return ServerResponse.ok() + .contentType(MediaType.APPLICATION_JSON) + .body(this.quoteStream.take(size), Quote.class); + } +} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app86/QuoteRouter.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app86/QuoteRouter.java new file mode 100644 index 000000000..116edfdba --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app86/QuoteRouter.java @@ -0,0 +1,79 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app86; + +import io.swagger.v3.oas.annotations.enums.ParameterIn; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.reactive.function.server.RouterFunction; +import org.springframework.web.reactive.function.server.ServerResponse; + +import static org.springdoc.core.fn.builders.apiresponse.Builder.responseBuilder; +import static org.springdoc.core.fn.builders.operation.Builder.operationBuilder; +import static org.springdoc.core.fn.builders.parameter.Builder.parameterBuilder; +import static org.springdoc.core.fn.builders.requestbody.Builder.requestBodyBuilder; +import static org.springdoc.core.utils.Constants.OPERATION_ATTRIBUTE; +import static org.springframework.http.MediaType.APPLICATION_JSON; +import static org.springframework.http.MediaType.APPLICATION_STREAM_JSON; +import static org.springframework.http.MediaType.TEXT_PLAIN; +import static org.springframework.web.reactive.function.server.RequestPredicates.GET; +import static org.springframework.web.reactive.function.server.RequestPredicates.POST; +import static org.springframework.web.reactive.function.server.RequestPredicates.accept; +import static org.springframework.web.reactive.function.server.RequestPredicates.contentType; +import static org.springframework.web.reactive.function.server.RouterFunctions.route; + +@Configuration +public class QuoteRouter { + + @Bean + public RouterFunction myroute(QuoteHandler quoteHandler) { + return route(GET("/hello").and(accept(TEXT_PLAIN)), quoteHandler::hello) + .withAttribute(OPERATION_ATTRIBUTE, operationBuilder().operationId("hello").response(responseBuilder().responseCode("200"))) + + .and(route(POST("/echo").and(accept(TEXT_PLAIN).and(contentType(TEXT_PLAIN))), quoteHandler::echo) + .withAttribute(OPERATION_ATTRIBUTE, operationBuilder().operationId("echo") + .requestBody(requestBodyBuilder().implementation(String.class)) + .response(responseBuilder().responseCode("200").implementation(String.class)))) + + .and(route(POST("/echo").and(accept(APPLICATION_JSON).and(contentType(APPLICATION_JSON))), quoteHandler::echo) + .withAttribute(OPERATION_ATTRIBUTE, operationBuilder().operationId("echo") + .requestBody(requestBodyBuilder().implementation(String.class)) + .response(responseBuilder().responseCode("200").implementation(String.class))) + ) + + .and(route(GET("/quotes").and(accept(APPLICATION_JSON)), quoteHandler::fetchQuotes) + .withAttribute(OPERATION_ATTRIBUTE, operationBuilder().operationId("fetchQuotes") + .parameter(parameterBuilder().in(ParameterIn.QUERY).name("size").implementation(String.class)) + .response(responseBuilder().responseCode("200").implementationArray(Quote.class)))) + + .and(route(GET("/quotes").and(accept(APPLICATION_STREAM_JSON)), quoteHandler::streamQuotes) + .withAttribute(OPERATION_ATTRIBUTE, operationBuilder().operationId("fetchQuotes") + .response(responseBuilder().responseCode("200").implementation(Quote.class)))); + } + +} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app86/SpringDocApp86Test.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app86/SpringDocApp86Test.java new file mode 100644 index 000000000..7007f91e3 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app86/SpringDocApp86Test.java @@ -0,0 +1,39 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app86; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.ComponentScan; + +public class SpringDocApp86Test extends AbstractSpringDocTest { + + @SpringBootApplication + @ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.v31.app86" }) + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app87/Book.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app87/Book.java new file mode 100644 index 000000000..7fe79ced7 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app87/Book.java @@ -0,0 +1,66 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app87; + +public class Book { + + private String id; + + private String title; + + private String author; + + public Book(String id, String title, String author) { + this.id = id; + this.title = title; + this.author = author; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getAuthor() { + return author; + } + + public void setAuthor(String author) { + this.author = author; + } +} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app87/BookRepository.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app87/BookRepository.java new file mode 100644 index 000000000..470d1ad77 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app87/BookRepository.java @@ -0,0 +1,44 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app87; + +import reactor.core.publisher.Flux; + +import org.springframework.stereotype.Component; + +@Component +public class BookRepository { + + + Flux findByAuthor(String author) { + return Flux.just(new Book("1", "title1", "author1")); + } + + Flux findAll() { + return Flux.just(new Book("2", "title2", "author2")); + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app87/BookRouter.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app87/BookRouter.java new file mode 100644 index 000000000..39b52a67d --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app87/BookRouter.java @@ -0,0 +1,60 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app87; + +import io.swagger.v3.oas.annotations.enums.ParameterIn; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.http.MediaType; +import org.springframework.web.reactive.function.server.RouterFunction; + +import static org.springdoc.core.fn.builders.operation.Builder.operationBuilder; +import static org.springdoc.core.fn.builders.parameter.Builder.parameterBuilder; +import static org.springdoc.core.utils.Constants.OPERATION_ATTRIBUTE; +import static org.springframework.web.reactive.function.server.RequestPredicates.GET; +import static org.springframework.web.reactive.function.server.RequestPredicates.accept; +import static org.springframework.web.reactive.function.server.RouterFunctions.route; +import static org.springframework.web.reactive.function.server.ServerResponse.ok; + +@Configuration +class BookRouter { + + @Bean + RouterFunction routes(BookRepository br) { + return route(GET("/books").and(accept(MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML)), req -> ok().body(br.findAll(), Book.class)) + .withAttribute(OPERATION_ATTRIBUTE, operationBuilder().beanClass(BookRepository.class).beanMethod("findAll")) + + .and(route(GET("/books").and(accept(MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN)), req -> ok().body(br.findAll(), Book.class)) + .withAttribute(OPERATION_ATTRIBUTE, operationBuilder().beanClass(BookRepository.class).beanMethod("findAll"))) + + .and(route(GET("/books/{author}"), req -> ok().body(br.findByAuthor(req.pathVariable("author")), Book.class)) + .withAttribute(OPERATION_ATTRIBUTE, operationBuilder() + .beanClass(BookRepository.class).beanMethod("findByAuthor") + .operationId("findByAuthor").parameter(parameterBuilder().in(ParameterIn.PATH).name("author")))); + } +} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app87/SpringDocApp87Test.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app87/SpringDocApp87Test.java new file mode 100644 index 000000000..8153c36cb --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app87/SpringDocApp87Test.java @@ -0,0 +1,39 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app87; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.ComponentScan; + +public class SpringDocApp87Test extends AbstractSpringDocTest { + + @SpringBootApplication + @ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.v31.app87" }) + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app88/Post.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app88/Post.java new file mode 100644 index 000000000..f2d617097 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app88/Post.java @@ -0,0 +1,79 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app88; + +import java.time.LocalDateTime; + +public class Post { + + private String id; + + private String title; + + private String content; + + private LocalDateTime createdDate; + + public Post(String id, String title, String content) { + this.id = id; + this.title = title; + this.content = content; + this.createdDate = LocalDateTime.now(); + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } + + public LocalDateTime getCreatedDate() { + return createdDate; + } + + public void setCreatedDate(LocalDateTime createdDate) { + this.createdDate = createdDate; + } +} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app88/PostHandler.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app88/PostHandler.java new file mode 100644 index 000000000..18378a7aa --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app88/PostHandler.java @@ -0,0 +1,83 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app88; + + +import java.net.URI; + +import reactor.core.publisher.Mono; + +import org.springframework.stereotype.Component; +import org.springframework.web.reactive.function.server.ServerRequest; +import org.springframework.web.reactive.function.server.ServerResponse; + +@Component +class PostHandler { + + private final PostRepository posts; + + public PostHandler(PostRepository posts) { + this.posts = posts; + } + + public Mono all(ServerRequest req) { + return ServerResponse.ok().body(this.posts.findAll(), Post.class); + } + + public Mono create(ServerRequest req) { + return req.bodyToMono(Post.class) + .flatMap(post -> this.posts.save(post)) + .flatMap(p -> ServerResponse.created(URI.create("/posts/" + p.getId())).build()); + } + + public Mono get(ServerRequest req) { + return this.posts.findById(req.pathVariable("id")) + .flatMap(post -> ServerResponse.ok().body(Mono.just(post), Post.class)) + .switchIfEmpty(ServerResponse.notFound().build()); + } + + public Mono update(ServerRequest req) { + + return Mono + .zip( + (data) -> { + Post p = (Post) data[0]; + Post p2 = (Post) data[1]; + p.setTitle(p2.getTitle()); + p.setContent(p2.getContent()); + return p; + }, + this.posts.findById(req.pathVariable("id")), + req.bodyToMono(Post.class) + ) + .cast(Post.class) + .flatMap(post -> this.posts.save(post)) + .flatMap(post -> ServerResponse.noContent().build()); + + } + +} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app88/PostRepository.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app88/PostRepository.java new file mode 100644 index 000000000..797897835 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app88/PostRepository.java @@ -0,0 +1,53 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app88; + +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +import org.springframework.stereotype.Component; + +@Component +public class PostRepository { + + public Flux findByAuthor(String author) { + return Flux.just(new Post("1", "title1", "author1")); + } + + public Flux findAll() { + return Flux.just(new Post("2", "title2", "author2")); + } + + public Mono findById(String id) { + return Mono.just(new Post("3", "title2", "author2")); + } + + public Mono save(Post post) { + return Mono.just(new Post("4", "title2", "author2")); + } + +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app88/PostRouter.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app88/PostRouter.java new file mode 100644 index 000000000..c873b386c --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app88/PostRouter.java @@ -0,0 +1,77 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app88; + +import io.swagger.v3.oas.annotations.enums.ParameterIn; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.reactive.function.server.RouterFunction; +import org.springframework.web.reactive.function.server.ServerResponse; + +import static org.springdoc.core.fn.builders.apiresponse.Builder.responseBuilder; +import static org.springdoc.core.fn.builders.operation.Builder.operationBuilder; +import static org.springdoc.core.fn.builders.parameter.Builder.parameterBuilder; +import static org.springdoc.core.fn.builders.requestbody.Builder.requestBodyBuilder; +import static org.springdoc.core.utils.Constants.OPERATION_ATTRIBUTE; +import static org.springframework.web.reactive.function.server.RequestPredicates.GET; +import static org.springframework.web.reactive.function.server.RequestPredicates.POST; +import static org.springframework.web.reactive.function.server.RequestPredicates.PUT; +import static org.springframework.web.reactive.function.server.RequestPredicates.queryParam; +import static org.springframework.web.reactive.function.server.RouterFunctions.route; + +@Configuration +class PostRouter { + + @Bean + public RouterFunction routes(PostHandler postController) { + return route(GET("/posts").and(queryParam("key", "value")), postController::all) + .withAttribute(OPERATION_ATTRIBUTE, + operationBuilder().operationId("all") + .parameter(parameterBuilder().name("key").description("sample description")) + .parameter(parameterBuilder().name("test").description("sample desc")) + .response(responseBuilder().responseCode("200").implementationArray(Post.class))) + + .and(route(POST("/posts"), postController::create) + .withAttribute(OPERATION_ATTRIBUTE, + operationBuilder().operationId("create") + .requestBody(requestBodyBuilder().implementation(Post.class)) + .response(responseBuilder().responseCode("201")))) + + .and(route(GET("/posts/{id}"), postController::get) + .withAttribute(OPERATION_ATTRIBUTE, + operationBuilder().operationId("get") + .parameter(parameterBuilder().in(ParameterIn.PATH).name("id")) + .response(responseBuilder().responseCode("200").implementation(Post.class)))) + + .and(route(PUT("/posts/{id}"), postController::update) + .withAttribute(OPERATION_ATTRIBUTE, + operationBuilder().operationId("update") + .parameter(parameterBuilder().in(ParameterIn.PATH).name("id")) + .response(responseBuilder().responseCode("202").implementation(Post.class)))); + } +} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app88/SpringDocApp88Test.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app88/SpringDocApp88Test.java new file mode 100644 index 000000000..d0a2f5027 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app88/SpringDocApp88Test.java @@ -0,0 +1,39 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app88; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.ComponentScan; + +public class SpringDocApp88Test extends AbstractSpringDocTest { + + @SpringBootApplication + @ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.v31.app88" }) + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app89/Book.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app89/Book.java new file mode 100644 index 000000000..5e70d22a5 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app89/Book.java @@ -0,0 +1,66 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app89; + +public class Book { + + private String id; + + private String title; + + private String author; + + public Book(String id, String title, String author) { + this.id = id; + this.title = title; + this.author = author; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getAuthor() { + return author; + } + + public void setAuthor(String author) { + this.author = author; + } +} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app89/BookRepository.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app89/BookRepository.java new file mode 100644 index 000000000..ddb344e01 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app89/BookRepository.java @@ -0,0 +1,44 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app89; + +import reactor.core.publisher.Flux; + +import org.springframework.stereotype.Component; + +@Component +public class BookRepository { + + + Flux findByAuthor(String author) { + return Flux.just(new Book("1", "title1", "author1")); + } + + Flux findAll() { + return Flux.just(new Book("2", "title2", "author2")); + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app89/BookRouter.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app89/BookRouter.java new file mode 100644 index 000000000..eaaff7589 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app89/BookRouter.java @@ -0,0 +1,109 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app89; + +import io.swagger.v3.oas.annotations.enums.ParameterIn; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.http.MediaType; +import org.springframework.web.reactive.function.server.RouterFunction; + +import static org.springdoc.core.fn.builders.operation.Builder.operationBuilder; +import static org.springdoc.core.fn.builders.parameter.Builder.parameterBuilder; +import static org.springdoc.core.utils.Constants.OPERATION_ATTRIBUTE; +import static org.springframework.web.reactive.function.server.RequestPredicates.GET; +import static org.springframework.web.reactive.function.server.RequestPredicates.accept; +import static org.springframework.web.reactive.function.server.RequestPredicates.path; +import static org.springframework.web.reactive.function.server.RouterFunctions.nest; +import static org.springframework.web.reactive.function.server.RouterFunctions.route; +import static org.springframework.web.reactive.function.server.ServerResponse.ok; + +@Configuration +class BookRouter { + + @Bean + RouterFunction routes(BookRepository br) { + return nest(path("/greeter").and(path("/greeter2")), + route(GET("/books").and(accept(MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML)), req -> ok().body(br.findAll(), Book.class)) + .withAttribute(OPERATION_ATTRIBUTE, getFindAll()) + + .and(route(GET("/books").and(accept(MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN)), req -> ok().body(br.findAll(), Book.class)) + .withAttribute(OPERATION_ATTRIBUTE, getFindAll())) + + .and(route(GET("/books/{author}"), req -> ok().body(br.findByAuthor(req.pathVariable("author")), Book.class)) + .withAttribute(OPERATION_ATTRIBUTE, getRouterAttribute())) + ); + } + + @Bean + RouterFunction routes1(BookRepository br) { + return nest(accept(MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML), + route(GET("/books"), req -> ok().body(br.findAll(), Book.class)) + .withAttribute(OPERATION_ATTRIBUTE, getFindAll()) + + .and(route(GET("/books/{author}"), req -> ok().body(br.findByAuthor(req.pathVariable("author")), Book.class)) + .withAttribute(OPERATION_ATTRIBUTE, getRouterAttribute()))); + } + + @Bean + RouterFunction routes3(BookRepository br) { + return nest(path("/greeter").or(path("/greeter2")), + route(GET("/books").and(accept(MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML)), req -> ok().body(br.findAll(), Book.class)) + .withAttribute(OPERATION_ATTRIBUTE, getFindAll()) + + + .and(route(GET("/books").and(accept(MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN)), req -> ok().body(br.findAll(), Book.class)) + .withAttribute(OPERATION_ATTRIBUTE, getFindAll())) + + .and(route(GET("/books/{author}"), req -> ok().body(br.findByAuthor(req.pathVariable("author")), Book.class)) + .withAttribute(OPERATION_ATTRIBUTE, getRouterAttribute()))); + } + + @Bean + RouterFunction routes4(BookRepository br) { + return nest(path("/test"), nest(path("/greeter").and(path("/greeter2")), + route(GET("/books").and(accept(MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML)), req -> ok().body(br.findAll(), Book.class)) + .withAttribute(OPERATION_ATTRIBUTE, getFindAll()) + + .and(route(GET("/books").and(accept(MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN)), req -> ok().body(br.findAll(), Book.class)) + .withAttribute(OPERATION_ATTRIBUTE, getFindAll())) + + .and(route(GET("/books/{author}"), req -> ok().body(br.findByAuthor(req.pathVariable("author")), Book.class)) + .withAttribute(OPERATION_ATTRIBUTE, getRouterAttribute())))); + } + + private org.springdoc.core.fn.builders.operation.Builder getFindAll() { + return operationBuilder().beanClass(BookRepository.class).beanMethod("findAll"); + } + + private org.springdoc.core.fn.builders.operation.Builder getRouterAttribute() { + return operationBuilder() + .operationId("findByAuthor").parameter(parameterBuilder().name("author").in(ParameterIn.PATH)) + .beanClass(BookRepository.class).beanMethod("findByAuthor"); + } +} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app89/SpringDocApp89Test.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app89/SpringDocApp89Test.java new file mode 100644 index 000000000..36e2d3e2c --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app89/SpringDocApp89Test.java @@ -0,0 +1,39 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app89; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.ComponentScan; + +public class SpringDocApp89Test extends AbstractSpringDocTest { + + @SpringBootApplication + @ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.v31.app89" }) + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app90/HelloRouter.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app90/HelloRouter.java new file mode 100644 index 000000000..4773ecf55 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app90/HelloRouter.java @@ -0,0 +1,52 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app90; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.reactive.function.server.RouterFunction; + +import static org.springdoc.core.fn.builders.apiresponse.Builder.responseBuilder; +import static org.springdoc.core.fn.builders.parameter.Builder.parameterBuilder; +import static org.springdoc.webflux.core.fn.SpringdocRouteBuilder.route; +import static test.org.springdoc.api.v30.AbstractSpringDocTest.HANDLER_FUNCTION; + +@Configuration +class HelloRouter { + + @Bean + RouterFunction routes() { + return route().GET("/foo", HANDLER_FUNCTION, ops -> ops + .operationId("hello") + .parameter(parameterBuilder().name("key1").description("My key1 description")) + .parameter(parameterBuilder().name("key2").description("My key2 description")) + .response(responseBuilder().responseCode("200").description("This is normal response description")) + .response(responseBuilder().responseCode("404").description("This is another response description")) + ).build(); + } + +} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app90/SpringDocApp90Test.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app90/SpringDocApp90Test.java new file mode 100644 index 000000000..ed87d3672 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app90/SpringDocApp90Test.java @@ -0,0 +1,39 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app90; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.ComponentScan; + +public class SpringDocApp90Test extends AbstractSpringDocTest { + + @SpringBootApplication + @ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.v31.app90" }) + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app90/book/BookRouter.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app90/book/BookRouter.java new file mode 100644 index 000000000..db3f06800 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app90/book/BookRouter.java @@ -0,0 +1,147 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app90.book; + +import java.util.function.Consumer; + +import io.swagger.v3.oas.annotations.enums.ParameterIn; +import reactor.core.publisher.Flux; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.http.MediaType; +import org.springframework.stereotype.Component; +import org.springframework.web.reactive.function.server.RouterFunction; + +import static org.springdoc.core.fn.builders.parameter.Builder.parameterBuilder; +import static org.springdoc.webflux.core.fn.SpringdocRouteBuilder.route; +import static org.springframework.web.reactive.function.server.RequestPredicates.accept; +import static org.springframework.web.reactive.function.server.RequestPredicates.path; +import static org.springframework.web.reactive.function.server.RouterFunctions.nest; +import static test.org.springdoc.api.v30.AbstractSpringDocTest.HANDLER_FUNCTION; + +@Configuration +class BookRouter { + + + @Bean + RouterFunction bookRoute(BookRepository br) { + return route().GET("/books", accept(MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML), HANDLER_FUNCTION, ops -> ops.operationId("findAll").tag("book") + .beanClass(BookRepository.class).beanMethod("findAll")).build() + + .and(route().GET("/books", accept(MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN), HANDLER_FUNCTION, + ops -> ops.operationId("findAll").tag("book").beanClass(BookRepository.class).beanMethod("findAll")).build()) + + .and(route().GET("/books/{author}", HANDLER_FUNCTION, ops -> ops.tag("book") + .beanClass(BookRepository.class).beanMethod("findByAuthor") + .operationId("findByAuthor").tag("book").parameter(parameterBuilder().in(ParameterIn.PATH).name("author"))).build()); + } + + @Bean + RouterFunction routes2() { + return nest(path("/greeter").and(path("/greeter2")), + route().GET("/books", accept(MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML), HANDLER_FUNCTION, getOperation1()).build()) + + .and(route().GET("/books/nest", accept(MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN), HANDLER_FUNCTION, getOperation1()).build()) + + .and(route().GET("/books/nest/{author}", HANDLER_FUNCTION, getOperation2()).build()); + } + + @Bean + RouterFunction routes4() { + return nest(path("/test"), nest(path("/greeter").and(path("/greeter2")), + route().GET("/books", accept(MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML), HANDLER_FUNCTION, getOperation1()).build() + + .and(route().GET("/books", accept(MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN), HANDLER_FUNCTION, getOperation1()).build()) + + .and(route().GET("/books/{author}", HANDLER_FUNCTION, getOperation2()).build()))); + } + + + private Consumer getOperation1() { + return ops -> ops.operationId("findAll").tag("book").beanClass(BookRepository.class).beanMethod("findAll"); + } + + private Consumer getOperation2() { + return ops -> ops.operationId("findAll").tag("book") + .operationId("findByAuthor").parameter(parameterBuilder().name("author").in(ParameterIn.PATH)) + .beanClass(BookRepository.class).beanMethod("findByAuthor"); + } + + + @Component + class BookRepository { + + Flux findByAuthor(String author) { + return Flux.just(new Book("1", "title1", "author1")); + } + + Flux findAll() { + return Flux.just(new Book("2", "title2", "author2")); + } + } + + class Book { + + private String id; + + private String title; + + private String author; + + public Book(String id, String title, String author) { + this.id = id; + this.title = title; + this.author = author; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getAuthor() { + return author; + } + + public void setAuthor(String author) { + this.author = author; + } + } + +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app90/employee/Employee.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app90/employee/Employee.java new file mode 100644 index 000000000..ed20e4c2a --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app90/employee/Employee.java @@ -0,0 +1,50 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app90.employee; + +public class Employee { + + private String id; + + private String name; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app90/employee/EmployeeRepository.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app90/employee/EmployeeRepository.java new file mode 100644 index 000000000..f8674eb84 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app90/employee/EmployeeRepository.java @@ -0,0 +1,58 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app90.employee; + +import java.util.Map; + +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.enums.ParameterIn; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + +public class EmployeeRepository { + + static Map employeeData; + + static Map employeeAccessData; + + + public Mono findEmployeeById(@Parameter(in = ParameterIn.PATH) String id) { + return Mono.just(employeeData.get(id)); + } + + public Flux findAllEmployees() { + return Flux.fromIterable(employeeData.values()); + } + + public Mono updateEmployee(Employee employee) { + Employee existingEmployee = employeeData.get(employee.getId()); + if (existingEmployee != null) { + existingEmployee.setName(employee.getName()); + } + return Mono.just(existingEmployee); + } +} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app90/employee/EmployeeRouter.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app90/employee/EmployeeRouter.java new file mode 100644 index 000000000..875888928 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app90/employee/EmployeeRouter.java @@ -0,0 +1,55 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app90.employee; + +import io.swagger.v3.oas.annotations.enums.ParameterIn; +import test.org.springdoc.api.v31.app84.Employee; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.reactive.function.server.RouterFunction; +import org.springframework.web.reactive.function.server.ServerResponse; + +import static org.springdoc.core.fn.builders.apiresponse.Builder.responseBuilder; +import static org.springdoc.core.fn.builders.parameter.Builder.parameterBuilder; +import static org.springdoc.webflux.core.fn.SpringdocRouteBuilder.route; +import static test.org.springdoc.api.v30.AbstractSpringDocTest.HANDLER_FUNCTION; + +@Configuration +class EmployeeRouter { + + @Bean + RouterFunction getEmployeeByIdRoute() { + return route().GET("/employees/{id}", HANDLER_FUNCTION, ops -> ops.tag("employee") + .operationId("findEmployeeById").summary("Find purchase order by ID").tags(new String[] { "MyEmployee" }) + .parameter(parameterBuilder().in(ParameterIn.PATH).name("id").description("Employee Id")) + .response(responseBuilder().responseCode("200").description("successful operation").implementation(Employee.class)) + .response(responseBuilder().responseCode("400").description("Invalid Employee ID supplied")) + .response(responseBuilder().responseCode("404").description("Employee not found"))).build(); + } + +} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app90/position/PositionRouter.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app90/position/PositionRouter.java new file mode 100644 index 000000000..28c07422b --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app90/position/PositionRouter.java @@ -0,0 +1,69 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app90.position; + +import io.swagger.v3.oas.annotations.enums.ParameterIn; +import test.org.springdoc.api.v31.app85.entity.Position; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.http.MediaType; +import org.springframework.web.reactive.function.server.RouterFunction; +import org.springframework.web.reactive.function.server.ServerResponse; + +import static org.springdoc.core.fn.builders.apiresponse.Builder.responseBuilder; +import static org.springdoc.core.fn.builders.parameter.Builder.parameterBuilder; +import static org.springdoc.core.fn.builders.requestbody.Builder.requestBodyBuilder; +import static org.springdoc.webflux.core.fn.SpringdocRouteBuilder.route; +import static org.springframework.web.reactive.function.server.RequestPredicates.accept; +import static test.org.springdoc.api.v30.AbstractSpringDocTest.HANDLER_FUNCTION; + +@Configuration +class PositionRouter { + + @Bean + public RouterFunction positionRoute() { + return route().GET("/getAllPositions", accept(MediaType.APPLICATION_JSON), HANDLER_FUNCTION, ops -> ops + .operationId("findAll").description("Get all positions").tags(new String[] { "positions" }) + .response(responseBuilder().responseCode("200").implementationArray(Position.class))).build() + + .and(route().GET("/getPosition/{id}", accept(MediaType.APPLICATION_STREAM_JSON), HANDLER_FUNCTION, ops -> ops + .operationId("findById").description("Find all").tags(new String[] { "positions" }) + .parameter(parameterBuilder().in(ParameterIn.PATH).name("id")) + .response(responseBuilder().responseCode("200").implementation(Position.class))).build()) + + .and(route().POST("/createPosition", accept(MediaType.APPLICATION_JSON), HANDLER_FUNCTION, ops -> ops + .operationId("save").description("Save position").tags(new String[] { "positions" }) + .requestBody(requestBodyBuilder().implementation(Position.class)) + .response(responseBuilder().responseCode("200").implementation(Position.class))).build()) + + .and(route().DELETE("/deletePosition/{id}", accept(MediaType.APPLICATION_JSON), HANDLER_FUNCTION, ops -> ops + .operationId("deleteBy").description("Delete By Id").tags(new String[] { "positions" }) + .parameter(parameterBuilder().in(ParameterIn.PATH).name("id")) + .response(responseBuilder().responseCode("200").content(org.springdoc.core.fn.builders.content.Builder.contentBuilder()))).build()); + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app90/quotes/QuotesRouter.java b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app90/quotes/QuotesRouter.java new file mode 100644 index 000000000..8cecd8435 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/java/test/org/springdoc/api/v31/app90/quotes/QuotesRouter.java @@ -0,0 +1,133 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app90.quotes; + +import java.math.BigDecimal; +import java.math.MathContext; +import java.time.Instant; + +import io.swagger.v3.oas.annotations.enums.ParameterIn; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.reactive.function.server.RouterFunction; +import org.springframework.web.reactive.function.server.ServerResponse; + +import static org.springdoc.core.fn.builders.apiresponse.Builder.responseBuilder; +import static org.springdoc.core.fn.builders.parameter.Builder.parameterBuilder; +import static org.springdoc.core.fn.builders.requestbody.Builder.requestBodyBuilder; +import static org.springdoc.webflux.core.fn.SpringdocRouteBuilder.route; +import static org.springframework.http.MediaType.APPLICATION_JSON; +import static org.springframework.http.MediaType.APPLICATION_STREAM_JSON; +import static org.springframework.http.MediaType.TEXT_PLAIN; +import static org.springframework.web.reactive.function.server.RequestPredicates.accept; +import static org.springframework.web.reactive.function.server.RequestPredicates.contentType; +import static test.org.springdoc.api.v30.AbstractSpringDocTest.HANDLER_FUNCTION; + +@Configuration +class QuotesRouter { + + @Bean + RouterFunction myroute() { + return route().GET("/hello", accept(TEXT_PLAIN), HANDLER_FUNCTION, ops -> ops.tag("quotes") + .operationId("hello").response(responseBuilder().responseCode("200"))).build() + + .and(route().POST("/echo", accept(TEXT_PLAIN).and(contentType(TEXT_PLAIN)), HANDLER_FUNCTION, ops -> ops.tag("quotes") + .operationId("echo") + .requestBody(requestBodyBuilder().implementation(String.class)) + .response(responseBuilder().responseCode("200").implementation(String.class))).build()) + + .and(route().POST("/echo", accept(APPLICATION_JSON).and(contentType(APPLICATION_JSON)), HANDLER_FUNCTION, ops -> ops.tag("quotes") + .operationId("echo") + .requestBody(requestBodyBuilder().implementation(String.class)) + .response(responseBuilder().responseCode("200").implementation(String.class))).build()) + + .and(route().GET("/quotes", accept(APPLICATION_JSON), HANDLER_FUNCTION, ops -> ops.tag("quotes") + .operationId("fetchQuotes") + .parameter(parameterBuilder().in(ParameterIn.QUERY).name("size").implementation(String.class)) + .response(responseBuilder().responseCode("200").implementationArray(Quote.class))).build()) + + .and(route().GET("/quotes", accept(APPLICATION_STREAM_JSON), HANDLER_FUNCTION, ops -> ops.tag("quotes") + .operationId("fetchQuotes") + .response(responseBuilder().responseCode("200").implementation(Quote.class))).build()); + } + + + class Quote { + + private String ticker; + + private BigDecimal price; + + private Instant instant; + + public Quote() { + } + + public Quote(String ticker, BigDecimal price) { + this.ticker = ticker; + this.price = price; + } + + public Quote(String ticker, Double price) { + this(ticker, new BigDecimal(price, new MathContext(2))); + } + + public String getTicker() { + return ticker; + } + + public void setTicker(String ticker) { + this.ticker = ticker; + } + + public BigDecimal getPrice() { + return price; + } + + public void setPrice(BigDecimal price) { + this.price = price; + } + + public Instant getInstant() { + return instant; + } + + public void setInstant(Instant instant) { + this.instant = instant; + } + + @Override + public String toString() { + return "Quote{" + + "ticker='" + ticker + '\'' + + ", price=" + price + + ", instant=" + instant + + '}'; + } + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/resources/results/app102.json b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.0.1/app102.json similarity index 100% rename from springdoc-openapi-starter-webflux-api/src/test/resources/results/app102.json rename to springdoc-openapi-starter-webflux-api/src/test/resources/results/3.0.1/app102.json diff --git a/springdoc-openapi-starter-webflux-api/src/test/resources/results/app149.json b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.0.1/app149.json similarity index 100% rename from springdoc-openapi-starter-webflux-api/src/test/resources/results/app149.json rename to springdoc-openapi-starter-webflux-api/src/test/resources/results/3.0.1/app149.json diff --git a/springdoc-openapi-starter-webflux-api/src/test/resources/results/app150.json b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.0.1/app150.json similarity index 100% rename from springdoc-openapi-starter-webflux-api/src/test/resources/results/app150.json rename to springdoc-openapi-starter-webflux-api/src/test/resources/results/3.0.1/app150.json diff --git a/springdoc-openapi-starter-webflux-api/src/test/resources/results/app151.json b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.0.1/app151.json similarity index 100% rename from springdoc-openapi-starter-webflux-api/src/test/resources/results/app151.json rename to springdoc-openapi-starter-webflux-api/src/test/resources/results/3.0.1/app151.json diff --git a/springdoc-openapi-starter-webflux-api/src/test/resources/results/app152.json b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.0.1/app152.json similarity index 100% rename from springdoc-openapi-starter-webflux-api/src/test/resources/results/app152.json rename to springdoc-openapi-starter-webflux-api/src/test/resources/results/3.0.1/app152.json diff --git a/springdoc-openapi-starter-webflux-api/src/test/resources/results/app153.json b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.0.1/app153.json similarity index 100% rename from springdoc-openapi-starter-webflux-api/src/test/resources/results/app153.json rename to springdoc-openapi-starter-webflux-api/src/test/resources/results/3.0.1/app153.json diff --git a/springdoc-openapi-starter-webflux-api/src/test/resources/results/app154.json b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.0.1/app154.json similarity index 100% rename from springdoc-openapi-starter-webflux-api/src/test/resources/results/app154.json rename to springdoc-openapi-starter-webflux-api/src/test/resources/results/3.0.1/app154.json diff --git a/springdoc-openapi-starter-webflux-api/src/test/resources/results/app184-1.json b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.0.1/app184-1.json similarity index 100% rename from springdoc-openapi-starter-webflux-api/src/test/resources/results/app184-1.json rename to springdoc-openapi-starter-webflux-api/src/test/resources/results/3.0.1/app184-1.json diff --git a/springdoc-openapi-starter-webflux-api/src/test/resources/results/app184-2.json b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.0.1/app184-2.json similarity index 100% rename from springdoc-openapi-starter-webflux-api/src/test/resources/results/app184-2.json rename to springdoc-openapi-starter-webflux-api/src/test/resources/results/3.0.1/app184-2.json diff --git a/springdoc-openapi-starter-webflux-api/src/test/resources/results/app184-3.json b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.0.1/app184-3.json similarity index 100% rename from springdoc-openapi-starter-webflux-api/src/test/resources/results/app184-3.json rename to springdoc-openapi-starter-webflux-api/src/test/resources/results/3.0.1/app184-3.json diff --git a/springdoc-openapi-starter-webflux-api/src/test/resources/results/app184.json b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.0.1/app184.json similarity index 100% rename from springdoc-openapi-starter-webflux-api/src/test/resources/results/app184.json rename to springdoc-openapi-starter-webflux-api/src/test/resources/results/3.0.1/app184.json diff --git a/springdoc-openapi-starter-webflux-api/src/test/resources/results/app187.json b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.0.1/app187.json similarity index 100% rename from springdoc-openapi-starter-webflux-api/src/test/resources/results/app187.json rename to springdoc-openapi-starter-webflux-api/src/test/resources/results/3.0.1/app187.json diff --git a/springdoc-openapi-starter-webflux-api/src/test/resources/results/app188.json b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.0.1/app188.json similarity index 100% rename from springdoc-openapi-starter-webflux-api/src/test/resources/results/app188.json rename to springdoc-openapi-starter-webflux-api/src/test/resources/results/3.0.1/app188.json diff --git a/springdoc-openapi-starter-webflux-api/src/test/resources/results/app189.json b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.0.1/app189.json similarity index 100% rename from springdoc-openapi-starter-webflux-api/src/test/resources/results/app189.json rename to springdoc-openapi-starter-webflux-api/src/test/resources/results/3.0.1/app189.json diff --git a/springdoc-openapi-starter-webflux-api/src/test/resources/results/app191.json b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.0.1/app191.json similarity index 100% rename from springdoc-openapi-starter-webflux-api/src/test/resources/results/app191.json rename to springdoc-openapi-starter-webflux-api/src/test/resources/results/3.0.1/app191.json diff --git a/springdoc-openapi-starter-webflux-api/src/test/resources/results/app3.json b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.0.1/app3.json similarity index 100% rename from springdoc-openapi-starter-webflux-api/src/test/resources/results/app3.json rename to springdoc-openapi-starter-webflux-api/src/test/resources/results/3.0.1/app3.json diff --git a/springdoc-openapi-starter-webflux-api/src/test/resources/results/app39.json b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.0.1/app39.json similarity index 100% rename from springdoc-openapi-starter-webflux-api/src/test/resources/results/app39.json rename to springdoc-openapi-starter-webflux-api/src/test/resources/results/3.0.1/app39.json diff --git a/springdoc-openapi-starter-webflux-api/src/test/resources/results/app4.json b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.0.1/app4.json similarity index 100% rename from springdoc-openapi-starter-webflux-api/src/test/resources/results/app4.json rename to springdoc-openapi-starter-webflux-api/src/test/resources/results/3.0.1/app4.json diff --git a/springdoc-openapi-starter-webflux-api/src/test/resources/results/app5.json b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.0.1/app5.json similarity index 100% rename from springdoc-openapi-starter-webflux-api/src/test/resources/results/app5.json rename to springdoc-openapi-starter-webflux-api/src/test/resources/results/3.0.1/app5.json diff --git a/springdoc-openapi-starter-webflux-api/src/test/resources/results/app63.json b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.0.1/app63.json similarity index 100% rename from springdoc-openapi-starter-webflux-api/src/test/resources/results/app63.json rename to springdoc-openapi-starter-webflux-api/src/test/resources/results/3.0.1/app63.json diff --git a/springdoc-openapi-starter-webflux-api/src/test/resources/results/app64.json b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.0.1/app64.json similarity index 100% rename from springdoc-openapi-starter-webflux-api/src/test/resources/results/app64.json rename to springdoc-openapi-starter-webflux-api/src/test/resources/results/3.0.1/app64.json diff --git a/springdoc-openapi-starter-webflux-api/src/test/resources/results/app65.json b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.0.1/app65.json similarity index 100% rename from springdoc-openapi-starter-webflux-api/src/test/resources/results/app65.json rename to springdoc-openapi-starter-webflux-api/src/test/resources/results/3.0.1/app65.json diff --git a/springdoc-openapi-starter-webflux-api/src/test/resources/results/app66.json b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.0.1/app66.json similarity index 100% rename from springdoc-openapi-starter-webflux-api/src/test/resources/results/app66.json rename to springdoc-openapi-starter-webflux-api/src/test/resources/results/3.0.1/app66.json diff --git a/springdoc-openapi-starter-webflux-api/src/test/resources/results/app67.json b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.0.1/app67.json similarity index 100% rename from springdoc-openapi-starter-webflux-api/src/test/resources/results/app67.json rename to springdoc-openapi-starter-webflux-api/src/test/resources/results/3.0.1/app67.json diff --git a/springdoc-openapi-starter-webflux-api/src/test/resources/results/app68.json b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.0.1/app68.json similarity index 100% rename from springdoc-openapi-starter-webflux-api/src/test/resources/results/app68.json rename to springdoc-openapi-starter-webflux-api/src/test/resources/results/3.0.1/app68.json diff --git a/springdoc-openapi-starter-webflux-api/src/test/resources/results/app69.json b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.0.1/app69.json similarity index 100% rename from springdoc-openapi-starter-webflux-api/src/test/resources/results/app69.json rename to springdoc-openapi-starter-webflux-api/src/test/resources/results/3.0.1/app69.json diff --git a/springdoc-openapi-starter-webflux-api/src/test/resources/results/app70.json b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.0.1/app70.json similarity index 100% rename from springdoc-openapi-starter-webflux-api/src/test/resources/results/app70.json rename to springdoc-openapi-starter-webflux-api/src/test/resources/results/3.0.1/app70.json diff --git a/springdoc-openapi-starter-webflux-api/src/test/resources/results/app71.json b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.0.1/app71.json similarity index 100% rename from springdoc-openapi-starter-webflux-api/src/test/resources/results/app71.json rename to springdoc-openapi-starter-webflux-api/src/test/resources/results/3.0.1/app71.json diff --git a/springdoc-openapi-starter-webflux-api/src/test/resources/results/app72.json b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.0.1/app72.json similarity index 100% rename from springdoc-openapi-starter-webflux-api/src/test/resources/results/app72.json rename to springdoc-openapi-starter-webflux-api/src/test/resources/results/3.0.1/app72.json diff --git a/springdoc-openapi-starter-webflux-api/src/test/resources/results/app73.json b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.0.1/app73.json similarity index 100% rename from springdoc-openapi-starter-webflux-api/src/test/resources/results/app73.json rename to springdoc-openapi-starter-webflux-api/src/test/resources/results/3.0.1/app73.json diff --git a/springdoc-openapi-starter-webflux-api/src/test/resources/results/app74.json b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.0.1/app74.json similarity index 100% rename from springdoc-openapi-starter-webflux-api/src/test/resources/results/app74.json rename to springdoc-openapi-starter-webflux-api/src/test/resources/results/3.0.1/app74.json diff --git a/springdoc-openapi-starter-webflux-api/src/test/resources/results/app75.json b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.0.1/app75.json similarity index 100% rename from springdoc-openapi-starter-webflux-api/src/test/resources/results/app75.json rename to springdoc-openapi-starter-webflux-api/src/test/resources/results/3.0.1/app75.json diff --git a/springdoc-openapi-starter-webflux-api/src/test/resources/results/app78.json b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.0.1/app78.json similarity index 100% rename from springdoc-openapi-starter-webflux-api/src/test/resources/results/app78.json rename to springdoc-openapi-starter-webflux-api/src/test/resources/results/3.0.1/app78.json diff --git a/springdoc-openapi-starter-webflux-api/src/test/resources/results/app79.json b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.0.1/app79.json similarity index 100% rename from springdoc-openapi-starter-webflux-api/src/test/resources/results/app79.json rename to springdoc-openapi-starter-webflux-api/src/test/resources/results/3.0.1/app79.json diff --git a/springdoc-openapi-starter-webflux-api/src/test/resources/results/app80.json b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.0.1/app80.json similarity index 100% rename from springdoc-openapi-starter-webflux-api/src/test/resources/results/app80.json rename to springdoc-openapi-starter-webflux-api/src/test/resources/results/3.0.1/app80.json diff --git a/springdoc-openapi-starter-webflux-api/src/test/resources/results/app81.json b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.0.1/app81.json similarity index 100% rename from springdoc-openapi-starter-webflux-api/src/test/resources/results/app81.json rename to springdoc-openapi-starter-webflux-api/src/test/resources/results/3.0.1/app81.json diff --git a/springdoc-openapi-starter-webflux-api/src/test/resources/results/app82.json b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.0.1/app82.json similarity index 100% rename from springdoc-openapi-starter-webflux-api/src/test/resources/results/app82.json rename to springdoc-openapi-starter-webflux-api/src/test/resources/results/3.0.1/app82.json diff --git a/springdoc-openapi-starter-webflux-api/src/test/resources/results/app83.json b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.0.1/app83.json similarity index 100% rename from springdoc-openapi-starter-webflux-api/src/test/resources/results/app83.json rename to springdoc-openapi-starter-webflux-api/src/test/resources/results/3.0.1/app83.json diff --git a/springdoc-openapi-starter-webflux-api/src/test/resources/results/app84.json b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.0.1/app84.json similarity index 100% rename from springdoc-openapi-starter-webflux-api/src/test/resources/results/app84.json rename to springdoc-openapi-starter-webflux-api/src/test/resources/results/3.0.1/app84.json diff --git a/springdoc-openapi-starter-webflux-api/src/test/resources/results/app85.json b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.0.1/app85.json similarity index 100% rename from springdoc-openapi-starter-webflux-api/src/test/resources/results/app85.json rename to springdoc-openapi-starter-webflux-api/src/test/resources/results/3.0.1/app85.json diff --git a/springdoc-openapi-starter-webflux-api/src/test/resources/results/app86.json b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.0.1/app86.json similarity index 100% rename from springdoc-openapi-starter-webflux-api/src/test/resources/results/app86.json rename to springdoc-openapi-starter-webflux-api/src/test/resources/results/3.0.1/app86.json diff --git a/springdoc-openapi-starter-webflux-api/src/test/resources/results/app87.json b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.0.1/app87.json similarity index 100% rename from springdoc-openapi-starter-webflux-api/src/test/resources/results/app87.json rename to springdoc-openapi-starter-webflux-api/src/test/resources/results/3.0.1/app87.json diff --git a/springdoc-openapi-starter-webflux-api/src/test/resources/results/app88.json b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.0.1/app88.json similarity index 100% rename from springdoc-openapi-starter-webflux-api/src/test/resources/results/app88.json rename to springdoc-openapi-starter-webflux-api/src/test/resources/results/3.0.1/app88.json diff --git a/springdoc-openapi-starter-webflux-api/src/test/resources/results/app89.json b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.0.1/app89.json similarity index 100% rename from springdoc-openapi-starter-webflux-api/src/test/resources/results/app89.json rename to springdoc-openapi-starter-webflux-api/src/test/resources/results/3.0.1/app89.json diff --git a/springdoc-openapi-starter-webflux-api/src/test/resources/results/app90.json b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.0.1/app90.json similarity index 100% rename from springdoc-openapi-starter-webflux-api/src/test/resources/results/app90.json rename to springdoc-openapi-starter-webflux-api/src/test/resources/results/3.0.1/app90.json diff --git a/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app102.json b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app102.json new file mode 100644 index 000000000..f43ac6133 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app102.json @@ -0,0 +1,144 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "", + "description": "Generated server url" + } + ], + "paths": { + "/test": { + "get": { + "tags": [ + "test-controller" + ], + "operationId": "getTest", + "parameters": [ + { + "name": "param", + "in": "query", + "required": false, + "schema": { + "type": "string" + } + }, + { + "name": "childParam", + "in": "query", + "description": "parameter from child of RequestParams", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "stringParam", + "in": "query", + "description": "string parameter", + "required": false, + "schema": { + "type": "string" + } + }, + { + "name": "stringParam1", + "in": "query", + "required": false, + "deprecated": true, + "schema": { + "type": "string" + } + }, + { + "name": "stringParam2", + "in": "query", + "description": "string parameter2", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "intParam", + "in": "query", + "description": "int parameter", + "required": false, + "schema": { + "type": "integer", + "format": "int32" + } + }, + { + "name": "intParam2", + "in": "query", + "required": false, + "schema": { + "type": "string" + } + }, + { + "name": "intParam3", + "in": "query", + "required": false, + "schema": { + "type": "string" + } + }, + { + "name": "nested.param1", + "in": "query", + "description": "nested string parameter", + "required": false, + "schema": { + "type": "string" + } + }, + { + "name": "nested.param2", + "in": "query", + "description": "nested BigInteger parameter", + "required": false, + "schema": { + "type": "integer" + } + }, + { + "name": "nestedList", + "in": "query", + "required": false, + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Nested" + } + } + } + ], + "responses": { + "200": { + "description": "OK" + } + } + } + } + }, + "components": { + "schemas": { + "Nested": { + "type": "object", + "properties": { + "param1": { + "type": "string" + }, + "param2": { + "type": "integer" + } + } + } + } + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app149.json b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app149.json new file mode 100644 index 000000000..b8e8a3f50 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app149.json @@ -0,0 +1,91 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "", + "description": "Generated server url" + } + ], + "paths": { + "/hello": { + "get": { + "tags": [ + "hello-controller" + ], + "operationId": "hello", + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/HelloMessage" + } + } + } + } + } + } + }, + "/message": { + "get": { + "tags": [ + "hello-controller" + ], + "operationId": "message", + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/HelloMessage" + } + } + } + } + } + } + }, + "/helloModelAndView": { + "get": { + "tags": [ + "hello-controller" + ], + "operationId": "helloModelAndView", + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/HelloMessage" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "HelloMessage": { + "type": "object", + "properties": { + "number": { + "type": "integer", + "format": "int32" + }, + "text": { + "type": "string" + } + } + } + } + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app150.json b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app150.json new file mode 100644 index 000000000..15af99852 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app150.json @@ -0,0 +1,76 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "", + "description": "Generated server url" + } + ], + "paths": { + "/users/test/greeter": { + "get": { + "operationId": "get-users", + "responses": {} + } + }, + "/users/test/greeter/greeter3/titi": { + "post": { + "operationId": "create-user-group-special", + "responses": {} + } + }, + "/users/test/greeter/greeter3/toto": { + "get": { + "operationId": "get-user-groups", + "responses": {} + } + }, + "/users/test/greeter/greeter4/titi": { + "post": { + "operationId": "create-user-group-special_1", + "responses": {} + } + }, + "/users/test/greeter/greeter4/toto": { + "get": { + "operationId": "get-user-groups_1", + "responses": {} + } + }, + "/users/test/greeter/groups/titi": { + "post": { + "operationId": "create-user-group-special_2", + "responses": {} + } + }, + "/users/test/greeter/groups/toto": { + "get": { + "operationId": "get-user-groups_2", + "responses": {} + } + }, + "/users/test/greeter/groups2/titi": { + "post": { + "operationId": "create-user-group-special_3", + "responses": {} + } + }, + "/users/test/greeter/groups2/toto": { + "get": { + "operationId": "get-user-groups_3", + "responses": {} + } + }, + "/users/test/greeter/special": { + "post": { + "operationId": "create-user-special", + "responses": {} + } + } + }, + "components": {} +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app151.json b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app151.json new file mode 100644 index 000000000..15af99852 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app151.json @@ -0,0 +1,76 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "", + "description": "Generated server url" + } + ], + "paths": { + "/users/test/greeter": { + "get": { + "operationId": "get-users", + "responses": {} + } + }, + "/users/test/greeter/greeter3/titi": { + "post": { + "operationId": "create-user-group-special", + "responses": {} + } + }, + "/users/test/greeter/greeter3/toto": { + "get": { + "operationId": "get-user-groups", + "responses": {} + } + }, + "/users/test/greeter/greeter4/titi": { + "post": { + "operationId": "create-user-group-special_1", + "responses": {} + } + }, + "/users/test/greeter/greeter4/toto": { + "get": { + "operationId": "get-user-groups_1", + "responses": {} + } + }, + "/users/test/greeter/groups/titi": { + "post": { + "operationId": "create-user-group-special_2", + "responses": {} + } + }, + "/users/test/greeter/groups/toto": { + "get": { + "operationId": "get-user-groups_2", + "responses": {} + } + }, + "/users/test/greeter/groups2/titi": { + "post": { + "operationId": "create-user-group-special_3", + "responses": {} + } + }, + "/users/test/greeter/groups2/toto": { + "get": { + "operationId": "get-user-groups_3", + "responses": {} + } + }, + "/users/test/greeter/special": { + "post": { + "operationId": "create-user-special", + "responses": {} + } + } + }, + "components": {} +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app152.json b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app152.json new file mode 100644 index 000000000..d199de3d1 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app152.json @@ -0,0 +1,36 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "", + "description": "Generated server url" + } + ], + "paths": { + "/persons": { + "get": { + "tags": [ + "hello-controller" + ], + "operationId": "persons", + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + } + }, + "components": {} +} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app153.json b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app153.json new file mode 100644 index 000000000..62552f3ac --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app153.json @@ -0,0 +1,46 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "", + "description": "Generated server url" + } + ], + "paths": { + "/echo": { + "post": { + "tags": [ + "test-controller" + ], + "operationId": "echo", + "parameters": [ + { + "name": "content", + "in": "query", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + } + }, + "components": {} +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app154.json b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app154.json new file mode 100644 index 000000000..4e3b84627 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app154.json @@ -0,0 +1,303 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "", + "description": "Generated server url" + } + ], + "paths": { + "/toto/lowercase": { + "post": { + "description": "lowercase function", + "operationId": "lowercase_POST", + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + }, + "text/plain": { + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + } + } + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + }, + "text/plain": { + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + } + } + } + } + } + }, + "/toto/lowercase/{lowercase}": { + "get": { + "description": "lowercase function", + "operationId": "lowercase_GET", + "parameters": [ + { + "name": "lowercase", + "in": "path", + "required": true, + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + }, + "text/plain": { + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + } + } + } + } + } + }, + "/toto/reverseString": { + "post": { + "description": "reverseString function", + "operationId": "reverseString_POST", + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "string" + } + }, + "text/plain": { + "schema": { + "type": "string" + } + } + } + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "string" + } + }, + "text/plain": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/toto/reverseString/{reverseString}": { + "get": { + "description": "reverseString function", + "operationId": "reverseString_GET", + "parameters": [ + { + "name": "reverseString", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "string" + } + }, + "text/plain": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/toto/titi": { + "get": { + "description": "titi supplier", + "operationId": "titi_GET", + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/PersonDTO" + } + } + } + } + } + } + }, + "/toto/uppercase": { + "post": { + "description": "uppercase function", + "operationId": "uppercase_POST", + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "string" + } + }, + "text/plain": { + "schema": { + "type": "string" + } + } + } + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "string" + } + }, + "text/plain": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/toto/uppercase/{uppercase}": { + "get": { + "description": "uppercase function", + "operationId": "uppercase_GET", + "parameters": [ + { + "name": "uppercase", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "string" + } + }, + "text/plain": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/toto/words": { + "get": { + "description": "words supplier", + "operationId": "words_GET", + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "PersonDTO": { + "type": "object", + "properties": { + "email": { + "type": "string" + }, + "firstName": { + "type": "string" + }, + "lastName": { + "type": "string" + } + } + } + } + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app184-1.json b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app184-1.json new file mode 100644 index 000000000..fa364a7ab --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app184-1.json @@ -0,0 +1,97 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "", + "description": "Generated server url" + }, + { + "url": "urlGlobalBean" + } + ], + "paths": { + "/group3Filtered": { + "get": { + "tags": [ + "hello-controller" + ], + "operationId": "group3Filtered", + "parameters": [ + { + "name": "headerGlobalBean", + "in": "header" + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/group2Filtered": { + "get": { + "tags": [ + "hello-controller" + ], + "operationId": "group2Filtered", + "parameters": [ + { + "name": "headerGlobalBean", + "in": "header" + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/beanFiltered": { + "get": { + "tags": [ + "hello-controller" + ], + "operationId": "beanFiltered", + "parameters": [ + { + "name": "headerGlobalBean", + "in": "header" + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + } + }, + "components": {} +} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app184-2.json b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app184-2.json new file mode 100644 index 000000000..c2217d892 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app184-2.json @@ -0,0 +1,112 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "", + "description": "Generated server url" + }, + { + "url": "urlGlobalBean" + }, + { + "url": "urlGroup2" + } + ], + "paths": { + "/group3Filtered": { + "get": { + "tags": [ + "hello-controller" + ], + "operationId": "group3Filtered", + "parameters": [ + { + "name": "headerGlobalBean", + "in": "header" + }, + { + "name": "headerGroup2", + "in": "header" + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/group1Filtered": { + "get": { + "tags": [ + "hello-controller" + ], + "operationId": "group1Filtered", + "parameters": [ + { + "name": "headerGlobalBean", + "in": "header" + }, + { + "name": "headerGroup2", + "in": "header" + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/beanFiltered": { + "get": { + "tags": [ + "hello-controller" + ], + "operationId": "beanFiltered", + "parameters": [ + { + "name": "headerGlobalBean", + "in": "header" + }, + { + "name": "headerGroup2", + "in": "header" + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + } + }, + "components": {} +} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app184-3.json b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app184-3.json new file mode 100644 index 000000000..4a2d1129e --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app184-3.json @@ -0,0 +1,112 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "", + "description": "Generated server url" + }, + { + "url": "urlGlobalBean" + }, + { + "url": "urlGroup3" + } + ], + "paths": { + "/group2Filtered": { + "get": { + "tags": [ + "hello-controller" + ], + "operationId": "group2Filtered", + "parameters": [ + { + "name": "headerGlobalBean", + "in": "header" + }, + { + "name": "headerGroup3", + "in": "header" + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/group1Filtered": { + "get": { + "tags": [ + "hello-controller" + ], + "operationId": "group1Filtered", + "parameters": [ + { + "name": "headerGlobalBean", + "in": "header" + }, + { + "name": "headerGroup3", + "in": "header" + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/beanFiltered": { + "get": { + "tags": [ + "hello-controller" + ], + "operationId": "beanFiltered", + "parameters": [ + { + "name": "headerGlobalBean", + "in": "header" + }, + { + "name": "headerGroup3", + "in": "header" + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + } + }, + "components": {} +} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app184.json b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app184.json new file mode 100644 index 000000000..b09f390f4 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app184.json @@ -0,0 +1,112 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "", + "description": "Generated server url" + }, + { + "url": "urlGlobalBean" + }, + { + "url": "urlBean" + } + ], + "paths": { + "/group3Filtered": { + "get": { + "tags": [ + "hello-controller" + ], + "operationId": "group3Filtered", + "parameters": [ + { + "name": "headerGlobalBean", + "in": "header" + }, + { + "name": "headerBean", + "in": "header" + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/group2Filtered": { + "get": { + "tags": [ + "hello-controller" + ], + "operationId": "group2Filtered", + "parameters": [ + { + "name": "headerGlobalBean", + "in": "header" + }, + { + "name": "headerBean", + "in": "header" + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/group1Filtered": { + "get": { + "tags": [ + "hello-controller" + ], + "operationId": "group1Filtered", + "parameters": [ + { + "name": "headerGlobalBean", + "in": "header" + }, + { + "name": "headerBean", + "in": "header" + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + } + }, + "components": {} +} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app187.json b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app187.json new file mode 100644 index 000000000..dfeedc7fd --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app187.json @@ -0,0 +1,56 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "", + "description": "Generated server url" + } + ], + "paths": { + "/duplicated": { + "get": { + "tags": [ + "duplicated-path-controller" + ], + "operationId": "duplicated1", + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/duplicated?filter=params": { + "get": { + "tags": [ + "duplicated-path-controller" + ], + "operationId": "duplicated2", + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + } + }, + "components": {} +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app188.json b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app188.json new file mode 100644 index 000000000..080c57047 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app188.json @@ -0,0 +1,47 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "1" + }, + { + "name": "2" + }, + { + "name": "3" + } + ], + "paths": { + "/test": { + "get": { + "tags": [ + "my-controller" + ], + "operationId": "testingMethod", + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + } + }, + "components": {} +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app189.json b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app189.json new file mode 100644 index 000000000..fbfed5874 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app189.json @@ -0,0 +1,67 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "Tweet API", + "license": { + "name": "Apache 2.0", + "url": "http://springdoc.org" + }, + "version": "v0" + }, + "servers": [ + { + "url": "https://customized.url", + "description": "customized description" + } + ], + "paths": { + "/parse-resume": { + "post": { + "tags": [ + "hello-controller" + ], + "summary": "Parse Resume", + "operationId": "parse", + "requestBody": { + "content": { + "multipart/form-data": { + "schema": { + "required": [ + "resumeFile" + ], + "type": "object", + "properties": { + "resumeFile": { + "type": "string", + "description": "Resume file to be parsed", + "format": "binary" + } + } + } + } + } + }, + "responses": { + "400": { + "description": "Invalid input", + "content": { + "application/json": { + "schema": { + "type": "string" + } + } + } + } + } + } + } + }, + "components": { + "securitySchemes": { + "basicScheme": { + "type": "http", + "scheme": "basic" + } + } + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app191.json b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app191.json new file mode 100644 index 000000000..b60e699c0 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app191.json @@ -0,0 +1,37 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "", + "description": "Generated server url" + } + ], + "paths": { + "/v1/name": { + "get": { + "tags": [ + "get-name-handler" + ], + "description": "get name", + "operationId": "getName", + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "string" + } + } + } + } + } + } + } + }, + "components": {} +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app3.json b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app3.json new file mode 100644 index 000000000..af92076cd --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app3.json @@ -0,0 +1,334 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "Tweet API", + "license": { + "name": "Apache 2.0", + "url": "http://springdoc.org" + }, + "version": "v0" + }, + "servers": [ + { + "url": "", + "description": "Generated server url" + } + ], + "paths": { + "/tweets": { + "get": { + "tags": [ + "tweet-controller" + ], + "operationId": "getAllTweets", + "responses": { + "404": { + "description": "Not Found", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + }, + "409": { + "description": "Conflict", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + }, + "200": { + "description": "get All Tweets", + "content": { + "*/*": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/TweetDTO" + } + } + } + } + } + } + }, + "post": { + "tags": [ + "tweet-controller" + ], + "operationId": "createTweets", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/TweetDTO" + } + } + }, + "required": true + }, + "responses": { + "404": { + "description": "Not Found", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + }, + "409": { + "description": "Conflict", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + }, + "200": { + "description": "create Tweets", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/TweetDTO" + } + } + } + } + } + } + }, + "/tweets/{id}": { + "get": { + "tags": [ + "tweet-controller" + ], + "operationId": "getTweetById", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "404": { + "description": "tweet not found", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + }, + "409": { + "description": "Conflict", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + }, + "200": { + "description": "get Tweet By Id", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/TweetDTO" + } + } + } + } + } + }, + "put": { + "tags": [ + "tweet-controller" + ], + "operationId": "updateTweet", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/TweetDTO" + } + } + }, + "required": true + }, + "responses": { + "404": { + "description": "tweet not found", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + }, + "409": { + "description": "Conflict", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + }, + "200": { + "description": "update Tweet", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/TweetDTO" + } + } + } + } + } + }, + "delete": { + "tags": [ + "tweet-controller" + ], + "operationId": "deleteTweet", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "404": { + "description": "tweet not found", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + }, + "409": { + "description": "Conflict", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + }, + "200": { + "description": "delete Tweet" + } + } + } + }, + "/stream/tweets": { + "get": { + "tags": [ + "tweet-controller" + ], + "description": "Tweets are Sent to the client as Server Sent Events", + "operationId": "streamAllTweets", + "responses": { + "404": { + "description": "Not Found", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + }, + "409": { + "description": "Conflict", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + }, + "200": { + "description": "stream All Tweets", + "content": { + "text/event-stream": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/TweetDTO" + } + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "TweetDTO": { + "required": [ + "createdAt", + "text" + ], + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "text": { + "maxLength": 140, + "minLength": 0, + "type": "string" + }, + "createdAt": { + "type": "string", + "format": "date-time" + } + } + } + }, + "securitySchemes": { + "basicScheme": { + "type": "http", + "scheme": "basic" + } + } + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app39.json b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app39.json new file mode 100644 index 000000000..560343aa6 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app39.json @@ -0,0 +1,85 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "", + "description": "Generated server url" + } + ], + "paths": { + "/hello": { + "get": { + "tags": [ + "hello-controller" + ], + "operationId": "hello", + "parameters": [ + { + "in": "header", + "$ref": "#/components/parameters/myGlobalHeader" + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/test": { + "post": { + "tags": [ + "hello-controller" + ], + "summary": "test Request", + "operationId": "searchEmployee", + "parameters": [ + { + "in": "header", + "$ref": "#/components/parameters/myGlobalHeader" + } + ], + "requestBody": { + "description": "test value", + "content": { + "application/json": { + "schema": { + "type": "string" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "OK" + } + } + } + } + }, + "components": { + "parameters": { + "myGlobalHeader": { + "name": "My-Global-Header", + "in": "header", + "description": "My Global Header", + "required": true, + "schema": { + "type": "string" + } + } + } + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app4.json b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app4.json new file mode 100644 index 000000000..d3aaa555e --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app4.json @@ -0,0 +1,67 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "Tweet API", + "license": { + "name": "Apache 2.0", + "url": "http://springdoc.org" + }, + "version": "v0" + }, + "servers": [ + { + "url": "", + "description": "Generated server url" + } + ], + "paths": { + "/parse-resume": { + "post": { + "tags": [ + "hello-controller" + ], + "summary": "Parse Resume", + "operationId": "parse", + "requestBody": { + "content": { + "multipart/form-data": { + "schema": { + "required": [ + "resumeFile" + ], + "type": "object", + "properties": { + "resumeFile": { + "type": "string", + "description": "Resume file to be parsed", + "format": "binary" + } + } + } + } + } + }, + "responses": { + "400": { + "description": "Invalid input", + "content": { + "application/json": { + "schema": { + "type": "string" + } + } + } + } + } + } + } + }, + "components": { + "securitySchemes": { + "basicScheme": { + "type": "http", + "scheme": "basic" + } + } + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app5.json b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app5.json new file mode 100644 index 000000000..8981c818b --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app5.json @@ -0,0 +1,100 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "Tweet API", + "license": { + "name": "Apache 2.0", + "url": "http://springdoc.org" + }, + "version": "v0" + }, + "servers": [ + { + "url": "", + "description": "Generated server url" + } + ], + "paths": { + "/test": { + "get": { + "tags": [ + "hello-controller" + ], + "operationId": "demo2", + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/tweets/does-not-work": { + "post": { + "tags": [ + "hello-controller" + ], + "operationId": "postNotWorks", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Tweet" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/Tweet" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "Tweet": { + "required": [ + "createdAt", + "text" + ], + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "text": { + "maxLength": 140, + "minLength": 0, + "type": "string" + }, + "createdAt": { + "type": "string", + "format": "date-time" + } + } + } + }, + "securitySchemes": { + "basicScheme": { + "type": "http", + "scheme": "basic" + } + } + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app63.json b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app63.json new file mode 100644 index 000000000..f6bf5a2ed --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app63.json @@ -0,0 +1,15 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "", + "description": "Generated server url" + } + ], + "paths": {}, + "components": {} +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app64.json b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app64.json new file mode 100644 index 000000000..868bddccf --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app64.json @@ -0,0 +1,47 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "", + "description": "Generated server url" + } + ], + "paths": { + "/api/balance/abcd": { + "get": { + "tags": [ + "hello-controller" + ], + "summary": "This is the test endpoint", + "operationId": "test2", + "parameters": [ + { + "name": "from", + "in": "query", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + } + }, + "components": {} +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app65.json b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app65.json new file mode 100644 index 000000000..20e7401da --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app65.json @@ -0,0 +1,88 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "Health", + "description": "Health check / ping API" + } + ], + "paths": { + "/health": { + "get": { + "tags": [ + "Health" + ], + "summary": "Check server status", + "description": "Check server status, will return 200 with simple string if alive. Do nothing else.", + "operationId": "ping", + "responses": { + "200": { + "description": "OK", + "content": { + "text/plain": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/ping": { + "get": { + "tags": [ + "Health" + ], + "summary": "Check server status", + "description": "Check server status, will return 200 with simple string if alive. Do nothing else.", + "operationId": "ping_1", + "responses": { + "200": { + "description": "OK", + "content": { + "text/plain": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/": { + "get": { + "tags": [ + "Health" + ], + "summary": "Check server status", + "description": "Check server status, will return 200 with simple string if alive. Do nothing else.", + "operationId": "ping_2", + "responses": { + "200": { + "description": "OK", + "content": { + "text/plain": { + "schema": { + "type": "string" + } + } + } + } + } + } + } + }, + "components": {} +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app66.json b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app66.json new file mode 100644 index 000000000..afd650cbe --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app66.json @@ -0,0 +1,94 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "Tweet API", + "license": { + "name": "Apache 2.0", + "url": "http://springdoc.org" + }, + "version": "v0" + }, + "servers": [ + { + "url": "", + "description": "Generated server url" + } + ], + "paths": { + "/stream/tweets": { + "get": { + "tags": [ + "tweet-controller" + ], + "description": "Tweets are Sent to the client as Server Sent Events", + "operationId": "streamAllTweets", + "responses": { + "200": { + "description": "stream All Tweets", + "content": { + "text/event-stream": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/TweetDTO" + } + } + } + } + }, + "404": { + "description": "Not Found", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + }, + "409": { + "description": "Conflict", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "TweetDTO": { + "required": [ + "createdAt", + "text" + ], + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "text": { + "maxLength": 140, + "minLength": 0, + "type": "string" + }, + "createdAt": { + "type": "string", + "format": "date-time" + } + } + } + }, + "securitySchemes": { + "basicScheme": { + "type": "http", + "scheme": "basic" + } + } + } +} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app67.json b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app67.json new file mode 100644 index 000000000..d800773bf --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app67.json @@ -0,0 +1,144 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "", + "description": "Generated server url" + } + ], + "paths": { + "/api": { + "get": { + "tags": [ + "hello-controller" + ], + "operationId": "test", + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + }, + "put": { + "tags": [ + "hello-controller" + ], + "operationId": "test_2", + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + }, + "post": { + "tags": [ + "hello-controller" + ], + "operationId": "test_1", + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + }, + "delete": { + "tags": [ + "hello-controller" + ], + "operationId": "test_3", + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + }, + "options": { + "tags": [ + "hello-controller" + ], + "operationId": "test_6", + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + }, + "head": { + "tags": [ + "hello-controller" + ], + "operationId": "test_5", + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + }, + "patch": { + "tags": [ + "hello-controller" + ], + "operationId": "test_4", + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + } + }, + "components": {} +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app68.json b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app68.json new file mode 100644 index 000000000..cba35f247 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app68.json @@ -0,0 +1,94 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "Tweet API", + "license": { + "name": "Apache 2.0", + "url": "http://springdoc.org" + }, + "version": "v0" + }, + "servers": [ + { + "url": "", + "description": "Generated server url" + } + ], + "paths": { + "/stream/tweets": { + "get": { + "tags": [ + "tweet-controller" + ], + "description": "Tweets are Sent to the client as Server Sent Events", + "operationId": "streamAllTweets", + "responses": { + "404": { + "description": "Not Found", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + }, + "409": { + "description": "Conflict", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + }, + "200": { + "description": "stream All Tweets", + "content": { + "text/event-stream": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/TweetDTO" + } + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "TweetDTO": { + "required": [ + "createdAt", + "text" + ], + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "text": { + "maxLength": 140, + "minLength": 0, + "type": "string" + }, + "createdAt": { + "type": "string", + "format": "date-time" + } + } + } + }, + "securitySchemes": { + "basicScheme": { + "type": "http", + "scheme": "basic" + } + } + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app69.json b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app69.json new file mode 100644 index 000000000..26ca11c6d --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app69.json @@ -0,0 +1,188 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "", + "description": "Generated server url" + } + ], + "paths": { + "/api/user/delete/{id}": { + "delete": { + "tags": [ + "user-repository-impl" + ], + "operationId": "deleteUser", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "integer", + "format": "int64" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/api/user/index": { + "get": { + "tags": [ + "user-repository-impl" + ], + "description": "get all the users", + "operationId": "getAllUsers", + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/User" + } + } + } + } + } + } + } + }, + "/api/user/post": { + "post": { + "tags": [ + "user-repository-impl" + ], + "operationId": "saveUser", + "parameters": [ + { + "name": "monoUser", + "in": "query", + "required": true, + "schema": { + "$ref": "#/components/schemas/User" + } + } + ], + "responses": { + "200": { + "description": "OK" + } + } + } + }, + "/api/user/put/{id}": { + "put": { + "tags": [ + "user-repository-impl" + ], + "operationId": "putUser", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "integer", + "format": "int64" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/User" + } + } + } + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/User" + } + } + } + } + } + } + }, + "/api/user/{id}": { + "get": { + "tags": [ + "user-repository-impl" + ], + "operationId": "getUserById", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "The user Id", + "required": true, + "schema": { + "type": "integer", + "format": "int64" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/User" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "User": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "firstname": { + "type": "string" + }, + "lastname": { + "type": "string" + }, + "age": { + "type": "integer", + "format": "int32" + } + } + } + } + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app70.json b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app70.json new file mode 100644 index 000000000..2848a341a --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app70.json @@ -0,0 +1,128 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "", + "description": "Generated server url" + } + ], + "paths": { + "/coffees": { + "get": { + "tags": [ + "coffee-service" + ], + "operationId": "getAllCoffees", + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Coffee" + } + } + } + } + } + } + } + }, + "/coffees/{id}": { + "get": { + "tags": [ + "coffee-service" + ], + "operationId": "getCoffeeById", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/Coffee" + } + } + } + } + } + } + }, + "/coffees/{id}/orders": { + "get": { + "tags": [ + "coffee-service" + ], + "operationId": "getOrdersForCoffeeById", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/CoffeeOrder" + } + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "Coffee": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "name": { + "type": "string" + } + } + }, + "CoffeeOrder": { + "type": "object", + "properties": { + "coffeeId": { + "type": "string" + }, + "whenOrdered": { + "type": "string", + "format": "date-time" + } + } + } + } + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app71.json b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app71.json new file mode 100644 index 000000000..922fb84f2 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app71.json @@ -0,0 +1,204 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "", + "description": "Generated server url" + } + ], + "paths": { + "/employees": { + "get": { + "tags": [ + "employee-repository" + ], + "operationId": "findAllEmployees", + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Employee" + } + } + } + } + } + } + } + }, + "/employees/{id}": { + "get": { + "tags": [ + "MyEmployee" + ], + "summary": "Find purchase order by ID", + "operationId": "findEmployeeById", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "Employee Id", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "successful operation", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/Employee" + } + } + } + }, + "400": { + "description": "Invalid Employee ID supplied" + }, + "404": { + "description": "Employee not found" + } + } + } + }, + "/employees/update": { + "post": { + "tags": [ + "employee-repository" + ], + "operationId": "updateEmployee", + "parameters": [ + { + "name": "employee", + "in": "query", + "required": true, + "schema": { + "$ref": "#/components/schemas/Employee" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/xml": { + "schema": { + "$ref": "#/components/schemas/Employee" + } + } + } + } + } + } + }, + "/employees-composed": { + "get": { + "tags": [ + "employee-repository" + ], + "operationId": "findAllEmployees_1", + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Employee" + } + } + } + } + } + } + } + }, + "/employees-composed/update": { + "post": { + "tags": [ + "employee-repository" + ], + "operationId": "updateEmployee_1", + "parameters": [ + { + "name": "employee", + "in": "query", + "required": true, + "schema": { + "$ref": "#/components/schemas/Employee" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/Employee" + } + } + } + } + } + } + }, + "/employees-composed/{id}": { + "get": { + "tags": [ + "employee-repository" + ], + "operationId": "findEmployeeById_1", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/Employee" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "Employee": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "name": { + "type": "string" + } + } + } + } + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app72.json b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app72.json new file mode 100644 index 000000000..0d6ca8afb --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app72.json @@ -0,0 +1,296 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "", + "description": "Generated server url" + } + ], + "paths": { + "/createPerson": { + "post": { + "tags": [ + "person-service" + ], + "operationId": "save", + "parameters": [ + { + "name": "person", + "in": "query", + "required": true, + "schema": { + "$ref": "#/components/schemas/Person" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/deletePerson/{id}": { + "delete": { + "tags": [ + "person-service" + ], + "operationId": "delete", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/getAllPersons": { + "get": { + "tags": [ + "person-service" + ], + "operationId": "getAll", + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Person" + } + } + } + } + } + } + } + }, + "/getPerson/{id}": { + "get": { + "tags": [ + "person-service" + ], + "operationId": "getById", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/stream+json": { + "schema": { + "$ref": "#/components/schemas/Person" + } + } + } + } + } + } + }, + "/createPosition": { + "post": { + "tags": [ + "positions" + ], + "description": "Save position", + "operationId": "save_1", + "requestBody": { + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/Position" + } + } + } + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Position" + } + } + } + } + } + } + }, + "/deletePosition/{id}": { + "delete": { + "tags": [ + "positions" + ], + "description": "Delete By Id", + "operationId": "deleteBy", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": {} + } + } + } + }, + "/getAllPositions": { + "get": { + "tags": [ + "positions" + ], + "description": "Get all positions", + "operationId": "findAll", + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Position" + } + } + } + } + } + } + } + }, + "/getPosition/{id}": { + "get": { + "tags": [ + "positions" + ], + "description": "Find all", + "operationId": "findById", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/stream+json": { + "schema": { + "$ref": "#/components/schemas/Position" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "Person": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "sex": { + "type": "string", + "enum": [ + "MAN", + "WOMEN" + ] + }, + "firstName": { + "type": "string" + }, + "lastName": { + "type": "string" + }, + "age": { + "type": "string" + }, + "interests": { + "type": "string" + }, + "email": { + "type": "string" + } + } + }, + "Position": { + "required": [ + "createdAt", + "positionName" + ], + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "positionName": { + "maxLength": 140, + "minLength": 0, + "type": "string" + }, + "description": { + "type": "string" + }, + "createdAt": { + "type": "string", + "format": "date-time" + } + } + } + } + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app73.json b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app73.json new file mode 100644 index 000000000..0b5640c8c --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app73.json @@ -0,0 +1,114 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "", + "description": "Generated server url" + } + ], + "paths": { + "/echo": { + "post": { + "operationId": "echo", + "requestBody": { + "content": { + "text/plain": { + "schema": { + "type": "string" + } + }, + "application/json": { + "schema": { + "type": "string" + } + } + } + }, + "responses": { + "200": { + "description": "OK", + "content": { + "text/plain": { + "schema": { + "type": "string" + } + }, + "application/json": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/hello": { + "get": { + "operationId": "hello", + "responses": { + "200": { + "description": "OK" + } + } + } + }, + "/quotes": { + "get": { + "operationId": "fetchQuotes", + "parameters": [ + { + "name": "size", + "in": "query", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Quote" + } + } + }, + "application/stream+json": { + "schema": { + "$ref": "#/components/schemas/Quote" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "Quote": { + "type": "object", + "properties": { + "ticker": { + "type": "string" + }, + "price": { + "type": "number" + }, + "instant": { + "type": "string", + "format": "date-time" + } + } + } + } + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app74.json b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app74.json new file mode 100644 index 000000000..563d5c142 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app74.json @@ -0,0 +1,105 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "", + "description": "Generated server url" + } + ], + "paths": { + "/books": { + "get": { + "tags": [ + "book-repository" + ], + "operationId": "findAll", + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Book" + } + } + }, + "application/xml": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Book" + } + } + }, + "text/plain": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Book" + } + } + } + } + } + } + } + }, + "/books/{author}": { + "get": { + "tags": [ + "book-repository" + ], + "operationId": "findByAuthor", + "parameters": [ + { + "name": "author", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Book" + } + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "Book": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "title": { + "type": "string" + }, + "author": { + "type": "string" + } + } + } + } + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app75.json b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app75.json new file mode 100644 index 000000000..48a13cd8f --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app75.json @@ -0,0 +1,166 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "", + "description": "Generated server url" + } + ], + "paths": { + "/posts": { + "get": { + "operationId": "all", + "parameters": [ + { + "name": "key", + "in": "query", + "description": "sample description", + "required": true, + "schema": { + "type": "string", + "default": "value" + } + }, + { + "name": "test", + "in": "query", + "description": "sample desc", + "schema": { + "type": "string" + } + }, + { + "name": "x-header1", + "in": "header", + "schema": { + "type": "string", + "enum": [ + "test1" + ] + } + }, + { + "name": "x-header2", + "in": "header", + "schema": { + "type": "string", + "enum": [ + "test2" + ] + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Post" + } + } + } + } + } + } + }, + "post": { + "operationId": "create", + "requestBody": { + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/Post" + } + } + } + }, + "responses": { + "201": { + "description": "Created" + } + } + } + }, + "/posts/{id}": { + "get": { + "operationId": "get", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/Post" + } + } + } + } + } + }, + "put": { + "operationId": "update", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "202": { + "description": "Accepted", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/Post" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "Post": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "title": { + "type": "string" + }, + "content": { + "type": "string" + }, + "createdDate": { + "type": "string", + "format": "date-time" + } + } + } + } + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app78.json b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app78.json new file mode 100644 index 000000000..251c9cc88 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app78.json @@ -0,0 +1,52 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "", + "description": "Generated server url" + } + ], + "paths": { + "/files": { + "post": { + "tags": [ + "hello-controller" + ], + "summary": "files", + "operationId": "handleFileUpload", + "requestBody": { + "content": { + "multipart/form-data": { + "schema": { + "required": [ + "files" + ], + "type": "object", + "properties": { + "files": { + "type": "array", + "description": "files", + "items": { + "type": "string", + "format": "binary" + } + } + } + } + } + } + }, + "responses": { + "200": { + "description": "OK" + } + } + } + } + }, + "components": {} +} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app79.json b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app79.json new file mode 100644 index 000000000..bf1794cf7 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app79.json @@ -0,0 +1,77 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "", + "description": "Generated server url" + } + ], + "paths": { + "/test2": { + "get": { + "tags": [ + "specific-controller" + ], + "operationId": "get2", + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/SpecificClientModel" + } + } + } + } + } + } + } + }, + "/test1": { + "get": { + "tags": [ + "specific-controller" + ], + "operationId": "get1", + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/SpecificClientModel" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "SpecificClientModel": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int32" + }, + "name": { + "title": "my title", + "pattern": "this is it", + "type": "string", + "example": "this is example" + } + } + } + } + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app80.json b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app80.json new file mode 100644 index 000000000..20fd9dc38 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app80.json @@ -0,0 +1,393 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "", + "description": "Generated server url" + } + ], + "paths": { + "/greeter/greeter2/books": { + "get": { + "tags": [ + "book-repository" + ], + "operationId": "findAll", + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Book" + } + } + }, + "application/xml": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Book" + } + } + }, + "text/plain": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Book" + } + } + } + } + } + } + } + }, + "/greeter/greeter2/books/{author}": { + "get": { + "tags": [ + "book-repository" + ], + "operationId": "findByAuthor", + "parameters": [ + { + "name": "author", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Book" + } + } + } + } + } + } + } + }, + "/books": { + "get": { + "tags": [ + "book-repository" + ], + "operationId": "findAll_1", + "responses": { + "200": { + "description": "OK", + "content": { + "application/xml": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Book" + } + } + }, + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Book" + } + } + } + } + } + } + } + }, + "/books/{author}": { + "get": { + "tags": [ + "book-repository" + ], + "operationId": "findByAuthor_1", + "parameters": [ + { + "name": "author", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Book" + } + } + }, + "application/xml": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Book" + } + } + } + } + } + } + } + }, + "/greeter/books": { + "get": { + "tags": [ + "book-repository" + ], + "operationId": "findAll_2", + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Book" + } + } + }, + "application/xml": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Book" + } + } + }, + "text/plain": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Book" + } + } + } + } + } + } + } + }, + "/greeter/books/{author}": { + "get": { + "tags": [ + "book-repository" + ], + "operationId": "findByAuthor_2", + "parameters": [ + { + "name": "author", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Book" + } + } + } + } + } + } + } + }, + "/greeter2/books": { + "get": { + "tags": [ + "book-repository" + ], + "operationId": "findAll_3", + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Book" + } + } + }, + "application/xml": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Book" + } + } + }, + "text/plain": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Book" + } + } + } + } + } + } + } + }, + "/greeter2/books/{author}": { + "get": { + "tags": [ + "book-repository" + ], + "operationId": "findByAuthor_3", + "parameters": [ + { + "name": "author", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Book" + } + } + } + } + } + } + } + }, + "/test/greeter/greeter2/books": { + "get": { + "tags": [ + "book-repository" + ], + "operationId": "findAll_4", + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Book" + } + } + }, + "application/xml": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Book" + } + } + }, + "text/plain": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Book" + } + } + } + } + } + } + } + }, + "/test/greeter/greeter2/books/{author}": { + "get": { + "tags": [ + "book-repository" + ], + "operationId": "findByAuthor_4", + "parameters": [ + { + "name": "author", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Book" + } + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "Book": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "title": { + "type": "string" + }, + "author": { + "type": "string" + } + } + } + } + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app81.json b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app81.json new file mode 100644 index 000000000..56b29f1ca --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app81.json @@ -0,0 +1,127 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/test_3": { + "get": { + "tags": [ + "operation-id-controller" + ], + "operationId": "opIdTest", + "parameters": [ + { + "name": "param", + "in": "query", + "required": true, + "schema": { + "type": "boolean" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/test_2": { + "get": { + "tags": [ + "operation-id-controller" + ], + "operationId": "opIdTest_1", + "parameters": [ + { + "name": "param", + "in": "query", + "required": true, + "schema": { + "type": "integer", + "format": "int32" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/test_1": { + "get": { + "tags": [ + "operation-id-controller" + ], + "operationId": "opIdTest_2", + "parameters": [ + { + "name": "param", + "in": "query", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/test_0": { + "get": { + "tags": [ + "operation-id-controller" + ], + "operationId": "opIdTest_3", + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + } + }, + "components": {} +} \ No newline at end of file diff --git a/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app82.json b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app82.json new file mode 100644 index 000000000..bf2b7ed71 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app82.json @@ -0,0 +1,188 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "", + "description": "Generated server url" + } + ], + "paths": { + "/api/user/delete/{id}": { + "delete": { + "tags": [ + "user-repository-impl" + ], + "operationId": "deleteUser", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "integer", + "format": "int64" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/api/user/index": { + "get": { + "tags": [ + "user-repository-impl" + ], + "description": "get all the users", + "operationId": "getAllUsers", + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/User" + } + } + } + } + } + } + } + }, + "/api/user/post": { + "post": { + "tags": [ + "user-repository-impl" + ], + "operationId": "saveUser", + "parameters": [ + { + "name": "monoUser", + "in": "query", + "required": true, + "schema": { + "$ref": "#/components/schemas/User" + } + } + ], + "responses": { + "200": { + "description": "OK" + } + } + } + }, + "/api/user/put": { + "put": { + "tags": [ + "user-repository-impl" + ], + "operationId": "putUser", + "parameters": [ + { + "name": "id", + "in": "query", + "required": true, + "schema": { + "type": "integer", + "format": "int64" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/User" + } + } + } + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/User" + } + } + } + } + } + } + }, + "/api/user/{id}": { + "get": { + "tags": [ + "user-repository-impl" + ], + "operationId": "getUserById", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "The user Id", + "required": true, + "schema": { + "type": "integer", + "format": "int64" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/User" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "User": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "firstname": { + "type": "string" + }, + "lastname": { + "type": "string" + }, + "age": { + "type": "integer", + "format": "int32" + } + } + } + } + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app83.json b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app83.json new file mode 100644 index 000000000..2848a341a --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app83.json @@ -0,0 +1,128 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "", + "description": "Generated server url" + } + ], + "paths": { + "/coffees": { + "get": { + "tags": [ + "coffee-service" + ], + "operationId": "getAllCoffees", + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Coffee" + } + } + } + } + } + } + } + }, + "/coffees/{id}": { + "get": { + "tags": [ + "coffee-service" + ], + "operationId": "getCoffeeById", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/Coffee" + } + } + } + } + } + } + }, + "/coffees/{id}/orders": { + "get": { + "tags": [ + "coffee-service" + ], + "operationId": "getOrdersForCoffeeById", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/CoffeeOrder" + } + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "Coffee": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "name": { + "type": "string" + } + } + }, + "CoffeeOrder": { + "type": "object", + "properties": { + "coffeeId": { + "type": "string" + }, + "whenOrdered": { + "type": "string", + "format": "date-time" + } + } + } + } + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app84.json b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app84.json new file mode 100644 index 000000000..922fb84f2 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app84.json @@ -0,0 +1,204 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "", + "description": "Generated server url" + } + ], + "paths": { + "/employees": { + "get": { + "tags": [ + "employee-repository" + ], + "operationId": "findAllEmployees", + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Employee" + } + } + } + } + } + } + } + }, + "/employees/{id}": { + "get": { + "tags": [ + "MyEmployee" + ], + "summary": "Find purchase order by ID", + "operationId": "findEmployeeById", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "Employee Id", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "successful operation", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/Employee" + } + } + } + }, + "400": { + "description": "Invalid Employee ID supplied" + }, + "404": { + "description": "Employee not found" + } + } + } + }, + "/employees/update": { + "post": { + "tags": [ + "employee-repository" + ], + "operationId": "updateEmployee", + "parameters": [ + { + "name": "employee", + "in": "query", + "required": true, + "schema": { + "$ref": "#/components/schemas/Employee" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/xml": { + "schema": { + "$ref": "#/components/schemas/Employee" + } + } + } + } + } + } + }, + "/employees-composed": { + "get": { + "tags": [ + "employee-repository" + ], + "operationId": "findAllEmployees_1", + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Employee" + } + } + } + } + } + } + } + }, + "/employees-composed/update": { + "post": { + "tags": [ + "employee-repository" + ], + "operationId": "updateEmployee_1", + "parameters": [ + { + "name": "employee", + "in": "query", + "required": true, + "schema": { + "$ref": "#/components/schemas/Employee" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/Employee" + } + } + } + } + } + } + }, + "/employees-composed/{id}": { + "get": { + "tags": [ + "employee-repository" + ], + "operationId": "findEmployeeById_1", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/Employee" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "Employee": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "name": { + "type": "string" + } + } + } + } + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app85.json b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app85.json new file mode 100644 index 000000000..0d6ca8afb --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app85.json @@ -0,0 +1,296 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "", + "description": "Generated server url" + } + ], + "paths": { + "/createPerson": { + "post": { + "tags": [ + "person-service" + ], + "operationId": "save", + "parameters": [ + { + "name": "person", + "in": "query", + "required": true, + "schema": { + "$ref": "#/components/schemas/Person" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/deletePerson/{id}": { + "delete": { + "tags": [ + "person-service" + ], + "operationId": "delete", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/getAllPersons": { + "get": { + "tags": [ + "person-service" + ], + "operationId": "getAll", + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Person" + } + } + } + } + } + } + } + }, + "/getPerson/{id}": { + "get": { + "tags": [ + "person-service" + ], + "operationId": "getById", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/stream+json": { + "schema": { + "$ref": "#/components/schemas/Person" + } + } + } + } + } + } + }, + "/createPosition": { + "post": { + "tags": [ + "positions" + ], + "description": "Save position", + "operationId": "save_1", + "requestBody": { + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/Position" + } + } + } + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Position" + } + } + } + } + } + } + }, + "/deletePosition/{id}": { + "delete": { + "tags": [ + "positions" + ], + "description": "Delete By Id", + "operationId": "deleteBy", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": {} + } + } + } + }, + "/getAllPositions": { + "get": { + "tags": [ + "positions" + ], + "description": "Get all positions", + "operationId": "findAll", + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Position" + } + } + } + } + } + } + } + }, + "/getPosition/{id}": { + "get": { + "tags": [ + "positions" + ], + "description": "Find all", + "operationId": "findById", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/stream+json": { + "schema": { + "$ref": "#/components/schemas/Position" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "Person": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "sex": { + "type": "string", + "enum": [ + "MAN", + "WOMEN" + ] + }, + "firstName": { + "type": "string" + }, + "lastName": { + "type": "string" + }, + "age": { + "type": "string" + }, + "interests": { + "type": "string" + }, + "email": { + "type": "string" + } + } + }, + "Position": { + "required": [ + "createdAt", + "positionName" + ], + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "positionName": { + "maxLength": 140, + "minLength": 0, + "type": "string" + }, + "description": { + "type": "string" + }, + "createdAt": { + "type": "string", + "format": "date-time" + } + } + } + } + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app86.json b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app86.json new file mode 100644 index 000000000..0b5640c8c --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app86.json @@ -0,0 +1,114 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "", + "description": "Generated server url" + } + ], + "paths": { + "/echo": { + "post": { + "operationId": "echo", + "requestBody": { + "content": { + "text/plain": { + "schema": { + "type": "string" + } + }, + "application/json": { + "schema": { + "type": "string" + } + } + } + }, + "responses": { + "200": { + "description": "OK", + "content": { + "text/plain": { + "schema": { + "type": "string" + } + }, + "application/json": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/hello": { + "get": { + "operationId": "hello", + "responses": { + "200": { + "description": "OK" + } + } + } + }, + "/quotes": { + "get": { + "operationId": "fetchQuotes", + "parameters": [ + { + "name": "size", + "in": "query", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Quote" + } + } + }, + "application/stream+json": { + "schema": { + "$ref": "#/components/schemas/Quote" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "Quote": { + "type": "object", + "properties": { + "ticker": { + "type": "string" + }, + "price": { + "type": "number" + }, + "instant": { + "type": "string", + "format": "date-time" + } + } + } + } + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app87.json b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app87.json new file mode 100644 index 000000000..563d5c142 --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app87.json @@ -0,0 +1,105 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "", + "description": "Generated server url" + } + ], + "paths": { + "/books": { + "get": { + "tags": [ + "book-repository" + ], + "operationId": "findAll", + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Book" + } + } + }, + "application/xml": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Book" + } + } + }, + "text/plain": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Book" + } + } + } + } + } + } + } + }, + "/books/{author}": { + "get": { + "tags": [ + "book-repository" + ], + "operationId": "findByAuthor", + "parameters": [ + { + "name": "author", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Book" + } + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "Book": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "title": { + "type": "string" + }, + "author": { + "type": "string" + } + } + } + } + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app88.json b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app88.json new file mode 100644 index 000000000..02a8ac4be --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app88.json @@ -0,0 +1,146 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "", + "description": "Generated server url" + } + ], + "paths": { + "/posts": { + "get": { + "operationId": "all", + "parameters": [ + { + "name": "key", + "in": "query", + "description": "sample description", + "required": true, + "schema": { + "type": "string", + "default": "value" + } + }, + { + "name": "test", + "in": "query", + "description": "sample desc", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Post" + } + } + } + } + } + } + }, + "post": { + "operationId": "create", + "requestBody": { + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/Post" + } + } + } + }, + "responses": { + "201": { + "description": "Created" + } + } + } + }, + "/posts/{id}": { + "get": { + "operationId": "get", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/Post" + } + } + } + } + } + }, + "put": { + "operationId": "update", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "202": { + "description": "Accepted", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/Post" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "Post": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "title": { + "type": "string" + }, + "content": { + "type": "string" + }, + "createdDate": { + "type": "string", + "format": "date-time" + } + } + } + } + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app89.json b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app89.json new file mode 100644 index 000000000..77e73364e --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app89.json @@ -0,0 +1,393 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "", + "description": "Generated server url" + } + ], + "paths": { + "/greeter/greeter2/books": { + "get": { + "tags": [ + "book-repository" + ], + "operationId": "findAll", + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Book" + } + } + }, + "application/xml": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Book" + } + } + }, + "text/plain": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Book" + } + } + } + } + } + } + } + }, + "/greeter/greeter2/books/{author}": { + "get": { + "tags": [ + "book-repository" + ], + "operationId": "findByAuthor", + "parameters": [ + { + "name": "author", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Book" + } + } + } + } + } + } + } + }, + "/books": { + "get": { + "tags": [ + "book-repository" + ], + "operationId": "findAll_1", + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Book" + } + } + }, + "application/xml": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Book" + } + } + } + } + } + } + } + }, + "/books/{author}": { + "get": { + "tags": [ + "book-repository" + ], + "operationId": "findByAuthor_1", + "parameters": [ + { + "name": "author", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Book" + } + } + }, + "application/xml": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Book" + } + } + } + } + } + } + } + }, + "/greeter/books": { + "get": { + "tags": [ + "book-repository" + ], + "operationId": "findAll_2", + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Book" + } + } + }, + "application/xml": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Book" + } + } + }, + "text/plain": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Book" + } + } + } + } + } + } + } + }, + "/greeter/books/{author}": { + "get": { + "tags": [ + "book-repository" + ], + "operationId": "findByAuthor_2", + "parameters": [ + { + "name": "author", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Book" + } + } + } + } + } + } + } + }, + "/greeter2/books": { + "get": { + "tags": [ + "book-repository" + ], + "operationId": "findAll_3", + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Book" + } + } + }, + "application/xml": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Book" + } + } + }, + "text/plain": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Book" + } + } + } + } + } + } + } + }, + "/greeter2/books/{author}": { + "get": { + "tags": [ + "book-repository" + ], + "operationId": "findByAuthor_3", + "parameters": [ + { + "name": "author", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Book" + } + } + } + } + } + } + } + }, + "/test/greeter/greeter2/books": { + "get": { + "tags": [ + "book-repository" + ], + "operationId": "findAll_4", + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Book" + } + } + }, + "application/xml": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Book" + } + } + }, + "text/plain": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Book" + } + } + } + } + } + } + } + }, + "/test/greeter/greeter2/books/{author}": { + "get": { + "tags": [ + "book-repository" + ], + "operationId": "findByAuthor_4", + "parameters": [ + { + "name": "author", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Book" + } + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "Book": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "title": { + "type": "string" + }, + "author": { + "type": "string" + } + } + } + } + } +} diff --git a/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app90.json b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app90.json new file mode 100644 index 000000000..1197cd09e --- /dev/null +++ b/springdoc-openapi-starter-webflux-api/src/test/resources/results/3.1.0/app90.json @@ -0,0 +1,591 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "", + "description": "Generated server url" + } + ], + "paths": { + "/foo": { + "get": { + "operationId": "hello", + "parameters": [ + { + "name": "key1", + "in": "query", + "description": "My key1 description", + "schema": { + "type": "string" + } + }, + { + "name": "key2", + "in": "query", + "description": "My key2 description", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "This is normal response description" + }, + "404": { + "description": "This is another response description" + } + } + } + }, + "/books": { + "get": { + "tags": [ + "book" + ], + "operationId": "findAll", + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Book" + } + } + }, + "application/xml": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Book" + } + } + }, + "text/plain": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Book" + } + } + } + } + } + } + } + }, + "/books/{author}": { + "get": { + "tags": [ + "book", + "book" + ], + "operationId": "findByAuthor", + "parameters": [ + { + "name": "author", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Book" + } + } + } + } + } + } + } + }, + "/books/nest": { + "get": { + "tags": [ + "book" + ], + "operationId": "findAll_1", + "responses": { + "200": { + "description": "OK", + "content": { + "application/xml": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Book" + } + } + }, + "text/plain": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Book" + } + } + } + } + } + } + } + }, + "/books/nest/{author}": { + "get": { + "tags": [ + "book" + ], + "operationId": "findByAuthor_1", + "parameters": [ + { + "name": "author", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Book" + } + } + } + } + } + } + } + }, + "/greeter/greeter2/books": { + "get": { + "tags": [ + "book" + ], + "operationId": "findAll_2", + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Book" + } + } + }, + "application/xml": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Book" + } + } + } + } + } + } + } + }, + "/test/greeter/greeter2/books": { + "get": { + "tags": [ + "book" + ], + "operationId": "findAll_3", + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Book" + } + } + }, + "application/xml": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Book" + } + } + }, + "text/plain": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Book" + } + } + } + } + } + } + } + }, + "/test/greeter/greeter2/books/{author}": { + "get": { + "tags": [ + "book" + ], + "operationId": "findByAuthor_2", + "parameters": [ + { + "name": "author", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Book" + } + } + } + } + } + } + } + }, + "/employees/{id}": { + "get": { + "tags": [ + "MyEmployee" + ], + "summary": "Find purchase order by ID", + "operationId": "findEmployeeById", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "Employee Id", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "successful operation", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/Employee" + } + } + } + }, + "400": { + "description": "Invalid Employee ID supplied" + }, + "404": { + "description": "Employee not found" + } + } + } + }, + "/createPosition": { + "post": { + "tags": [ + "positions" + ], + "description": "Save position", + "operationId": "save", + "requestBody": { + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/Position" + } + } + } + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Position" + } + } + } + } + } + } + }, + "/deletePosition/{id}": { + "delete": { + "tags": [ + "positions" + ], + "description": "Delete By Id", + "operationId": "deleteBy", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": {} + } + } + } + }, + "/getAllPositions": { + "get": { + "tags": [ + "positions" + ], + "description": "Get all positions", + "operationId": "findAll_4", + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Position" + } + } + } + } + } + } + } + }, + "/getPosition/{id}": { + "get": { + "tags": [ + "positions" + ], + "description": "Find all", + "operationId": "findById", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/stream+json": { + "schema": { + "$ref": "#/components/schemas/Position" + } + } + } + } + } + } + }, + "/echo": { + "post": { + "tags": [ + "quotes" + ], + "operationId": "echo", + "requestBody": { + "content": { + "text/plain": { + "schema": { + "type": "string" + } + }, + "application/json": { + "schema": { + "type": "string" + } + } + } + }, + "responses": { + "200": { + "description": "OK", + "content": { + "text/plain": { + "schema": { + "type": "string" + } + }, + "application/json": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/hello": { + "get": { + "tags": [ + "quotes" + ], + "operationId": "hello_1", + "responses": { + "200": { + "description": "OK" + } + } + } + }, + "/quotes": { + "get": { + "tags": [ + "quotes" + ], + "operationId": "fetchQuotes", + "parameters": [ + { + "name": "size", + "in": "query", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Quote" + } + } + }, + "application/stream+json": { + "schema": { + "$ref": "#/components/schemas/Quote" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "Book": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "title": { + "type": "string" + }, + "author": { + "type": "string" + } + } + }, + "Employee": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "name": { + "type": "string" + } + } + }, + "Position": { + "required": [ + "createdAt", + "positionName" + ], + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "positionName": { + "maxLength": 140, + "minLength": 0, + "type": "string" + }, + "description": { + "type": "string" + }, + "createdAt": { + "type": "string", + "format": "date-time" + } + } + }, + "Quote": { + "type": "object", + "properties": { + "ticker": { + "type": "string" + }, + "price": { + "type": "number" + }, + "instant": { + "type": "string", + "format": "date-time" + } + } + } + } + } +} diff --git a/springdoc-openapi-starter-webflux-ui/pom.xml b/springdoc-openapi-starter-webflux-ui/pom.xml index 2d4b328b3..1893687d5 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.1 + 2.8.2 springdoc-openapi-starter-webflux-ui diff --git a/springdoc-openapi-starter-webflux-ui/src/test/java/test/org/springdoc/ui/app14/HelloController.java b/springdoc-openapi-starter-webflux-ui/src/test/java/test/org/springdoc/ui/app14/HelloController.java index 0720d7cc1..899df5d01 100644 --- a/springdoc-openapi-starter-webflux-ui/src/test/java/test/org/springdoc/ui/app14/HelloController.java +++ b/springdoc-openapi-starter-webflux-ui/src/test/java/test/org/springdoc/ui/app14/HelloController.java @@ -39,7 +39,7 @@ public void persons(@Valid @RequestParam @Size(min = 4, max = 6) String name) { public GroupedOpenApi userOpenApi() { return GroupedOpenApi.builder() .group("users") - .packagesToScan("test.org.springdoc.api.app145") + .packagesToScan("test.org.springdoc.api.v30.app145") .build(); } } diff --git a/springdoc-openapi-starter-webflux-ui/src/test/java/test/org/springdoc/ui/app16/HelloController.java b/springdoc-openapi-starter-webflux-ui/src/test/java/test/org/springdoc/ui/app16/HelloController.java index a397c47d5..ccbdc8d78 100644 --- a/springdoc-openapi-starter-webflux-ui/src/test/java/test/org/springdoc/ui/app16/HelloController.java +++ b/springdoc-openapi-starter-webflux-ui/src/test/java/test/org/springdoc/ui/app16/HelloController.java @@ -39,7 +39,7 @@ public void persons(@Valid @RequestParam @Size(min = 4, max = 6) String name) { public GroupedOpenApi userOpenApi() { return GroupedOpenApi.builder() .group("users") - .packagesToScan("test.org.springdoc.api.app145") + .packagesToScan("test.org.springdoc.api.v30.app145") .build(); } } 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 5f23af5e7..189643268 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 @@ -41,7 +41,7 @@ @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, properties = { "management.endpoints.web.exposure.include=*", "springdoc.use-management-port=true", - "management.server.port=9284", + "management.server.port=9295", "management.server.base-path=/test", "management.endpoints.web.base-path=/application" }) class SpringDocApp16Test extends AbstractSpringDocActuatorTest { diff --git a/springdoc-openapi-starter-webflux-ui/src/test/java/test/org/springdoc/ui/app18/HelloController.java b/springdoc-openapi-starter-webflux-ui/src/test/java/test/org/springdoc/ui/app18/HelloController.java index 875c7ddee..49d4058e7 100644 --- a/springdoc-openapi-starter-webflux-ui/src/test/java/test/org/springdoc/ui/app18/HelloController.java +++ b/springdoc-openapi-starter-webflux-ui/src/test/java/test/org/springdoc/ui/app18/HelloController.java @@ -39,7 +39,7 @@ public void persons(@Valid @RequestParam @Size(min = 4, max = 6) String name) { public GroupedOpenApi userOpenApi() { return GroupedOpenApi.builder() .group("users") - .packagesToScan("test.org.springdoc.api.app145") + .packagesToScan("test.org.springdoc.api.v30.app145") .build(); } } diff --git a/springdoc-openapi-starter-webflux-ui/src/test/java/test/org/springdoc/ui/app19/HelloController.java b/springdoc-openapi-starter-webflux-ui/src/test/java/test/org/springdoc/ui/app19/HelloController.java index f49f7800b..87c214d44 100644 --- a/springdoc-openapi-starter-webflux-ui/src/test/java/test/org/springdoc/ui/app19/HelloController.java +++ b/springdoc-openapi-starter-webflux-ui/src/test/java/test/org/springdoc/ui/app19/HelloController.java @@ -39,7 +39,7 @@ public void persons(@Valid @RequestParam @Size(min = 4, max = 6) String name) { public GroupedOpenApi userOpenApi() { return GroupedOpenApi.builder() .group("users") - .packagesToScan("test.org.springdoc.api.app145") + .packagesToScan("test.org.springdoc.api.v30.app145") .build(); } } 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 99b357cfe..7de5abf41 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:9284/test/application/webjars/swagger-ui/oauth2-redirect.html", + "oauth2RedirectUrl": "http://localhost:9295/test/application/webjars/swagger-ui/oauth2-redirect.html", "urls": [ { "url": "/test/application/openapi/users", diff --git a/springdoc-openapi-starter-webmvc-api/pom.xml b/springdoc-openapi-starter-webmvc-api/pom.xml index 4242bdc79..ba30771db 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.1 + 2.8.2 springdoc-openapi-starter-webmvc-api diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/AbstractSpringDocTest.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/AbstractSpringDocTest.java new file mode 100644 index 000000000..43b5c977e --- /dev/null +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/AbstractSpringDocTest.java @@ -0,0 +1,55 @@ +/* + * + * * + * * * + * * * * + * * * * * 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; + +import org.junit.jupiter.api.Test; +import org.springdoc.core.utils.Constants; +import test.org.springdoc.api.AbstractCommonTest; + +import org.springframework.boot.test.context.SpringBootTest; +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; + +@SpringBootTest +public abstract class AbstractSpringDocTest extends AbstractCommonTest { + + public static String className; + + @Test + protected void testApp() throws Exception { + className = getClass().getSimpleName(); + String testNumber = className.replaceAll("[^0-9]", ""); + MvcResult mockMvcResult = mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL)).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 + ".json"); + assertEquals(expected, result, true); + } +} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/AbstractSpringDocV31Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/AbstractSpringDocV31Test.java deleted file mode 100644 index 1c3f0ffca..000000000 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/AbstractSpringDocV31Test.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * - * * - * * * - * * * * - * * * * * 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; - -import org.junit.jupiter.api.Test; -import org.springdoc.core.utils.Constants; -import test.org.springdoc.api.AbstractCommonTest; - -import org.springframework.boot.test.context.SpringBootTest; -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; - -@SpringBootTest -public abstract class AbstractSpringDocV31Test extends AbstractCommonTest { - - public static String className; - - @Test - protected void testApp() throws Exception { - className = getClass().getSimpleName(); - String testNumber = className.replaceAll("[^0-9]", ""); - MvcResult mockMvcResult = mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL)).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 + ".json"); - assertEquals(expected, result, true); - } -} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app1/SpringDocApp1Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app1/SpringDocApp1Test.java index cfaf5d013..f7ae35969 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app1/SpringDocApp1Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app1/SpringDocApp1Test.java @@ -29,14 +29,14 @@ import io.swagger.v3.oas.models.info.Info; import io.swagger.v3.oas.models.info.License; import io.swagger.v3.oas.models.security.SecurityScheme; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.annotation.Bean; import org.springframework.test.context.TestPropertySource; @TestPropertySource(properties = { "springdoc.default-produces-media-type=application/json", "prop.toto=tea" }) -public class SpringDocApp1Test extends AbstractSpringDocV31Test { +public class SpringDocApp1Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp { diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app10/SpringDocApp10Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app10/SpringDocApp10Test.java index af96adf03..0d0384cc5 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app10/SpringDocApp10Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app10/SpringDocApp10Test.java @@ -18,11 +18,11 @@ package test.org.springdoc.api.v31.app10; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; -public class SpringDocApp10Test extends AbstractSpringDocV31Test { +public class SpringDocApp10Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp { diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app100/SpringDocApp100Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app100/SpringDocApp100Test.java index eee8650ee..f3e68d3aa 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app100/SpringDocApp100Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app100/SpringDocApp100Test.java @@ -25,11 +25,11 @@ package test.org.springdoc.api.v31.app100; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; -public class SpringDocApp100Test extends AbstractSpringDocV31Test { +public class SpringDocApp100Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app101/SpringDocApp101Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app101/SpringDocApp101Test.java index f66477825..28d945f69 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app101/SpringDocApp101Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app101/SpringDocApp101Test.java @@ -25,13 +25,13 @@ package test.org.springdoc.api.v31.app101; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.test.context.ActiveProfiles; @ActiveProfiles("101") -public class SpringDocApp101Test extends AbstractSpringDocV31Test { +public class SpringDocApp101Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app102/SpringDocApp102Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app102/SpringDocApp102Test.java index 56ee20aec..e94f102b7 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app102/SpringDocApp102Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app102/SpringDocApp102Test.java @@ -24,11 +24,11 @@ package test.org.springdoc.api.v31.app102; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; -public class SpringDocApp102Test extends AbstractSpringDocV31Test { +public class SpringDocApp102Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} } diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app103/SpringDocApp103Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app103/SpringDocApp103Test.java index a3db241ca..265852f70 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app103/SpringDocApp103Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app103/SpringDocApp103Test.java @@ -24,11 +24,11 @@ package test.org.springdoc.api.v31.app103; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; -public class SpringDocApp103Test extends AbstractSpringDocV31Test { +public class SpringDocApp103Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} } diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app104/SpringDocApp104Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app104/SpringDocApp104Test.java index 27119691b..37d8e669e 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app104/SpringDocApp104Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app104/SpringDocApp104Test.java @@ -24,11 +24,11 @@ package test.org.springdoc.api.v31.app104; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; -public class SpringDocApp104Test extends AbstractSpringDocV31Test { +public class SpringDocApp104Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} } diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app105/SpringDocApp105Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app105/SpringDocApp105Test.java index acfbfd77a..b68e94a80 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app105/SpringDocApp105Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app105/SpringDocApp105Test.java @@ -31,7 +31,7 @@ import io.swagger.v3.oas.models.security.SecurityScheme; import org.junit.jupiter.api.Test; import org.springdoc.core.utils.Constants; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.annotation.Bean; @@ -55,7 +55,7 @@ "springdoc.group-configs[3].paths-to-exclude=/v1/users", "springdoc.group-configs[3].packages-to-scan=test.org.springdoc.api.v31.app105.api.user,test.org.springdoc.api.v31.app105.api.store", }) -public class SpringDocApp105Test extends AbstractSpringDocV31Test { +public class SpringDocApp105Test extends AbstractSpringDocTest { public static String className; diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app106/SpringDocApp106Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app106/SpringDocApp106Test.java index 9ede8356f..e10d11f8b 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app106/SpringDocApp106Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app106/SpringDocApp106Test.java @@ -24,11 +24,11 @@ package test.org.springdoc.api.v31.app106; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; -public class SpringDocApp106Test extends AbstractSpringDocV31Test { +public class SpringDocApp106Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} } diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app107/SpringDocApp107Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app107/SpringDocApp107Test.java index 0b5d086da..c9fb54029 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app107/SpringDocApp107Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app107/SpringDocApp107Test.java @@ -24,11 +24,11 @@ package test.org.springdoc.api.v31.app107; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; -public class SpringDocApp107Test extends AbstractSpringDocV31Test { +public class SpringDocApp107Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} } diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app108/SpringDocApp108Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app108/SpringDocApp108Test.java index 1b8b43bb3..93ee2717a 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app108/SpringDocApp108Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app108/SpringDocApp108Test.java @@ -24,11 +24,11 @@ package test.org.springdoc.api.v31.app108; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; -public class SpringDocApp108Test extends AbstractSpringDocV31Test { +public class SpringDocApp108Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} } diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app109/SpringDocApp109Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app109/SpringDocApp109Test.java index ff6cb37f8..5079c7443 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app109/SpringDocApp109Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app109/SpringDocApp109Test.java @@ -24,11 +24,11 @@ package test.org.springdoc.api.v31.app109; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; -public class SpringDocApp109Test extends AbstractSpringDocV31Test { +public class SpringDocApp109Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} } diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app11/SpringDocApp11Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app11/SpringDocApp11Test.java index 46a2e117f..d0e22275c 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app11/SpringDocApp11Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app11/SpringDocApp11Test.java @@ -24,11 +24,11 @@ package test.org.springdoc.api.v31.app11; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; -public class SpringDocApp11Test extends AbstractSpringDocV31Test { +public class SpringDocApp11Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app110/SpringDocApp110Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app110/SpringDocApp110Test.java index 06e97ac27..d0639c8d1 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app110/SpringDocApp110Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app110/SpringDocApp110Test.java @@ -27,7 +27,7 @@ import io.swagger.v3.oas.models.OpenAPI; import io.swagger.v3.oas.models.info.Info; import io.swagger.v3.oas.models.info.License; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.autoconfigure.SpringBootApplication; @@ -37,7 +37,7 @@ @TestPropertySource(properties = { "application-description=description", "application-version=v1" }) -public class SpringDocApp110Test extends AbstractSpringDocV31Test { +public class SpringDocApp110Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp { diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app111/SpringDocApp111Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app111/SpringDocApp111Test.java index baa3d692b..f8b8954ba 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app111/SpringDocApp111Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app111/SpringDocApp111Test.java @@ -27,7 +27,7 @@ import io.swagger.v3.oas.models.OpenAPI; import io.swagger.v3.oas.models.info.Info; import io.swagger.v3.oas.models.info.License; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.autoconfigure.SpringBootApplication; @@ -37,7 +37,7 @@ @TestPropertySource(properties = { "application-description=description", "application-version=v1" }) -public class SpringDocApp111Test extends AbstractSpringDocV31Test { +public class SpringDocApp111Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp { diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app112/SpringDocApp112Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app112/SpringDocApp112Test.java index 91f260b22..308852152 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app112/SpringDocApp112Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app112/SpringDocApp112Test.java @@ -27,7 +27,7 @@ import io.swagger.v3.oas.models.OpenAPI; import io.swagger.v3.oas.models.info.Info; import io.swagger.v3.oas.models.info.License; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.autoconfigure.SpringBootApplication; @@ -37,7 +37,7 @@ @TestPropertySource(properties = { "application-description=description", "application-version=v1" }) -public class SpringDocApp112Test extends AbstractSpringDocV31Test { +public class SpringDocApp112Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp { diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app113/SpringDocApp113Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app113/SpringDocApp113Test.java index d003a01c4..1edb293f2 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app113/SpringDocApp113Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app113/SpringDocApp113Test.java @@ -24,12 +24,12 @@ package test.org.springdoc.api.v31.app113; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; -public class SpringDocApp113Test extends AbstractSpringDocV31Test { +public class SpringDocApp113Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app114/SpringDocApp114Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app114/SpringDocApp114Test.java index 603fdb1c3..e283f9c88 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app114/SpringDocApp114Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app114/SpringDocApp114Test.java @@ -29,12 +29,12 @@ import javax.money.MonetaryAmount; import org.springdoc.core.utils.SpringDocUtils; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; -public class SpringDocApp114Test extends AbstractSpringDocV31Test { +public class SpringDocApp114Test extends AbstractSpringDocTest { static { SpringDocUtils.getConfig() diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app115/JavaTimeOperationCustomizer.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app115/JavaTimeOperationCustomizer.java index f59f723e1..097d70d76 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app115/JavaTimeOperationCustomizer.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app115/JavaTimeOperationCustomizer.java @@ -26,6 +26,7 @@ import java.time.Duration; import java.util.Map; +import java.util.Set; import io.swagger.v3.oas.models.Operation; import io.swagger.v3.oas.models.media.Content; @@ -47,7 +48,7 @@ public Operation customize(Operation operation, HandlerMethod handlerMethod) { if (content.containsKey(MediaType.APPLICATION_JSON_VALUE)) { Schema schema = content.get(MediaType.APPLICATION_JSON_VALUE).getSchema(); schema.getProperties().clear(); - schema.setType("string"); + schema.types(Set.of("string")); } } } diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app115/SpringDocApp115Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app115/SpringDocApp115Test.java index 6251c0888..d399eb272 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app115/SpringDocApp115Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app115/SpringDocApp115Test.java @@ -24,12 +24,12 @@ package test.org.springdoc.api.v31.app115; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; -public class SpringDocApp115Test extends AbstractSpringDocV31Test { +public class SpringDocApp115Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app116/SpringDocApp116Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app116/SpringDocApp116Test.java index fd117917c..3c8d9cf4b 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app116/SpringDocApp116Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app116/SpringDocApp116Test.java @@ -24,12 +24,12 @@ package test.org.springdoc.api.v31.app116; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; -public class SpringDocApp116Test extends AbstractSpringDocV31Test { +public class SpringDocApp116Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app117/SpringDocApp117Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app117/SpringDocApp117Test.java index e7f39f1dd..f6eab3cfd 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app117/SpringDocApp117Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app117/SpringDocApp117Test.java @@ -24,12 +24,12 @@ package test.org.springdoc.api.v31.app117; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; -public class SpringDocApp117Test extends AbstractSpringDocV31Test { +public class SpringDocApp117Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app118/SpringDocApp118Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app118/SpringDocApp118Test.java index 615340fb6..55b3af8e9 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app118/SpringDocApp118Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app118/SpringDocApp118Test.java @@ -24,12 +24,12 @@ package test.org.springdoc.api.v31.app118; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; -public class SpringDocApp118Test extends AbstractSpringDocV31Test { +public class SpringDocApp118Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app119/SpringDocApp119Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app119/SpringDocApp119Test.java index 622d03bb5..ca309ce1b 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app119/SpringDocApp119Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app119/SpringDocApp119Test.java @@ -24,12 +24,12 @@ package test.org.springdoc.api.v31.app119; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; -public class SpringDocApp119Test extends AbstractSpringDocV31Test { +public class SpringDocApp119Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app12/SpringDocApp12Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app12/SpringDocApp12Test.java index 55c5a37d3..72a64d4a0 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app12/SpringDocApp12Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app12/SpringDocApp12Test.java @@ -24,11 +24,11 @@ package test.org.springdoc.api.v31.app12; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; -public class SpringDocApp12Test extends AbstractSpringDocV31Test { +public class SpringDocApp12Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app120/SpringDocApp120Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app120/SpringDocApp120Test.java index e6c03fbf3..ec685cb1c 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app120/SpringDocApp120Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app120/SpringDocApp120Test.java @@ -23,7 +23,7 @@ */ package test.org.springdoc.api.v31.app120; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; @@ -31,7 +31,7 @@ /** * Tests Spring meta-annotations as method parameters */ -public class SpringDocApp120Test extends AbstractSpringDocV31Test { +public class SpringDocApp120Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app121/SpringDocApp121Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app121/SpringDocApp121Test.java index 5feb19927..679c0bf9f 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app121/SpringDocApp121Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app121/SpringDocApp121Test.java @@ -23,7 +23,7 @@ */ package test.org.springdoc.api.v31.app121; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; @@ -31,7 +31,7 @@ /** * Tests Spring meta-annotations as method parameters */ -public class SpringDocApp121Test extends AbstractSpringDocV31Test { +public class SpringDocApp121Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app122/SpringDocApp122Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app122/SpringDocApp122Test.java index df9dfd8d8..4559e8d3f 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app122/SpringDocApp122Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app122/SpringDocApp122Test.java @@ -23,7 +23,7 @@ */ package test.org.springdoc.api.v31.app122; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; @@ -31,7 +31,7 @@ /** * Tests Spring meta-annotations as method parameters */ -public class SpringDocApp122Test extends AbstractSpringDocV31Test { +public class SpringDocApp122Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app123/SpringDocApp123Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app123/SpringDocApp123Test.java index db3e495d7..b54b9e1a1 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app123/SpringDocApp123Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app123/SpringDocApp123Test.java @@ -23,7 +23,7 @@ */ package test.org.springdoc.api.v31.app123; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; @@ -31,7 +31,7 @@ /** * Tests Spring meta-annotations as method parameters */ -public class SpringDocApp123Test extends AbstractSpringDocV31Test { +public class SpringDocApp123Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app124/SpringDocApp124Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app124/SpringDocApp124Test.java index b00a4a020..ae548662b 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app124/SpringDocApp124Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app124/SpringDocApp124Test.java @@ -23,7 +23,7 @@ */ package test.org.springdoc.api.v31.app124; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; @@ -31,7 +31,7 @@ /** * Tests Spring meta-annotations as method parameters */ -public class SpringDocApp124Test extends AbstractSpringDocV31Test { +public class SpringDocApp124Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app126/SpringDocApp126Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app126/SpringDocApp126Test.java index 2158ff8d2..ad0b2d6aa 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app126/SpringDocApp126Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app126/SpringDocApp126Test.java @@ -31,7 +31,7 @@ import io.swagger.v3.core.converter.ResolvedSchema; import io.swagger.v3.oas.models.responses.ApiResponse; import org.springdoc.core.customizers.OpenApiCustomizer; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.annotation.Bean; @@ -40,7 +40,7 @@ /** * Tests Spring meta-annotations as method parameters */ -public class SpringDocApp126Test extends AbstractSpringDocV31Test { +public class SpringDocApp126Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp { diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app127/SpringDocApp127Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app127/SpringDocApp127Test.java index cd6249b1b..27626d005 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app127/SpringDocApp127Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app127/SpringDocApp127Test.java @@ -26,7 +26,7 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.springdoc.core.utils.Constants; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.test.web.servlet.MvcResult; @@ -38,7 +38,7 @@ /** * Tests Spring meta-annotations as method parameters */ -public class SpringDocApp127Test extends AbstractSpringDocV31Test { +public class SpringDocApp127Test extends AbstractSpringDocTest { @Test protected void testApp() throws Exception { diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app129/SpringDocApp129Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app129/SpringDocApp129Test.java index d7664659a..9885ca6c3 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app129/SpringDocApp129Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app129/SpringDocApp129Test.java @@ -23,7 +23,7 @@ */ package test.org.springdoc.api.v31.app129; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; @@ -31,7 +31,7 @@ /** * Tests Spring meta-annotations as method parameters */ -public class SpringDocApp129Test extends AbstractSpringDocV31Test { +public class SpringDocApp129Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app13/SpringDocApp13Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app13/SpringDocApp13Test.java index 8b206d4a3..5dc816b23 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app13/SpringDocApp13Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app13/SpringDocApp13Test.java @@ -24,11 +24,11 @@ package test.org.springdoc.api.v31.app13; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; -public class SpringDocApp13Test extends AbstractSpringDocV31Test { +public class SpringDocApp13Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app130/SpringDocApp130Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app130/SpringDocApp130Test.java index 90baa73bd..dfff87af8 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app130/SpringDocApp130Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app130/SpringDocApp130Test.java @@ -23,7 +23,7 @@ */ package test.org.springdoc.api.v31.app130; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; @@ -31,7 +31,7 @@ /** * Tests Spring meta-annotations as method parameters */ -public class SpringDocApp130Test extends AbstractSpringDocV31Test { +public class SpringDocApp130Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app131/SpringDocApp131Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app131/SpringDocApp131Test.java index 17bd6a8d2..bb2e613c1 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app131/SpringDocApp131Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app131/SpringDocApp131Test.java @@ -23,7 +23,7 @@ */ package test.org.springdoc.api.v31.app131; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; @@ -31,7 +31,7 @@ /** * Tests Spring meta-annotations as method parameters */ -public class SpringDocApp131Test extends AbstractSpringDocV31Test { +public class SpringDocApp131Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app132/SpringDocApp132Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app132/SpringDocApp132Test.java index 18754ed00..e7f15ea43 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app132/SpringDocApp132Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app132/SpringDocApp132Test.java @@ -23,7 +23,7 @@ */ package test.org.springdoc.api.v31.app132; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; @@ -31,7 +31,7 @@ /** * Tests Spring meta-annotations as method parameters */ -public class SpringDocApp132Test extends AbstractSpringDocV31Test { +public class SpringDocApp132Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app133/SpringDocApp133Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app133/SpringDocApp133Test.java index f9fcd29d5..c8e4f1cc0 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app133/SpringDocApp133Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app133/SpringDocApp133Test.java @@ -23,7 +23,7 @@ */ package test.org.springdoc.api.v31.app133; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; @@ -31,7 +31,7 @@ /** * Tests Spring meta-annotations as method parameters */ -public class SpringDocApp133Test extends AbstractSpringDocV31Test { +public class SpringDocApp133Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app134/SpringDocApp134Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app134/SpringDocApp134Test.java index 7db7de622..a741a014c 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app134/SpringDocApp134Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app134/SpringDocApp134Test.java @@ -25,7 +25,7 @@ import org.junit.jupiter.api.Test; import org.springdoc.core.utils.Constants; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; @@ -39,7 +39,7 @@ /** * Tests Spring meta-annotations as method parameters */ -public class SpringDocApp134Test extends AbstractSpringDocV31Test { +public class SpringDocApp134Test extends AbstractSpringDocTest { @Test protected void testApp() throws Exception { diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app135/SpringDocApp135Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app135/SpringDocApp135Test.java index e6b8e1bab..d680aa304 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app135/SpringDocApp135Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app135/SpringDocApp135Test.java @@ -23,7 +23,7 @@ */ package test.org.springdoc.api.v31.app135; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; @@ -31,7 +31,7 @@ /** * Tests Spring meta-annotations as method parameters */ -public class SpringDocApp135Test extends AbstractSpringDocV31Test { +public class SpringDocApp135Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app137/SpringDocApp137Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app137/SpringDocApp137Test.java index 00a8270ca..210f5fecc 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app137/SpringDocApp137Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app137/SpringDocApp137Test.java @@ -23,7 +23,7 @@ */ package test.org.springdoc.api.v31.app137; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.test.context.TestPropertySource; @@ -33,7 +33,7 @@ * Tests Spring meta-annotations as method parameters */ @TestPropertySource(properties = { "test.server=http://test.toto.com", "test.desc=toto desc" }) -public class SpringDocApp137Test extends AbstractSpringDocV31Test { +public class SpringDocApp137Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app138/SpringDocApp138Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app138/SpringDocApp138Test.java index e5d7e456f..b625777ee 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app138/SpringDocApp138Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app138/SpringDocApp138Test.java @@ -37,7 +37,7 @@ import org.junit.jupiter.api.Test; import org.springdoc.core.providers.ObjectMapperProvider; import org.springdoc.core.utils.Constants; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.SpringBootApplication; @@ -55,7 +55,7 @@ * Tests Spring meta-annotations as method parameters */ @TestPropertySource(properties = "springdoc.writer-with-order-by-keys=true") -public class SpringDocApp138Test extends AbstractSpringDocV31Test { +public class SpringDocApp138Test extends AbstractSpringDocTest { @Autowired ObjectMapperProvider objectMapperProvider; diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app139/SpringDocApp139Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app139/SpringDocApp139Test.java index eb668d465..d2c46fef9 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app139/SpringDocApp139Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app139/SpringDocApp139Test.java @@ -23,7 +23,7 @@ */ package test.org.springdoc.api.v31.app139; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.test.context.TestPropertySource; @@ -33,7 +33,7 @@ * Tests Spring meta-annotations as method parameters */ @TestPropertySource(properties = { "test.name=text", "test.value=text", "test.default-value=default-text" }) -public class SpringDocApp139Test extends AbstractSpringDocV31Test { +public class SpringDocApp139Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app14/SpringDocApp14Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app14/SpringDocApp14Test.java index 103358ab9..71cc95987 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app14/SpringDocApp14Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app14/SpringDocApp14Test.java @@ -28,11 +28,11 @@ import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; -public class SpringDocApp14Test extends AbstractSpringDocV31Test { +public class SpringDocApp14Test extends AbstractSpringDocTest { private static Locale DEFAULT_LOCALE; diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app140/SpringDocApp140Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app140/SpringDocApp140Test.java index 50bc5b2e5..f14b164f8 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app140/SpringDocApp140Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app140/SpringDocApp140Test.java @@ -24,12 +24,12 @@ package test.org.springdoc.api.v31.app140; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; -public class SpringDocApp140Test extends AbstractSpringDocV31Test { +public class SpringDocApp140Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app141/SpringDocApp141Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app141/SpringDocApp141Test.java index 3ff28cc9f..5efba1c67 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app141/SpringDocApp141Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app141/SpringDocApp141Test.java @@ -23,7 +23,7 @@ */ package test.org.springdoc.api.v31.app141; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; @@ -31,7 +31,7 @@ /** * Tests Spring meta-annotations as method parameters */ -public class SpringDocApp141Test extends AbstractSpringDocV31Test { +public class SpringDocApp141Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app142/SpringDocApp142Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app142/SpringDocApp142Test.java index a97bd8032..a793b1c86 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app142/SpringDocApp142Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app142/SpringDocApp142Test.java @@ -24,12 +24,12 @@ package test.org.springdoc.api.v31.app142; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; -public class SpringDocApp142Test extends AbstractSpringDocV31Test { +public class SpringDocApp142Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app143/SpringDocApp143Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app143/SpringDocApp143Test.java index 615978187..c4b733b0a 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app143/SpringDocApp143Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app143/SpringDocApp143Test.java @@ -24,7 +24,7 @@ package test.org.springdoc.api.v31.app143; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.test.context.TestPropertySource; @@ -36,7 +36,7 @@ @TestPropertySource(properties = { "management.endpoints.enabled-by-default=true", "springdoc.show-actuator=true", "management.endpoints.web.exposure.exclude=functions" }) -public class SpringDocApp143Test extends AbstractSpringDocV31Test { +public class SpringDocApp143Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app149/SpringDocApp149Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app149/SpringDocApp149Test.java index 99089738f..89d398b04 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app149/SpringDocApp149Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app149/SpringDocApp149Test.java @@ -26,13 +26,13 @@ import org.junit.jupiter.api.BeforeAll; import org.springdoc.core.utils.SpringDocUtils; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.test.context.TestPropertySource; @TestPropertySource(properties = "springdoc.model-and-view-allowed=true") -public class SpringDocApp149Test extends AbstractSpringDocV31Test { +public class SpringDocApp149Test extends AbstractSpringDocTest { @BeforeAll public static void init() { diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app15/SpringDocApp15Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app15/SpringDocApp15Test.java index adc0c3bdb..2e7355723 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app15/SpringDocApp15Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app15/SpringDocApp15Test.java @@ -28,7 +28,7 @@ import io.swagger.v3.oas.annotations.info.Contact; import io.swagger.v3.oas.annotations.info.Info; import io.swagger.v3.oas.annotations.info.License; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.test.context.TestPropertySource; @@ -45,7 +45,7 @@ "springdoc.openapidefinition.info.contact.email=My contact email", "springdoc.openapidefinition.info.contact.url=My contact url" }) -public class SpringDocApp15Test extends AbstractSpringDocV31Test { +public class SpringDocApp15Test extends AbstractSpringDocTest { @SpringBootApplication @OpenAPIDefinition(info = @Info( diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app150/SpringDocApp150Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app150/SpringDocApp150Test.java index 4bf8db2dd..4d9b01f56 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app150/SpringDocApp150Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app150/SpringDocApp150Test.java @@ -25,14 +25,14 @@ package test.org.springdoc.api.v31.app150; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; /** * Tests Spring meta-annotations as method parameters */ -public class SpringDocApp150Test extends AbstractSpringDocV31Test { +public class SpringDocApp150Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app151/SpringDocApp151Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app151/SpringDocApp151Test.java index eebecf638..c39c30f26 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app151/SpringDocApp151Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app151/SpringDocApp151Test.java @@ -25,14 +25,14 @@ package test.org.springdoc.api.v31.app151; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; /** * Tests Spring meta-annotations as method parameters */ -public class SpringDocApp151Test extends AbstractSpringDocV31Test { +public class SpringDocApp151Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app152/SpringDocApp152Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app152/SpringDocApp152Test.java index 39f8701b3..52837ecbd 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app152/SpringDocApp152Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app152/SpringDocApp152Test.java @@ -25,14 +25,14 @@ package test.org.springdoc.api.v31.app152; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; /** * Tests Spring meta-annotations as method parameters */ -public class SpringDocApp152Test extends AbstractSpringDocV31Test { +public class SpringDocApp152Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app153/SpringDocApp153Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app153/SpringDocApp153Test.java index b1439c000..b855f41bc 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app153/SpringDocApp153Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app153/SpringDocApp153Test.java @@ -25,14 +25,14 @@ package test.org.springdoc.api.v31.app153; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; /** * Tests Spring meta-annotations as method parameters */ -public class SpringDocApp153Test extends AbstractSpringDocV31Test { +public class SpringDocApp153Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app154/SpringDocApp154Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app154/SpringDocApp154Test.java index aeae6dc9b..20e7cf26e 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app154/SpringDocApp154Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app154/SpringDocApp154Test.java @@ -25,14 +25,14 @@ package test.org.springdoc.api.v31.app154; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; /** * Tests Spring meta-annotations as method parameters */ -public class SpringDocApp154Test extends AbstractSpringDocV31Test { +public class SpringDocApp154Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app155/SpringDocApp155Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app155/SpringDocApp155Test.java index 89633882f..27116df31 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app155/SpringDocApp155Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app155/SpringDocApp155Test.java @@ -25,14 +25,14 @@ package test.org.springdoc.api.v31.app155; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; /** * Tests Spring meta-annotations as method parameters */ -public class SpringDocApp155Test extends AbstractSpringDocV31Test { +public class SpringDocApp155Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app156/SpringDocApp156Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app156/SpringDocApp156Test.java index 56d609527..54f636e89 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app156/SpringDocApp156Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app156/SpringDocApp156Test.java @@ -25,14 +25,14 @@ package test.org.springdoc.api.v31.app156; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; /** * Tests Spring meta-annotations as method parameters */ -public class SpringDocApp156Test extends AbstractSpringDocV31Test { +public class SpringDocApp156Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app157/SpringDocApp157Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app157/SpringDocApp157Test.java index 7d8c447ea..9930508ab 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app157/SpringDocApp157Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app157/SpringDocApp157Test.java @@ -30,7 +30,7 @@ import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.Test; import org.springdoc.core.utils.Constants; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.SpringBootApplication; @@ -47,7 +47,7 @@ * the type is enclosed in an ignored wrapper. We test this by setting up a model converter which * adds "stringy" to the "required" property of a schema's parent, when the sub schema is a String. */ -public class SpringDocApp157Test extends AbstractSpringDocV31Test { +public class SpringDocApp157Test extends AbstractSpringDocTest { /** * The Converters. diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app158/SpringDocApp158Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app158/SpringDocApp158Test.java index 547700c61..9711707c1 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app158/SpringDocApp158Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app158/SpringDocApp158Test.java @@ -24,11 +24,11 @@ package test.org.springdoc.api.v31.app158; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; -public class SpringDocApp158Test extends AbstractSpringDocV31Test { +public class SpringDocApp158Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app159/SpringDocApp159Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app159/SpringDocApp159Test.java index 21d4861b5..fd6e297ba 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app159/SpringDocApp159Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app159/SpringDocApp159Test.java @@ -24,11 +24,11 @@ package test.org.springdoc.api.v31.app159; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; -public class SpringDocApp159Test extends AbstractSpringDocV31Test { +public class SpringDocApp159Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app16/SpringDocApp16Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app16/SpringDocApp16Test.java index 60b5fed17..73f17a928 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app16/SpringDocApp16Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app16/SpringDocApp16Test.java @@ -26,7 +26,7 @@ import org.junit.jupiter.api.Test; import org.springdoc.core.utils.Constants; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.SpringBootConfiguration; import org.springframework.test.context.TestPropertySource; @@ -35,7 +35,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; @TestPropertySource(properties = "springdoc.api-docs.enabled=false") -public class SpringDocApp16Test extends AbstractSpringDocV31Test { +public class SpringDocApp16Test extends AbstractSpringDocTest { @Test protected void testApp() throws Exception { diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app160/SpringDocApp160Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app160/SpringDocApp160Test.java index 871b7feb4..acf906ba7 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app160/SpringDocApp160Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app160/SpringDocApp160Test.java @@ -26,7 +26,7 @@ import org.junit.jupiter.api.Test; import org.springdoc.core.utils.Constants; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.test.context.TestPropertySource; @@ -38,7 +38,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; @TestPropertySource(properties = "springdoc.api-docs.resolve-schema-properties=true") -public class SpringDocApp160Test extends AbstractSpringDocV31Test { +public class SpringDocApp160Test extends AbstractSpringDocTest { @Test void testApp2() throws Exception { diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app161/SpringDocApp161Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app161/SpringDocApp161Test.java index 3904634cb..044e9e091 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app161/SpringDocApp161Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app161/SpringDocApp161Test.java @@ -27,11 +27,11 @@ import java.util.Locale; import org.junit.jupiter.api.Test; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; -public class SpringDocApp161Test extends AbstractSpringDocV31Test { +public class SpringDocApp161Test extends AbstractSpringDocTest { @Test protected void testApp() throws Exception { diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app162/SpringDocApp162Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app162/SpringDocApp162Test.java index 119b2a5b8..b03a53ec5 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app162/SpringDocApp162Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app162/SpringDocApp162Test.java @@ -25,11 +25,11 @@ package test.org.springdoc.api.v31.app162; import org.junit.jupiter.api.Test; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; -public class SpringDocApp162Test extends AbstractSpringDocV31Test { +public class SpringDocApp162Test extends AbstractSpringDocTest { @Test void testApp2() throws Exception { diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app163/SpringDocApp163Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app163/SpringDocApp163Test.java index 4a5c5ebf7..8592121e3 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app163/SpringDocApp163Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app163/SpringDocApp163Test.java @@ -24,12 +24,12 @@ package test.org.springdoc.api.v31.app163; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.annotation.Import; -public class SpringDocApp163Test extends AbstractSpringDocV31Test { +public class SpringDocApp163Test extends AbstractSpringDocTest { @SpringBootApplication @Import({ Examples.class, ExampleRegistrationCustomizer.class }) diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app164/SpringDocApp164Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app164/SpringDocApp164Test.java index b6854a913..59b1a57e5 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app164/SpringDocApp164Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app164/SpringDocApp164Test.java @@ -24,13 +24,13 @@ package test.org.springdoc.api.v31.app164; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.test.context.TestPropertySource; @TestPropertySource(properties = "springdoc.api-docs.resolve-schema-properties=true") -public class SpringDocApp164Test extends AbstractSpringDocV31Test { +public class SpringDocApp164Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp { diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app165/SpringDocApp165Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app165/SpringDocApp165Test.java index fbb6f7994..30f4827dd 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app165/SpringDocApp165Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app165/SpringDocApp165Test.java @@ -24,11 +24,11 @@ package test.org.springdoc.api.v31.app165; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; -public class SpringDocApp165Test extends AbstractSpringDocV31Test { +public class SpringDocApp165Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app166/SpringDocApp166Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app166/SpringDocApp166Test.java index 04d29b9d1..169fd2791 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app166/SpringDocApp166Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app166/SpringDocApp166Test.java @@ -24,7 +24,7 @@ package test.org.springdoc.api.v31.app166; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.test.context.TestPropertySource; @@ -34,7 +34,7 @@ * Exactly, that the local handler takes precedence over the global one * */ @TestPropertySource(properties = "springdoc.api-docs.resolve-schema-properties=true") -public class SpringDocApp166Test extends AbstractSpringDocV31Test { +public class SpringDocApp166Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp { diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app167/SpringDocApp167Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app167/SpringDocApp167Test.java index 6b9a882ce..1006e95fc 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app167/SpringDocApp167Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app167/SpringDocApp167Test.java @@ -24,14 +24,14 @@ package test.org.springdoc.api.v31.app167; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.test.context.TestPropertySource; @TestPropertySource(properties = "springdoc.disable-i18n=true") -public class SpringDocApp167Test extends AbstractSpringDocV31Test { +public class SpringDocApp167Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp { diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app168/SpringDocApp168Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app168/SpringDocApp168Test.java index bae10c3a3..04c6fc926 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app168/SpringDocApp168Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app168/SpringDocApp168Test.java @@ -30,14 +30,14 @@ import io.swagger.v3.core.converter.ModelConverters; import org.springdoc.core.converters.PolymorphicModelConverter; import org.springdoc.core.utils.Constants; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.test.context.TestPropertySource; @TestPropertySource(properties = Constants.SPRINGDOC_POLYMORPHIC_CONVERTER_ENABLED + "=false") -public class SpringDocApp168Test extends AbstractSpringDocV31Test { +public class SpringDocApp168Test extends AbstractSpringDocTest { static { Optional modelConverterOptional = diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app169/SpringDocApp169Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app169/SpringDocApp169Test.java index 26611564f..bda13ca64 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app169/SpringDocApp169Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app169/SpringDocApp169Test.java @@ -24,12 +24,12 @@ package test.org.springdoc.api.v31.app169; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; -public class SpringDocApp169Test extends AbstractSpringDocV31Test { +public class SpringDocApp169Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app17/SpringDocApp17Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app17/SpringDocApp17Test.java index 812978613..e5332b64c 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app17/SpringDocApp17Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app17/SpringDocApp17Test.java @@ -24,11 +24,11 @@ package test.org.springdoc.api.v31.app17; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; -public class SpringDocApp17Test extends AbstractSpringDocV31Test { +public class SpringDocApp17Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app170/SpringDocApp170Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app170/SpringDocApp170Test.java index 0e3900c98..c06f59f9b 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app170/SpringDocApp170Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app170/SpringDocApp170Test.java @@ -26,13 +26,13 @@ import org.junit.jupiter.api.Test; import org.springdoc.core.customizers.OpenApiCustomizer; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.annotation.Bean; -public class SpringDocApp170Test extends AbstractSpringDocV31Test { +public class SpringDocApp170Test extends AbstractSpringDocTest { @Test void testApp1() throws Exception { diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app171/SpringDocApp171Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app171/SpringDocApp171Test.java index e908519e9..6c2c4d17d 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app171/SpringDocApp171Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app171/SpringDocApp171Test.java @@ -29,7 +29,7 @@ import org.junit.jupiter.api.Test; import org.springdoc.core.customizers.OpenApiLocaleCustomizer; import org.springdoc.core.utils.Constants; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.SpringBootApplication; @@ -46,7 +46,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; @TestPropertySource(properties = Constants.SPRINGDOC_CACHE_DISABLED + "=false") -public class SpringDocApp171Test extends AbstractSpringDocV31Test { +public class SpringDocApp171Test extends AbstractSpringDocTest { @Test @Override diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app172/SpringDocApp172Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app172/SpringDocApp172Test.java index bfd701b29..b80f75f16 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app172/SpringDocApp172Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app172/SpringDocApp172Test.java @@ -29,7 +29,7 @@ import org.springdoc.core.customizers.OperationCustomizer; import org.springdoc.core.models.GroupedOpenApi; import org.springdoc.core.utils.Constants; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.annotation.Bean; @@ -43,7 +43,7 @@ @TestPropertySource(properties = { "springdoc.show-actuator=true", "management.endpoints.enabled-by-default=true", "management.endpoints.web.exposure.include = tenant" }) -public class SpringDocApp172Test extends AbstractSpringDocV31Test { +public class SpringDocApp172Test extends AbstractSpringDocTest { @Test protected void testApp() throws Exception { diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app173/SpringDocApp173Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app173/SpringDocApp173Test.java index a0ee8321e..6724b015a 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app173/SpringDocApp173Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app173/SpringDocApp173Test.java @@ -31,7 +31,7 @@ import io.swagger.v3.oas.models.info.Info; import org.junit.jupiter.api.Test; import org.springdoc.core.utils.Constants; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.annotation.Bean; @@ -44,7 +44,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; -public class SpringDocApp173Test extends AbstractSpringDocV31Test { +public class SpringDocApp173Test extends AbstractSpringDocTest { @Test @Override diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app177/SpringDocApp177Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app177/SpringDocApp177Test.java index 133adbc80..abc05f695 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app177/SpringDocApp177Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app177/SpringDocApp177Test.java @@ -26,7 +26,7 @@ import org.junit.jupiter.api.Test; import org.springdoc.core.utils.Constants; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; @@ -36,7 +36,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; -class SpringDocApp177Test extends AbstractSpringDocV31Test { +class SpringDocApp177Test extends AbstractSpringDocTest { @Test void testFilterOnlyPicksUpMatchedMethods() throws Exception { diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app178/SpringDocApp178Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app178/SpringDocApp178Test.java index 33f5e7ea7..dd26be040 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app178/SpringDocApp178Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app178/SpringDocApp178Test.java @@ -26,7 +26,7 @@ import org.junit.jupiter.api.Test; import org.springdoc.core.utils.Constants; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; @@ -36,7 +36,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; -class SpringDocApp178Test extends AbstractSpringDocV31Test { +class SpringDocApp178Test extends AbstractSpringDocTest { @Test void testFilterOnlyPicksUpMatchedMethods() throws Exception { diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app179/SpringDocApp179Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app179/SpringDocApp179Test.java index 35e13f330..550760710 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app179/SpringDocApp179Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app179/SpringDocApp179Test.java @@ -24,11 +24,11 @@ package test.org.springdoc.api.v31.app179; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; -public class SpringDocApp179Test extends AbstractSpringDocV31Test { +public class SpringDocApp179Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app18/SpringDocApp18Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app18/SpringDocApp18Test.java index f0dff7717..9baa2e0f7 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app18/SpringDocApp18Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app18/SpringDocApp18Test.java @@ -24,13 +24,13 @@ package test.org.springdoc.api.v31.app18; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.test.context.TestPropertySource; @TestPropertySource(properties = "springdoc.pre-loading-enabled=true") -public class SpringDocApp18Test extends AbstractSpringDocV31Test { +public class SpringDocApp18Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app180/SpringDocApp180Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app180/SpringDocApp180Test.java index 7fbefa669..b90b21361 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app180/SpringDocApp180Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app180/SpringDocApp180Test.java @@ -24,11 +24,11 @@ package test.org.springdoc.api.v31.app180; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; -class SpringDocApp180Test extends AbstractSpringDocV31Test { +class SpringDocApp180Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app181/SpringDocApp181Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app181/SpringDocApp181Test.java index 36dfa6d20..193eee4da 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app181/SpringDocApp181Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app181/SpringDocApp181Test.java @@ -25,14 +25,14 @@ package test.org.springdoc.api.v31.app181; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; /** * Tests Spring meta-annotations as method parameters */ -public class SpringDocApp181Test extends AbstractSpringDocV31Test { +public class SpringDocApp181Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app182/SpringDocApp182Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app182/SpringDocApp182Test.java index ebdcc964e..6263b9991 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app182/SpringDocApp182Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app182/SpringDocApp182Test.java @@ -24,14 +24,14 @@ package test.org.springdoc.api.v31.app182; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; /** * @author bnasslahsen */ -public class SpringDocApp182Test extends AbstractSpringDocV31Test { +public class SpringDocApp182Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app183/SpringDocApp183Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app183/SpringDocApp183Test.java index c2a280015..34ba0b7e1 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app183/SpringDocApp183Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app183/SpringDocApp183Test.java @@ -24,7 +24,7 @@ package test.org.springdoc.api.v31.app183; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.core.convert.converter.Converter; @@ -33,7 +33,7 @@ import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RestController; -public class SpringDocApp183Test extends AbstractSpringDocV31Test { +public class SpringDocApp183Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp { diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app184/SpringDocApp184Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app184/SpringDocApp184Test.java index 40734b9b6..5a2cb6182 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app184/SpringDocApp184Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app184/SpringDocApp184Test.java @@ -37,7 +37,7 @@ import org.springdoc.core.filters.OpenApiMethodFilter; import org.springdoc.core.models.GroupedOpenApi; import org.springdoc.core.utils.Constants; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.annotation.Bean; @@ -51,7 +51,7 @@ "springdoc.group-configs[0].group=group1", "springdoc.group-configs[0].paths-to-exclude=/group1Filtered", }) -public class SpringDocApp184Test extends AbstractSpringDocV31Test { +public class SpringDocApp184Test extends AbstractSpringDocTest { @Test void testGroup1() throws Exception { diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app185/SpringDocApp185Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app185/SpringDocApp185Test.java index 81d8c6c7b..287f2c132 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app185/SpringDocApp185Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app185/SpringDocApp185Test.java @@ -24,11 +24,11 @@ package test.org.springdoc.api.v31.app185; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; -public class SpringDocApp185Test extends AbstractSpringDocV31Test { +public class SpringDocApp185Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app187/SpringDocApp187Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app187/SpringDocApp187Test.java index 37400187a..8a03f3098 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app187/SpringDocApp187Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app187/SpringDocApp187Test.java @@ -24,11 +24,11 @@ package test.org.springdoc.api.v31.app187; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; -public class SpringDocApp187Test extends AbstractSpringDocV31Test { +public class SpringDocApp187Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app188/HelloController.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app188/HelloController.java index 729cde606..d1f60c51a 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app188/HelloController.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app188/HelloController.java @@ -68,7 +68,7 @@ public OperationCustomizer operationCustomizer(OpenAPI api) { api.getComponents(), ErrorResponse.class, null, - null, SpecVersion.V30 + null, SpecVersion.V31 ); ApiResponse errorApiResponse = new ApiResponse().content(new Content().addMediaType( diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app188/SpringDocApp188Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app188/SpringDocApp188Test.java index 02627c6ae..00098ebcb 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app188/SpringDocApp188Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app188/SpringDocApp188Test.java @@ -24,11 +24,11 @@ package test.org.springdoc.api.v31.app188; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; -public class SpringDocApp188Test extends AbstractSpringDocV31Test { +public class SpringDocApp188Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app189/SpringDocApp189Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app189/SpringDocApp189Test.java index b9f7126c3..660376be3 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app189/SpringDocApp189Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app189/SpringDocApp189Test.java @@ -22,13 +22,13 @@ package test.org.springdoc.api.v31.app189; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.test.context.TestPropertySource; @TestPropertySource(properties = "springdoc.default-support-form-data=true") -public class SpringDocApp189Test extends AbstractSpringDocV31Test { +public class SpringDocApp189Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app19/SpringDocApp19Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app19/SpringDocApp19Test.java index a468e89ba..50af0170b 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app19/SpringDocApp19Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app19/SpringDocApp19Test.java @@ -24,11 +24,11 @@ package test.org.springdoc.api.v31.app19; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; -public class SpringDocApp19Test extends AbstractSpringDocV31Test { +public class SpringDocApp19Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app190/SpringDocApp190Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app190/SpringDocApp190Test.java index 8b2134819..6e45987b1 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app190/SpringDocApp190Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app190/SpringDocApp190Test.java @@ -22,11 +22,11 @@ package test.org.springdoc.api.v31.app190; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; -public class SpringDocApp190Test extends AbstractSpringDocV31Test { +public class SpringDocApp190Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app192/SpringDocApp192Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app192/SpringDocApp192Test.java index 9a8311f09..0666614fd 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app192/SpringDocApp192Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app192/SpringDocApp192Test.java @@ -23,12 +23,12 @@ package test.org.springdoc.api.v31.app192; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; -public class SpringDocApp192Test extends AbstractSpringDocV31Test { +public class SpringDocApp192Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app194/SpringDocApp194Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app194/SpringDocApp194Test.java index b295d71c2..ec414ad59 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app194/SpringDocApp194Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app194/SpringDocApp194Test.java @@ -22,13 +22,13 @@ package test.org.springdoc.api.v31.app194; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.test.context.TestPropertySource; @TestPropertySource(properties = "springdoc.default-support-form-data=false") -public class SpringDocApp194Test extends AbstractSpringDocV31Test { +public class SpringDocApp194Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app195/SpringDocApp195Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app195/SpringDocApp195Test.java index 532e291e5..c769a2878 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app195/SpringDocApp195Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app195/SpringDocApp195Test.java @@ -22,11 +22,11 @@ package test.org.springdoc.api.v31.app195; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; -public class SpringDocApp195Test extends AbstractSpringDocV31Test { +public class SpringDocApp195Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app196/SpringDocApp196Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app196/SpringDocApp196Test.java index 3aa6f7e7b..0487687d3 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app196/SpringDocApp196Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app196/SpringDocApp196Test.java @@ -22,14 +22,14 @@ package test.org.springdoc.api.v31.app196; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.test.context.TestPropertySource; @TestPropertySource(properties = { "springdoc.show-actuator=true", "springdoc.model-and-view-allowed=false" }) -public class SpringDocApp196Test extends AbstractSpringDocV31Test { +public class SpringDocApp196Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app197/SpringDocApp197Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app197/SpringDocApp197Test.java index d0e65539d..1fbd484ac 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app197/SpringDocApp197Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app197/SpringDocApp197Test.java @@ -22,11 +22,11 @@ package test.org.springdoc.api.v31.app197; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; -public class SpringDocApp197Test extends AbstractSpringDocV31Test { +public class SpringDocApp197Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app198/SpringDocApp198Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app198/SpringDocApp198Test.java index cc2d2d891..43ea7d0c0 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app198/SpringDocApp198Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app198/SpringDocApp198Test.java @@ -26,11 +26,11 @@ import io.swagger.v3.oas.models.media.Schema; import org.springdoc.core.utils.SpringDocUtils; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; -public class SpringDocApp198Test extends AbstractSpringDocV31Test { +public class SpringDocApp198Test extends AbstractSpringDocTest { static { SpringDocUtils.getConfig().replaceWithSchema( diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app199/SpringDocApp199Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app199/SpringDocApp199Test.java index a9b452889..3f518d9f8 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app199/SpringDocApp199Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app199/SpringDocApp199Test.java @@ -22,11 +22,11 @@ package test.org.springdoc.api.v31.app199; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; -public class SpringDocApp199Test extends AbstractSpringDocV31Test { +public class SpringDocApp199Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app2/SpringDocApp2Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app2/SpringDocApp2Test.java index e594c537f..1825d93d7 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app2/SpringDocApp2Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app2/SpringDocApp2Test.java @@ -29,12 +29,12 @@ import io.swagger.v3.oas.models.info.Info; import io.swagger.v3.oas.models.info.License; import io.swagger.v3.oas.models.security.SecurityScheme; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.annotation.Bean; -public class SpringDocApp2Test extends AbstractSpringDocV31Test { +public class SpringDocApp2Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp { diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app20/SpringDocApp20Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app20/SpringDocApp20Test.java index e1d833e5b..98bff6314 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app20/SpringDocApp20Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app20/SpringDocApp20Test.java @@ -24,11 +24,11 @@ package test.org.springdoc.api.v31.app20; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; -public class SpringDocApp20Test extends AbstractSpringDocV31Test { +public class SpringDocApp20Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app200/SpringDocApp200Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app200/SpringDocApp200Test.java index ac35e45b0..6e25880b5 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app200/SpringDocApp200Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app200/SpringDocApp200Test.java @@ -22,11 +22,11 @@ package test.org.springdoc.api.v31.app200; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; -public class SpringDocApp200Test extends AbstractSpringDocV31Test { +public class SpringDocApp200Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app201/SpringDocApp201Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app201/SpringDocApp201Test.java index e5326cb61..dc8b630f4 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app201/SpringDocApp201Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app201/SpringDocApp201Test.java @@ -22,11 +22,11 @@ package test.org.springdoc.api.v31.app201; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; -public class SpringDocApp201Test extends AbstractSpringDocV31Test { +public class SpringDocApp201Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app202/SpringDocApp202Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app202/SpringDocApp202Test.java index 32d826980..b0b354ee1 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app202/SpringDocApp202Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app202/SpringDocApp202Test.java @@ -22,11 +22,11 @@ package test.org.springdoc.api.v31.app202; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; -public class SpringDocApp202Test extends AbstractSpringDocV31Test { +public class SpringDocApp202Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app203/SpringDocApp203Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app203/SpringDocApp203Test.java index 78e88e89b..440badb3c 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app203/SpringDocApp203Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app203/SpringDocApp203Test.java @@ -24,7 +24,7 @@ import org.junit.jupiter.api.Test; import org.springdoc.core.utils.Constants; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.annotation.Import; @@ -37,7 +37,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; @TestPropertySource(properties = { "springdoc.group-configs[0].group=mygroup", "springdoc.group-configs[0].paths-to-match=/test" }) -public class SpringDocApp203Test extends AbstractSpringDocV31Test { +public class SpringDocApp203Test extends AbstractSpringDocTest { @SpringBootApplication @Import({ diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app204/SpringDocApp204Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app204/SpringDocApp204Test.java index 321ea265d..540fc89f3 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app204/SpringDocApp204Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app204/SpringDocApp204Test.java @@ -22,13 +22,13 @@ package test.org.springdoc.api.v31.app204; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.test.context.TestPropertySource; @TestPropertySource(properties = { "springdoc.default-flat-param-object=true" }) -public class SpringDocApp204Test extends AbstractSpringDocV31Test { +public class SpringDocApp204Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} } diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app205/SpringdocApp205Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app205/SpringdocApp205Test.java index e3a966937..52e9f0256 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app205/SpringdocApp205Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app205/SpringdocApp205Test.java @@ -4,7 +4,7 @@ * @author bnasslahsen */ -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.test.context.TestPropertySource; @@ -13,7 +13,7 @@ * Fix regression in #2031 */ @TestPropertySource(properties = { "springdoc.group-configs[0].group=mygroup", "springdoc.group-configs[0].paths-to-match=/test" }) -public class SpringdocApp205Test extends AbstractSpringDocV31Test { +public class SpringdocApp205Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app206/SpringdocApp206Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app206/SpringdocApp206Test.java index a5b8f4fd3..f9d4e2829 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app206/SpringdocApp206Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app206/SpringdocApp206Test.java @@ -1,10 +1,10 @@ package test.org.springdoc.api.v31.app206; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; -public class SpringdocApp206Test extends AbstractSpringDocV31Test { +public class SpringdocApp206Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app207/SpringdocApp207Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app207/SpringdocApp207Test.java index c5792a193..ffc85cc3b 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app207/SpringdocApp207Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app207/SpringdocApp207Test.java @@ -1,10 +1,10 @@ package test.org.springdoc.api.v31.app207; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; -public class SpringdocApp207Test extends AbstractSpringDocV31Test { +public class SpringdocApp207Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app208/SpringdocApp208Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app208/SpringdocApp208Test.java index aad3005db..f8a5e767d 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app208/SpringdocApp208Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app208/SpringdocApp208Test.java @@ -1,12 +1,12 @@ package test.org.springdoc.api.v31.app208; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.test.context.TestPropertySource; @TestPropertySource(properties = { "springdoc.default-flat-param-object=true" }) -public class SpringdocApp208Test extends AbstractSpringDocV31Test { +public class SpringdocApp208Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app21/SpringDocApp21Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app21/SpringDocApp21Test.java index de657fbae..07ab6ff6a 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app21/SpringDocApp21Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app21/SpringDocApp21Test.java @@ -24,13 +24,13 @@ package test.org.springdoc.api.v31.app21; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.test.context.TestPropertySource; @TestPropertySource(properties = "springdoc.oAuthFlow.authorizationUrl=http://personstore.swagger.io/oauth/dialog") -public class SpringDocApp21Test extends AbstractSpringDocV31Test { +public class SpringDocApp21Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app211/SpringDocApp211Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app211/SpringDocApp211Test.java index a677445ab..66b4e95f3 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app211/SpringDocApp211Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app211/SpringDocApp211Test.java @@ -24,11 +24,11 @@ package test.org.springdoc.api.v31.app211; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; -public class SpringDocApp211Test extends AbstractSpringDocV31Test { +public class SpringDocApp211Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app212/SpringDocApp212Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app212/SpringDocApp212Test.java index 5ff33d815..6d3219a8d 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app212/SpringDocApp212Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app212/SpringDocApp212Test.java @@ -21,7 +21,7 @@ import org.junit.jupiter.api.Test; import org.springdoc.core.customizers.SpecPropertiesCustomizer; import org.springdoc.core.models.GroupedOpenApi; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.annotation.Bean; @@ -37,7 +37,7 @@ * A test for {@link SpecPropertiesCustomizer} */ @ActiveProfiles("212") -public class SpringDocApp212Test extends AbstractSpringDocV31Test { +public class SpringDocApp212Test extends AbstractSpringDocTest { /** * The type Spring doc test app. diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app213/SpringDocApp213Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app213/SpringDocApp213Test.java index d3ffa5b1f..89af14b8c 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app213/SpringDocApp213Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app213/SpringDocApp213Test.java @@ -19,7 +19,7 @@ package test.org.springdoc.api.v31.app213; import org.springdoc.core.customizers.SpecPropertiesCustomizer; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.test.context.SpringBootTest; @@ -31,7 +31,7 @@ */ @SpringBootTest @ActiveProfiles("213") -public class SpringDocApp213Test extends AbstractSpringDocV31Test { +public class SpringDocApp213Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app216/SpringDocApp216Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app216/SpringDocApp216Test.java index 7082d1b6a..5298bb3c0 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app216/SpringDocApp216Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app216/SpringDocApp216Test.java @@ -19,7 +19,7 @@ package test.org.springdoc.api.v31.app216; import org.springdoc.core.customizers.SpecPropertiesCustomizer; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.test.context.SpringBootTest; @@ -29,7 +29,7 @@ * A test for {@link SpecPropertiesCustomizer} */ @SpringBootTest -public class SpringDocApp216Test extends AbstractSpringDocV31Test { +public class SpringDocApp216Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app217/SpringDocApp217Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app217/SpringDocApp217Test.java index 556e405ab..31335635f 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app217/SpringDocApp217Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app217/SpringDocApp217Test.java @@ -21,7 +21,7 @@ import org.junit.jupiter.api.Test; import org.springdoc.core.customizers.SpecPropertiesCustomizer; import org.springdoc.core.utils.Constants; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.test.context.SpringBootTest; @@ -39,7 +39,7 @@ */ @SpringBootTest @ActiveProfiles("217") -public class SpringDocApp217Test extends AbstractSpringDocV31Test { +public class SpringDocApp217Test extends AbstractSpringDocTest { @Test diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app218/SpringDocApp218Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app218/SpringDocApp218Test.java index 1613acc45..077a4cc85 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app218/SpringDocApp218Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app218/SpringDocApp218Test.java @@ -19,7 +19,7 @@ package test.org.springdoc.api.v31.app218; import org.springdoc.core.customizers.SpecPropertiesCustomizer; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.test.context.SpringBootTest; @@ -29,7 +29,7 @@ * A test for {@link SpecPropertiesCustomizer} */ @SpringBootTest -public class SpringDocApp218Test extends AbstractSpringDocV31Test { +public class SpringDocApp218Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app219/SpringDocApp219Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app219/SpringDocApp219Test.java index d88c0d2e5..9b1798335 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app219/SpringDocApp219Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app219/SpringDocApp219Test.java @@ -24,13 +24,13 @@ package test.org.springdoc.api.v31.app219; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.test.context.ActiveProfiles; @ActiveProfiles("219") -public class SpringDocApp219Test extends AbstractSpringDocV31Test { +public class SpringDocApp219Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app22/SpringDocApp22Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app22/SpringDocApp22Test.java index 378843370..d6a25493e 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app22/SpringDocApp22Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app22/SpringDocApp22Test.java @@ -24,11 +24,11 @@ package test.org.springdoc.api.v31.app22; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; -public class SpringDocApp22Test extends AbstractSpringDocV31Test { +public class SpringDocApp22Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app220/SpringDocApp220Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app220/SpringDocApp220Test.java index 4269e21fe..7cd56061d 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app220/SpringDocApp220Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app220/SpringDocApp220Test.java @@ -24,11 +24,11 @@ package test.org.springdoc.api.v31.app220; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; -public class SpringDocApp220Test extends AbstractSpringDocV31Test { +public class SpringDocApp220Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app221/SpringDocApp221Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app221/SpringDocApp221Test.java index 0f52c106f..28eaee9d5 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app221/SpringDocApp221Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app221/SpringDocApp221Test.java @@ -24,11 +24,11 @@ package test.org.springdoc.api.v31.app221; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; -public class SpringDocApp221Test extends AbstractSpringDocV31Test { +public class SpringDocApp221Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app222/SpringDocApp222Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app222/SpringDocApp222Test.java index eaac7c8bd..ffa9bb163 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app222/SpringDocApp222Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app222/SpringDocApp222Test.java @@ -28,11 +28,11 @@ import com.fasterxml.jackson.annotation.JsonSubTypes.Type; import com.fasterxml.jackson.annotation.JsonTypeInfo; import com.fasterxml.jackson.annotation.JsonTypeInfo.Id; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; -public class SpringDocApp222Test extends AbstractSpringDocV31Test { +public class SpringDocApp222Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app223/SpringDocApp223Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app223/SpringDocApp223Test.java index ce7271e27..7e7580ad9 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app223/SpringDocApp223Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app223/SpringDocApp223Test.java @@ -24,11 +24,11 @@ package test.org.springdoc.api.v31.app223; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; -public class SpringDocApp223Test extends AbstractSpringDocV31Test { +public class SpringDocApp223Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app224/SpringDocApp224Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app224/SpringDocApp224Test.java index 91f027489..da2f5ab13 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app224/SpringDocApp224Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app224/SpringDocApp224Test.java @@ -24,11 +24,11 @@ package test.org.springdoc.api.v31.app224; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; -public class SpringDocApp224Test extends AbstractSpringDocV31Test { +public class SpringDocApp224Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app225/SpringDocApp225Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app225/SpringDocApp225Test.java index 6aaa0635a..600f9484b 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app225/SpringDocApp225Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app225/SpringDocApp225Test.java @@ -24,11 +24,11 @@ package test.org.springdoc.api.v31.app225; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; -public class SpringDocApp225Test extends AbstractSpringDocV31Test { +public class SpringDocApp225Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app226/SpringDocApp226Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app226/SpringDocApp226Test.java index d74b4634e..a260efdf9 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app226/SpringDocApp226Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app226/SpringDocApp226Test.java @@ -24,11 +24,11 @@ package test.org.springdoc.api.v31.app226; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; -public class SpringDocApp226Test extends AbstractSpringDocV31Test { +public class SpringDocApp226Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app227/SpringDocApp227Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app227/SpringDocApp227Test.java index f57c2fa38..13bbf1f87 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app227/SpringDocApp227Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app227/SpringDocApp227Test.java @@ -18,11 +18,11 @@ package test.org.springdoc.api.v31.app227; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; -public class SpringDocApp227Test extends AbstractSpringDocV31Test { +public class SpringDocApp227Test extends AbstractSpringDocTest { @SpringBootApplication diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app228/SpringDocApp228Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app228/SpringDocApp228Test.java index 2abf63e2d..9c4ca8b4a 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app228/SpringDocApp228Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app228/SpringDocApp228Test.java @@ -24,11 +24,11 @@ package test.org.springdoc.api.v31.app228; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; -public class SpringDocApp228Test extends AbstractSpringDocV31Test { +public class SpringDocApp228Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app229/SpringDocApp229Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app229/SpringDocApp229Test.java index 097ad4076..45ee13cfc 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app229/SpringDocApp229Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app229/SpringDocApp229Test.java @@ -26,11 +26,11 @@ package test.org.springdoc.api.v31.app229; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; -public class SpringDocApp229Test extends AbstractSpringDocV31Test { +public class SpringDocApp229Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app23/SpringDocApp23Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app23/SpringDocApp23Test.java index b029a1994..87a11bf47 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app23/SpringDocApp23Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app23/SpringDocApp23Test.java @@ -24,11 +24,11 @@ package test.org.springdoc.api.v31.app23; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; -public class SpringDocApp23Test extends AbstractSpringDocV31Test { +public class SpringDocApp23Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app230/SpringDocApp230Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app230/SpringDocApp230Test.java index 48deb80f5..24bb726e8 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app230/SpringDocApp230Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app230/SpringDocApp230Test.java @@ -26,14 +26,14 @@ package test.org.springdoc.api.v31.app230; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; /** * @author edudar */ -public class SpringDocApp230Test extends AbstractSpringDocV31Test { +public class SpringDocApp230Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app231/SpringDocApp231Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app231/SpringDocApp231Test.java index d0f478d9b..bd968441b 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app231/SpringDocApp231Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app231/SpringDocApp231Test.java @@ -26,14 +26,14 @@ package test.org.springdoc.api.v31.app231; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; /** * @author bnasslahsen */ -public class SpringDocApp231Test extends AbstractSpringDocV31Test { +public class SpringDocApp231Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app232/SpringDocApp232Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app232/SpringDocApp232Test.java index e72a9f3ae..8b224cde2 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app232/SpringDocApp232Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app232/SpringDocApp232Test.java @@ -27,7 +27,7 @@ package test.org.springdoc.api.v31.app232; import org.springdoc.core.customizers.OperationCustomizer; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.annotation.Bean; @@ -35,7 +35,7 @@ /** * @author bnasslahsen */ -public class SpringDocApp232Test extends AbstractSpringDocV31Test { +public class SpringDocApp232Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp { diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app233/SpringDocApp233Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app233/SpringDocApp233Test.java index b1644f6d0..1636f52a4 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app233/SpringDocApp233Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app233/SpringDocApp233Test.java @@ -39,7 +39,7 @@ import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.CsvSource; import org.springdoc.core.utils.Constants; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.test.web.servlet.MvcResult; @@ -54,7 +54,7 @@ /** * @author bnasslahsen, michael.clarke */ -class SpringDocApp233Test extends AbstractSpringDocV31Test { +class SpringDocApp233Test extends AbstractSpringDocTest { @CsvSource({"requiredNotNullParameterObject.requiredNotNullField, true", "requiredNotNullParameterObject.requiredNoValidationField, true", diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app234/SpringDocApp234Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app234/SpringDocApp234Test.java index 7790c7a0e..e5c00df48 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app234/SpringDocApp234Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app234/SpringDocApp234Test.java @@ -24,11 +24,11 @@ package test.org.springdoc.api.v31.app234; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; -public class SpringDocApp234Test extends AbstractSpringDocV31Test { +public class SpringDocApp234Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app235/SpringDocApp235Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app235/SpringDocApp235Test.java index 0e89e9469..ca319c40f 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app235/SpringDocApp235Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app235/SpringDocApp235Test.java @@ -26,11 +26,11 @@ package test.org.springdoc.api.v31.app235; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; -public class SpringDocApp235Test extends AbstractSpringDocV31Test { +public class SpringDocApp235Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app236/SpringDocApp236Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app236/SpringDocApp236Test.java index a1ed6d0e3..7266e0f04 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app236/SpringDocApp236Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app236/SpringDocApp236Test.java @@ -26,11 +26,11 @@ package test.org.springdoc.api.v31.app236; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; -public class SpringDocApp236Test extends AbstractSpringDocV31Test { +public class SpringDocApp236Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app24/SpringDocApp24Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app24/SpringDocApp24Test.java index 86cc7a42f..2475d2856 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app24/SpringDocApp24Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app24/SpringDocApp24Test.java @@ -24,9 +24,9 @@ package test.org.springdoc.api.v31.app24; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; -public class SpringDocApp24Test extends AbstractSpringDocV31Test { +public class SpringDocApp24Test extends AbstractSpringDocTest { } \ No newline at end of file diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app25/SpringDocApp25Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app25/SpringDocApp25Test.java index 0f6206665..c17d2ea9c 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app25/SpringDocApp25Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app25/SpringDocApp25Test.java @@ -24,11 +24,11 @@ package test.org.springdoc.api.v31.app25; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; -public class SpringDocApp25Test extends AbstractSpringDocV31Test { +public class SpringDocApp25Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app26/SpringDocApp26Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app26/SpringDocApp26Test.java index cf44ab1a9..70bc0053e 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app26/SpringDocApp26Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app26/SpringDocApp26Test.java @@ -24,11 +24,11 @@ package test.org.springdoc.api.v31.app26; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; -public class SpringDocApp26Test extends AbstractSpringDocV31Test { +public class SpringDocApp26Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app27/SpringDocApp27Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app27/SpringDocApp27Test.java index d45525ff0..ce1419da0 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app27/SpringDocApp27Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app27/SpringDocApp27Test.java @@ -26,7 +26,7 @@ import org.junit.jupiter.api.Test; import org.springdoc.core.utils.Constants; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; @@ -36,7 +36,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; -public class SpringDocApp27Test extends AbstractSpringDocV31Test { +public class SpringDocApp27Test extends AbstractSpringDocTest { @Test protected void testApp() throws Exception { diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app28/SpringDocApp28Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app28/SpringDocApp28Test.java index 5f0838323..2f5b9feda 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app28/SpringDocApp28Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app28/SpringDocApp28Test.java @@ -24,11 +24,11 @@ package test.org.springdoc.api.v31.app28; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; -public class SpringDocApp28Test extends AbstractSpringDocV31Test { +public class SpringDocApp28Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app29/SpringDocApp29Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app29/SpringDocApp29Test.java index 158519a89..dbf4d0d6b 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app29/SpringDocApp29Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app29/SpringDocApp29Test.java @@ -24,11 +24,11 @@ package test.org.springdoc.api.v31.app29; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; -public class SpringDocApp29Test extends AbstractSpringDocV31Test { +public class SpringDocApp29Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app30/SpringDocApp30Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app30/SpringDocApp30Test.java index 6190ed802..7822a66ce 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app30/SpringDocApp30Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app30/SpringDocApp30Test.java @@ -24,11 +24,11 @@ package test.org.springdoc.api.v31.app30; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; -public class SpringDocApp30Test extends AbstractSpringDocV31Test { +public class SpringDocApp30Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app31/SpringDocApp31Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app31/SpringDocApp31Test.java index a34f35e18..8ef855f8b 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app31/SpringDocApp31Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app31/SpringDocApp31Test.java @@ -24,11 +24,11 @@ package test.org.springdoc.api.v31.app31; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; -public class SpringDocApp31Test extends AbstractSpringDocV31Test { +public class SpringDocApp31Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app32/SpringDocApp32Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app32/SpringDocApp32Test.java index b452bfcba..8c9843653 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app32/SpringDocApp32Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app32/SpringDocApp32Test.java @@ -24,11 +24,11 @@ package test.org.springdoc.api.v31.app32; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; -public class SpringDocApp32Test extends AbstractSpringDocV31Test { +public class SpringDocApp32Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app33/SpringDocApp33Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app33/SpringDocApp33Test.java index f1adc727b..faf667c9a 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app33/SpringDocApp33Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app33/SpringDocApp33Test.java @@ -24,11 +24,11 @@ package test.org.springdoc.api.v31.app33; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; -public class SpringDocApp33Test extends AbstractSpringDocV31Test { +public class SpringDocApp33Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app34/SpringDocApp34Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app34/SpringDocApp34Test.java index 2683450cf..e87b88992 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app34/SpringDocApp34Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app34/SpringDocApp34Test.java @@ -24,11 +24,11 @@ package test.org.springdoc.api.v31.app34; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; -public class SpringDocApp34Test extends AbstractSpringDocV31Test { +public class SpringDocApp34Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app35/SpringDocApp35Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app35/SpringDocApp35Test.java index 220cad3e4..5b69dd104 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app35/SpringDocApp35Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app35/SpringDocApp35Test.java @@ -24,13 +24,13 @@ package test.org.springdoc.api.v31.app35; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; import static org.springdoc.core.utils.SpringDocUtils.getConfig; -public class SpringDocApp35Test extends AbstractSpringDocV31Test { +public class SpringDocApp35Test extends AbstractSpringDocTest { static { getConfig().addRestControllers(HelloController.class); diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app37/SpringDocApp37Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app37/SpringDocApp37Test.java index 6940d6550..2197587cf 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app37/SpringDocApp37Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app37/SpringDocApp37Test.java @@ -24,11 +24,11 @@ package test.org.springdoc.api.v31.app37; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; -public class SpringDocApp37Test extends AbstractSpringDocV31Test { +public class SpringDocApp37Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app38/SpringDocApp38Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app38/SpringDocApp38Test.java index 53eb32da4..255e0ad51 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app38/SpringDocApp38Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app38/SpringDocApp38Test.java @@ -24,11 +24,11 @@ package test.org.springdoc.api.v31.app38; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; -public class SpringDocApp38Test extends AbstractSpringDocV31Test { +public class SpringDocApp38Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app39/SpringDocApp39Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app39/SpringDocApp39Test.java index bbf9cb18c..c01e13c0f 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app39/SpringDocApp39Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app39/SpringDocApp39Test.java @@ -24,9 +24,9 @@ package test.org.springdoc.api.v31.app39; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; -public class SpringDocApp39Test extends AbstractSpringDocV31Test { +public class SpringDocApp39Test extends AbstractSpringDocTest { } \ No newline at end of file diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app4/SpringDocApp4Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app4/SpringDocApp4Test.java index 4524da731..e084d3af8 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app4/SpringDocApp4Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app4/SpringDocApp4Test.java @@ -26,13 +26,13 @@ import io.swagger.v3.core.jackson.TypeNameResolver; import org.junit.jupiter.api.AfterAll; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +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 SpringDocApp4Test extends AbstractSpringDocV31Test { +public class SpringDocApp4Test extends AbstractSpringDocTest { @AfterAll static void restore() { diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app40/SpringDocApp40Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app40/SpringDocApp40Test.java index 574cf12ae..1771729a7 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app40/SpringDocApp40Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app40/SpringDocApp40Test.java @@ -24,11 +24,11 @@ package test.org.springdoc.api.v31.app40; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; -public class SpringDocApp40Test extends AbstractSpringDocV31Test { +public class SpringDocApp40Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app41/SpringDocApp411Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app41/SpringDocApp411Test.java index 5ab88f36e..57fd432c5 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app41/SpringDocApp411Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app41/SpringDocApp411Test.java @@ -30,7 +30,7 @@ import org.junit.jupiter.api.Test; import org.springdoc.core.utils.Constants; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.test.web.servlet.MvcResult; @@ -41,7 +41,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; -public class SpringDocApp411Test extends AbstractSpringDocV31Test { +public class SpringDocApp411Test extends AbstractSpringDocTest { @Test protected void testApp() throws Exception { diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app41/SpringDocApp41Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app41/SpringDocApp41Test.java index 92c71fedc..4225e1f6f 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app41/SpringDocApp41Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app41/SpringDocApp41Test.java @@ -30,7 +30,7 @@ import org.junit.jupiter.api.Test; import org.springdoc.core.utils.Constants; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.test.context.TestPropertySource; @@ -43,7 +43,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; @TestPropertySource(properties = "springdoc.cache.disabled=true") -public class SpringDocApp41Test extends AbstractSpringDocV31Test { +public class SpringDocApp41Test extends AbstractSpringDocTest { @Test protected void testApp() throws Exception { diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app42/SpringDocApp42Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app42/SpringDocApp42Test.java index a22993b25..463734fb5 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app42/SpringDocApp42Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app42/SpringDocApp42Test.java @@ -27,12 +27,12 @@ import io.swagger.v3.oas.models.Components; import io.swagger.v3.oas.models.OpenAPI; import io.swagger.v3.oas.models.media.StringSchema; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.annotation.Bean; -public class SpringDocApp42Test extends AbstractSpringDocV31Test { +public class SpringDocApp42Test extends AbstractSpringDocTest { @SpringBootApplication diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app43/SpringDocApp43Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app43/SpringDocApp43Test.java index d263624ec..26efbbf47 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app43/SpringDocApp43Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app43/SpringDocApp43Test.java @@ -24,11 +24,11 @@ package test.org.springdoc.api.v31.app43; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; -public class SpringDocApp43Test extends AbstractSpringDocV31Test { +public class SpringDocApp43Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app44/SpringDocApp44Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app44/SpringDocApp44Test.java index 806597b82..caf251b63 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app44/SpringDocApp44Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app44/SpringDocApp44Test.java @@ -26,7 +26,7 @@ import org.junit.jupiter.api.Test; import org.springdoc.core.utils.Constants; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; @@ -36,7 +36,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; -public class SpringDocApp44Test extends AbstractSpringDocV31Test { +public class SpringDocApp44Test extends AbstractSpringDocTest { @Test public void testApp() throws Exception { diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app45/SpringDocApp45Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app45/SpringDocApp45Test.java index 244f337d2..714bb040e 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app45/SpringDocApp45Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app45/SpringDocApp45Test.java @@ -24,11 +24,11 @@ package test.org.springdoc.api.v31.app45; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; -public class SpringDocApp45Test extends AbstractSpringDocV31Test { +public class SpringDocApp45Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app46/SpringDocApp46Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app46/SpringDocApp46Test.java index 5a7595e2f..03ff032cc 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app46/SpringDocApp46Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app46/SpringDocApp46Test.java @@ -24,11 +24,11 @@ package test.org.springdoc.api.v31.app46; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; -public class SpringDocApp46Test extends AbstractSpringDocV31Test { +public class SpringDocApp46Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app47/SpringDocApp47Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app47/SpringDocApp47Test.java index ff4f11ec7..f1617be93 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app47/SpringDocApp47Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app47/SpringDocApp47Test.java @@ -24,11 +24,11 @@ package test.org.springdoc.api.v31.app47; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; -public class SpringDocApp47Test extends AbstractSpringDocV31Test { +public class SpringDocApp47Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app48/SpringDocApp48Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app48/SpringDocApp48Test.java index 49fb83e85..678f6efa7 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app48/SpringDocApp48Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app48/SpringDocApp48Test.java @@ -24,11 +24,11 @@ package test.org.springdoc.api.v31.app48; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; -public class SpringDocApp48Test extends AbstractSpringDocV31Test { +public class SpringDocApp48Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app49/SpringDocApp49Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app49/SpringDocApp49Test.java index f0ccb5f87..73d5c6db4 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app49/SpringDocApp49Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app49/SpringDocApp49Test.java @@ -24,9 +24,9 @@ package test.org.springdoc.api.v31.app49; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; -public class SpringDocApp49Test extends AbstractSpringDocV31Test { +public class SpringDocApp49Test extends AbstractSpringDocTest { } \ No newline at end of file diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app5/SpringDocApp5Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app5/SpringDocApp5Test.java index 166fa1974..dfb2f26e3 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app5/SpringDocApp5Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app5/SpringDocApp5Test.java @@ -3,7 +3,7 @@ import org.junit.jupiter.api.Test; import org.springdoc.core.customizers.RouterOperationCustomizer; import org.springdoc.core.utils.Constants; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.annotation.Bean; @@ -16,7 +16,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; -class SpringDocApp5Test extends AbstractSpringDocV31Test { +class SpringDocApp5Test extends AbstractSpringDocTest { @Test void testAddRouterOperationCustomizerBean() throws Exception { diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app50/SpringDocApp50Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app50/SpringDocApp50Test.java index cbfe6386d..5806b235f 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app50/SpringDocApp50Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app50/SpringDocApp50Test.java @@ -24,9 +24,9 @@ package test.org.springdoc.api.v31.app50; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; -public class SpringDocApp50Test extends AbstractSpringDocV31Test { +public class SpringDocApp50Test extends AbstractSpringDocTest { } \ No newline at end of file diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app51/SpringDocApp51Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app51/SpringDocApp51Test.java index 63a94b2ae..0d768df4f 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app51/SpringDocApp51Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app51/SpringDocApp51Test.java @@ -24,11 +24,11 @@ package test.org.springdoc.api.v31.app51; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; -public class SpringDocApp51Test extends AbstractSpringDocV31Test { +public class SpringDocApp51Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app52/SpringDocApp52Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app52/SpringDocApp52Test.java index 9d363ec42..8831e9bcd 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app52/SpringDocApp52Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app52/SpringDocApp52Test.java @@ -24,11 +24,11 @@ package test.org.springdoc.api.v31.app52; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; -public class SpringDocApp52Test extends AbstractSpringDocV31Test { +public class SpringDocApp52Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app53/SpringDocApp53Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app53/SpringDocApp53Test.java index c482f7efb..6185f2a25 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app53/SpringDocApp53Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app53/SpringDocApp53Test.java @@ -24,11 +24,11 @@ package test.org.springdoc.api.v31.app53; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; -public class SpringDocApp53Test extends AbstractSpringDocV31Test { +public class SpringDocApp53Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app54/SpringDocApp54Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app54/SpringDocApp54Test.java index 4d52e5a9a..aae9a1e67 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app54/SpringDocApp54Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app54/SpringDocApp54Test.java @@ -24,11 +24,11 @@ package test.org.springdoc.api.v31.app54; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; -public class SpringDocApp54Test extends AbstractSpringDocV31Test { +public class SpringDocApp54Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app55/SpringDocApp55Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app55/SpringDocApp55Test.java index 995e5e975..9debd320d 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app55/SpringDocApp55Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app55/SpringDocApp55Test.java @@ -24,11 +24,11 @@ package test.org.springdoc.api.v31.app55; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; -public class SpringDocApp55Test extends AbstractSpringDocV31Test { +public class SpringDocApp55Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app56/SpringDocApp56Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app56/SpringDocApp56Test.java index 0f0d4b4ad..6712f24c4 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app56/SpringDocApp56Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app56/SpringDocApp56Test.java @@ -24,11 +24,11 @@ package test.org.springdoc.api.v31.app56; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; -public class SpringDocApp56Test extends AbstractSpringDocV31Test { +public class SpringDocApp56Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app57/SpringDocApp57Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app57/SpringDocApp57Test.java index 102bb08b9..29aaced64 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app57/SpringDocApp57Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app57/SpringDocApp57Test.java @@ -24,11 +24,11 @@ package test.org.springdoc.api.v31.app57; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; -public class SpringDocApp57Test extends AbstractSpringDocV31Test { +public class SpringDocApp57Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app58/SpringDocApp58Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app58/SpringDocApp58Test.java index d396b1590..c05748a14 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app58/SpringDocApp58Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app58/SpringDocApp58Test.java @@ -24,11 +24,11 @@ package test.org.springdoc.api.v31.app58; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; -public class SpringDocApp58Test extends AbstractSpringDocV31Test { +public class SpringDocApp58Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app59/SpringDocApp59Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app59/SpringDocApp59Test.java index 11a838af5..612e61504 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app59/SpringDocApp59Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app59/SpringDocApp59Test.java @@ -24,11 +24,11 @@ package test.org.springdoc.api.v31.app59; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; -public class SpringDocApp59Test extends AbstractSpringDocV31Test { +public class SpringDocApp59Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app6/SpringDocApp6Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app6/SpringDocApp6Test.java index a334374b3..01b7906b9 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app6/SpringDocApp6Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app6/SpringDocApp6Test.java @@ -22,11 +22,11 @@ package test.org.springdoc.api.v31.app6; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; -public class SpringDocApp6Test extends AbstractSpringDocV31Test { +public class SpringDocApp6Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp { diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app60/SpringDocApp60Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app60/SpringDocApp60Test.java index 45c8365a6..2f4ffaffd 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app60/SpringDocApp60Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app60/SpringDocApp60Test.java @@ -24,11 +24,11 @@ package test.org.springdoc.api.v31.app60; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; -public class SpringDocApp60Test extends AbstractSpringDocV31Test { +public class SpringDocApp60Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app61/SpringDocApp61Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app61/SpringDocApp61Test.java index 2f1feeff3..0d633f3a5 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app61/SpringDocApp61Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app61/SpringDocApp61Test.java @@ -24,11 +24,11 @@ package test.org.springdoc.api.v31.app61; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; -public class SpringDocApp61Test extends AbstractSpringDocV31Test { +public class SpringDocApp61Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app62/SpringDocApp62Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app62/SpringDocApp62Test.java index 34d2dd007..ce529cecb 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app62/SpringDocApp62Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app62/SpringDocApp62Test.java @@ -24,11 +24,11 @@ package test.org.springdoc.api.v31.app62; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; -public class SpringDocApp62Test extends AbstractSpringDocV31Test { +public class SpringDocApp62Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app63/SpringDocApp63Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app63/SpringDocApp63Test.java index 1f40a7c40..ce18e4a06 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app63/SpringDocApp63Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app63/SpringDocApp63Test.java @@ -24,7 +24,7 @@ package test.org.springdoc.api.v31.app63; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.test.context.TestPropertySource; @@ -33,7 +33,7 @@ @TestPropertySource(properties = { "springdoc.packagesToScan=hell,hello1, hello.me", "springdoc.packagesToExclude=test.org.springdoc.api.app63.65" }) -public class SpringDocApp63Test extends AbstractSpringDocV31Test { +public class SpringDocApp63Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app64/SpringDocApp64Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app64/SpringDocApp64Test.java index 8646ab74a..10f51cd93 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app64/SpringDocApp64Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app64/SpringDocApp64Test.java @@ -24,13 +24,13 @@ package test.org.springdoc.api.v31.app64; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.test.context.TestPropertySource; @TestPropertySource(properties = "springdoc.paths-to-match=/v1, /api/**") -public class SpringDocApp64Test extends AbstractSpringDocV31Test { +public class SpringDocApp64Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app65/SpringDocApp65Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app65/SpringDocApp65Test.java index 1e712e6b9..3421d9a62 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app65/SpringDocApp65Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app65/SpringDocApp65Test.java @@ -24,11 +24,11 @@ package test.org.springdoc.api.v31.app65; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; -public class SpringDocApp65Test extends AbstractSpringDocV31Test { +public class SpringDocApp65Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app66/SpringDocApp66Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app66/SpringDocApp66Test.java index 247d3f71f..45eda738d 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app66/SpringDocApp66Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app66/SpringDocApp66Test.java @@ -24,11 +24,11 @@ package test.org.springdoc.api.v31.app66; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; -public class SpringDocApp66Test extends AbstractSpringDocV31Test { +public class SpringDocApp66Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app67/SpringDocApp67Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app67/SpringDocApp67Test.java index a3f287387..83644b486 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app67/SpringDocApp67Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app67/SpringDocApp67Test.java @@ -24,11 +24,11 @@ package test.org.springdoc.api.v31.app67; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; -public class SpringDocApp67Test extends AbstractSpringDocV31Test { +public class SpringDocApp67Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app69/SpringDocApp69Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app69/SpringDocApp69Test.java index b91110de9..dab360b27 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app69/SpringDocApp69Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app69/SpringDocApp69Test.java @@ -24,11 +24,11 @@ package test.org.springdoc.api.v31.app69; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; -public class SpringDocApp69Test extends AbstractSpringDocV31Test { +public class SpringDocApp69Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app7/SpringDocApp7Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app7/SpringDocApp7Test.java index 22d05ba05..c0016bf8d 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app7/SpringDocApp7Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app7/SpringDocApp7Test.java @@ -22,11 +22,11 @@ package test.org.springdoc.api.v31.app7; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; -public class SpringDocApp7Test extends AbstractSpringDocV31Test { +public class SpringDocApp7Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp { diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app70/SpringDocApp70Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app70/SpringDocApp70Test.java index b8c67fd30..d8eb61abb 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app70/SpringDocApp70Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app70/SpringDocApp70Test.java @@ -24,11 +24,11 @@ package test.org.springdoc.api.v31.app70; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; -public class SpringDocApp70Test extends AbstractSpringDocV31Test { +public class SpringDocApp70Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app71/SpringDocApp71Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app71/SpringDocApp71Test.java index bf0126c5f..4f1ff9e95 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app71/SpringDocApp71Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app71/SpringDocApp71Test.java @@ -24,11 +24,11 @@ package test.org.springdoc.api.v31.app71; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; -public class SpringDocApp71Test extends AbstractSpringDocV31Test { +public class SpringDocApp71Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app73/SpringDocApp73Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app73/SpringDocApp73Test.java index 5dedb91e1..f95961aaf 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app73/SpringDocApp73Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app73/SpringDocApp73Test.java @@ -24,11 +24,11 @@ package test.org.springdoc.api.v31.app73; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; -public class SpringDocApp73Test extends AbstractSpringDocV31Test { +public class SpringDocApp73Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app74/SpringDocApp74Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app74/SpringDocApp74Test.java index 596d5ff8d..2f1b9835a 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app74/SpringDocApp74Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app74/SpringDocApp74Test.java @@ -24,11 +24,11 @@ package test.org.springdoc.api.v31.app74; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; -public class SpringDocApp74Test extends AbstractSpringDocV31Test { +public class SpringDocApp74Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app75/SpringDocApp75Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app75/SpringDocApp75Test.java index ad236b208..802d2cdc3 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app75/SpringDocApp75Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app75/SpringDocApp75Test.java @@ -24,11 +24,11 @@ package test.org.springdoc.api.v31.app75; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; -public class SpringDocApp75Test extends AbstractSpringDocV31Test { +public class SpringDocApp75Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp { diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app76/SpringDocApp76Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app76/SpringDocApp76Test.java index 087424658..d63d70bc9 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app76/SpringDocApp76Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app76/SpringDocApp76Test.java @@ -30,12 +30,12 @@ import io.swagger.v3.oas.models.OpenAPI; import io.swagger.v3.oas.models.security.SecurityRequirement; import io.swagger.v3.oas.models.security.SecurityScheme; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.annotation.Bean; -public class SpringDocApp76Test extends AbstractSpringDocV31Test { +public class SpringDocApp76Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp { diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app77/SpringDocApp77Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app77/SpringDocApp77Test.java index 4f0da18f1..9cc234dd6 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app77/SpringDocApp77Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app77/SpringDocApp77Test.java @@ -24,11 +24,11 @@ package test.org.springdoc.api.v31.app77; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; -public class SpringDocApp77Test extends AbstractSpringDocV31Test { +public class SpringDocApp77Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app78/SpringDocApp78Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app78/SpringDocApp78Test.java index be455c17c..95fd647b4 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app78/SpringDocApp78Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app78/SpringDocApp78Test.java @@ -24,11 +24,11 @@ package test.org.springdoc.api.v31.app78; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; -public class SpringDocApp78Test extends AbstractSpringDocV31Test { +public class SpringDocApp78Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app79/SpringDocApp79Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app79/SpringDocApp79Test.java index 358b6ddf3..33406a06d 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app79/SpringDocApp79Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app79/SpringDocApp79Test.java @@ -24,12 +24,12 @@ package test.org.springdoc.api.v31.app79; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; -public class SpringDocApp79Test extends AbstractSpringDocV31Test { +public class SpringDocApp79Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app8/SpringDocApp8Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app8/SpringDocApp8Test.java index 5864b1d8c..c35e6a856 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app8/SpringDocApp8Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app8/SpringDocApp8Test.java @@ -22,11 +22,11 @@ package test.org.springdoc.api.v31.app8; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; -public class SpringDocApp8Test extends AbstractSpringDocV31Test { +public class SpringDocApp8Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp { diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app80/SpringDocApp80Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app80/SpringDocApp80Test.java index 8cb0c2a04..a6e57cd21 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app80/SpringDocApp80Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app80/SpringDocApp80Test.java @@ -24,13 +24,13 @@ package test.org.springdoc.api.v31.app80; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.test.context.ActiveProfiles; @ActiveProfiles("80") -public class SpringDocApp80Test extends AbstractSpringDocV31Test { +public class SpringDocApp80Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app81/SpringDocApp81Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app81/SpringDocApp81Test.java index 6d6e86d0f..fcfa5af68 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app81/SpringDocApp81Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app81/SpringDocApp81Test.java @@ -26,7 +26,7 @@ import org.junit.jupiter.api.Test; import org.springdoc.core.utils.Constants; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; @@ -37,7 +37,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; -public class SpringDocApp81Test extends AbstractSpringDocV31Test { +public class SpringDocApp81Test extends AbstractSpringDocTest { @Test protected void testApp() throws Exception { diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app82/SpringDocApp82Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app82/SpringDocApp82Test.java index f37ee6793..8acc948d9 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app82/SpringDocApp82Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app82/SpringDocApp82Test.java @@ -24,11 +24,11 @@ package test.org.springdoc.api.v31.app82; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; -public class SpringDocApp82Test extends AbstractSpringDocV31Test { +public class SpringDocApp82Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app83/SpringDocApp83Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app83/SpringDocApp83Test.java index 1092d262c..a458d41ac 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app83/SpringDocApp83Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app83/SpringDocApp83Test.java @@ -24,11 +24,11 @@ package test.org.springdoc.api.v31.app83; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; -public class SpringDocApp83Test extends AbstractSpringDocV31Test { +public class SpringDocApp83Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app84/SpringDocApp84Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app84/SpringDocApp84Test.java index 378619bc3..5492dd0d5 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app84/SpringDocApp84Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app84/SpringDocApp84Test.java @@ -24,11 +24,11 @@ package test.org.springdoc.api.v31.app84; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; -public class SpringDocApp84Test extends AbstractSpringDocV31Test { +public class SpringDocApp84Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app85/SpringDocApp85Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app85/SpringDocApp85Test.java index 5fea0fe0c..316be129b 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app85/SpringDocApp85Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app85/SpringDocApp85Test.java @@ -24,11 +24,11 @@ package test.org.springdoc.api.v31.app85; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; -public class SpringDocApp85Test extends AbstractSpringDocV31Test { +public class SpringDocApp85Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app86/SpringDocApp86Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app86/SpringDocApp86Test.java index 7d959e496..09a8b31d9 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app86/SpringDocApp86Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app86/SpringDocApp86Test.java @@ -24,7 +24,7 @@ package test.org.springdoc.api.v31.app86; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.test.context.TestPropertySource; @@ -32,7 +32,7 @@ @TestPropertySource(properties = { "springdoc.packagesToScan=test.org.springdoc.api.v31.app86", "springdoc.packagesToExclude=test.org.springdoc.api.v31.app86.test" }) -public class SpringDocApp86Test extends AbstractSpringDocV31Test { +public class SpringDocApp86Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app87/SpringDocApp87Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app87/SpringDocApp87Test.java index 305875fab..90532b8ef 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app87/SpringDocApp87Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app87/SpringDocApp87Test.java @@ -24,11 +24,11 @@ package test.org.springdoc.api.v31.app87; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; -public class SpringDocApp87Test extends AbstractSpringDocV31Test { +public class SpringDocApp87Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app88/SpringDocApp88Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app88/SpringDocApp88Test.java index b6e44b556..3f64cdbeb 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app88/SpringDocApp88Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app88/SpringDocApp88Test.java @@ -24,13 +24,13 @@ package test.org.springdoc.api.v31.app88; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.test.context.TestPropertySource; @TestPropertySource(properties = "springdoc.auto-tag-classes=false") -public class SpringDocApp88Test extends AbstractSpringDocV31Test { +public class SpringDocApp88Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app89/SpringDocApp89Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app89/SpringDocApp89Test.java index c89cfb36e..5d371964a 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app89/SpringDocApp89Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app89/SpringDocApp89Test.java @@ -26,7 +26,7 @@ import io.swagger.v3.oas.models.media.ObjectSchema; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.test.context.TestPropertySource; @@ -35,7 +35,7 @@ import static org.springdoc.core.utils.SpringDocUtils.getConfig; @TestPropertySource(properties = "springdoc.model-and-view-allowed=true") -public class SpringDocApp89Test extends AbstractSpringDocV31Test { +public class SpringDocApp89Test extends AbstractSpringDocTest { static { getConfig().replaceWithSchema(ModelAndView.class, new ObjectSchema()); diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app9/SpringDocApp9Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app9/SpringDocApp9Test.java index 737b8aa3a..8eca5dc7a 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app9/SpringDocApp9Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app9/SpringDocApp9Test.java @@ -22,13 +22,13 @@ package test.org.springdoc.api.v31.app9; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.test.context.TestPropertySource; @TestPropertySource(properties = "springdoc.remove-broken-reference-definitions=false") -public class SpringDocApp9Test extends AbstractSpringDocV31Test { +public class SpringDocApp9Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp { diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app90/SpringDocApp90Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app90/SpringDocApp90Test.java index 4cd61de46..4601c8d00 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app90/SpringDocApp90Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app90/SpringDocApp90Test.java @@ -25,8 +25,8 @@ package test.org.springdoc.api.v31.app90; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; -public class SpringDocApp90Test extends AbstractSpringDocV31Test { +public class SpringDocApp90Test extends AbstractSpringDocTest { } \ No newline at end of file diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app91/SpringDocApp91Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app91/SpringDocApp91Test.java index bba9b1674..78e550d68 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app91/SpringDocApp91Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app91/SpringDocApp91Test.java @@ -25,13 +25,13 @@ package test.org.springdoc.api.v31.app91; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.test.context.TestPropertySource; @TestPropertySource(properties = "springdoc.override-with-generic-response=false") -public class SpringDocApp91Test extends AbstractSpringDocV31Test { +public class SpringDocApp91Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app92/SpringDocApp92Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app92/SpringDocApp92Test.java index bf2c4fa88..ffbe38057 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app92/SpringDocApp92Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app92/SpringDocApp92Test.java @@ -25,11 +25,11 @@ package test.org.springdoc.api.v31.app92; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; -public class SpringDocApp92Test extends AbstractSpringDocV31Test { +public class SpringDocApp92Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app93/SpringDocApp93Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app93/SpringDocApp93Test.java index 135a61f4e..322381d80 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app93/SpringDocApp93Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app93/SpringDocApp93Test.java @@ -25,11 +25,11 @@ package test.org.springdoc.api.v31.app93; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; -public class SpringDocApp93Test extends AbstractSpringDocV31Test { +public class SpringDocApp93Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app94/SpringDocApp94Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app94/SpringDocApp94Test.java index 01677475b..9da963a94 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app94/SpringDocApp94Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app94/SpringDocApp94Test.java @@ -40,7 +40,7 @@ import org.springdoc.core.service.OpenAPIService; import org.springdoc.core.service.OperationService; import org.springdoc.webmvc.api.OpenApiWebMvcResource; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import test.org.springdoc.api.v31.app91.Greeting; import org.springframework.beans.BeansException; @@ -62,7 +62,7 @@ import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE; @TestPropertySource(properties = "springdoc.default-produces-media-type=application/json") -public class SpringDocApp94Test extends AbstractSpringDocV31Test { +public class SpringDocApp94Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp implements ApplicationContextAware { diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app95/SpringDocApp95Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app95/SpringDocApp95Test.java index 542c13970..20305eb2b 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app95/SpringDocApp95Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app95/SpringDocApp95Test.java @@ -25,13 +25,13 @@ package test.org.springdoc.api.v31.app95; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.test.context.ActiveProfiles; @ActiveProfiles("95") -public class SpringDocApp95Test extends AbstractSpringDocV31Test { +public class SpringDocApp95Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app96/SpringDocApp96Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app96/SpringDocApp96Test.java index 920025d73..496407c1b 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app96/SpringDocApp96Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app96/SpringDocApp96Test.java @@ -25,11 +25,11 @@ package test.org.springdoc.api.v31.app96; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; -public class SpringDocApp96Test extends AbstractSpringDocV31Test { +public class SpringDocApp96Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app97/SpringDocApp97Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app97/SpringDocApp97Test.java index 5b697407e..ab024ee98 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app97/SpringDocApp97Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app97/SpringDocApp97Test.java @@ -25,11 +25,11 @@ package test.org.springdoc.api.v31.app97; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; -public class SpringDocApp97Test extends AbstractSpringDocV31Test { +public class SpringDocApp97Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app98/SpringDocApp98Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app98/SpringDocApp98Test.java index c01a3567b..2fe0748b5 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app98/SpringDocApp98Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app98/SpringDocApp98Test.java @@ -26,11 +26,11 @@ import org.springdoc.core.utils.SpringDocUtils; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; -public class SpringDocApp98Test extends AbstractSpringDocV31Test { +public class SpringDocApp98Test extends AbstractSpringDocTest { static { SpringDocUtils.getConfig().addAnnotationsToIgnore(IgnoredAnnotationParameter.class); diff --git a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app99/SpringDocApp99Test.java b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app99/SpringDocApp99Test.java index 0fb89eb58..581da4173 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app99/SpringDocApp99Test.java +++ b/springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v31/app99/SpringDocApp99Test.java @@ -25,13 +25,13 @@ package test.org.springdoc.api.v31.app99; -import test.org.springdoc.api.v31.AbstractSpringDocV31Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.test.context.ActiveProfiles; @ActiveProfiles("99") -public class SpringDocApp99Test extends AbstractSpringDocV31Test { +public class SpringDocApp99Test extends AbstractSpringDocTest { @SpringBootApplication static class SpringDocTestApp {} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/resources/application-217.yml b/springdoc-openapi-starter-webmvc-api/src/test/resources/application-217.yml index 169c3e06c..eb7a49fd5 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/resources/application-217.yml +++ b/springdoc-openapi-starter-webmvc-api/src/test/resources/application-217.yml @@ -4,6 +4,7 @@ springdoc: display-name: Example Interfaces packages-to-scan: - test.org.springdoc.api.v30.app217 + - test.org.springdoc.api.v31.app217 open-api: info: title: Example Interfaces @@ -24,6 +25,7 @@ springdoc: display-name: User Interfaces packages-to-scan: - test.org.springdoc.api.v30.app217 + - test.org.springdoc.api.v31.app217 open-api: info: title: User Interfaces diff --git a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app1.json b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app1.json index 72ec88a1f..27d5cdfab 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app1.json +++ b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app1.json @@ -87,6 +87,10 @@ "content": { "application/x-www-form-urlencoded": { "schema": { + "required": [ + "firstName", + "lastName" + ], "type": "object", "properties": { "firstName": { @@ -97,11 +101,7 @@ "type": "string", "description": "Last Name" } - }, - "required": [ - "firstName", - "lastName" - ] + } } } } @@ -210,9 +210,9 @@ "in": "query", "required": true, "schema": { - "type": "string", "maxLength": 6, - "minLength": 4 + "minLength": 4, + "type": "string" } }, { @@ -220,10 +220,10 @@ "in": "query", "required": true, "schema": { - "type": "integer", - "format": "int32", "maximum": 6, - "minimum": 4 + "minimum": 4, + "type": "integer", + "format": "int32" } }, { @@ -231,6 +231,7 @@ "in": "query", "required": false, "schema": { + "type": "string", "format": "date-time", "example": "1970-01-01T00:00:00.000Z" } @@ -242,7 +243,9 @@ "explode": false, "schema": { "type": "array", - "items": {} + "items": { + "type": "string" + } } } ], @@ -337,9 +340,9 @@ "description": "number of records to skip for pagination", "required": true, "schema": { + "minimum": 0, "type": "integer", - "format": "int32", - "minimum": 0 + "format": "int32" } }, { @@ -348,10 +351,10 @@ "description": "maximum number of records to return", "required": true, "schema": { - "type": "integer", - "format": "int32", "maximum": 50, - "minimum": 0 + "minimum": 0, + "type": "integer", + "format": "int32" } } ], @@ -564,6 +567,12 @@ } }, "InventoryItem": { + "required": [ + "id", + "manufacturer", + "name", + "releaseDate" + ], "type": "object", "properties": { "id": { @@ -582,15 +591,12 @@ "manufacturer": { "$ref": "#/components/schemas/Manufacturer" } - }, - "required": [ - "id", - "manufacturer", - "name", - "releaseDate" - ] + } }, "Manufacturer": { + "required": [ + "name" + ], "type": "object", "properties": { "name": { @@ -605,10 +611,7 @@ "type": "string", "example": "408-867-5309" } - }, - "required": [ - "name" - ] + } }, "ItemDTO": { "type": "object", diff --git a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app10.json b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app10.json index c20537fa9..849627a53 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app10.json +++ b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app10.json @@ -46,7 +46,5 @@ } } }, - "components": { - - } -} \ No newline at end of file + "components": {} +} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app101.json b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app101.json index eea1fe64e..e2a1e07eb 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app101.json +++ b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app101.json @@ -1 +1,50 @@ -{"openapi":"3.1.0","info":{"title":"OpenAPI definition","version":"v0"},"servers":[{"url":"http://localhost","description":"Generated server url"}],"paths":{"/hello":{"get":{"tags":["hello-controller"],"operationId":"hello","responses":{"default":{"description":"default response","content":{"*/*":{"schema":{"$ref":"#/components/schemas/HelloDTO","description":"${test.app101.operation.hello.response.schema.description}"}}}}}}}},"components":{"schemas":{"HelloDTO":{"type":"object","description":"Description of schema of hello entity","properties":{"id":{"type":"string","description":"Description of schema of param id for api hello"}}}}}} +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/hello": { + "get": { + "tags": [ + "hello-controller" + ], + "operationId": "hello", + "responses": { + "default": { + "description": "default response", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/HelloDTO", + "description": "${test.app101.operation.hello.response.schema.description}" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "HelloDTO": { + "type": "object", + "description": "Description of schema of hello entity", + "properties": { + "id": { + "type": "string", + "description": "Description of schema of param id for api hello" + } + } + } + } + } +} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app105-1.json b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app105-1.json index fcc8b3feb..fd9d09128 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app105-1.json +++ b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app105-1.json @@ -23,53 +23,6 @@ } ], "paths": { - "/store/order": { - "post": { - "tags": [ - "store" - ], - "summary": "Place an order for a pet", - "operationId": "placeOrder", - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/Order" - } - } - }, - "required": true - }, - "responses": { - "400": { - "description": "Invalid Order", - "content": { - "*/*": { - "schema": { - "type": "object", - "additionalProperties": {} - } - } - } - }, - "200": { - "description": "successful operation", - "content": { - "application/xml": { - "schema": { - "$ref": "#/components/schemas/Order" - } - }, - "application/json": { - "schema": { - "$ref": "#/components/schemas/Order" - } - } - } - } - } - } - }, "/store/order/{orderId}": { "get": { "tags": [ @@ -84,10 +37,10 @@ "description": "ID of pet that needs to be fetched", "required": true, "schema": { - "type": "integer", - "format": "int64", "maximum": 5, - "minimum": 1 + "minimum": 1, + "type": "integer", + "format": "int64" } } ], @@ -98,13 +51,15 @@ "*/*": { "schema": { "type": "object", - "additionalProperties": {} + "additionalProperties": { + "type": "object" + } } } } }, - "404": { - "description": "Order not found", + "200": { + "description": "successful operation", "content": { "application/xml": { "schema": { @@ -118,8 +73,8 @@ } } }, - "200": { - "description": "successful operation", + "404": { + "description": "Order not found", "content": { "application/xml": { "schema": { @@ -159,7 +114,9 @@ "*/*": { "schema": { "type": "object", - "additionalProperties": {} + "additionalProperties": { + "type": "object" + } } } } @@ -170,6 +127,55 @@ } } }, + "/store/order": { + "post": { + "tags": [ + "store" + ], + "summary": "Place an order for a pet", + "operationId": "placeOrder", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Order" + } + } + }, + "required": true + }, + "responses": { + "400": { + "description": "Invalid Order", + "content": { + "*/*": { + "schema": { + "type": "object", + "additionalProperties": { + "type": "object" + } + } + } + } + }, + "200": { + "description": "successful operation", + "content": { + "application/xml": { + "schema": { + "$ref": "#/components/schemas/Order" + } + }, + "application/json": { + "schema": { + "$ref": "#/components/schemas/Order" + } + } + } + } + } + } + }, "/store/inventory": { "get": { "tags": [ @@ -185,7 +191,9 @@ "*/*": { "schema": { "type": "object", - "additionalProperties": {} + "additionalProperties": { + "type": "object" + } } } } @@ -196,7 +204,9 @@ "application/json": { "schema": { "type": "array", - "items": {} + "items": { + "type": "string" + } } } } diff --git a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app105-2.json b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app105-2.json index e386419da..13b1cee9f 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app105-2.json +++ b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app105-2.json @@ -23,6 +23,126 @@ } ], "paths": { + "/user/createWithList": { + "post": { + "tags": [ + "user" + ], + "summary": "Creates list of users with given input array", + "operationId": "createUsersWithListInput", + "requestBody": { + "description": "List of user object", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/User" + } + } + } + }, + "required": true + }, + "responses": { + "400": { + "description": "Bad Request", + "content": { + "*/*": { + "schema": { + "type": "object", + "additionalProperties": { + "type": "object" + } + } + } + } + }, + "200": { + "description": "successful operation" + } + } + } + }, + "/user/createWithArray": { + "post": { + "tags": [ + "user" + ], + "summary": "Creates list of users with given input array", + "operationId": "createUsersWithArrayInput", + "requestBody": { + "description": "List of user object", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/User" + } + } + } + }, + "required": true + }, + "responses": { + "400": { + "description": "Bad Request", + "content": { + "*/*": { + "schema": { + "type": "object", + "additionalProperties": { + "type": "object" + } + } + } + } + }, + "200": { + "description": "successful operation" + } + } + } + }, + "/user": { + "post": { + "tags": [ + "user" + ], + "summary": "Create user", + "operationId": "createUser", + "requestBody": { + "description": "Created user object", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/User" + } + } + }, + "required": true + }, + "responses": { + "400": { + "description": "Bad Request", + "content": { + "*/*": { + "schema": { + "type": "object", + "additionalProperties": { + "type": "object" + } + } + } + } + }, + "200": { + "description": "successful operation" + } + } + } + }, "/user/{username}": { "get": { "tags": [ @@ -48,7 +168,9 @@ "*/*": { "schema": { "type": "object", - "additionalProperties": {} + "additionalProperties": { + "type": "object" + } } } } @@ -120,7 +242,9 @@ "*/*": { "schema": { "type": "object", - "additionalProperties": {} + "additionalProperties": { + "type": "object" + } } } } @@ -153,121 +277,9 @@ "*/*": { "schema": { "type": "object", - "additionalProperties": {} - } - } - } - }, - "200": { - "description": "successful operation" - } - } - } - }, - "/user": { - "post": { - "tags": [ - "user" - ], - "summary": "Create user", - "operationId": "createUser", - "requestBody": { - "description": "Created user object", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/User" - } - } - }, - "required": true - }, - "responses": { - "400": { - "description": "Bad Request", - "content": { - "*/*": { - "schema": { - "type": "object", - "additionalProperties": {} - } - } - } - }, - "200": { - "description": "successful operation" - } - } - } - }, - "/user/createWithList": { - "post": { - "tags": [ - "user" - ], - "summary": "Creates list of users with given input array", - "operationId": "createUsersWithListInput", - "requestBody": { - "description": "List of user object", - "content": { - "application/json": { - "schema": { - "type": "array", - "items": { - "$ref": "#/components/schemas/User" - } - } - } - }, - "required": true - }, - "responses": { - "400": { - "description": "Bad Request", - "content": { - "*/*": { - "schema": { - "type": "object", - "additionalProperties": {} - } - } - } - }, - "200": { - "description": "successful operation" - } - } - } - }, - "/user/createWithArray": { - "post": { - "tags": [ - "user" - ], - "summary": "Creates list of users with given input array", - "operationId": "createUsersWithArrayInput", - "requestBody": { - "description": "List of user object", - "content": { - "application/json": { - "schema": { - "type": "array", - "items": { - "$ref": "#/components/schemas/User" - } - } - } - }, - "required": true - }, - "responses": { - "400": { - "description": "Bad Request", - "content": { - "*/*": { - "schema": { - "type": "object", - "additionalProperties": {} + "additionalProperties": { + "type": "object" + } } } } @@ -292,7 +304,9 @@ "*/*": { "schema": { "type": "object", - "additionalProperties": {} + "additionalProperties": { + "type": "object" + } } } } @@ -337,7 +351,9 @@ "*/*": { "schema": { "type": "object", - "additionalProperties": {} + "additionalProperties": { + "type": "object" + } } } } @@ -390,8 +406,8 @@ }, "userStatus": { "type": "integer", - "format": "int32", - "description": "User Status" + "description": "User Status", + "format": "int32" } } } diff --git a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app105-3.json b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app105-3.json index 12f49ef26..661ff52b7 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app105-3.json +++ b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app105-3.json @@ -53,7 +53,9 @@ "*/*": { "schema": { "type": "object", - "additionalProperties": {} + "additionalProperties": { + "type": "object" + } } } } @@ -103,7 +105,9 @@ "*/*": { "schema": { "type": "object", - "additionalProperties": {} + "additionalProperties": { + "type": "object" + } } } } @@ -149,13 +153,15 @@ "*/*": { "schema": { "type": "object", - "additionalProperties": {} + "additionalProperties": { + "type": "object" + } } } } }, - "404": { - "description": "Pet not found", + "200": { + "description": "successful operation", "content": { "application/xml": { "schema": { @@ -169,8 +175,8 @@ } } }, - "200": { - "description": "successful operation", + "404": { + "description": "Pet not found", "content": { "application/xml": { "schema": { @@ -235,7 +241,9 @@ "*/*": { "schema": { "type": "object", - "additionalProperties": {} + "additionalProperties": { + "type": "object" + } } } } @@ -286,7 +294,9 @@ "*/*": { "schema": { "type": "object", - "additionalProperties": {} + "additionalProperties": { + "type": "object" + } } } } @@ -337,17 +347,17 @@ "content": { "multipart/form-data": { "schema": { + "required": [ + "file" + ], "type": "object", "properties": { "file": { "type": "string", - "format": "binary", - "description": "file detail" + "description": "file detail", + "format": "binary" } - }, - "required": [ - "file" - ] + } } } } @@ -359,7 +369,9 @@ "*/*": { "schema": { "type": "object", - "additionalProperties": {} + "additionalProperties": { + "type": "object" + } } } } @@ -414,7 +426,9 @@ "*/*": { "schema": { "type": "object", - "additionalProperties": {} + "additionalProperties": { + "type": "object" + } } } } @@ -480,7 +494,9 @@ "*/*": { "schema": { "type": "object", - "additionalProperties": {} + "additionalProperties": { + "type": "object" + } } } } @@ -533,6 +549,10 @@ } }, "Pet": { + "required": [ + "name", + "photoUrls" + ], "type": "object", "properties": { "id": { @@ -567,11 +587,7 @@ "sold" ] } - }, - "required": [ - "name", - "photoUrls" - ] + } }, "Tag": { "type": "object", diff --git a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app105-4.json b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app105-4.json index 71f333acb..f393a5154 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app105-4.json +++ b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app105-4.json @@ -46,7 +46,9 @@ "*/*": { "schema": { "type": "object", - "additionalProperties": {} + "additionalProperties": { + "type": "object" + } } } } diff --git a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app106.json b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app106.json index 58a416c8c..4caa60636 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app106.json +++ b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app106.json @@ -25,6 +25,7 @@ "description": "DateTime", "required": false, "schema": { + "type": "string", "format": "date-time" }, "example": "2020-01-01T00:00:00.000Z" diff --git a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app108.json b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app108.json index c6640eaaf..e25da4126 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app108.json +++ b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app108.json @@ -1 +1,72 @@ -{"openapi":"3.1.0","info":{"title":"OpenAPI definition","version":"v0"},"servers":[{"url":"http://localhost","description":"Generated server url"}],"paths":{"/":{"post":{"tags":["hello-controller"],"operationId":"update","parameters":[{"name":"toto","in":"query","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"OK","content":{"*/*":{"schema":{"$ref":"#/components/schemas/ActionResultVoid"}}}}}}}},"components":{"schemas":{"ActionResultVoid":{"type":"object","properties":{"value":{"type":"object"},"success":{"type":"boolean"},"errorCode":{"type":"string"},"message":{"type":"string"},"errorValue":{},"targetUrl":{"type":"string"}}}}}} +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/": { + "post": { + "tags": [ + "hello-controller" + ], + "operationId": "update", + "parameters": [ + { + "name": "toto", + "in": "query", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/ActionResultVoid" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "ActionResultVoid": { + "type": "object", + "properties": { + "value": { + "type": "object" + }, + "success": { + "type": "boolean" + }, + "errorCode": { + "type": "string" + }, + "message": { + "type": "string" + }, + "errorValue": { + "type": "object" + }, + "targetUrl": { + "type": "string" + } + } + } + } + } +} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app109.json b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app109.json index bcc81417a..f54c1edb9 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app109.json +++ b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app109.json @@ -1 +1,58 @@ -{"openapi":"3.1.0","info":{"title":"OpenAPI definition","version":"v0"},"servers":[{"url":"http://localhost","description":"Generated server url"}],"paths":{"/api/v1/resource":{"get":{"tags":["hello-controller"],"operationId":"getResource","responses":{"200":{"description":"OK","content":{"*/*":{"schema":{"type":"string","format":"binary"}}}}}}},"/api/v1/bytearray":{"get":{"tags":["hello-controller"],"operationId":"getByteArray","responses":{"default":{"description":"default response","content":{"*/*":{"schema":{"format":"binary"}}}}}}}},"components":{}} +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/api/v1/resource": { + "get": { + "tags": [ + "hello-controller" + ], + "operationId": "getResource", + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "string", + "format": "binary" + } + } + } + } + } + } + }, + "/api/v1/bytearray": { + "get": { + "tags": [ + "hello-controller" + ], + "operationId": "getByteArray", + "responses": { + "default": { + "description": "default response", + "content": { + "*/*": { + "schema": { + "type": "string", + "format": "binary" + } + } + } + } + } + } + } + }, + "components": {} +} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app115.json b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app115.json index 79dea40bf..f3685cb97 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app115.json +++ b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app115.json @@ -23,7 +23,7 @@ "content": { "application/json": { "schema": { - "type": "object", + "type": "string", "properties": {} } } diff --git a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app118.json b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app118.json index 1592778dc..297312880 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app118.json +++ b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app118.json @@ -1 +1,223 @@ -{"openapi":"3.1.0","info":{"title":"OpenAPI definition","version":"v0"},"servers":[{"url":"http://localhost","description":"Generated server url"}],"paths":{"/class-hierarchy/concrete-parent":{"post":{"tags":["controller"],"operationId":"concreteParent","requestBody":{"content":{"application/json":{"schema":{"oneOf":[{"$ref":"#/components/schemas/ConcreteParent"},{"$ref":"#/components/schemas/ChildOfConcrete1"},{"$ref":"#/components/schemas/ChildOfConcrete2"}]}}},"required":true},"responses":{"200":{"description":"OK","content":{"*/*":{"schema":{"$ref":"#/components/schemas/Response"}}}}}}},"/class-hierarchy/abstract-parent":{"post":{"tags":["controller"],"operationId":"abstractParent","requestBody":{"content":{"application/json":{"schema":{"oneOf":[{"$ref":"#/components/schemas/ChildOfAbstract1"},{"$ref":"#/components/schemas/ChildOfAbstract2"}]}}},"required":true},"responses":{"200":{"description":"OK","content":{"*/*":{"schema":{"$ref":"#/components/schemas/Response"}}}}}}}},"components":{"schemas":{"ChildOfConcrete1":{"allOf":[{"$ref":"#/components/schemas/ConcreteParent"},{"type":"object","properties":{"concreteChild1Param":{"type":"string"}}}]},"ChildOfConcrete2":{"allOf":[{"$ref":"#/components/schemas/ConcreteParent"},{"type":"object","properties":{"concreteChild2Param":{"type":"string"}}}]},"ConcreteParent":{"type":"object","discriminator":{"propertyName":"type"},"properties":{"id":{"type":"integer","format":"int32"},"type":{"type":"string"}},"required":["type"]},"AbstractParent":{"type":"object","discriminator":{"propertyName":"type"},"properties":{"id":{"type":"integer","format":"int32"},"type":{"type":"string"}},"required":["type"]},"ChildOfAbstract1":{"allOf":[{"$ref":"#/components/schemas/AbstractParent"},{"type":"object","properties":{"abstrachChild1Param":{"type":"string"}}}]},"ChildOfAbstract2":{"allOf":[{"$ref":"#/components/schemas/AbstractParent"},{"type":"object","properties":{"abstractChild2Param":{"type":"string"}}}]},"Response":{"type":"object","properties":{"abstractParent":{"oneOf":[{"$ref":"#/components/schemas/ChildOfAbstract1"},{"$ref":"#/components/schemas/ChildOfAbstract2"}]},"concreteParents":{"type":"array","items":{"oneOf":[{"$ref":"#/components/schemas/ConcreteParent"},{"$ref":"#/components/schemas/ChildOfConcrete1"},{"$ref":"#/components/schemas/ChildOfConcrete2"}]}}}}}}} +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/class-hierarchy/concrete-parent": { + "post": { + "tags": [ + "controller" + ], + "operationId": "concreteParent", + "requestBody": { + "content": { + "application/json": { + "schema": { + "oneOf": [ + { + "$ref": "#/components/schemas/ConcreteParent" + }, + { + "$ref": "#/components/schemas/ChildOfConcrete1" + }, + { + "$ref": "#/components/schemas/ChildOfConcrete2" + } + ] + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/Response" + } + } + } + } + } + } + }, + "/class-hierarchy/abstract-parent": { + "post": { + "tags": [ + "controller" + ], + "operationId": "abstractParent", + "requestBody": { + "content": { + "application/json": { + "schema": { + "oneOf": [ + { + "$ref": "#/components/schemas/ChildOfAbstract1" + }, + { + "$ref": "#/components/schemas/ChildOfAbstract2" + } + ] + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/Response" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "ChildOfConcrete1": { + "allOf": [ + { + "$ref": "#/components/schemas/ConcreteParent" + }, + { + "type": "object", + "properties": { + "concreteChild1Param": { + "type": "string" + } + } + } + ] + }, + "ChildOfConcrete2": { + "allOf": [ + { + "$ref": "#/components/schemas/ConcreteParent" + }, + { + "type": "object", + "properties": { + "concreteChild2Param": { + "type": "string" + } + } + } + ] + }, + "ConcreteParent": { + "type": "object", + "discriminator": { + "propertyName": "type" + }, + "properties": { + "id": { + "type": "integer", + "format": "int32" + }, + "type": { + "type": "string" + } + }, + "required": [ + "type" + ] + }, + "AbstractParent": { + "type": "object", + "discriminator": { + "propertyName": "type" + }, + "properties": { + "id": { + "type": "integer", + "format": "int32" + }, + "type": { + "type": "string" + } + }, + "required": [ + "type" + ] + }, + "ChildOfAbstract1": { + "allOf": [ + { + "$ref": "#/components/schemas/AbstractParent" + }, + { + "type": "object", + "properties": { + "abstrachChild1Param": { + "type": "string" + } + } + } + ] + }, + "ChildOfAbstract2": { + "allOf": [ + { + "$ref": "#/components/schemas/AbstractParent" + }, + { + "type": "object", + "properties": { + "abstractChild2Param": { + "type": "string" + } + } + } + ] + }, + "Response": { + "type": "object", + "properties": { + "abstractParent": { + "oneOf": [ + { + "$ref": "#/components/schemas/ChildOfAbstract1" + }, + { + "$ref": "#/components/schemas/ChildOfAbstract2" + } + ] + }, + "concreteParents": { + "type": "array", + "items": { + "oneOf": [ + { + "$ref": "#/components/schemas/ConcreteParent" + }, + { + "$ref": "#/components/schemas/ChildOfConcrete1" + }, + { + "$ref": "#/components/schemas/ChildOfConcrete2" + } + ] + } + } + } + } + } + } +} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app123.json b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app123.json index e0df022c4..092050ac2 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app123.json +++ b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app123.json @@ -37,22 +37,26 @@ } ], "responses": { - "404": { - "description": "Not here" - }, "502": { "description": "Bad Gateway", "content": { "*/*": { - "schema": {} + "schema": { + "type": "object" + } } } }, + "404": { + "description": "Not here" + }, "418": { "description": "I'm a teapot", "content": { "*/*": { - "schema": {} + "schema": { + "type": "object" + } } } } diff --git a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app124.json b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app124.json index c7b77c0d0..092050ac2 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app124.json +++ b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app124.json @@ -1 +1,68 @@ -{"openapi":"3.1.0","info":{"title":"OpenAPI definition","version":"v0"},"servers":[{"url":"http://localhost","description":"Generated server url"}],"paths":{"/hello/{numTelco}":{"get":{"tags":["hello-controller"],"summary":"GET Persons","operationId":"index","parameters":[{"name":"numTelco","in":"path","required":true,"schema":{"type":"string"}},{"name":"adresse","in":"query","required":true,"schema":{"type":"string"}}],"responses":{"404":{"description":"Not here"},"502":{"description":"Bad Gateway","content":{"*/*":{"schema":{}}}},"418":{"description":"I'm a teapot","content":{"*/*":{"schema":{}}}}}}}},"components":{}} +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/hello/{numTelco}": { + "get": { + "tags": [ + "hello-controller" + ], + "summary": "GET Persons", + "operationId": "index", + "parameters": [ + { + "name": "numTelco", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "adresse", + "in": "query", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "502": { + "description": "Bad Gateway", + "content": { + "*/*": { + "schema": { + "type": "object" + } + } + } + }, + "404": { + "description": "Not here" + }, + "418": { + "description": "I'm a teapot", + "content": { + "*/*": { + "schema": { + "type": "object" + } + } + } + } + } + } + } + }, + "components": {} +} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app126.json b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app126.json index d330aab33..a20e02a5f 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app126.json +++ b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app126.json @@ -58,17 +58,19 @@ }, "parameters": { "type": "object", - "additionalProperties": {} + "additionalProperties": { + "type": "object" + } + }, + "status": { + "type": "integer", + "format": "int32" }, "title": { "type": "string" }, "detail": { "type": "string" - }, - "status": { - "type": "integer", - "format": "int32" } } } diff --git a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app133.json b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app133.json index ef679bb99..41b2012aa 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app133.json +++ b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app133.json @@ -11,19 +11,25 @@ } ], "paths": { - "/test3": { + "/test1": { "get": { "tags": [ "hello-controller" ], - "operationId": "getMessageFromHeader3", + "operationId": "getMessageFromHeader1", "parameters": [ { "name": "myHeader", "in": "header", "description": "A header", "required": true, - "schema": {} + "schema": { + "type": "string", + "enum": [ + "foo", + "bar" + ] + } } ], "responses": { @@ -52,7 +58,9 @@ "in": "header", "description": "A header", "required": true, - "schema": {} + "schema": { + "type": "integer" + } } ], "responses": { @@ -69,12 +77,12 @@ } } }, - "/test1": { + "/test3": { "get": { "tags": [ "hello-controller" ], - "operationId": "getMessageFromHeader1", + "operationId": "getMessageFromHeader3", "parameters": [ { "name": "myHeader", @@ -82,10 +90,7 @@ "description": "A header", "required": true, "schema": { - "enum": [ - "foo", - "bar" - ] + "type": "integer" } } ], diff --git a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app138.json b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app138.json index 29733ee9b..066691692 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app138.json +++ b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app138.json @@ -1 +1 @@ -{"openapi":"3.1.0","info":{"title":"OpenAPI definition","version":"v0"},"servers":[{"url":"http://localhost","description":"Generated server url"}],"paths":{"/testA":{"get":{"operationId":"testA","parameters":[{"in":"query","name":"hello","required":true,"schema":{"type":["string"],"example":null}}],"responses":{"200":{"description":"OK"}},"tags":["hello-controller"]}},"/testB":{"get":{"operationId":"testB","parameters":[{"in":"query","name":"hello","required":true,"schema":{"type":["string"],"example":null}}],"responses":{"200":{"description":"OK"}},"tags":["hello-controller"]}}},"components":{},"x-my-vendor-extensions":{"property1":"value1","property2":null}} \ No newline at end of file +{"openapi":"3.1.0","info":{"title":"OpenAPI definition","version":"v0"},"servers":[{"url":"http://localhost","description":"Generated server url"}],"paths":{"/testA":{"get":{"operationId":"testA","parameters":[{"in":"query","name":"hello","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"OK"}},"tags":["hello-controller"]}},"/testB":{"get":{"operationId":"testB","parameters":[{"in":"query","name":"hello","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"OK"}},"tags":["hello-controller"]}}},"components":{},"x-my-vendor-extensions":{"property1":"value1","property2":null}} \ No newline at end of file diff --git a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app143.json b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app143.json index 317ac46a4..394ce3f0d 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app143.json +++ b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app143.json @@ -1 +1,120 @@ -{"openapi":"3.1.0","info":{"title":"OpenAPI definition","version":"v0"},"servers":[{"url":"http://localhost","description":"Generated server url"}],"tags":[{"name":"Actuator","description":"Monitor and interact","externalDocs":{"description":"Spring Boot Actuator Web API Documentation","url":"https://docs.spring.io/spring-boot/docs/current/actuator-api/html/"}}],"paths":{"/actuator":{"get":{"tags":["Actuator"],"summary":"Actuator root web endpoint","operationId":"links","responses":{"200":{"description":"OK","content":{"application/vnd.spring-boot.actuator.v3+json":{"schema":{"type":"object","additionalProperties":{"type":"object","additionalProperties":{"$ref":"#/components/schemas/Link"}}}},"application/vnd.spring-boot.actuator.v2+json":{"schema":{"type":"object","additionalProperties":{"type":"object","additionalProperties":{"$ref":"#/components/schemas/Link"}}}},"application/json":{"schema":{"type":"object","additionalProperties":{"type":"object","additionalProperties":{"$ref":"#/components/schemas/Link"}}}}}}}}},"/actuator/health":{"get":{"tags":["Actuator"],"summary":"Actuator web endpoint 'health'","operationId":"health","responses":{"200":{"description":"OK","content":{"application/vnd.spring-boot.actuator.v3+json":{"schema":{}},"application/vnd.spring-boot.actuator.v2+json":{"schema":{}},"application/json":{"schema":{}}}}}}}},"components":{"schemas":{"Link":{"type":"object","properties":{"href":{"type":"string"},"templated":{"type":"boolean"}}}}}} +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "Actuator", + "description": "Monitor and interact", + "externalDocs": { + "description": "Spring Boot Actuator Web API Documentation", + "url": "https://docs.spring.io/spring-boot/docs/current/actuator-api/html/" + } + } + ], + "paths": { + "/actuator": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator root web endpoint", + "operationId": "links", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object", + "additionalProperties": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/Link" + } + } + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object", + "additionalProperties": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/Link" + } + } + } + }, + "application/json": { + "schema": { + "type": "object", + "additionalProperties": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/Link" + } + } + } + } + } + } + } + } + }, + "/actuator/health": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'health'", + "operationId": "health", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "Link": { + "type": "object", + "properties": { + "href": { + "type": "string" + }, + "templated": { + "type": "boolean" + } + } + } + } + } +} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app150.json b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app150.json index f6cba6c41..87be08a80 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app150.json +++ b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app150.json @@ -48,13 +48,13 @@ "required": false, "schema": { "type": "array", + "items": { + "type": "string" + }, "default": [ "users", "123" - ], - "items": { - "type": "string" - } + ] } } ], @@ -77,6 +77,7 @@ "in": "query", "required": true, "schema": { + "type": "boolean", "default": false } } diff --git a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app153.json b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app153.json index f2b2c06ae..fe556ae12 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app153.json +++ b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app153.json @@ -1 +1,51 @@ -{"openapi":"3.1.0","info":{"title":"OpenAPI definition","version":"v0"},"servers":[{"url":"http://localhost","description":"Generated server url"}],"paths":{"/orders":{"get":{"tags":["test-controller"],"operationId":"method","parameters":[{"name":"state","in":"query","required":false,"schema":{"type":"string","default":"finished","enum":["finished","new"]}}],"responses":{"200":{"description":"OK","content":{"*/*":{"schema":{}}}}}}}},"components":{}} +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/orders": { + "get": { + "tags": [ + "test-controller" + ], + "operationId": "method", + "parameters": [ + { + "name": "state", + "in": "query", + "required": false, + "schema": { + "type": "string", + "enum": [ + "finished", + "new" + ], + "default": "finished" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "object" + } + } + } + } + } + } + } + }, + "components": {} +} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app154.json b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app154.json index bc0505787..c6e6cc6d5 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app154.json +++ b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app154.json @@ -1 +1,172 @@ -{"openapi":"3.1.0","info":{"title":"toto","version":"1.0"},"servers":[{"url":"http://localhost","description":"Generated server url"}],"security":[{"basicAuth":[]},{"bearerToken":[]}],"paths":{"/personsone":{"post":{"tags":["hello-controller"],"operationId":"createone","parameters":[{"name":"id","in":"query","required":true,"schema":{"type":"integer","format":"int64"}}],"requestBody":{"content":{"application/json":{"schema":{}}},"required":true},"responses":{"200":{"description":"OK"}}}},"/persons":{"post":{"tags":["hello-controller"],"operationId":"create","parameters":[{"name":"id","in":"query","required":true,"schema":{"type":"integer","format":"int64"}}],"requestBody":{"content":{"application/json":{"schema":{}}},"required":true},"responses":{"200":{"description":"OK"}}}},"/createtwo":{"post":{"tags":["hello-controller"],"operationId":"createtwo","parameters":[{"name":"id","in":"query","required":true,"schema":{"type":"integer","format":"int32"}}],"responses":{"200":{"description":"OK"}}}},"/createthree":{"post":{"tags":["hello-controller"],"operationId":"createthree","parameters":[{"name":"id","in":"query","required":true,"schema":{"type":"integer","format":"int32"}}],"responses":{"200":{"description":"OK"}}}},"/":{"get":{"tags":["hello-controller"],"operationId":"hello","responses":{"200":{"description":"OK","content":{"*/*":{"schema":{"type":"string"}}}}}}}},"components":{"securitySchemes":{"bearerToken":{"type":"http","scheme":"bearer","bearerFormat":"JWT"},"basicAuth":{"type":"http","scheme":"basic"}}}} +{ + "openapi": "3.1.0", + "info": { + "title": "toto", + "version": "1.0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "security": [ + { + "basicAuth": [] + }, + { + "bearerToken": [] + } + ], + "paths": { + "/personsone": { + "post": { + "tags": [ + "hello-controller" + ], + "operationId": "createone", + "parameters": [ + { + "name": "id", + "in": "query", + "required": true, + "schema": { + "type": "integer", + "format": "int64" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "object" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "OK" + } + } + } + }, + "/persons": { + "post": { + "tags": [ + "hello-controller" + ], + "operationId": "create", + "parameters": [ + { + "name": "id", + "in": "query", + "required": true, + "schema": { + "type": "integer", + "format": "int64" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "object" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "OK" + } + } + } + }, + "/createtwo": { + "post": { + "tags": [ + "hello-controller" + ], + "operationId": "createtwo", + "parameters": [ + { + "name": "id", + "in": "query", + "required": true, + "schema": { + "type": "integer", + "format": "int32" + } + } + ], + "responses": { + "200": { + "description": "OK" + } + } + } + }, + "/createthree": { + "post": { + "tags": [ + "hello-controller" + ], + "operationId": "createthree", + "parameters": [ + { + "name": "id", + "in": "query", + "required": true, + "schema": { + "type": "integer", + "format": "int32" + } + } + ], + "responses": { + "200": { + "description": "OK" + } + } + } + }, + "/": { + "get": { + "tags": [ + "hello-controller" + ], + "operationId": "hello", + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + } + }, + "components": { + "securitySchemes": { + "bearerToken": { + "type": "http", + "scheme": "bearer", + "bearerFormat": "JWT" + }, + "basicAuth": { + "type": "http", + "scheme": "basic" + } + } + } +} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app155.json b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app155.json index 50d513314..1ec6f0b6a 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app155.json +++ b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app155.json @@ -90,6 +90,7 @@ "in": "query", "required": false, "schema": { + "type": "string", "enum": [ "ONE", "TWO" diff --git a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app156.json b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app156.json index 71cfa6b19..f95ffc308 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app156.json +++ b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app156.json @@ -48,7 +48,9 @@ "name": "someText", "in": "query", "description": "Second decs", - "schema": {} + "schema": { + "type": "string" + } } ], "responses": { diff --git a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app157.json b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app157.json index 2df4c0fd2..cf4bea57e 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app157.json +++ b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app157.json @@ -1,8 +1,8 @@ { "openapi": "3.1.0", "info": { - "title": "OpenAPI definition", - "version": "v0" + "title": "API Examples", + "version": "1.0" }, "servers": [ { @@ -10,40 +10,35 @@ "description": "Generated server url" } ], + "tags": [ + { + "name": "Operations" + } + ], "paths": { - "/foo": { + "/api/foo": { "get": { "tags": [ "hello-controller" ], - "operationId": "getFoo", + "operationId": "hello", "responses": { - "200": { - "description": "OK", + "409": { + "description": "Conflict", "content": { "*/*": { "schema": { - "$ref": "#/components/schemas/Foo" + "$ref": "#/components/schemas/ErrorDTO" } } } - } - } - } - }, - "/bar": { - "get": { - "tags": [ - "hello-controller" - ], - "operationId": "getBar", - "responses": { + }, "200": { "description": "OK", "content": { "*/*": { "schema": { - "$ref": "#/components/schemas/Bar" + "$ref": "#/components/schemas/SimpleDTO" } } } @@ -54,21 +49,20 @@ }, "components": { "schemas": { - "Foo": { + "ErrorDTO": { "type": "object", "properties": { - "child": { + "message": { "type": "string" } - }, - "required": [ - "stringy" - ] + } }, - "Bar": { + "SimpleDTO": { "type": "object", "properties": { - "child": {} + "payload": { + "type": "string" + } } } } diff --git a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app164.json b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app164.json index e747ff02b..9ffea82bc 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app164.json +++ b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app164.json @@ -52,7 +52,7 @@ "listBlah": { "type": "array", "items": { - "description": "${blahDescription.value}" + "description": "test" } } } diff --git a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app168.json b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app168.json index d8126e7bb..dcf6f53d0 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app168.json +++ b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app168.json @@ -75,10 +75,10 @@ "components": { "schemas": { "ConcreteParent": { + "required": [ + "type" + ], "type": "object", - "discriminator": { - "propertyName": "type" - }, "properties": { "id": { "type": "integer", @@ -88,15 +88,15 @@ "type": "string" } }, - "required": [ - "type" - ] + "discriminator": { + "propertyName": "type" + } }, "AbstractParent": { + "required": [ + "type" + ], "type": "object", - "discriminator": { - "propertyName": "type" - }, "properties": { "id": { "type": "integer", @@ -106,9 +106,9 @@ "type": "string" } }, - "required": [ - "type" - ] + "discriminator": { + "propertyName": "type" + } }, "Response": { "type": "object", @@ -126,4 +126,4 @@ } } } -} +} \ No newline at end of file diff --git a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app177-1.json b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app177-1.json index 8594622ac..0b0365e20 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app177-1.json +++ b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app177-1.json @@ -51,4 +51,4 @@ } }, "components": {} -} +} \ No newline at end of file diff --git a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app177-2.json b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app177-2.json index 659051922..99e914caa 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app177-2.json +++ b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app177-2.json @@ -33,4 +33,4 @@ } }, "components": {} -} +} \ No newline at end of file diff --git a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app177-3.json b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app177-3.json index 0f76a96fc..f060a7a7c 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app177-3.json +++ b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app177-3.json @@ -69,4 +69,4 @@ } }, "components": {} -} +} \ No newline at end of file diff --git a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app180.json b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app180.json index bb6457b04..2596d5e9a 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app180.json +++ b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app180.json @@ -79,6 +79,7 @@ "Body": { "type": "object", "additionalProperties": { + "type": "object", "description": "Body", "example": { "key": "value" diff --git a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app182.json b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app182.json index c7b77c0d0..11b8af150 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app182.json +++ b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app182.json @@ -1 +1,68 @@ -{"openapi":"3.1.0","info":{"title":"OpenAPI definition","version":"v0"},"servers":[{"url":"http://localhost","description":"Generated server url"}],"paths":{"/hello/{numTelco}":{"get":{"tags":["hello-controller"],"summary":"GET Persons","operationId":"index","parameters":[{"name":"numTelco","in":"path","required":true,"schema":{"type":"string"}},{"name":"adresse","in":"query","required":true,"schema":{"type":"string"}}],"responses":{"404":{"description":"Not here"},"502":{"description":"Bad Gateway","content":{"*/*":{"schema":{}}}},"418":{"description":"I'm a teapot","content":{"*/*":{"schema":{}}}}}}}},"components":{}} +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/hello/{numTelco}": { + "get": { + "tags": [ + "hello-controller" + ], + "summary": "GET Persons", + "operationId": "index", + "parameters": [ + { + "name": "numTelco", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "adresse", + "in": "query", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "502": { + "description": "Bad Gateway", + "content": { + "*/*": { + "schema": { + "type": "object" + } + } + } + }, + "404": { + "description": "Not here" + }, + "418": { + "description": "I'm a teapot", + "content": { + "*/*": { + "schema": { + "type": "object" + } + } + } + } + } + } + } + }, + "components": {} +} \ No newline at end of file diff --git a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app188.json b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app188.json index b7d58f899..600c11506 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app188.json +++ b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app188.json @@ -1 +1,104 @@ -{"openapi":"3.1.0","info":{"title":"OpenAPI definition","version":"v0"},"servers":[{"url":"http://localhost","description":"Generated server url"}],"paths":{"/test":{"get":{"tags":["hello-controller"],"operationId":"test","responses":{"200":{"description":"OK"},"5xx":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}},"/example/{fooBar}":{"get":{"tags":["hello-controller"],"operationId":"getFooBar","parameters":[{"name":"fooBar","in":"path","required":true,"schema":{"type":"string","enum":["foo","bar"]}}],"responses":{"200":{"description":"OK","content":{"*/*":{"schema":{"type":"string"}}}},"5xx":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ErrorResponse"}}}}}}}},"components":{"schemas":{"ErrorResponse":{"properties":{"timestamp":{"type":"string","format":"date-time","example":"2022-05-09T00:00:00Z"},"data":{"type":"object","additionalProperties":{"type":"object","example":{"param1":"val1","param2":"val2"}},"example":{"param1":"val1","param2":"val2"}}}}}}} +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/test": { + "get": { + "tags": [ + "hello-controller" + ], + "operationId": "test", + "responses": { + "200": { + "description": "OK" + }, + "5xx": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + } + } + } + }, + "/example/{fooBar}": { + "get": { + "tags": [ + "hello-controller" + ], + "operationId": "getFooBar", + "parameters": [ + { + "name": "fooBar", + "in": "path", + "required": true, + "schema": { + "type": "string", + "enum": [ + "foo", + "bar" + ] + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + }, + "5xx": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "ErrorResponse": { + "type": "object", + "properties": { + "timestamp": { + "type": "string", + "format": "date-time", + "example": "2022-05-09T00:00:00.000Z" + }, + "data": { + "type": "object", + "additionalProperties": { + "type": "object" + }, + "example": { + "param1": "val1", + "param2": "val2" + } + } + } + } + } + } +} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app193-1.json b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app193-1.json index 2e5ae2d85..85c860f06 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app193-1.json +++ b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app193-1.json @@ -1 +1,150 @@ -{"openapi":"3.1.0","info":{"title":"OpenAPI definition","version":"v0"},"servers":[{"url":"http://localhost","description":"Generated server url"}],"paths":{"/test":{"get":{"tags":["basic-controller"],"summary":"get","description":"Provides a list of books.","operationId":"get","responses":{"200":{"description":"OK","content":{"*/*":{"schema":{"oneOf":[{"$ref":"#/components/schemas/Books"}]}}}}}}},"/test1":{"get":{"tags":["basic-controller"],"summary":"get1","description":"Provides an animal.","operationId":"get1","responses":{"200":{"description":"OK","content":{"*/*":{"schema":{"oneOf":[{"$ref":"#/components/schemas/Cat"},{"$ref":"#/components/schemas/Dog"}]}}}}}}}},"components":{"schemas":{"Book":{"type":"object","description":"Represents a Book.","properties":{"title":{"type":"string"}}},"Books":{"allOf":[{"$ref":"#/components/schemas/Knowledge"},{"type":"object","properties":{"empty":{"type":"boolean"},"first":{"$ref":"#/components/schemas/Book"},"last":{"$ref":"#/components/schemas/Book"}}}],"description":"Represents a list of Books."},"Knowledge":{"type":"object","description":"Represents the knowledge."},"Animal":{"type":"object","description":"Represents an Animal class."},"Cat":{"allOf":[{"$ref":"#/components/schemas/Animal"},{"type":"object","properties":{"speed":{"type":"integer","format":"int32"}}}],"description":"Represents a Cat class."},"Dog":{"allOf":[{"$ref":"#/components/schemas/Animal"},{"type":"object","properties":{"name":{"type":"string"},"age":{"type":"integer","format":"int32"}}}],"description":"Represents a Dog class."}}}} +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/test": { + "get": { + "tags": [ + "basic-controller" + ], + "summary": "get", + "description": "Provides a list of books.", + "operationId": "get", + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "oneOf": [ + { + "$ref": "#/components/schemas/Books" + } + ] + } + } + } + } + } + } + }, + "/test1": { + "get": { + "tags": [ + "basic-controller" + ], + "summary": "get1", + "description": "Provides an animal.", + "operationId": "get1", + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "oneOf": [ + { + "$ref": "#/components/schemas/Cat" + }, + { + "$ref": "#/components/schemas/Dog" + } + ] + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "Book": { + "type": "object", + "description": "Represents a Book.", + "properties": { + "title": { + "type": "string" + } + } + }, + "Books": { + "allOf": [ + { + "$ref": "#/components/schemas/Knowledge" + }, + { + "type": "object", + "properties": { + "empty": { + "type": "boolean" + }, + "first": { + "$ref": "#/components/schemas/Book" + }, + "last": { + "$ref": "#/components/schemas/Book" + } + } + } + ], + "description": "Represents a list of Books." + }, + "Knowledge": { + "type": "object", + "description": "Represents the knowledge." + }, + "Animal": { + "type": "object", + "description": "Represents an Animal class." + }, + "Cat": { + "allOf": [ + { + "$ref": "#/components/schemas/Animal" + }, + { + "type": "object", + "properties": { + "speed": { + "type": "integer", + "format": "int32" + } + } + } + ], + "description": "Represents a Cat class." + }, + "Dog": { + "allOf": [ + { + "$ref": "#/components/schemas/Animal" + }, + { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "age": { + "type": "integer", + "format": "int32" + } + } + } + ], + "description": "Represents a Dog class." + } + } + } +} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app196.json b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app196.json index 979345088..a5ca0bd5a 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app196.json +++ b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app196.json @@ -102,13 +102,19 @@ "description": "OK", "content": { "application/vnd.spring-boot.actuator.v3+json": { - "schema": {} + "schema": { + "type": "object" + } }, "application/vnd.spring-boot.actuator.v2+json": { - "schema": {} + "schema": { + "type": "object" + } }, "application/json": { - "schema": {} + "schema": { + "type": "object" + } } } } diff --git a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app197.json b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app197.json index e510d4be3..e16e5789c 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app197.json +++ b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app197.json @@ -18,6 +18,9 @@ ], "operationId": "index", "responses": { + "200": { + "description": "OK" + }, "400": { "description": "Bad Request", "content": { @@ -34,13 +37,12 @@ "*/*": { "schema": { "type": "object", - "additionalProperties": {} + "additionalProperties": { + "type": "object" + } } } } - }, - "200": { - "description": "OK" } } } @@ -52,6 +54,9 @@ ], "operationId": "index_1", "responses": { + "200": { + "description": "OK" + }, "404": { "description": "Not Found", "content": { @@ -68,13 +73,12 @@ "*/*": { "schema": { "type": "object", - "additionalProperties": {} + "additionalProperties": { + "type": "object" + } } } } - }, - "200": { - "description": "OK" } } } diff --git a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app198.json b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app198.json index d231502d1..06c29c3a0 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app198.json +++ b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app198.json @@ -1 +1,57 @@ -{"openapi":"3.1.0","info":{"title":"OpenAPI definition","version":"v0"},"servers":[{"url":"http://localhost","description":"Generated server url"}],"paths":{"/":{"get":{"tags":["hello-controller"],"operationId":"test","responses":{"200":{"description":"OK","content":{"*/*":{"schema":{"$ref":"#/components/schemas/Response"}}}}}}}},"components":{"schemas":{"Response":{"type":"object","properties":{"val1":{"format":"decimal","deprecated":true},"val2":{"format":"decimal"},"val3":{"format":"decimal"}}}}}} +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/": { + "get": { + "tags": [ + "hello-controller" + ], + "operationId": "test", + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/Response" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "Response": { + "type": "object", + "properties": { + "val1": { + "type": "string", + "format": "decimal", + "deprecated": true + }, + "val2": { + "type": "string", + "format": "decimal" + }, + "val3": { + "type": "string", + "format": "decimal" + } + } + } + } + } +} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app2.json b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app2.json index eb04abe53..e368e60b3 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app2.json +++ b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app2.json @@ -56,7 +56,9 @@ "*/*": { "schema": { "type": "object", - "additionalProperties": {} + "additionalProperties": { + "type": "object" + } } } } @@ -128,7 +130,9 @@ "*/*": { "schema": { "type": "object", - "additionalProperties": {} + "additionalProperties": { + "type": "object" + } } } } @@ -161,7 +165,9 @@ "*/*": { "schema": { "type": "object", - "additionalProperties": {} + "additionalProperties": { + "type": "object" + } } } } @@ -202,7 +208,9 @@ "*/*": { "schema": { "type": "object", - "additionalProperties": {} + "additionalProperties": { + "type": "object" + } } } } @@ -252,7 +260,9 @@ "*/*": { "schema": { "type": "object", - "additionalProperties": {} + "additionalProperties": { + "type": "object" + } } } } @@ -296,7 +306,9 @@ "*/*": { "schema": { "type": "object", - "additionalProperties": {} + "additionalProperties": { + "type": "object" + } } } } @@ -335,7 +347,9 @@ "*/*": { "schema": { "type": "object", - "additionalProperties": {} + "additionalProperties": { + "type": "object" + } } } } @@ -374,7 +388,9 @@ "*/*": { "schema": { "type": "object", - "additionalProperties": {} + "additionalProperties": { + "type": "object" + } } } } @@ -409,7 +425,9 @@ "*/*": { "schema": { "type": "object", - "additionalProperties": {} + "additionalProperties": { + "type": "object" + } } } } @@ -459,7 +477,9 @@ "*/*": { "schema": { "type": "object", - "additionalProperties": {} + "additionalProperties": { + "type": "object" + } } } } @@ -545,7 +565,9 @@ "*/*": { "schema": { "type": "object", - "additionalProperties": {} + "additionalProperties": { + "type": "object" + } } } } @@ -596,7 +618,9 @@ "*/*": { "schema": { "type": "object", - "additionalProperties": {} + "additionalProperties": { + "type": "object" + } } } } @@ -647,17 +671,17 @@ "content": { "multipart/form-data": { "schema": { + "required": [ + "file" + ], "type": "object", "properties": { "file": { "type": "string", - "format": "binary", - "description": "file detail" + "description": "file detail", + "format": "binary" } - }, - "required": [ - "file" - ] + } } } } @@ -669,7 +693,9 @@ "*/*": { "schema": { "type": "object", - "additionalProperties": {} + "additionalProperties": { + "type": "object" + } } } } @@ -709,7 +735,9 @@ "*/*": { "schema": { "type": "object", - "additionalProperties": {} + "additionalProperties": { + "type": "object" + } } } } @@ -754,7 +782,9 @@ "*/*": { "schema": { "type": "object", - "additionalProperties": {} + "additionalProperties": { + "type": "object" + } } } } @@ -791,10 +821,10 @@ "description": "ID of pet that needs to be fetched", "required": true, "schema": { - "type": "integer", - "format": "int64", "maximum": 5, - "minimum": 1 + "minimum": 1, + "type": "integer", + "format": "int64" } } ], @@ -805,13 +835,15 @@ "*/*": { "schema": { "type": "object", - "additionalProperties": {} + "additionalProperties": { + "type": "object" + } } } } }, - "200": { - "description": "successful operation", + "404": { + "description": "Order not found", "content": { "application/xml": { "schema": { @@ -825,8 +857,8 @@ } } }, - "404": { - "description": "Order not found", + "200": { + "description": "successful operation", "content": { "application/xml": { "schema": { @@ -866,7 +898,9 @@ "*/*": { "schema": { "type": "object", - "additionalProperties": {} + "additionalProperties": { + "type": "object" + } } } } @@ -892,7 +926,9 @@ "*/*": { "schema": { "type": "object", - "additionalProperties": {} + "additionalProperties": { + "type": "object" + } } } } @@ -903,7 +939,9 @@ "application/json": { "schema": { "type": "array", - "items": {} + "items": { + "type": "string" + } } } } @@ -945,7 +983,9 @@ "*/*": { "schema": { "type": "object", - "additionalProperties": {} + "additionalProperties": { + "type": "object" + } } } } @@ -1011,7 +1051,9 @@ "*/*": { "schema": { "type": "object", - "additionalProperties": {} + "additionalProperties": { + "type": "object" + } } } } @@ -1078,8 +1120,8 @@ }, "userStatus": { "type": "integer", - "format": "int32", - "description": "User Status" + "description": "User Status", + "format": "int32" } } }, @@ -1096,6 +1138,10 @@ } }, "Pet": { + "required": [ + "name", + "photoUrls" + ], "type": "object", "properties": { "id": { @@ -1130,11 +1176,7 @@ "sold" ] } - }, - "required": [ - "name", - "photoUrls" - ] + } }, "Tag": { "type": "object", diff --git a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app202.json b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app202.json index 61ab97f67..e16e5789c 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app202.json +++ b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app202.json @@ -1 +1,88 @@ -{"openapi":"3.1.0","info":{"title":"OpenAPI definition","version":"v0"},"servers":[{"url":"http://localhost","description":"Generated server url"}],"paths":{"/example2/":{"get":{"tags":["example-2-controller"],"operationId":"index","responses":{"400":{"description":"Bad Request","content":{"*/*":{"schema":{"type":"string"}}}},"500":{"description":"Internal Server Error","content":{"*/*":{"schema":{"type":"object","additionalProperties":{}}}}},"200":{"description":"OK"}}}},"/example/":{"get":{"tags":["example-controller"],"operationId":"index_1","responses":{"404":{"description":"Not Found","content":{"*/*":{"schema":{"type":"string"}}}},"500":{"description":"Internal Server Error","content":{"*/*":{"schema":{"type":"object","additionalProperties":{}}}}},"200":{"description":"OK"}}}}},"components":{}} +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/example2/": { + "get": { + "tags": [ + "example-2-controller" + ], + "operationId": "index", + "responses": { + "200": { + "description": "OK" + }, + "400": { + "description": "Bad Request", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + }, + "500": { + "description": "Internal Server Error", + "content": { + "*/*": { + "schema": { + "type": "object", + "additionalProperties": { + "type": "object" + } + } + } + } + } + } + } + }, + "/example/": { + "get": { + "tags": [ + "example-controller" + ], + "operationId": "index_1", + "responses": { + "200": { + "description": "OK" + }, + "404": { + "description": "Not Found", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + }, + "500": { + "description": "Internal Server Error", + "content": { + "*/*": { + "schema": { + "type": "object", + "additionalProperties": { + "type": "object" + } + } + } + } + } + } + } + } + }, + "components": {} +} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app211.json b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app211.json index 40f7f80e3..9b89bf4d0 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app211.json +++ b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app211.json @@ -1 +1,79 @@ -{"openapi":"3.1.0","info":{"title":"OpenAPI definition","version":"v0"},"servers":[{"url":"http://localhost","description":"Generated server url"}],"paths":{"/":{"get":{"tags":["hello-controller"],"operationId":"index","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"properties":{"items":{"type":"array","items":{"$ref":"#/components/schemas/PagedObject"}},"paging":{"$ref":"#/components/schemas/Paging"}}}}}}}}}},"components":{"schemas":{"PagedObject":{"type":"object","properties":{"id":{"type":"integer","format":"int64"},"name":{"type":"string"}}},"Paging":{"type":"object","properties":{"page":{"type":"integer","format":"int32"},"total":{"type":"integer","format":"int32"},"lastPage":{"type":"integer","format":"int32"}}}}}} +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/": { + "get": { + "tags": [ + "hello-controller" + ], + "operationId": "index", + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "items": { + "type": "array", + "items": { + "$ref": "#/components/schemas/PagedObject" + } + }, + "paging": { + "$ref": "#/components/schemas/Paging" + } + } + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "PagedObject": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "name": { + "type": "string" + } + } + }, + "Paging": { + "type": "object", + "properties": { + "page": { + "type": "integer", + "format": "int32" + }, + "total": { + "type": "integer", + "format": "int32" + }, + "lastPage": { + "type": "integer", + "format": "int32" + } + } + } + } + } +} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app213.json b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app213.json index 534280009..d8ac4d797 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app213.json +++ b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app213.json @@ -4,7 +4,15 @@ "title": "MKMTestWS (Test Microservice API)", "description": "This API exposes endpoints for testing anything", "termsOfService": "https://www.test.ca/terms", - "version": "1.0" + "version": "1.0", + "x-amazon-apigateway-integration": { + "passthroughBehavior": "when_no_match", + "connectionId": "1rqafw", + "type": "http_proxy", + "httpMethod": "GET", + "uri": "http://my-vpc/nlb-link/testcontroller/getTest", + "connectionType": "VPC_LINK" + } }, "servers": [ { diff --git a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app217-1.json b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app217-1.json index bcf9a4ebf..837008658 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app217-1.json +++ b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app217-1.json @@ -1 +1,55 @@ -{"openapi":"3.1.0","info":{"title":"Example Interfaces","description":"List of Example Interfaces","termsOfService":"http://localhost:8080/","license":{"name":"Apache 2.0"},"version":"v1.0"},"servers":[{"url":"http://localhost","description":"Generated server url"}],"paths":{},"components":{"schemas":{"PersonDTO":{"description":"Description for PersonDTO component","properties":{"name":{"description":"Description for 'name' property","example":"Example value for 'name' property"}}}}}} +{ + "openapi": "3.1.0", + "info": { + "title": "Example Interfaces", + "description": "List of Example Interfaces", + "termsOfService": "http://localhost:8080/", + "license": { + "name": "Apache 2.0" + }, + "version": "v1.0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/persons": { + "get": { + "tags": [ + "hello-controller" + ], + "operationId": "persons", + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/PersonDTO" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "PersonDTO": { + "type": "object", + "properties": { + "name": { + "type": "string", + "description": "Description for 'name' property", + "example": "Example value for 'name' property" + } + }, + "description": "Description for PersonDTO component" + } + } + } +} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app217-2.json b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app217-2.json index a51dd73bf..0406d93f7 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app217-2.json +++ b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app217-2.json @@ -1 +1,55 @@ -{"openapi":"3.1.0","info":{"title":"User Interfaces","description":"List of User Interfaces","termsOfService":"http://localhost:8080/","license":{"name":"Apache 2.0"},"version":"v1.0"},"servers":[{"url":"http://localhost","description":"Generated server url"}],"paths":{},"components":{"schemas":{"PersonDTO":{"description":"Description for PersonDTO component","properties":{"name":{"description":"Description for 'name' property","example":"Example value for 'name' property"}}}}}} +{ + "openapi": "3.1.0", + "info": { + "title": "User Interfaces", + "description": "List of User Interfaces", + "termsOfService": "http://localhost:8080/", + "license": { + "name": "Apache 2.0" + }, + "version": "v1.0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/persons": { + "get": { + "tags": [ + "hello-controller" + ], + "operationId": "persons", + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/PersonDTO" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "PersonDTO": { + "type": "object", + "properties": { + "name": { + "type": "string", + "description": "Description for 'name' property", + "example": "Example value for 'name' property" + } + }, + "description": "Description for PersonDTO component" + } + } + } +} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app219.json b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app219.json index a322d4b8a..6d81662c2 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app219.json +++ b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app219.json @@ -19,12 +19,12 @@ "operationId": "testpost", "requestBody": { "content": { - "application/json;charset=UTF-8": { + "application/json": { "schema": { "$ref": "#/components/schemas/TestObject" } }, - "application/json": { + "application/json;charset=UTF-8": { "schema": { "$ref": "#/components/schemas/TestObject" } @@ -41,12 +41,12 @@ "200": { "description": "OK", "content": { - "application/json": { + "application/xml": { "schema": { "$ref": "#/components/schemas/TestObject" } }, - "application/xml": { + "application/json": { "schema": { "$ref": "#/components/schemas/TestObject" } diff --git a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app220.json b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app220.json index 4b15bda0d..9cbd404b2 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app220.json +++ b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app220.json @@ -1 +1,128 @@ -{"openapi":"3.1.0","info":{"title":"OpenAPI definition","version":"v0"},"servers":[{"url":"http://localhost","description":"Generated server url"}],"paths":{"/parent":{"post":{"tags":["hello-controller"],"operationId":"parentEndpoint","requestBody":{"content":{"application/json":{"schema":{"oneOf":[{"$ref":"#/components/schemas/Superclass"},{"$ref":"#/components/schemas/IntermediateClass"},{"$ref":"#/components/schemas/Image"},{"$ref":"#/components/schemas/Mail"},{"$ref":"#/components/schemas/Home"}]}}},"required":true},"responses":{"200":{"description":"OK"}}}}},"components":{"schemas":{"Home":{"allOf":[{"$ref":"#/components/schemas/Mail"}]},"Image":{"allOf":[{"$ref":"#/components/schemas/IntermediateClass"}]},"IntermediateClass":{"allOf":[{"$ref":"#/components/schemas/Superclass"},{"type":"object","properties":{"@type":{"type":"string"}}}],"discriminator":{"propertyName":"@type"},"required":["@type"]},"Mail":{"allOf":[{"$ref":"#/components/schemas/IntermediateClass"},{"type":"object","properties":{"@type":{"type":"string"}}}],"discriminator":{"propertyName":"@type"},"required":["@type"]},"Superclass":{"type":"object","discriminator":{"propertyName":"@type"},"properties":{"@type":{"type":"string"}},"required":["@type"]}}}} +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/parent": { + "post": { + "tags": [ + "hello-controller" + ], + "operationId": "parentEndpoint", + "requestBody": { + "content": { + "application/json": { + "schema": { + "oneOf": [ + { + "$ref": "#/components/schemas/Superclass" + }, + { + "$ref": "#/components/schemas/IntermediateClass" + }, + { + "$ref": "#/components/schemas/Image" + }, + { + "$ref": "#/components/schemas/Mail" + }, + { + "$ref": "#/components/schemas/Home" + } + ] + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "OK" + } + } + } + } + }, + "components": { + "schemas": { + "Home": { + "allOf": [ + { + "$ref": "#/components/schemas/Mail" + } + ] + }, + "Image": { + "allOf": [ + { + "$ref": "#/components/schemas/IntermediateClass" + } + ] + }, + "IntermediateClass": { + "allOf": [ + { + "$ref": "#/components/schemas/Superclass" + }, + { + "type": "object", + "properties": { + "@type": { + "type": "string" + } + } + } + ], + "discriminator": { + "propertyName": "@type" + }, + "required": [ + "@type" + ] + }, + "Mail": { + "allOf": [ + { + "$ref": "#/components/schemas/IntermediateClass" + }, + { + "type": "object", + "properties": { + "@type": { + "type": "string" + } + } + } + ], + "discriminator": { + "propertyName": "@type" + }, + "required": [ + "@type" + ] + }, + "Superclass": { + "type": "object", + "discriminator": { + "propertyName": "@type" + }, + "properties": { + "@type": { + "type": "string" + } + }, + "required": [ + "@type" + ] + } + } + } +} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app223.json b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app223.json index 4692e7ccf..bb0b80ca3 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app223.json +++ b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app223.json @@ -1 +1,224 @@ -{"openapi":"3.1.0","info":{"title":"OpenAPI definition","version":"v0"},"servers":[{"url":"http://localhost","description":"Generated server url"}],"paths":{"/parent":{"post":{"tags":["a-rest-controller"],"operationId":"parentEndpoint","requestBody":{"content":{"application/json":{"schema":{"oneOf":[{"$ref":"#/components/schemas/ParentType1"},{"$ref":"#/components/schemas/ParentType2"}]}}},"required":true},"responses":{"200":{"description":"OK","content":{"*/*":{"schema":{"$ref":"#/components/schemas/Response"}}}}}}},"/child":{"post":{"tags":["a-rest-controller"],"operationId":"childEndpoint","requestBody":{"content":{"application/json":{"schema":{"oneOf":[{"$ref":"#/components/schemas/ChildType1"},{"$ref":"#/components/schemas/ChildType2"}]}}},"required":true},"responses":{"200":{"description":"OK","content":{"*/*":{"schema":{"$ref":"#/components/schemas/Response"}}}}}}}},"components":{"schemas":{"AbstractChild":{"type":"object","discriminator":{"propertyName":"type"},"properties":{"id":{"type":"integer","format":"int32"},"type":{"type":"string"}},"required":["type"]},"AbstractParent":{"type":"object","discriminator":{"propertyName":"type"},"properties":{"id":{"type":"integer","format":"int32"},"type":{"type":"string"}},"required":["type"]},"ChildType1":{"allOf":[{"$ref":"#/components/schemas/AbstractChild"},{"type":"object","properties":{"childType1Param":{"type":"string"}}}]},"ChildType2":{"allOf":[{"$ref":"#/components/schemas/AbstractChild"},{"type":"object","properties":{"childType2Param":{"type":"string"}}}]},"ParentType1":{"allOf":[{"$ref":"#/components/schemas/AbstractParent"},{"type":"object","properties":{"parentType1Param":{"type":"string"},"abstractChild":{"oneOf":[{"$ref":"#/components/schemas/ChildType1"},{"$ref":"#/components/schemas/ChildType2"}]}}}]},"ParentType2":{"allOf":[{"$ref":"#/components/schemas/AbstractParent"},{"type":"object","properties":{"parentType2Param":{"type":"string"}}}]},"Response":{"type":"object","properties":{"abstractParent":{"oneOf":[{"$ref":"#/components/schemas/ParentType1"},{"$ref":"#/components/schemas/ParentType2"}]},"abstractChild":{"oneOf":[{"$ref":"#/components/schemas/ChildType1"},{"$ref":"#/components/schemas/ChildType2"}]}}}}}} +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/parent": { + "post": { + "tags": [ + "a-rest-controller" + ], + "operationId": "parentEndpoint", + "requestBody": { + "content": { + "application/json": { + "schema": { + "oneOf": [ + { + "$ref": "#/components/schemas/ParentType1" + }, + { + "$ref": "#/components/schemas/ParentType2" + } + ] + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/Response" + } + } + } + } + } + } + }, + "/child": { + "post": { + "tags": [ + "a-rest-controller" + ], + "operationId": "childEndpoint", + "requestBody": { + "content": { + "application/json": { + "schema": { + "oneOf": [ + { + "$ref": "#/components/schemas/ChildType1" + }, + { + "$ref": "#/components/schemas/ChildType2" + } + ] + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/Response" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "AbstractChild": { + "type": "object", + "discriminator": { + "propertyName": "type" + }, + "properties": { + "id": { + "type": "integer", + "format": "int32" + }, + "type": { + "type": "string" + } + }, + "required": [ + "type" + ] + }, + "AbstractParent": { + "type": "object", + "discriminator": { + "propertyName": "type" + }, + "properties": { + "id": { + "type": "integer", + "format": "int32" + }, + "type": { + "type": "string" + } + }, + "required": [ + "type" + ] + }, + "ChildType1": { + "allOf": [ + { + "$ref": "#/components/schemas/AbstractChild" + }, + { + "type": "object", + "properties": { + "childType1Param": { + "type": "string" + } + } + } + ] + }, + "ChildType2": { + "allOf": [ + { + "$ref": "#/components/schemas/AbstractChild" + }, + { + "type": "object", + "properties": { + "childType2Param": { + "type": "string" + } + } + } + ] + }, + "ParentType1": { + "allOf": [ + { + "$ref": "#/components/schemas/AbstractParent" + }, + { + "type": "object", + "properties": { + "parentType1Param": { + "type": "string" + }, + "abstractChild": { + "oneOf": [ + { + "$ref": "#/components/schemas/ChildType1" + }, + { + "$ref": "#/components/schemas/ChildType2" + } + ] + } + } + } + ] + }, + "ParentType2": { + "allOf": [ + { + "$ref": "#/components/schemas/AbstractParent" + }, + { + "type": "object", + "properties": { + "parentType2Param": { + "type": "string" + } + } + } + ] + }, + "Response": { + "type": "object", + "properties": { + "abstractParent": { + "oneOf": [ + { + "$ref": "#/components/schemas/ParentType1" + }, + { + "$ref": "#/components/schemas/ParentType2" + } + ] + }, + "abstractChild": { + "oneOf": [ + { + "$ref": "#/components/schemas/ChildType1" + }, + { + "$ref": "#/components/schemas/ChildType2" + } + ] + } + } + } + } + } +} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app228.json b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app228.json index a60d4d146..8e4bb868e 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app228.json +++ b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app228.json @@ -74,35 +74,11 @@ } ] }, - "Child3": { - "allOf": [ - { - "$ref": "#/components/schemas/Parent" - }, - { - "type": "object", - "properties": { - "childProperty3": { - "type": "string" - } - } - } - ] - }, "MyRequest": { "type": "object", "properties": { "parent": { "oneOf": [ - { - "$ref": "#/components/schemas/Child1" - }, - { - "$ref": "#/components/schemas/Child2" - }, - { - "$ref": "#/components/schemas/Child3" - }, { "$ref": "#/components/schemas/Child1" }, diff --git a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app229.json b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app229.json index cf799c997..2ccf3fc5f 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app229.json +++ b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app229.json @@ -1 +1,81 @@ -{"openapi":"3.1.0","info":{"title":"OpenAPI definition","version":"v0"},"servers":[{"url":"http://localhost","description":"Generated server url"}],"paths":{"/":{"get":{"tags":["x-controller"],"operationId":"manualTranslationUpdateRun","parameters":[{"name":"locale","in":"query","required":true,"schema":{"type":"string","maxLength":16,"minLength":2,"pattern":"\\w+([-.]?\\w+)*"},"examples":{"el-gr":{"description":"el-gr"},"pl-pl":{"description":"pl-pl"},"de-de":{"description":"de-de"},"hu-hu":{"description":"hu-hu"},"en-us.src":{"description":"en-us.src"},"ro-ro":{"description":"ro-ro"},"sk-sk":{"description":"sk-sk"},"bg-bg":{"description":"bg-bg"},"ar-ae":{"description":"ar-ae"},"cs-cz":{"description":"cs-cz"}}}],"responses":{"200":{"description":"OK","content":{"*/*":{"schema":{}}}}}}}},"components":{}} +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/": { + "get": { + "tags": [ + "x-controller" + ], + "operationId": "manualTranslationUpdateRun", + "parameters": [ + { + "name": "locale", + "in": "query", + "required": true, + "schema": { + "maxLength": 16, + "minLength": 2, + "pattern": "\\w+([-.]?\\w+)*", + "type": "string" + }, + "examples": { + "el-gr": { + "description": "el-gr" + }, + "pl-pl": { + "description": "pl-pl" + }, + "de-de": { + "description": "de-de" + }, + "hu-hu": { + "description": "hu-hu" + }, + "en-us.src": { + "description": "en-us.src" + }, + "ro-ro": { + "description": "ro-ro" + }, + "sk-sk": { + "description": "sk-sk" + }, + "bg-bg": { + "description": "bg-bg" + }, + "ar-ae": { + "description": "ar-ae" + }, + "cs-cz": { + "description": "cs-cz" + } + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "object" + } + } + } + } + } + } + } + }, + "components": {} +} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app233.json b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app233.json index 627e6b909..526d7dfc1 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app233.json +++ b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app233.json @@ -378,4 +378,4 @@ } }, "components": {} -} +} \ No newline at end of file diff --git a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app25.json b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app25.json index 50fbba377..acdbf5e3a 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app25.json +++ b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app25.json @@ -1 +1,162 @@ -{"openapi":"3.1.0","info":{"title":"OpenAPI definition","version":"v0"},"servers":[{"url":"http://localhost","description":"Generated server url"}],"paths":{"/values/{trackerId}/data":{"get":{"tags":["hello-controller"],"description":"Get last data from a tracker","operationId":"thirdList","parameters":[{"name":"trackerId","in":"path","required":true,"schema":{"example":"the-tracker-id"}},{"name":"start","in":"query","required":false,"schema":{"format":"date-time","example":"1970-01-01T00:00:00.000Z"}},{"name":"end","in":"query","required":false,"schema":{"format":"date-time","example":"1970-01-01T00:10:00.000Z"}},{"name":"limit","in":"query","required":false,"schema":{"example":10}}],"responses":{"200":{"description":"OK"}}}},"/secondlist/{trackerId}":{"get":{"tags":["hello-controller"],"operationId":"secondlist","parameters":[{"name":"trackerId","in":"path","required":true,"schema":{"example":"the-tracker-id"}},{"name":"start","in":"query","required":false,"schema":{"format":"date-time","example":"1970-01-01T00:00:00.000Z"}},{"name":"end","in":"query","required":false,"schema":{"format":"date-time","example":"1970-01-01T00:10:00.000Z"}}],"responses":{"200":{"description":"OK"}}}},"/list":{"get":{"tags":["hello-controller"],"operationId":"list","parameters":[{"name":"start","in":"query","required":false,"schema":{"format":"date-time","example":"1970-01-01T00:00:00.000Z"}},{"name":"end","in":"query","required":false,"schema":{"format":"date-time","example":"1970-01-01T00:10:00.000Z"}}],"responses":{"200":{"description":"OK"}}}},"/check":{"get":{"tags":["hello-controller"],"operationId":"check","responses":{"200":{"description":"OK"}}}}},"components":{}} +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/values/{trackerId}/data": { + "get": { + "tags": [ + "hello-controller" + ], + "description": "Get last data from a tracker", + "operationId": "thirdList", + "parameters": [ + { + "name": "trackerId", + "in": "path", + "required": true, + "schema": { + "type": "string", + "example": "the-tracker-id" + } + }, + { + "name": "start", + "in": "query", + "required": false, + "schema": { + "type": "string", + "format": "date-time", + "example": "1970-01-01T00:00:00.000Z" + } + }, + { + "name": "end", + "in": "query", + "required": false, + "schema": { + "type": "string", + "format": "date-time", + "example": "1970-01-01T00:10:00.000Z" + } + }, + { + "name": "limit", + "in": "query", + "required": false, + "schema": { + "type": "number", + "example": 10 + } + } + ], + "responses": { + "200": { + "description": "OK" + } + } + } + }, + "/secondlist/{trackerId}": { + "get": { + "tags": [ + "hello-controller" + ], + "operationId": "secondlist", + "parameters": [ + { + "name": "trackerId", + "in": "path", + "required": true, + "schema": { + "type": "string", + "example": "the-tracker-id" + } + }, + { + "name": "start", + "in": "query", + "required": false, + "schema": { + "type": "string", + "format": "date-time", + "example": "1970-01-01T00:00:00.000Z" + } + }, + { + "name": "end", + "in": "query", + "required": false, + "schema": { + "type": "string", + "format": "date-time", + "example": "1970-01-01T00:10:00.000Z" + } + } + ], + "responses": { + "200": { + "description": "OK" + } + } + } + }, + "/list": { + "get": { + "tags": [ + "hello-controller" + ], + "operationId": "list", + "parameters": [ + { + "name": "start", + "in": "query", + "required": false, + "schema": { + "type": "string", + "format": "date-time", + "example": "1970-01-01T00:00:00.000Z" + } + }, + { + "name": "end", + "in": "query", + "required": false, + "schema": { + "type": "string", + "format": "date-time", + "example": "1970-01-01T00:10:00.000Z" + } + } + ], + "responses": { + "200": { + "description": "OK" + } + } + } + }, + "/check": { + "get": { + "tags": [ + "hello-controller" + ], + "operationId": "check", + "responses": { + "200": { + "description": "OK" + } + } + } + } + }, + "components": {} +} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app31.json b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app31.json index 4d9c39eb1..9f1c0376e 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app31.json +++ b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app31.json @@ -1 +1,103 @@ -{"openapi":"3.1.0","info":{"title":"OpenAPI definition","version":"v0"},"servers":[{"url":"http://localhost","description":"Generated server url"}],"paths":{"/test":{"post":{"tags":["hello-controller"],"description":"subscribes a client to updates relevant to the requestor's account, as identified by the input token. The supplied url will be used as the delivery address for response payloads","operationId":"subscribe","parameters":[{"name":"x-auth-token","in":"header","description":"the authentication token provided after initially authenticating to the application","required":true,"schema":{"type":"string","description":"the authentication token provided after initially authenticating to the application"}},{"name":"url","in":"query","description":"the URL to call with response data","required":true,"schema":{"type":"string","description":"the URL to call with response data"}}],"responses":{"200":{"description":"OK","content":{"*/*":{"schema":{"$ref":"#/components/schemas/SubscriptionResponse"}}}}},"callbacks":{"subscription":{"http://$request.query.url":{"post":{"description":"payload data will be sent","parameters":[{"name":"subscriptionId","in":"path","required":true,"schema":{"format":"uuid","description":"the generated UUID","readOnly":true}}],"responses":{"200":{"description":"Return this code if the callback was received and processed successfully"},"205":{"description":"Return this code to unsubscribe from future data updates"},"default":{"description":"All other response codes will disable this callback subscription"}}}}}}}}},"components":{"schemas":{"SubscriptionResponse":{"type":"object","properties":{"subscriptionUuid":{"type":"string"}}}}}} +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/test": { + "post": { + "tags": [ + "hello-controller" + ], + "description": "subscribes a client to updates relevant to the requestor's account, as identified by the input token. The supplied url will be used as the delivery address for response payloads", + "operationId": "subscribe", + "parameters": [ + { + "name": "x-auth-token", + "in": "header", + "description": "the authentication token provided after initially authenticating to the application", + "required": true, + "schema": { + "type": "string", + "description": "the authentication token provided after initially authenticating to the application" + } + }, + { + "name": "url", + "in": "query", + "description": "the URL to call with response data", + "required": true, + "schema": { + "type": "string", + "description": "the URL to call with response data" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/SubscriptionResponse" + } + } + } + } + }, + "callbacks": { + "subscription": { + "http://$request.query.url": { + "post": { + "description": "payload data will be sent", + "parameters": [ + { + "name": "subscriptionId", + "in": "path", + "required": true, + "schema": { + "type": "string", + "description": "the generated UUID", + "format": "uuid", + "readOnly": true + } + } + ], + "responses": { + "200": { + "description": "Return this code if the callback was received and processed successfully" + }, + "205": { + "description": "Return this code to unsubscribe from future data updates" + }, + "default": { + "description": "All other response codes will disable this callback subscription" + } + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "SubscriptionResponse": { + "type": "object", + "properties": { + "subscriptionUuid": { + "type": "string" + } + } + } + } + } +} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app33.json b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app33.json index 582e2aa8f..bb37ea7ab 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app33.json +++ b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app33.json @@ -1 +1,55 @@ -{"openapi":"3.1.0","info":{"title":"OpenAPI definition","version":"v0"},"servers":[{"url":"http://localhost","description":"Generated server url"}],"paths":{"/hello/{numTelco}":{"get":{"tags":["hello-controller"],"summary":"GET Persons","operationId":"index","parameters":[{"name":"numTelco","in":"path","required":true,"schema":{"type":"string"}},{"name":"adresse","in":"query","required":true,"schema":{"type":"string"}}],"responses":{"418":{"description":"I'm a teapot","content":{"*/*":{"schema":{}}}}}}}},"components":{}} +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/hello/{numTelco}": { + "get": { + "tags": [ + "hello-controller" + ], + "summary": "GET Persons", + "operationId": "index", + "parameters": [ + { + "name": "numTelco", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "adresse", + "in": "query", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "418": { + "description": "I'm a teapot", + "content": { + "*/*": { + "schema": { + "type": "object" + } + } + } + } + } + } + } + }, + "components": {} +} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app34.json b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app34.json index 582e2aa8f..bb37ea7ab 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app34.json +++ b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app34.json @@ -1 +1,55 @@ -{"openapi":"3.1.0","info":{"title":"OpenAPI definition","version":"v0"},"servers":[{"url":"http://localhost","description":"Generated server url"}],"paths":{"/hello/{numTelco}":{"get":{"tags":["hello-controller"],"summary":"GET Persons","operationId":"index","parameters":[{"name":"numTelco","in":"path","required":true,"schema":{"type":"string"}},{"name":"adresse","in":"query","required":true,"schema":{"type":"string"}}],"responses":{"418":{"description":"I'm a teapot","content":{"*/*":{"schema":{}}}}}}}},"components":{}} +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/hello/{numTelco}": { + "get": { + "tags": [ + "hello-controller" + ], + "summary": "GET Persons", + "operationId": "index", + "parameters": [ + { + "name": "numTelco", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "adresse", + "in": "query", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "418": { + "description": "I'm a teapot", + "content": { + "*/*": { + "schema": { + "type": "object" + } + } + } + } + } + } + } + }, + "components": {} +} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app4.json b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app4.json index 584edad37..06c7dd2f7 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app4.json +++ b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app4.json @@ -45,6 +45,11 @@ "components": { "schemas": { "test.org.springdoc.api.v31.app4.TrackerData": { + "required": [ + "timestamp", + "trackerId", + "value" + ], "type": "object", "properties": { "trackerId": { @@ -58,16 +63,11 @@ }, "value": { "type": "number", - "format": "double", "description": "The data value", + "format": "double", "example": 19.0 } - }, - "required": [ - "timestamp", - "trackerId", - "value" - ] + } } } } diff --git a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app41.json b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app41.json index d20756135..6fb3d61a0 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app41.json +++ b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app41.json @@ -1 +1,69 @@ -{"openapi":"3.1.0","info":{"title":"OpenAPI definition","version":"v0"},"servers":[{"url":"http://localhost","description":"Generated server url"}],"paths":{"/file":{"get":{"tags":["hello-controller"],"description":"Download file","operationId":"getFile","parameters":[{"name":"path","in":"query","description":"File path","required":true,"schema":{"type":"string"}}],"responses":{"400":{"description":"Wrong request","content":{"application/json":{"schema":{}}}},"200":{"description":"File resource","content":{"application/json":{"schema":{"type":"string","format":"binary"}}}},"500":{"description":"Unexpected error","content":{"application/json":{"schema":{}}}}}}}},"components":{}} +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/file": { + "get": { + "tags": [ + "hello-controller" + ], + "description": "Download file", + "operationId": "getFile", + "parameters": [ + { + "name": "path", + "in": "query", + "description": "File path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "500": { + "description": "Unexpected error", + "content": { + "application/json": { + "schema": { + "type": "string" + } + } + } + }, + "200": { + "description": "File resource", + "content": { + "application/json": { + "schema": { + "type": "string", + "format": "binary" + } + } + } + }, + "400": { + "description": "Wrong request", + "content": { + "application/json": { + "schema": { + "type": "string" + } + } + } + } + } + } + } + }, + "components": {} +} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app46.json b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app46.json index 33102e5a5..43bb151a6 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app46.json +++ b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app46.json @@ -1 +1,58 @@ -{"openapi":"3.1.0","info":{"title":"OpenAPI definition","version":"v0"},"servers":[{"url":"http://localhost","description":"Generated server url"}],"paths":{"/persons/{subscriptionId}":{"get":{"tags":["Example Tag"],"summary":"Operation Summary","description":"Operation Description","externalDocs":{"description":"External documentation description","url":"http://url.com"},"operationId":"operationId","parameters":[{"name":"subscriptionId","in":"path","description":"parameter description","required":true,"allowEmptyValue":true,"allowReserved":true,"schema":{"format":"uuid","description":"the generated UUID","readOnly":true}}],"responses":{"200":{"description":"voila!","content":{"application/json":{"schema":{"type":"string"}}}}}}}},"components":{}} +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/persons/{subscriptionId}": { + "get": { + "tags": [ + "Example Tag" + ], + "summary": "Operation Summary", + "description": "Operation Description", + "externalDocs": { + "description": "External documentation description", + "url": "http://url.com" + }, + "operationId": "operationId", + "parameters": [ + { + "name": "subscriptionId", + "in": "path", + "description": "parameter description", + "required": true, + "allowEmptyValue": true, + "allowReserved": true, + "schema": { + "type": "string", + "description": "the generated UUID", + "format": "uuid", + "readOnly": true + } + } + ], + "responses": { + "200": { + "description": "voila!", + "content": { + "application/json": { + "schema": { + "type": "string" + } + } + } + } + } + } + } + }, + "components": {} +} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app47.json b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app47.json index db3d4bf63..1b4b05960 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app47.json +++ b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app47.json @@ -1 +1,98 @@ -{"openapi":"3.1.0","info":{"title":"OpenAPI definition","version":"v0"},"servers":[{"url":"http://localhost","description":"Generated server url"}],"paths":{"/documents/{locale}":{"get":{"tags":["hello-controller"],"operationId":"getDocumentsWithLocale","parameters":[{"name":"locale","in":"path","required":true,"schema":{}}],"responses":{"200":{"description":"OK","content":{"*/*":{"schema":{"type":"string"}}}}}}},"/":{"get":{"tags":["basic-controller"],"operationId":"get1","parameters":[{"name":"foo","in":"header","schema":{"type":"string","enum":["bar"]}},{"name":"fi","in":"header","schema":{"type":"string","enum":["ri"]}},{"name":"User-Agent","in":"header","schema":{"type":"string","enum":["MyUserAgent"]}}],"responses":{"200":{"description":"OK","content":{"*/*":{"schema":{"type":"string"}}}}}}}},"components":{}} +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/documents/{locale}": { + "get": { + "tags": [ + "hello-controller" + ], + "operationId": "getDocumentsWithLocale", + "parameters": [ + { + "name": "locale", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/": { + "get": { + "tags": [ + "basic-controller" + ], + "operationId": "get1", + "parameters": [ + { + "name": "foo", + "in": "header", + "schema": { + "type": "string", + "enum": [ + "bar" + ] + } + }, + { + "name": "fi", + "in": "header", + "schema": { + "type": "string", + "enum": [ + "ri" + ] + } + }, + { + "name": "User-Agent", + "in": "header", + "schema": { + "type": "string", + "enum": [ + "MyUserAgent" + ] + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + } + }, + "components": {} +} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app51.json b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app51.json index 16c0f1719..280eab52e 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app51.json +++ b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app51.json @@ -22,7 +22,9 @@ "application/json": { "schema": { "type": "object", - "additionalProperties": {} + "additionalProperties": { + "type": "object" + } } } }, @@ -35,7 +37,9 @@ "*/*": { "schema": { "type": "object", - "additionalProperties": {} + "additionalProperties": { + "type": "object" + } } } } @@ -55,6 +59,7 @@ "in": "header", "required": true, "schema": { + "type": "string", "example": "rherherherherh" } }, @@ -64,6 +69,7 @@ "description": "desc1", "required": true, "schema": { + "type": "string", "example": "something" } } @@ -94,6 +100,7 @@ "in": "header", "required": true, "schema": { + "type": "string", "example": "rherherherherh" } }, @@ -132,6 +139,7 @@ "in": "header", "required": true, "schema": { + "type": "string", "example": "rherherherherh" } } diff --git a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app58.json b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app58.json index 5bda4b078..a3551a5d7 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app58.json +++ b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app58.json @@ -1 +1,119 @@ -{"openapi":"3.1.0","info":{"title":"OpenAPI definition","version":"v0"},"servers":[{"url":"http://localhost","description":"Generated server url"}],"paths":{"/examplePost":{"post":{"tags":["hello-controller"],"summary":"schema example","operationId":"example","responses":{"200":{"description":"OK","content":{"*/*":{"schema":{}}}}}}},"/foo":{"get":{"tags":["hello-controller"],"operationId":"foobar","parameters":[{"name":"user","in":"query","description":"User","required":true,"schema":{"$ref":"#/components/schemas/PersonDTO"}}],"responses":{"200":{"description":"OK"}}}},"/foo1":{"get":{"tags":["hello-controller"],"operationId":"foobar1","parameters":[{"name":"user","in":"query","description":"User","required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PersonDTO"}}}}],"responses":{"200":{"description":"OK"}}}},"/example":{"get":{"tags":["hello-controller"],"operationId":"test","responses":{"200":{"description":"OK"}}}}},"components":{"schemas":{"PersonDTO":{"type":"object","properties":{"email":{"type":"string"},"firstName":{"type":"string"},"lastName":{"type":"string"}}}}}} +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/example": { + "get": { + "tags": [ + "hello-controller" + ], + "operationId": "test", + "responses": { + "200": { + "description": "OK" + } + } + } + }, + "/examplePost": { + "post": { + "tags": [ + "hello-controller" + ], + "summary": "schema example", + "operationId": "example", + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/foo": { + "get": { + "tags": [ + "hello-controller" + ], + "operationId": "foobar", + "parameters": [ + { + "name": "user", + "in": "query", + "description": "User", + "required": true, + "schema": { + "$ref": "#/components/schemas/PersonDTO" + } + } + ], + "responses": { + "200": { + "description": "OK" + } + } + } + }, + "/foo1": { + "get": { + "tags": [ + "hello-controller" + ], + "operationId": "foobar1", + "parameters": [ + { + "name": "user", + "in": "query", + "description": "User", + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/PersonDTO" + } + } + } + } + ], + "responses": { + "200": { + "description": "OK" + } + } + } + } + }, + "components": { + "schemas": { + "PersonDTO": { + "type": "object", + "properties": { + "email": { + "type": "string" + }, + "firstName": { + "type": "string" + }, + "lastName": { + "type": "string" + } + } + } + } + } +} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app59.json b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app59.json index a5f0edb21..1bbe411e6 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app59.json +++ b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app59.json @@ -28,19 +28,23 @@ "required": true }, "responses": { - "500": { - "description": "An unknown error occurred", + "400": { + "description": "The request is malformed or information is missing.", "content": { "*/*": { - "schema": {} + "schema": { + "type": "object" + } } } }, - "400": { - "description": "The request is malformed or information is missing.", + "500": { + "description": "An unknown error occurred", "content": { "*/*": { - "schema": {} + "schema": { + "type": "object" + } } } }, @@ -74,19 +78,23 @@ "required": true }, "responses": { - "500": { - "description": "An unknown error occurred", + "400": { + "description": "The request is malformed or information is missing.", "content": { "*/*": { - "schema": {} + "schema": { + "type": "object" + } } } }, - "400": { - "description": "The request is malformed or information is missing.", + "500": { + "description": "An unknown error occurred", "content": { "*/*": { - "schema": {} + "schema": { + "type": "object" + } } } }, @@ -111,19 +119,23 @@ ], "operationId": "test", "responses": { - "500": { - "description": "An unknown error occurred", + "400": { + "description": "The request is malformed or information is missing.", "content": { "*/*": { - "schema": {} + "schema": { + "type": "object" + } } } }, - "400": { - "description": "The request is malformed or information is missing.", + "500": { + "description": "An unknown error occurred", "content": { "*/*": { - "schema": {} + "schema": { + "type": "object" + } } } }, @@ -141,19 +153,23 @@ ], "operationId": "test_1", "responses": { - "500": { - "description": "An unknown error occurred", + "400": { + "description": "The request is malformed or information is missing.", "content": { "*/*": { - "schema": {} + "schema": { + "type": "object" + } } } }, - "400": { - "description": "The request is malformed or information is missing.", + "500": { + "description": "An unknown error occurred", "content": { "*/*": { - "schema": {} + "schema": { + "type": "object" + } } } }, @@ -168,15 +184,15 @@ "components": { "schemas": { "HelloBody": { + "required": [ + "helloValue" + ], "type": "object", "properties": { "helloValue": { "type": "string" } - }, - "required": [ - "helloValue" - ] + } } } } diff --git a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app60.json b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app60.json index d239d9164..e613245c1 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app60.json +++ b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app60.json @@ -11,18 +11,18 @@ } ], "paths": { - "/hello2": { + "/hello1": { "get": { "tags": [ "hello-controller" ], - "summary": "summary2", - "operationId": "list2", + "summary": "summary1", + "operationId": "list1", "parameters": [ { "name": "page", "in": "query", - "description": "desc page from Annotated interface", + "description": "The page", "required": true, "schema": { "type": "string" @@ -31,16 +31,7 @@ { "name": "size", "in": "query", - "description": "desc page from Annotated interface", - "required": true, - "schema": { - "type": "string" - } - }, - { - "name": "sort", - "in": "query", - "description": "desc sort from Annotated interface", + "description": "The size", "required": true, "schema": { "type": "string" @@ -54,7 +45,9 @@ "*/*": { "schema": { "type": "array", - "items": {} + "items": { + "type": "object" + } } } } @@ -62,18 +55,18 @@ } } }, - "/hello1": { + "/hello2": { "get": { "tags": [ "hello-controller" ], - "summary": "summary1", - "operationId": "list1", + "summary": "summary2", + "operationId": "list2", "parameters": [ { "name": "page", "in": "query", - "description": "The page", + "description": "desc page from Annotated interface", "required": true, "schema": { "type": "string" @@ -82,7 +75,16 @@ { "name": "size", "in": "query", - "description": "The size", + "description": "desc page from Annotated interface", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "sort", + "in": "query", + "description": "desc sort from Annotated interface", "required": true, "schema": { "type": "string" @@ -96,7 +98,9 @@ "*/*": { "schema": { "type": "array", - "items": {} + "items": { + "type": "object" + } } } } diff --git a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app61.json b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app61.json index e28ff3499..992f4efd4 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app61.json +++ b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app61.json @@ -46,7 +46,9 @@ "*/*": { "schema": { "type": "array", - "items": {} + "items": { + "type": "string" + } } } } @@ -57,12 +59,13 @@ "description": "createdRange", "required": true, "schema": { + "maxItems": 2, + "minItems": 2, "type": "array", "items": { + "type": "string", "format": "date" - }, - "maxItems": 2, - "minItems": 2 + } } } ], diff --git a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app67.json b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app67.json index 7f4ef7ef6..eeb238d51 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app67.json +++ b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app67.json @@ -1 +1,178 @@ -{"openapi":"3.1.0","info":{"title":"OpenAPI definition","version":"v0"},"servers":[{"url":"http://localhost","description":"Generated server url"}],"paths":{"/demo/operation4":{"get":{"tags":["hello-controller"],"summary":"Operation 4 (expected result - 3 parameters)","operationId":"operation4","parameters":[{"name":"pageNumber","in":"query","description":"page number","schema":{}},{"name":"pageSize","in":"query","description":"page size","schema":{}},{"name":"sort","in":"query","description":"sort specification","schema":{}}],"responses":{"200":{"description":"OK","content":{"text/plain":{"schema":{"type":"string"}}}}}}},"/demo/operation3":{"get":{"tags":["hello-controller"],"summary":"Operation 3 (expected result - 3 parameters)","operationId":"operation3","parameters":[{"name":"pageNumber","in":"query","description":"page number","schema":{}},{"name":"pageSize","in":"query","description":"page size","schema":{}},{"name":"sort","in":"query","description":"sort specification","schema":{}}],"responses":{"200":{"description":"OK","content":{"text/plain":{"schema":{"type":"string"}}}}}}},"/demo/operation2":{"get":{"tags":["hello-controller"],"summary":"Operation 2 (expected result - 3 parameters)","operationId":"operation2","parameters":[{"name":"pageNumber","in":"query","description":"page number","schema":{}},{"name":"pageSize","in":"query","description":"page size","schema":{}},{"name":"sort","in":"query","description":"sort specification","schema":{}}],"responses":{"200":{"description":"OK","content":{"text/plain":{"schema":{"type":"string"}}}}}}},"/demo/operation1":{"get":{"tags":["hello-controller"],"summary":"Operation 1 (expected result - no parameters)","operationId":"operation1","responses":{"200":{"description":"OK","content":{"text/plain":{"schema":{"type":"string"}}}}}}}},"components":{}} +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/demo/operation1": { + "get": { + "tags": [ + "hello-controller" + ], + "summary": "Operation 1 (expected result - no parameters)", + "operationId": "operation1", + "responses": { + "200": { + "description": "OK", + "content": { + "text/plain": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/demo/operation2": { + "get": { + "tags": [ + "hello-controller" + ], + "summary": "Operation 2 (expected result - 3 parameters)", + "operationId": "operation2", + "parameters": [ + { + "name": "pageNumber", + "in": "query", + "description": "page number", + "schema": { + "type": "integer" + } + }, + { + "name": "pageSize", + "in": "query", + "description": "page size", + "schema": { + "type": "integer" + } + }, + { + "name": "sort", + "in": "query", + "description": "sort specification", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "text/plain": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/demo/operation4": { + "get": { + "tags": [ + "hello-controller" + ], + "summary": "Operation 4 (expected result - 3 parameters)", + "operationId": "operation4", + "parameters": [ + { + "name": "pageNumber", + "in": "query", + "description": "page number", + "schema": { + "type": "integer" + } + }, + { + "name": "pageSize", + "in": "query", + "description": "page size", + "schema": { + "type": "integer" + } + }, + { + "name": "sort", + "in": "query", + "description": "sort specification", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "text/plain": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/demo/operation3": { + "get": { + "tags": [ + "hello-controller" + ], + "summary": "Operation 3 (expected result - 3 parameters)", + "operationId": "operation3", + "parameters": [ + { + "name": "pageNumber", + "in": "query", + "description": "page number", + "schema": { + "type": "integer" + } + }, + { + "name": "pageSize", + "in": "query", + "description": "page size", + "schema": { + "type": "integer" + } + }, + { + "name": "sort", + "in": "query", + "description": "sort specification", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "text/plain": { + "schema": { + "type": "string" + } + } + } + } + } + } + } + }, + "components": {} +} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app70.json b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app70.json index e396f47a2..1bc5135c8 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app70.json +++ b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app70.json @@ -1 +1,62 @@ -{"openapi":"3.1.0","info":{"title":"OpenAPI definition","version":"v0"},"servers":[{"url":"http://localhost","description":"Generated server url"}],"paths":{"/example/{test}":{"get":{"tags":["hello-controller"],"description":"Some operation, customized operation!","operationId":"test","parameters":[{"name":"test","in":"path","description":"Parameter description, customized parameter!","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"OK","content":{"*/*":{"schema":{"$ref":"#/components/schemas/ApiType"}}}}}}}},"components":{"schemas":{"ApiType":{"type":"object","properties":{"someProperty":{"type":"string","format":"duration","description":"Test description","properties":{}}}}}}} +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/example/{test}": { + "get": { + "tags": [ + "hello-controller" + ], + "description": "Some operation, customized operation!", + "operationId": "test", + "parameters": [ + { + "name": "test", + "in": "path", + "description": "Parameter description, customized parameter!", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/ApiType" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "ApiType": { + "type": "object", + "properties": { + "someProperty": { + "type": "string", + "format": "duration", + "description": "Test description", + "properties": {} + } + } + } + } + } +} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app75.json b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app75.json index e36b96f3a..fb2f9393f 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app75.json +++ b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app75.json @@ -1 +1,168 @@ -{"openapi":"3.1.0","info":{"title":"OpenAPI definition","version":"v0"},"servers":[{"url":"http://localhost","description":"Generated server url"}],"paths":{"/test3/{uuid}":{"post":{"tags":["hello-controller"],"summary":"Example api that realize an ECHO operation","description":"The result of the echo is the input value of the api","operationId":"postMyRequestBody3","parameters":[{"name":"uuid","in":"path","description":"Is the identification of the document","required":true,"schema":{"example":"uuid"}}],"responses":{"200":{"description":"OK","content":{"*/*":{"schema":{"type":"array","items":{}}}}},"201":{"description":"other possible response","content":{"*/*":{"schema":{"type":"string"}}}}}}},"/test2/{uuid}":{"post":{"tags":["hello-controller"],"summary":"Example api that realize an ECHO operation","description":"The result of the echo is the input value of the api","operationId":"postMyRequestBody2","parameters":[{"name":"uuid","in":"path","description":"Is the identification of the document","required":true,"schema":{"example":"uuid"}}],"responses":{"200":{"description":"Successful Operation","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PersonDTO"}}}},"201":{"description":"other possible response","content":{"*/*":{"schema":{"type":"string"}}}}}}},"/test1/{uuid}":{"post":{"tags":["hello-controller"],"summary":"Example api that realize an ECHO operation","description":"The result of the echo is the input value of the api","operationId":"postMyRequestBody1","parameters":[{"name":"uuid","in":"path","description":"Is the identification of the document","required":true,"schema":{"example":"uuid"}}],"responses":{"200":{"description":"Successful Operation","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PersonDTO"}}}},"201":{"description":"other possible response","content":{"*/*":{"schema":{"type":"string"}}}}}}}},"components":{"schemas":{"PersonDTO":{"type":"object","properties":{"email":{"type":"string"},"firstName":{"type":"string"},"lastName":{"type":"string"}}}}}} +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/test1/{uuid}": { + "post": { + "tags": [ + "hello-controller" + ], + "summary": "Example api that realize an ECHO operation", + "description": "The result of the echo is the input value of the api", + "operationId": "postMyRequestBody1", + "parameters": [ + { + "name": "uuid", + "in": "path", + "description": "Is the identification of the document", + "required": true, + "schema": { + "type": "string", + "example": "uuid" + } + } + ], + "responses": { + "200": { + "description": "Successful Operation", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/PersonDTO" + } + } + } + }, + "201": { + "description": "other possible response", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/test2/{uuid}": { + "post": { + "tags": [ + "hello-controller" + ], + "summary": "Example api that realize an ECHO operation", + "description": "The result of the echo is the input value of the api", + "operationId": "postMyRequestBody2", + "parameters": [ + { + "name": "uuid", + "in": "path", + "description": "Is the identification of the document", + "required": true, + "schema": { + "type": "string", + "example": "uuid" + } + } + ], + "responses": { + "200": { + "description": "Successful Operation", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/PersonDTO" + } + } + } + }, + "201": { + "description": "other possible response", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/test3/{uuid}": { + "post": { + "tags": [ + "hello-controller" + ], + "summary": "Example api that realize an ECHO operation", + "description": "The result of the echo is the input value of the api", + "operationId": "postMyRequestBody3", + "parameters": [ + { + "name": "uuid", + "in": "path", + "description": "Is the identification of the document", + "required": true, + "schema": { + "type": "string", + "example": "uuid" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "array", + "items": { + "type": "object" + } + } + } + } + }, + "201": { + "description": "other possible response", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "PersonDTO": { + "type": "object", + "properties": { + "email": { + "type": "string" + }, + "firstName": { + "type": "string" + }, + "lastName": { + "type": "string" + } + } + } + } + } +} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app77.json b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app77.json index 338fcfc64..ba0083f4b 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app77.json +++ b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app77.json @@ -1 +1,78 @@ -{"openapi":"3.1.0","info":{"title":"OpenAPI definition","version":"v0"},"servers":[{"url":"http://localhost","description":"Generated server url"}],"paths":{"/persons":{"get":{"tags":["hello-controller"],"operationId":"persons","parameters":[{"name":"name","in":"query","required":true,"schema":{"type":"string"}}],"responses":{"default":{"description":"default response","content":{"*/*":{"schema":{}}},"x-is-file":"true"}}}},"/persons2":{"get":{"tags":["hello-controller"],"operationId":"persons2","parameters":[{"name":"name","in":"query","required":true,"schema":{"type":"string"}}],"responses":{"default":{"description":"default response","content":{"*/*":{"schema":{}}},"x-is-file":"true"}}}}},"components":{}} +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/persons2": { + "get": { + "tags": [ + "hello-controller" + ], + "operationId": "persons2", + "parameters": [ + { + "name": "name", + "in": "query", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "default": { + "description": "default response", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + }, + "x-is-file": "true" + } + } + } + }, + "/persons": { + "get": { + "tags": [ + "hello-controller" + ], + "operationId": "persons", + "parameters": [ + { + "name": "name", + "in": "query", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "default": { + "description": "default response", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + }, + "x-is-file": "true" + } + } + } + } + }, + "components": {} +} diff --git a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app82.json b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app82.json index 6efed1a5f..6c48000cf 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app82.json +++ b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app82.json @@ -48,7 +48,9 @@ "description": "OK", "content": { "*/*": { - "schema": {} + "schema": { + "type": "object" + } } } } diff --git a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app83.json b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app83.json index 6b92220a2..c793dd357 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app83.json +++ b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app83.json @@ -31,20 +31,21 @@ "content": { "multipart/form-data": { "schema": { + "required": [ + "configuration", + "file" + ], "type": "object", "properties": { "configuration": { + "type": "string", "format": "binary" }, "file": { "type": "string", "format": "binary" } - }, - "required": [ - "configuration", - "file" - ] + } } } } @@ -54,7 +55,9 @@ "description": "OK", "content": { "application/json": { - "schema": {} + "schema": { + "type": "object" + } } } } @@ -71,14 +74,16 @@ "content": { "multipart/form-data": { "schema": { + "required": [ + "file" + ], + "type": "object", "properties": { "file": { + "type": "string", "format": "binary" } - }, - "required": [ - "file" - ] + } } } } @@ -88,7 +93,9 @@ "description": "OK", "content": { "application/json": { - "schema": {} + "schema": { + "type": "object" + } } } } diff --git a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app90.json b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app90.json index 51f49fab1..b63c8ebf5 100644 --- a/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app90.json +++ b/springdoc-openapi-starter-webmvc-api/src/test/resources/results/3.1.0/app90.json @@ -1 +1,142 @@ -{"openapi":"3.1.0","info":{"title":"OpenAPI definition","version":"v0"},"servers":[{"url":"http://localhost","description":"Generated server url"}],"paths":{"/test2":{"post":{"tags":["hello-controller"],"operationId":"test2","requestBody":{"description":"Details of the Item to be created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/User"},"examples":{"An example request with the minimum required fields to create.":{"summary":"Minimal request","description":"An example request with the minimum required fields to create.","value":"min"},"An example request with all fields provided with example values.":{"summary":"Full request","description":"An example request with all fields provided with example values.","value":"full"}}}},"required":true},"responses":{"200":{"description":"OK"}}}},"/test":{"get":{"tags":["hello-controller"],"operationId":"test1","parameters":[{"name":"hello","in":"query","required":true,"schema":{"type":"string"}}],"responses":{"default":{"description":"successful operation","content":{"application/json":{"schema":{"$ref":"#/components/schemas/User"},"examples":{"500":{"$ref":"#/components/examples/http500Example"}}},"application/xml":{"schema":{"$ref":"#/components/schemas/User"}}}}}}}},"components":{"schemas":{"User":{"type":"object","properties":{"id":{"type":"integer","format":"int64","example":10},"username":{"type":"string","example":"theUser"},"firstName":{"type":"string","example":"John"},"lastName":{"type":"string","example":"James"},"email":{"type":"string","example":"john@email.com"},"password":{"type":"string","example":12345},"phone":{"type":"string","example":12345},"userStatus":{"type":"integer","format":"int32","description":"User Status","example":1}}}},"examples":{"http500Example":{"summary":"HTTP 500 JSON Body response example","description":"An example of HTTP response in case an error occurs on server side. instance attribute reference a traceId to ease server side analysis.","value":"{\"500\":{\"$ref\":\"#/components/examples/http500Example\"}}"}}}} +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/test2": { + "post": { + "tags": [ + "hello-controller" + ], + "operationId": "test2", + "requestBody": { + "description": "Details of the Item to be created", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/User" + }, + "examples": { + "An example request with the minimum required fields to create.": { + "summary": "Minimal request", + "description": "An example request with the minimum required fields to create.", + "value": "min" + }, + "An example request with all fields provided with example values.": { + "summary": "Full request", + "description": "An example request with all fields provided with example values.", + "value": "full" + } + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "OK" + } + } + } + }, + "/test": { + "get": { + "tags": [ + "hello-controller" + ], + "operationId": "test1", + "parameters": [ + { + "name": "hello", + "in": "query", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "default": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/User" + }, + "examples": { + "500": { + "$ref": "#/components/examples/http500Example" + } + } + }, + "application/xml": { + "schema": { + "$ref": "#/components/schemas/User" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "User": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64", + "example": 10 + }, + "username": { + "type": "string", + "example": "theUser" + }, + "firstName": { + "type": "string", + "example": "John" + }, + "lastName": { + "type": "string", + "example": "James" + }, + "email": { + "type": "string", + "example": "john@email.com" + }, + "password": { + "type": "string", + "example": 12345 + }, + "phone": { + "type": "string", + "example": 12345 + }, + "userStatus": { + "type": "integer", + "format": "int32", + "description": "User Status", + "example": 1 + } + } + } + }, + "examples": { + "http500Example": { + "summary": "HTTP 500 JSON Body response example", + "description": "An example of HTTP response in case an error occurs on server side. instance attribute reference a traceId to ease server side analysis.", + "value": "{\"500\":{\"$ref\":\"#/components/examples/http500Example\"}}" + } + } + } +} diff --git a/springdoc-openapi-starter-webmvc-ui/pom.xml b/springdoc-openapi-starter-webmvc-ui/pom.xml index a33d39632..6e79cc8ea 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.1 + 2.8.2 springdoc-openapi-starter-webmvc-ui diff --git a/springdoc-openapi-starter-webmvc-ui/src/test/java/test/org/springdoc/ui/app1/SpringDocSwaggerConfigTest.java b/springdoc-openapi-starter-webmvc-ui/src/test/java/test/org/springdoc/ui/app1/SpringDocSwaggerConfigTest.java index fedbb254b..11a020f81 100644 --- a/springdoc-openapi-starter-webmvc-ui/src/test/java/test/org/springdoc/ui/app1/SpringDocSwaggerConfigTest.java +++ b/springdoc-openapi-starter-webmvc-ui/src/test/java/test/org/springdoc/ui/app1/SpringDocSwaggerConfigTest.java @@ -35,7 +35,7 @@ @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, properties = { "spring.jackson.property-naming-strategy=UPPER_CAMEL_CASE", "springdoc.show-actuator=true", "management.endpoints.web.base-path=/management", - "server.servlet.context-path=/demo/api", "management.server.port=9201", "management.server.base-path=/demo/api" }) + "server.servlet.context-path=/demo/api", "management.server.port=9301", "management.server.base-path=/demo/api" }) public class SpringDocSwaggerConfigTest extends AbstractSpringDocActuatorTest { @Test diff --git a/springdoc-openapi-starter-webmvc-ui/src/test/java/test/org/springdoc/ui/app1/SpringDocSwaggerConfigWithBothFileGeneratedSpecsTest.java b/springdoc-openapi-starter-webmvc-ui/src/test/java/test/org/springdoc/ui/app1/SpringDocSwaggerConfigWithBothFileGeneratedSpecsTest.java index 201a63717..69cbf8726 100644 --- a/springdoc-openapi-starter-webmvc-ui/src/test/java/test/org/springdoc/ui/app1/SpringDocSwaggerConfigWithBothFileGeneratedSpecsTest.java +++ b/springdoc-openapi-starter-webmvc-ui/src/test/java/test/org/springdoc/ui/app1/SpringDocSwaggerConfigWithBothFileGeneratedSpecsTest.java @@ -39,7 +39,7 @@ @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, properties = { "spring.jackson.property-naming-strategy=UPPER_CAMEL_CASE", "springdoc.show-actuator=true", "management.endpoints.web.base-path=/management", - "server.servlet.context-path=/demo/api", "management.server.port=9002", "management.server.base-path=/demo/api", + "server.servlet.context-path=/demo/api", "management.server.port=9302", "management.server.base-path=/demo/api", "springdoc.swagger-ui.urls[0].url=/api-docs/xxx/v1/openapi.yml", "springdoc.swagger-ui.urls[0].name=toto", }) diff --git a/springdoc-openapi-starter-webmvc-ui/src/test/java/test/org/springdoc/ui/app13/SpringDocApp13Test.java b/springdoc-openapi-starter-webmvc-ui/src/test/java/test/org/springdoc/ui/app13/SpringDocApp13Test.java index 4ef00a02a..ca4b91e7d 100644 --- a/springdoc-openapi-starter-webmvc-ui/src/test/java/test/org/springdoc/ui/app13/SpringDocApp13Test.java +++ b/springdoc-openapi-starter-webmvc-ui/src/test/java/test/org/springdoc/ui/app13/SpringDocApp13Test.java @@ -33,7 +33,7 @@ @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, properties = { "management.endpoints.web.exposure.include=*", "springdoc.use-management-port=true", - "management.server.port=9292", "management.endpoints.web.base-path=/application" }) + "management.server.port=9392", "management.endpoints.web.base-path=/application" }) class SpringDocApp13Test extends AbstractSpringDocActuatorTest { @Test diff --git a/springdoc-openapi-starter-webmvc-ui/src/test/java/test/org/springdoc/ui/app14/HelloController.java b/springdoc-openapi-starter-webmvc-ui/src/test/java/test/org/springdoc/ui/app14/HelloController.java index eae081732..a122ff906 100644 --- a/springdoc-openapi-starter-webmvc-ui/src/test/java/test/org/springdoc/ui/app14/HelloController.java +++ b/springdoc-openapi-starter-webmvc-ui/src/test/java/test/org/springdoc/ui/app14/HelloController.java @@ -40,7 +40,7 @@ public void persons(@Valid @RequestParam @Size(min = 4, max = 6) String name) { public GroupedOpenApi userOpenApi() { return GroupedOpenApi.builder() .group("users") - .packagesToScan("test.org.springdoc.api.app145") + .packagesToScan("test.org.springdoc.api.v30.app145") .build(); } } diff --git a/springdoc-openapi-starter-webmvc-ui/src/test/java/test/org/springdoc/ui/app14/SpringDocApp14Test.java b/springdoc-openapi-starter-webmvc-ui/src/test/java/test/org/springdoc/ui/app14/SpringDocApp14Test.java index b0974c254..57427c878 100644 --- a/springdoc-openapi-starter-webmvc-ui/src/test/java/test/org/springdoc/ui/app14/SpringDocApp14Test.java +++ b/springdoc-openapi-starter-webmvc-ui/src/test/java/test/org/springdoc/ui/app14/SpringDocApp14Test.java @@ -33,7 +33,7 @@ @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, properties = { "management.endpoints.web.exposure.include=*", "springdoc.use-management-port=true", - "management.server.port=9293", "management.endpoints.web.base-path=/application" }) + "management.server.port=9393", "management.endpoints.web.base-path=/application" }) class SpringDocApp14Test extends AbstractSpringDocActuatorTest { @Test diff --git a/springdoc-openapi-starter-webmvc-ui/src/test/java/test/org/springdoc/ui/app15/SpringDocApp15Test.java b/springdoc-openapi-starter-webmvc-ui/src/test/java/test/org/springdoc/ui/app15/SpringDocApp15Test.java index d22960442..88675ccba 100644 --- a/springdoc-openapi-starter-webmvc-ui/src/test/java/test/org/springdoc/ui/app15/SpringDocApp15Test.java +++ b/springdoc-openapi-starter-webmvc-ui/src/test/java/test/org/springdoc/ui/app15/SpringDocApp15Test.java @@ -34,7 +34,7 @@ @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, properties = { "management.endpoints.web.exposure.include=*", "springdoc.use-management-port=true", - "management.server.port=9294", + "management.server.port=9394", "management.server.base-path=/test", "management.endpoints.web.base-path=/application" }) class SpringDocApp15Test extends AbstractSpringDocActuatorTest { diff --git a/springdoc-openapi-starter-webmvc-ui/src/test/java/test/org/springdoc/ui/app16/HelloController.java b/springdoc-openapi-starter-webmvc-ui/src/test/java/test/org/springdoc/ui/app16/HelloController.java index a397c47d5..ccbdc8d78 100644 --- a/springdoc-openapi-starter-webmvc-ui/src/test/java/test/org/springdoc/ui/app16/HelloController.java +++ b/springdoc-openapi-starter-webmvc-ui/src/test/java/test/org/springdoc/ui/app16/HelloController.java @@ -39,7 +39,7 @@ public void persons(@Valid @RequestParam @Size(min = 4, max = 6) String name) { public GroupedOpenApi userOpenApi() { return GroupedOpenApi.builder() .group("users") - .packagesToScan("test.org.springdoc.api.app145") + .packagesToScan("test.org.springdoc.api.v30.app145") .build(); } } diff --git a/springdoc-openapi-starter-webmvc-ui/src/test/java/test/org/springdoc/ui/app16/SpringDocApp16Test.java b/springdoc-openapi-starter-webmvc-ui/src/test/java/test/org/springdoc/ui/app16/SpringDocApp16Test.java index 1e904ba5c..e7a9d7eea 100644 --- a/springdoc-openapi-starter-webmvc-ui/src/test/java/test/org/springdoc/ui/app16/SpringDocApp16Test.java +++ b/springdoc-openapi-starter-webmvc-ui/src/test/java/test/org/springdoc/ui/app16/SpringDocApp16Test.java @@ -34,7 +34,7 @@ @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, properties = { "management.endpoints.web.exposure.include=*", "springdoc.use-management-port=true", - "management.server.port=9295", + "management.server.port=9395", "management.server.base-path=/test", "management.endpoints.web.base-path=/application" }) class SpringDocApp16Test extends AbstractSpringDocActuatorTest { diff --git a/springdoc-openapi-starter-webmvc-ui/src/test/java/test/org/springdoc/ui/app17/SpringDocApp17Test.java b/springdoc-openapi-starter-webmvc-ui/src/test/java/test/org/springdoc/ui/app17/SpringDocApp17Test.java index ec462eb8e..a74aabf93 100644 --- a/springdoc-openapi-starter-webmvc-ui/src/test/java/test/org/springdoc/ui/app17/SpringDocApp17Test.java +++ b/springdoc-openapi-starter-webmvc-ui/src/test/java/test/org/springdoc/ui/app17/SpringDocApp17Test.java @@ -33,7 +33,7 @@ @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, properties = { "management.endpoints.web.exposure.include=*", "springdoc.show-actuator=true", - "management.server.port=9296", + "management.server.port=9396", "server.servlet.context-path=/sample", "management.server.base-path=/test", "management.endpoints.web.base-path=/application" }) diff --git a/springdoc-openapi-starter-webmvc-ui/src/test/resources/results/app13-1.json b/springdoc-openapi-starter-webmvc-ui/src/test/resources/results/app13-1.json index 324ce7cb0..b52718be9 100644 --- a/springdoc-openapi-starter-webmvc-ui/src/test/resources/results/app13-1.json +++ b/springdoc-openapi-starter-webmvc-ui/src/test/resources/results/app13-1.json @@ -1,6 +1,6 @@ { "configUrl": "/application/swagger-ui/swagger-config", - "oauth2RedirectUrl": "http://localhost:9292/application/swagger-ui/oauth2-redirect.html", + "oauth2RedirectUrl": "http://localhost:9392/application/swagger-ui/oauth2-redirect.html", "url": "/application/openapi", "validatorUrl": "" } \ No newline at end of file diff --git a/springdoc-openapi-starter-webmvc-ui/src/test/resources/results/app14-1.json b/springdoc-openapi-starter-webmvc-ui/src/test/resources/results/app14-1.json index 8a0e78ae8..4ff87fb65 100644 --- a/springdoc-openapi-starter-webmvc-ui/src/test/resources/results/app14-1.json +++ b/springdoc-openapi-starter-webmvc-ui/src/test/resources/results/app14-1.json @@ -1,6 +1,6 @@ { "configUrl": "/application/swagger-ui/swagger-config", - "oauth2RedirectUrl": "http://localhost:9293/application/swagger-ui/oauth2-redirect.html", + "oauth2RedirectUrl": "http://localhost:9393/application/swagger-ui/oauth2-redirect.html", "urls": [ { "url": "/application/openapi/users", diff --git a/springdoc-openapi-starter-webmvc-ui/src/test/resources/results/app15-1.json b/springdoc-openapi-starter-webmvc-ui/src/test/resources/results/app15-1.json index e4a59fac8..b408d4b00 100644 --- a/springdoc-openapi-starter-webmvc-ui/src/test/resources/results/app15-1.json +++ b/springdoc-openapi-starter-webmvc-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/swagger-ui/oauth2-redirect.html", + "oauth2RedirectUrl": "http://localhost:9394/test/application/swagger-ui/oauth2-redirect.html", "url": "/test/application/openapi", "validatorUrl": "" } \ No newline at end of file diff --git a/springdoc-openapi-starter-webmvc-ui/src/test/resources/results/app16-1.json b/springdoc-openapi-starter-webmvc-ui/src/test/resources/results/app16-1.json index e8f48875b..4686ed28b 100644 --- a/springdoc-openapi-starter-webmvc-ui/src/test/resources/results/app16-1.json +++ b/springdoc-openapi-starter-webmvc-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/swagger-ui/oauth2-redirect.html", + "oauth2RedirectUrl": "http://localhost:9395/test/application/swagger-ui/oauth2-redirect.html", "urls": [ { "url": "/test/application/openapi/users", diff --git a/springdoc-openapi-tests/pom.xml b/springdoc-openapi-tests/pom.xml index c8ea5e5b1..6da52c0cd 100644 --- a/springdoc-openapi-tests/pom.xml +++ b/springdoc-openapi-tests/pom.xml @@ -2,7 +2,7 @@ springdoc-openapi org.springdoc - 2.8.1 + 2.8.2 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 a0ab201c4..a9115f87a 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.1 + 2.8.2 4.0.0 diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/AbstractCommonTest.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/AbstractCommonTest.java deleted file mode 100644 index 9100ddb4e..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/AbstractCommonTest.java +++ /dev/null @@ -1,56 +0,0 @@ -package test.org.springdoc.api; - -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springdoc.core.utils.Constants; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.web.reactive.AutoConfigureWebTestClient; -import org.springframework.test.context.ActiveProfiles; -import org.springframework.test.context.TestPropertySource; -import org.springframework.test.web.reactive.server.EntityExchangeResult; -import org.springframework.test.web.reactive.server.WebTestClient; - -import static org.skyscreamer.jsonassert.JSONAssert.assertEquals; - -@AutoConfigureWebTestClient(timeout = "3600000") -@ActiveProfiles("test") -@TestPropertySource(properties = { "management.endpoints.enabled-by-default=false" , "springdoc.api-docs.version=openapi_3_0" }) -public abstract class AbstractCommonTest { - - protected static final Logger LOGGER = LoggerFactory.getLogger(AbstractCommonTest.class); - - @Autowired - protected WebTestClient webTestClient; - - protected String getContent(String fileName) { - try { - Path path = Paths.get(AbstractCommonTest.class.getClassLoader().getResource(fileName).toURI()); - byte[] fileBytes = Files.readAllBytes(path); - return new String(fileBytes, StandardCharsets.UTF_8); - } - catch (Exception e) { - throw new RuntimeException("Failed to read file: " + fileName, e); - } - } - - protected void testApp(String testId, String groupName) throws Exception{ - String result = null; - try { - EntityExchangeResult getResult = webTestClient.get().uri(Constants.DEFAULT_API_DOCS_URL + "/" + groupName).exchange() - .expectStatus().isOk().expectBody().returnResult(); - result = new String(getResult.getResponseBody()); - String expected = getContent("results/app" + testId + ".json"); - assertEquals(expected, result, true); - } - catch (AssertionError e) { - LOGGER.error(result); - throw e; - } - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/AbstractSpringDocActuatorTest.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/AbstractSpringDocActuatorTest.java deleted file mode 100644 index d40f8cbd6..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/AbstractSpringDocActuatorTest.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * - * * - * * * - * * * * - * * * * * 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; - -import jakarta.annotation.PostConstruct; - -import org.springframework.boot.test.web.server.LocalManagementPort; -import org.springframework.test.context.TestPropertySource; -import org.springframework.web.reactive.function.client.WebClient; - -import static org.skyscreamer.jsonassert.JSONAssert.assertEquals; - -@TestPropertySource(properties = { "management.endpoints.enabled-by-default=true" }) -public abstract class AbstractSpringDocActuatorTest extends AbstractCommonTest { - - protected WebClient webClient; - - @LocalManagementPort - private int managementPort; - - @PostConstruct - void init() { - webClient = WebClient.builder().baseUrl("http://localhost:" + this.managementPort) - .build(); - } - - protected void testWithWebClient(String testId, String uri) throws Exception{ - String result = null; - try { - result = webClient.get().uri(uri).retrieve() - .bodyToMono(String.class).block(); - String expected = getContent("results/app"+testId+".json"); - assertEquals(expected, result, true); - } - catch (AssertionError e) { - LOGGER.error(result); - throw e; - } - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/AbstractSpringDocTest.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/AbstractSpringDocTest.java deleted file mode 100644 index 208bea214..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/AbstractSpringDocTest.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * - * * Copyright 2019-2020 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; - -import org.apache.commons.lang3.StringUtils; -import org.junit.jupiter.api.Test; - -import org.springframework.boot.test.autoconfigure.web.reactive.WebFluxTest; - - -@WebFluxTest -public abstract class AbstractSpringDocTest extends AbstractCommonTest { - - @Test - protected void testApp() throws Exception { - String className = getClass().getSimpleName(); - String testId = className.replaceAll("[^0-9]", ""); - testApp(testId, StringUtils.EMPTY); - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/app144/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/app144/HelloController.java deleted file mode 100644 index 59fee7564..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/app144/HelloController.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app144; - -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -@RestController -public class HelloController { - - @GetMapping("/persons") - public String persons() { - return "OK"; - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/app144/SpringDocApp144Test.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/app144/SpringDocApp144Test.java deleted file mode 100644 index cddabb844..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/app144/SpringDocApp144Test.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app144; - -import org.junit.jupiter.api.Test; -import org.springdoc.core.utils.Constants; -import test.org.springdoc.api.AbstractSpringDocActuatorTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; - -import static org.skyscreamer.jsonassert.JSONAssert.assertEquals; - - -@SpringBootTest(webEnvironment = WebEnvironment.DEFINED_PORT, - properties = { "management.endpoints.web.exposure.include=*", - "server.port=52555", - "springdoc.use-management-port=true", - "management.server.port=9289", - "management.endpoints.web.base-path=/application" }) -public class SpringDocApp144Test extends AbstractSpringDocActuatorTest { - - @Test - void testApp() { - webTestClient.get().uri(Constants.DEFAULT_API_DOCS_URL).exchange() - .expectStatus().isNotFound(); - } - - @Test - void testApp1() throws Exception { - String result = webClient.get().uri("/application/openapi").retrieve() - .bodyToMono(String.class) - .block(); - String expected = getContent("results/app144.json"); - assertEquals(expected, result, true); - } - - @SpringBootApplication - static class SpringDocTestApp {} - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/app145/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/app145/HelloController.java deleted file mode 100644 index 8174acd71..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/app145/HelloController.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app145; - -import org.springframework.context.annotation.Configuration; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -@RestController -@Configuration -public class HelloController { - - @GetMapping("/persons") - public String persons() { - return "OK"; - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/app145/SpringDocApp1451Test.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/app145/SpringDocApp1451Test.java deleted file mode 100644 index f47274bb2..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/app145/SpringDocApp1451Test.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app145; - -import org.junit.jupiter.api.Test; -import test.org.springdoc.api.AbstractSpringDocActuatorTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; -import org.springframework.http.HttpStatus; -import org.springframework.test.annotation.DirtiesContext; -import org.springframework.web.reactive.function.client.WebClientResponseException; - -import static org.junit.jupiter.api.Assertions.assertTrue; -import static org.junit.jupiter.api.Assertions.fail; -import static org.skyscreamer.jsonassert.JSONAssert.assertEquals; - -@DirtiesContext -@SpringBootTest(webEnvironment = WebEnvironment.DEFINED_PORT, - properties = { "management.endpoints.web.exposure.include=*", - "server.port=52594", - "springdoc.use-management-port=true", - "springdoc.group-configs[0].group=users", - "springdoc.group-configs[0].packages-to-scan=test.org.springdoc.api.app145", - "management.server.port=9294", - "management.endpoints.web.base-path=/application" }) -public class SpringDocApp1451Test extends AbstractSpringDocActuatorTest { - - @Test - void testApp() { - try { - webClient.get().uri("/application/openapi").retrieve() - .bodyToMono(String.class).block(); - fail(); - } - catch (WebClientResponseException ex) { - if (ex.getStatusCode() == HttpStatus.NOT_FOUND) - assertTrue(true); - else - fail(); - } - } - - @Test - void testApp2() throws Exception { - try { - String result = webClient.get().uri("/application/openapi/users").retrieve() - .bodyToMono(String.class).block(); - String expected = getContent("results/app145-1.json"); - assertEquals(expected, result, true); - } - catch (WebClientResponseException ex) { - fail(); - } - } - - @SpringBootApplication - static class SpringDocTestApp {} - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/app145/SpringDocApp1452Test.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/app145/SpringDocApp1452Test.java deleted file mode 100644 index b2efc928a..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/app145/SpringDocApp1452Test.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app145; - -import org.junit.jupiter.api.Test; -import test.org.springdoc.api.AbstractSpringDocActuatorTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; -import org.springframework.web.reactive.function.client.WebClientResponseException; - -import static org.junit.jupiter.api.Assertions.fail; -import static org.skyscreamer.jsonassert.JSONAssert.assertEquals; - - -@SpringBootTest(webEnvironment = WebEnvironment.DEFINED_PORT, - properties = { "management.endpoints.web.exposure.include=*", - "server.port=52595", - "springdoc.use-management-port=true", - "springdoc.group-configs[0].group=users", - "springdoc.group-configs[0].packages-to-scan=test.org.springdoc.api.app145", - "management.server.port=9285", - "management.endpoints.web.base-path=/application" }) -public class SpringDocApp1452Test extends AbstractSpringDocActuatorTest { - - @Test - void testApp() throws Exception { - try { - String result = webClient.get().uri("/application/openapi/users").retrieve() - .bodyToMono(String.class).block(); - String expected = getContent("results/app145-2.json"); - assertEquals(expected, result, true); - } - catch (WebClientResponseException ex) { - fail(); - } - } - - @SpringBootApplication - static class SpringDocTestApp {} - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/app145/SpringDocApp145Test.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/app145/SpringDocApp145Test.java deleted file mode 100644 index d723f920b..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/app145/SpringDocApp145Test.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * - * * 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.app145; - -import org.junit.jupiter.api.Test; -import org.springdoc.core.utils.Constants; -import test.org.springdoc.api.AbstractSpringDocActuatorTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; -import org.springframework.http.HttpStatus; -import org.springframework.web.reactive.function.client.WebClientResponseException; - -import static org.junit.jupiter.api.Assertions.assertTrue; -import static org.junit.jupiter.api.Assertions.fail; - - -@SpringBootTest(webEnvironment = WebEnvironment.DEFINED_PORT, - properties = { "management.endpoints.web.exposure.include=*", - "server.port=52593", - "springdoc.use-management-port=true", - "springdoc.group-configs[0].group=users", - "springdoc.group-configs[0].packages-to-scan=test.org.springdoc.api.app145", - "management.server.port=9300", - "management.endpoints.web.base-path=/application" }) -public class SpringDocApp145Test extends AbstractSpringDocActuatorTest { - - @Test - void testApp() { - webTestClient.get().uri(Constants.DEFAULT_API_DOCS_URL + "/users") - .exchange() - .expectStatus().isNotFound(); - } - - @Test - void testApp3() throws Exception { - try { - webClient.get().uri("/application/openapi" + "/" + Constants.DEFAULT_GROUP_NAME).retrieve() - .bodyToMono(String.class).block(); - fail(); - } - catch (WebClientResponseException ex) { - if (ex.getStatusCode() == HttpStatus.NOT_FOUND) - assertTrue(true); - else - fail(); - } - } - - @SpringBootApplication - static class SpringDocTestApp {} - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/app146/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/app146/HelloController.java deleted file mode 100644 index 9bacb38df..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/app146/HelloController.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app146; - -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -@RestController -public class HelloController { - - @GetMapping("/persons") - public String persons() { - return "OK"; - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/app146/SpringDocApp146Test.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/app146/SpringDocApp146Test.java deleted file mode 100644 index 593016888..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/app146/SpringDocApp146Test.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app146; - -import org.junit.jupiter.api.Test; -import org.springdoc.core.utils.Constants; -import test.org.springdoc.api.AbstractSpringDocActuatorTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.context.annotation.ComponentScan; - -@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, - properties = { "management.endpoints.web.exposure.include=*", - "springdoc.show-actuator=true", - "management.server.port=9286", - "management.endpoints.web.exposure.exclude=functions, shutdown", - "management.server.base-path=/test", - "management.endpoints.web.base-path=/application" }) -public class SpringDocApp146Test extends AbstractSpringDocActuatorTest { - - @Test - void testApp() throws Exception { - super.testApp("146-1", Constants.ACTUATOR_DEFAULT_GROUP); - } - - @Test - void testApp1() throws Exception { - super.testApp("146-2", Constants.DEFAULT_GROUP_NAME); - } - - @SpringBootApplication - @ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.app146" }) - static class SpringDocTestApp {} - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/app147/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/app147/HelloController.java deleted file mode 100644 index 056601a28..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/app147/HelloController.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app147; - -import org.springdoc.core.models.GroupedOpenApi; - -import org.springframework.context.annotation.Bean; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -@RestController -public class HelloController { - - @GetMapping("/persons") - public String persons() { - return "OK"; - } - - @Bean - public GroupedOpenApi userOpenApi() { - return GroupedOpenApi.builder() - .group("users") - .packagesToScan("test.org.springdoc.api.app147") - .build(); - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/app147/SpringDocApp147Test.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/app147/SpringDocApp147Test.java deleted file mode 100644 index 158bfd4d0..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/app147/SpringDocApp147Test.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app147; - -import org.junit.jupiter.api.Test; -import org.springdoc.core.utils.Constants; -import test.org.springdoc.api.AbstractSpringDocActuatorTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.test.context.SpringBootTest; - - -@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, - properties = { "management.endpoints.web.exposure.include=*", - "springdoc.show-actuator=true", - "management.endpoints.web.exposure.exclude=functions, shutdown", - "management.server.port=9297", - "management.server.base-path=/test", - "management.endpoints.web.base-path=/application" }) -public class SpringDocApp147Test extends AbstractSpringDocActuatorTest { - - @Test - void testApp() throws Exception { - super.testApp("147-1", Constants.ACTUATOR_DEFAULT_GROUP); - } - - @Test - void testApp1() throws Exception { - super.testApp("147-2", Constants.ACTUATOR_DEFAULT_GROUP); - - } - - @Test - void testApp2() throws Exception { - webTestClient.get().uri(Constants.DEFAULT_API_DOCS_URL + "/" + Constants.DEFAULT_GROUP_NAME) - .exchange() - .expectStatus().isNotFound(); - } - - @SpringBootApplication - static class SpringDocTestApp {} - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/app148/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/app148/HelloController.java deleted file mode 100644 index 9fd033a99..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/app148/HelloController.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app148; - - -import org.springdoc.core.models.GroupedOpenApi; - -import org.springframework.context.annotation.Bean; -import org.springframework.core.Ordered; -import org.springframework.core.annotation.Order; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -@RestController -public class HelloController { - - @GetMapping("/persons") - public String persons() { - return "OK"; - } - - @Bean - @Order(Ordered.HIGHEST_PRECEDENCE) - public GroupedOpenApi userOpenApi() { - return GroupedOpenApi.builder() - .group("users") - .packagesToScan("test.org.springdoc.api.app148") - .build(); - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/app148/SpringDocApp148Test.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/app148/SpringDocApp148Test.java deleted file mode 100644 index 0db1f4cd3..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/app148/SpringDocApp148Test.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app148; - -import org.junit.jupiter.api.Test; -import org.springdoc.core.utils.Constants; -import test.org.springdoc.api.AbstractSpringDocActuatorTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; -import org.springframework.http.HttpStatus; -import org.springframework.web.reactive.function.client.WebClientResponseException; - -import static org.junit.jupiter.api.Assertions.assertTrue; -import static org.junit.jupiter.api.Assertions.fail; - - -@SpringBootTest(webEnvironment = WebEnvironment.DEFINED_PORT, - properties = { "management.endpoints.web.exposure.include=*", - "springdoc.show-actuator=true", - "management.endpoints.web.exposure.exclude=functions, shutdown", - "management.server.port=9288", - "server.port=6266", - "springdoc.use-management-port=true", - "management.server.base-path=/test", - "management.endpoints.web.base-path=/application" }) -public class SpringDocApp148Test extends AbstractSpringDocActuatorTest { - - @Test - void testApp() throws Exception { - super.testWithWebClient("148-1","/test/application/openapi/users"); - } - - @Test - void testApp2() throws Exception { - super.testWithWebClient("148-2","/test/application/openapi/x-actuator"); - } - - @Test - void testApp3() throws Exception { - try { - webClient.get().uri("/test/application/openapi" + "/" + Constants.DEFAULT_GROUP_NAME).retrieve() - .bodyToMono(String.class).block(); - fail(); - } - catch (WebClientResponseException ex) { - if (ex.getStatusCode() == HttpStatus.NOT_FOUND) - assertTrue(true); - else - fail(); - } - } - - @SpringBootApplication - static class SpringDocTestApp {} -} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/app186/SpringDocApp186Test.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/app186/SpringDocApp186Test.java deleted file mode 100644 index 7b6509736..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/app186/SpringDocApp186Test.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * - * * - * * * - * * * * - * * * * * 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.app186; - - -import org.junit.jupiter.api.Test; -import org.springdoc.core.customizers.OperationCustomizer; -import org.springdoc.core.models.GroupedOpenApi; -import org.springdoc.core.utils.Constants; -import test.org.springdoc.api.AbstractCommonTest; - -import org.springframework.boot.actuate.autoconfigure.endpoint.web.WebEndpointProperties; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.test.context.TestPropertySource; - -import static org.springdoc.core.utils.Constants.ALL_PATTERN; - -@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) -@TestPropertySource(properties = { "springdoc.show-actuator=true", - "springdoc.group-configs[0].group=group-actuator-as-properties", - "springdoc.group-configs[0].paths-to-match=${management.endpoints.web.base-path:/actuator}/**", - "management.endpoints.enabled-by-default=true", - "management.endpoints.web.exposure.include=*", - "management.endpoints.web.exposure.exclude=functions, shutdown" }) -public class SpringDocApp186Test extends AbstractCommonTest { - - @Test - void testApp() throws Exception { - webTestClient.get().uri(Constants.DEFAULT_API_DOCS_URL).exchange() - .expectStatus().isOk() - .expectBody().json(getContent("results/app186.json"), true); - } - - @Test - void testGroupActuatorAsCodeCheckBackwardsCompatibility() { - webTestClient.get().uri(Constants.DEFAULT_API_DOCS_URL + "/group-actuator-as-code-check-backwards-compatibility").exchange() - .expectStatus().isOk() - .expectBody().json(getContent("results/app186.json"), true); - } - - @Test - void testGroupActuatorAsCode() { - webTestClient.get().uri(Constants.DEFAULT_API_DOCS_URL + "/group-actuator-as-code").exchange() - .expectStatus().isOk() - .expectBody().json(getContent("results/app186.json"), true); - } - - @Test - void testGroupActuatorAsProperties() { - webTestClient.get().uri(Constants.DEFAULT_API_DOCS_URL + "/group-actuator-as-properties").exchange() - .expectStatus().isOk() - .expectBody().json(getContent("results/app186.json"), true); - } - - @SpringBootApplication - @ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.app186" }) - static class SpringDocTestApp { - - @Bean - public GroupedOpenApi asCodeCheckBackwardsCompatibility(OperationCustomizer actuatorCustomizer, WebEndpointProperties endpointProperties) { - return GroupedOpenApi.builder() - .group("group-actuator-as-code-check-backwards-compatibility") - .pathsToMatch(endpointProperties.getBasePath() + ALL_PATTERN) - .addOperationCustomizer(actuatorCustomizer) - .build(); - } - - @Bean - public GroupedOpenApi asCode(WebEndpointProperties endpointProperties) { - return GroupedOpenApi.builder() - .group("group-actuator-as-code") - .pathsToMatch(endpointProperties.getBasePath() + ALL_PATTERN) - .build(); - } - } -} - diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/app76/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/app76/HelloController.java deleted file mode 100644 index 902637398..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/app76/HelloController.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * - * * - * * * - * * * * Copyright 2019-2020 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.app76; - -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.media.Content; -import io.swagger.v3.oas.annotations.responses.ApiResponse; -import io.swagger.v3.oas.annotations.responses.ApiResponses; -import reactor.core.publisher.Mono; - -import org.springframework.http.MediaType; -import org.springframework.http.codec.multipart.FilePart; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestPart; -import org.springframework.web.bind.annotation.RestController; - - -@RestController -public class HelloController { - - - @Operation(summary = "Parse Resume") - @PostMapping(value = "/parse-resume", produces = { MediaType.APPLICATION_JSON_VALUE }, consumes = { - MediaType.MULTIPART_FORM_DATA_VALUE }) - @ApiResponses({ @ApiResponse(responseCode = "400", description = "Invalid input") }) - public Mono parse( - @RequestPart(name = "resumeFile") @Parameter(description = "Resume file to be parsed", content = @Content(mediaType = MediaType.APPLICATION_OCTET_STREAM_VALUE)) FilePart resumeFile) { - return null; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/app76/SpringDocApp76Test.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/app76/SpringDocApp76Test.java deleted file mode 100644 index ac7d1a833..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/app76/SpringDocApp76Test.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * - * * - * * * - * * * * Copyright 2019-2020 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.app76; - -import org.junit.jupiter.api.Test; -import org.springdoc.core.utils.Constants; -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.test.context.TestPropertySource; - -@TestPropertySource(properties = { - "springdoc.show-actuator=true", - "management.endpoints.enabled-by-default=true" -}) -public class SpringDocApp76Test extends AbstractSpringDocTest { - - @Test - protected void testApp() { - webTestClient.get().uri(Constants.DEFAULT_API_DOCS_URL + "/actuator").exchange().expectStatus().isOk().expectBody() - .jsonPath("$.openapi").isEqualTo("3.0.1") - .jsonPath("$.paths./actuator/health.get.operationId").exists(); - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/app76/SpringDocTestApp.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/app76/SpringDocTestApp.java deleted file mode 100644 index 628a8a691..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/app76/SpringDocTestApp.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * - * * - * * * - * * * * Copyright 2019-2020 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.app76; - -import io.swagger.v3.oas.models.Components; -import io.swagger.v3.oas.models.OpenAPI; -import io.swagger.v3.oas.models.info.Info; -import io.swagger.v3.oas.models.info.License; -import io.swagger.v3.oas.models.security.SecurityScheme; -import org.springdoc.core.models.GroupedOpenApi; - -import org.springframework.boot.actuate.autoconfigure.endpoint.EndpointAutoConfiguration; -import org.springframework.boot.actuate.autoconfigure.endpoint.web.WebEndpointAutoConfiguration; -import org.springframework.boot.actuate.autoconfigure.endpoint.web.reactive.WebFluxEndpointManagementContextConfiguration; -import org.springframework.boot.actuate.autoconfigure.health.HealthEndpointAutoConfiguration; -import org.springframework.boot.actuate.autoconfigure.info.InfoEndpointAutoConfiguration; -import org.springframework.boot.actuate.autoconfigure.web.reactive.ReactiveManagementContextAutoConfiguration; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Import; - -@SpringBootApplication -@Import({ WebEndpointAutoConfiguration.class, - EndpointAutoConfiguration.class, - InfoEndpointAutoConfiguration.class, - HealthEndpointAutoConfiguration.class, - WebFluxEndpointManagementContextConfiguration.class, - ReactiveManagementContextAutoConfiguration.class }) -@ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.app76" }) -public class SpringDocTestApp { - - @Bean - public OpenAPI customOpenAPI() { - return new OpenAPI() - .components(new Components().addSecuritySchemes("basicScheme", - new SecurityScheme().type(SecurityScheme.Type.HTTP).scheme("basic"))) - .info(new Info().title("Tweet API").version("v0") - .license(new License().name("Apache 2.0").url("http://springdoc.org"))); - } - - - @Bean - public GroupedOpenApi actuatorApi() { - return GroupedOpenApi.builder().group("actuator") - .pathsToMatch("/actuator/**") - .pathsToExclude("/actuator/health/*") - .build(); - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/v30/AbstractCommonTest.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/v30/AbstractCommonTest.java new file mode 100644 index 000000000..a9ca71da1 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/v30/AbstractCommonTest.java @@ -0,0 +1,82 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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; + +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springdoc.core.utils.Constants; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.reactive.AutoConfigureWebTestClient; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.context.TestPropertySource; +import org.springframework.test.web.reactive.server.EntityExchangeResult; +import org.springframework.test.web.reactive.server.WebTestClient; + +import static org.skyscreamer.jsonassert.JSONAssert.assertEquals; + +@AutoConfigureWebTestClient(timeout = "3600000") +@ActiveProfiles("test") +@TestPropertySource(properties = { "management.endpoints.enabled-by-default=false" , "springdoc.api-docs.version=openapi_3_0" }) +public abstract class AbstractCommonTest { + + protected static final Logger LOGGER = LoggerFactory.getLogger(AbstractCommonTest.class); + + @Autowired + protected WebTestClient webTestClient; + + protected String getContent(String fileName) { + try { + Path path = Paths.get(AbstractCommonTest.class.getClassLoader().getResource(fileName).toURI()); + byte[] fileBytes = Files.readAllBytes(path); + return new String(fileBytes, StandardCharsets.UTF_8); + } + catch (Exception e) { + throw new RuntimeException("Failed to read file: " + fileName, e); + } + } + + protected void testApp(String testId, String groupName) throws Exception{ + String result = null; + try { + EntityExchangeResult getResult = webTestClient.get().uri(Constants.DEFAULT_API_DOCS_URL + "/" + groupName).exchange() + .expectStatus().isOk().expectBody().returnResult(); + result = new String(getResult.getResponseBody()); + String expected = getContent("results/3.0.1/app" + testId + ".json"); + assertEquals(expected, result, true); + } + catch (AssertionError e) { + LOGGER.error(result); + throw e; + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/v30/AbstractSpringDocActuatorTest.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/v30/AbstractSpringDocActuatorTest.java new file mode 100644 index 000000000..9cf22257e --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/v30/AbstractSpringDocActuatorTest.java @@ -0,0 +1,64 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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; + +import jakarta.annotation.PostConstruct; + +import org.springframework.boot.test.web.server.LocalManagementPort; +import org.springframework.test.context.TestPropertySource; +import org.springframework.web.reactive.function.client.WebClient; + +import static org.skyscreamer.jsonassert.JSONAssert.assertEquals; + +@TestPropertySource(properties = { "management.endpoints.enabled-by-default=true" }) +public abstract class AbstractSpringDocActuatorTest extends AbstractCommonTest { + + protected WebClient webClient; + + @LocalManagementPort + private int managementPort; + + @PostConstruct + void init() { + webClient = WebClient.builder().baseUrl("http://localhost:" + this.managementPort) + .build(); + } + + protected void testWithWebClient(String testId, String uri) throws Exception{ + String result = null; + try { + result = webClient.get().uri(uri).retrieve() + .bodyToMono(String.class).block(); + String expected = getContent("results/3.0.1/app"+testId+".json"); + assertEquals(expected, result, true); + } + catch (AssertionError e) { + LOGGER.error(result); + throw e; + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/v30/AbstractSpringDocTest.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/v30/AbstractSpringDocTest.java new file mode 100644 index 000000000..e48725728 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/v30/AbstractSpringDocTest.java @@ -0,0 +1,45 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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; + +import org.apache.commons.lang3.StringUtils; +import org.junit.jupiter.api.Test; + +import org.springframework.boot.test.autoconfigure.web.reactive.WebFluxTest; + + +@WebFluxTest +public abstract class AbstractSpringDocTest extends AbstractCommonTest { + + @Test + protected void testApp() throws Exception { + String className = getClass().getSimpleName(); + String testId = className.replaceAll("[^0-9]", ""); + testApp(testId, StringUtils.EMPTY); + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/v30/app144/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/v30/app144/HelloController.java new file mode 100644 index 000000000..a5027a7c4 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/v30/app144/HelloController.java @@ -0,0 +1,32 @@ +/* + * + * * Copyright 2019-2020 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.app144; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class HelloController { + + @GetMapping("/persons") + public String persons() { + return "OK"; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/v30/app144/SpringDocApp144Test.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/v30/app144/SpringDocApp144Test.java new file mode 100644 index 000000000..999675edc --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/v30/app144/SpringDocApp144Test.java @@ -0,0 +1,58 @@ +/* + * + * * Copyright 2019-2020 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.app144; + +import org.junit.jupiter.api.Test; +import org.springdoc.core.utils.Constants; +import test.org.springdoc.api.v30.AbstractSpringDocActuatorTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; + +import static org.skyscreamer.jsonassert.JSONAssert.assertEquals; + + +@SpringBootTest(webEnvironment = WebEnvironment.DEFINED_PORT, + properties = { "management.endpoints.web.exposure.include=*", + "server.port=52555", + "springdoc.use-management-port=true", + "management.server.port=9289", + "management.endpoints.web.base-path=/application" }) +public class SpringDocApp144Test extends AbstractSpringDocActuatorTest { + + @Test + void testApp() { + webTestClient.get().uri(Constants.DEFAULT_API_DOCS_URL).exchange() + .expectStatus().isNotFound(); + } + + @Test + void testApp1() throws Exception { + String result = webClient.get().uri("/application/openapi").retrieve() + .bodyToMono(String.class) + .block(); + String expected = getContent("results/3.0.1/app144.json"); + assertEquals(expected, result, true); + } + + @SpringBootApplication + static class SpringDocTestApp {} + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/v30/app145/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/v30/app145/HelloController.java new file mode 100644 index 000000000..7f962e07a --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/v30/app145/HelloController.java @@ -0,0 +1,34 @@ +/* + * + * * Copyright 2019-2020 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.app145; + +import org.springframework.context.annotation.Configuration; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@Configuration +public class HelloController { + + @GetMapping("/persons") + public String persons() { + return "OK"; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/v30/app145/SpringDocApp1451Test.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/v30/app145/SpringDocApp1451Test.java new file mode 100644 index 000000000..4332992fa --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/v30/app145/SpringDocApp1451Test.java @@ -0,0 +1,77 @@ +/* + * + * * Copyright 2019-2020 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.app145; + +import org.junit.jupiter.api.Test; +import test.org.springdoc.api.v30.AbstractSpringDocActuatorTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; +import org.springframework.http.HttpStatus; +import org.springframework.test.annotation.DirtiesContext; +import org.springframework.web.reactive.function.client.WebClientResponseException; + +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; +import static org.skyscreamer.jsonassert.JSONAssert.assertEquals; + +@DirtiesContext +@SpringBootTest(webEnvironment = WebEnvironment.DEFINED_PORT, + properties = { "management.endpoints.web.exposure.include=*", + "server.port=52594", + "springdoc.use-management-port=true", + "springdoc.group-configs[0].group=users", + "springdoc.group-configs[0].packages-to-scan=test.org.springdoc.api.v30.app145", + "management.server.port=9284", + "management.endpoints.web.base-path=/application" }) +public class SpringDocApp1451Test extends AbstractSpringDocActuatorTest { + + @Test + void testApp() { + try { + webClient.get().uri("/application/openapi").retrieve() + .bodyToMono(String.class).block(); + fail(); + } + catch (WebClientResponseException ex) { + if (ex.getStatusCode() == HttpStatus.NOT_FOUND) + assertTrue(true); + else + fail(); + } + } + + @Test + void testApp2() throws Exception { + try { + String result = webClient.get().uri("/application/openapi/users").retrieve() + .bodyToMono(String.class).block(); + String expected = getContent("results/3.0.1/app145-1.json"); + assertEquals(expected, result, true); + } + catch (WebClientResponseException ex) { + fail(); + } + } + + @SpringBootApplication + static class SpringDocTestApp {} + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/v30/app145/SpringDocApp1452Test.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/v30/app145/SpringDocApp1452Test.java new file mode 100644 index 000000000..2a1bb3030 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/v30/app145/SpringDocApp1452Test.java @@ -0,0 +1,59 @@ +/* + * + * * Copyright 2019-2020 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.app145; + +import org.junit.jupiter.api.Test; +import test.org.springdoc.api.v30.AbstractSpringDocActuatorTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; +import org.springframework.web.reactive.function.client.WebClientResponseException; + +import static org.junit.jupiter.api.Assertions.fail; +import static org.skyscreamer.jsonassert.JSONAssert.assertEquals; + + +@SpringBootTest(webEnvironment = WebEnvironment.DEFINED_PORT, + properties = { "management.endpoints.web.exposure.include=*", + "server.port=52595", + "springdoc.use-management-port=true", + "springdoc.group-configs[0].group=users", + "springdoc.group-configs[0].packages-to-scan=test.org.springdoc.api.v30.app145", + "management.server.port=9285", + "management.endpoints.web.base-path=/application" }) +public class SpringDocApp1452Test extends AbstractSpringDocActuatorTest { + + @Test + void testApp() throws Exception { + try { + String result = webClient.get().uri("/application/openapi/users").retrieve() + .bodyToMono(String.class).block(); + String expected = getContent("results/3.0.1/app145-2.json"); + assertEquals(expected, result, true); + } + catch (WebClientResponseException ex) { + fail(); + } + } + + @SpringBootApplication + static class SpringDocTestApp {} + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/v30/app145/SpringDocApp145Test.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/v30/app145/SpringDocApp145Test.java new file mode 100644 index 000000000..44024ebbc --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/v30/app145/SpringDocApp145Test.java @@ -0,0 +1,70 @@ +/* + * + * * 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.app145; + +import org.junit.jupiter.api.Test; +import org.springdoc.core.utils.Constants; +import test.org.springdoc.api.v30.AbstractSpringDocActuatorTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; +import org.springframework.http.HttpStatus; +import org.springframework.web.reactive.function.client.WebClientResponseException; + +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; + + +@SpringBootTest(webEnvironment = WebEnvironment.DEFINED_PORT, + properties = { "management.endpoints.web.exposure.include=*", + "server.port=53593", + "springdoc.use-management-port=true", + "springdoc.group-configs[0].group=users", + "springdoc.group-configs[0].packages-to-scan=test.org.springdoc.api.v30.app145", + "management.server.port=9283", + "management.endpoints.web.base-path=/application" }) +public class SpringDocApp145Test extends AbstractSpringDocActuatorTest { + + @Test + void testApp() { + webTestClient.get().uri(Constants.DEFAULT_API_DOCS_URL + "/users") + .exchange() + .expectStatus().isNotFound(); + } + + @Test + void testApp3() throws Exception { + try { + webClient.get().uri("/application/openapi" + "/" + Constants.DEFAULT_GROUP_NAME).retrieve() + .bodyToMono(String.class).block(); + fail(); + } + catch (WebClientResponseException ex) { + if (ex.getStatusCode() == HttpStatus.NOT_FOUND) + assertTrue(true); + else + fail(); + } + } + + @SpringBootApplication + static class SpringDocTestApp {} + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/v30/app146/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/v30/app146/HelloController.java new file mode 100644 index 000000000..6465eb350 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/v30/app146/HelloController.java @@ -0,0 +1,32 @@ +/* + * + * * Copyright 2019-2020 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.app146; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class HelloController { + + @GetMapping("/persons") + public String persons() { + return "OK"; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/v30/app146/SpringDocApp146Test.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/v30/app146/SpringDocApp146Test.java new file mode 100644 index 000000000..42743fbad --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/v30/app146/SpringDocApp146Test.java @@ -0,0 +1,52 @@ +/* + * + * * Copyright 2019-2020 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.app146; + +import org.junit.jupiter.api.Test; +import org.springdoc.core.utils.Constants; +import test.org.springdoc.api.v30.AbstractSpringDocActuatorTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.context.annotation.ComponentScan; + +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, + properties = { "management.endpoints.web.exposure.include=*", + "springdoc.show-actuator=true", + "management.server.port=9286", + "management.endpoints.web.exposure.exclude=functions, shutdown", + "management.server.base-path=/test", + "management.endpoints.web.base-path=/application" }) +public class SpringDocApp146Test extends AbstractSpringDocActuatorTest { + + @Test + void testApp() throws Exception { + super.testApp("146-1", Constants.ACTUATOR_DEFAULT_GROUP); + } + + @Test + void testApp1() throws Exception { + super.testApp("146-2", Constants.DEFAULT_GROUP_NAME); + } + + @SpringBootApplication + @ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.v30.app146" }) + static class SpringDocTestApp {} + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/v30/app147/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/v30/app147/HelloController.java new file mode 100644 index 000000000..cb48d6693 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/v30/app147/HelloController.java @@ -0,0 +1,43 @@ +/* + * + * * Copyright 2019-2020 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.app147; + +import org.springdoc.core.models.GroupedOpenApi; + +import org.springframework.context.annotation.Bean; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class HelloController { + + @GetMapping("/persons") + public String persons() { + return "OK"; + } + + @Bean + public GroupedOpenApi userOpenApi() { + return GroupedOpenApi.builder() + .group("users") + .packagesToScan("test.org.springdoc.api.v30.app147") + .build(); + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/v30/app147/SpringDocApp147Test.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/v30/app147/SpringDocApp147Test.java new file mode 100644 index 000000000..02ea134ae --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/v30/app147/SpringDocApp147Test.java @@ -0,0 +1,59 @@ +/* + * + * * Copyright 2019-2020 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.app147; + +import org.junit.jupiter.api.Test; +import org.springdoc.core.utils.Constants; +import test.org.springdoc.api.v30.AbstractSpringDocActuatorTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.test.context.SpringBootTest; + + +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, + properties = { "management.endpoints.web.exposure.include=*", + "springdoc.show-actuator=true", + "management.endpoints.web.exposure.exclude=functions, shutdown", + "management.server.port=9287", + "management.server.base-path=/test", + "management.endpoints.web.base-path=/application" }) +public class SpringDocApp147Test extends AbstractSpringDocActuatorTest { + + @Test + void testApp() throws Exception { + super.testApp("147-1", Constants.ACTUATOR_DEFAULT_GROUP); + } + + @Test + void testApp1() throws Exception { + super.testApp("147-2", Constants.ACTUATOR_DEFAULT_GROUP); + + } + + @Test + void testApp2() throws Exception { + webTestClient.get().uri(Constants.DEFAULT_API_DOCS_URL + "/" + Constants.DEFAULT_GROUP_NAME) + .exchange() + .expectStatus().isNotFound(); + } + + @SpringBootApplication + static class SpringDocTestApp {} + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/v30/app148/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/v30/app148/HelloController.java new file mode 100644 index 000000000..14ccf700e --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/v30/app148/HelloController.java @@ -0,0 +1,47 @@ +/* + * + * * Copyright 2019-2020 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.app148; + + +import org.springdoc.core.models.GroupedOpenApi; + +import org.springframework.context.annotation.Bean; +import org.springframework.core.Ordered; +import org.springframework.core.annotation.Order; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class HelloController { + + @GetMapping("/persons") + public String persons() { + return "OK"; + } + + @Bean + @Order(Ordered.HIGHEST_PRECEDENCE) + public GroupedOpenApi userOpenApi() { + return GroupedOpenApi.builder() + .group("users") + .packagesToScan("test.org.springdoc.api.v30.app148") + .build(); + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/v30/app148/SpringDocApp148Test.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/v30/app148/SpringDocApp148Test.java new file mode 100644 index 000000000..d47194eb5 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/v30/app148/SpringDocApp148Test.java @@ -0,0 +1,73 @@ +/* + * + * * Copyright 2019-2020 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.app148; + +import org.junit.jupiter.api.Test; +import org.springdoc.core.utils.Constants; +import test.org.springdoc.api.v30.AbstractSpringDocActuatorTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; +import org.springframework.http.HttpStatus; +import org.springframework.web.reactive.function.client.WebClientResponseException; + +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; + + +@SpringBootTest(webEnvironment = WebEnvironment.DEFINED_PORT, + properties = { "management.endpoints.web.exposure.include=*", + "springdoc.show-actuator=true", + "management.endpoints.web.exposure.exclude=functions, shutdown", + "management.server.port=9288", + "server.port=6266", + "springdoc.use-management-port=true", + "management.server.base-path=/test", + "management.endpoints.web.base-path=/application" }) +public class SpringDocApp148Test extends AbstractSpringDocActuatorTest { + + @Test + void testApp() throws Exception { + super.testWithWebClient("148-1","/test/application/openapi/users"); + } + + @Test + void testApp2() throws Exception { + super.testWithWebClient("148-2","/test/application/openapi/x-actuator"); + } + + @Test + void testApp3() throws Exception { + try { + webClient.get().uri("/test/application/openapi" + "/" + Constants.DEFAULT_GROUP_NAME).retrieve() + .bodyToMono(String.class).block(); + fail(); + } + catch (WebClientResponseException ex) { + if (ex.getStatusCode() == HttpStatus.NOT_FOUND) + assertTrue(true); + else + fail(); + } + } + + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/v30/app186/SpringDocApp186Test.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/v30/app186/SpringDocApp186Test.java new file mode 100644 index 000000000..882079630 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/v30/app186/SpringDocApp186Test.java @@ -0,0 +1,102 @@ +/* + * + * * + * * * + * * * * + * * * * * 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.app186; + + +import org.junit.jupiter.api.Test; +import org.springdoc.core.customizers.OperationCustomizer; +import org.springdoc.core.models.GroupedOpenApi; +import org.springdoc.core.utils.Constants; +import test.org.springdoc.api.v30.AbstractCommonTest; + +import org.springframework.boot.actuate.autoconfigure.endpoint.web.WebEndpointProperties; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.test.context.TestPropertySource; + +import static org.springdoc.core.utils.Constants.ALL_PATTERN; + +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) +@TestPropertySource(properties = { "springdoc.show-actuator=true", + "springdoc.group-configs[0].group=group-actuator-as-properties", + "springdoc.group-configs[0].paths-to-match=${management.endpoints.web.base-path:/actuator}/**", + "management.endpoints.enabled-by-default=true", + "management.endpoints.web.exposure.include=*", + "management.endpoints.web.exposure.exclude=functions, shutdown" }) +public class SpringDocApp186Test extends AbstractCommonTest { + + @Test + void testApp() throws Exception { + webTestClient.get().uri(Constants.DEFAULT_API_DOCS_URL).exchange() + .expectStatus().isOk() + .expectBody().json(getContent("results/3.0.1/app186.json"), true); + } + + @Test + void testGroupActuatorAsCodeCheckBackwardsCompatibility() { + webTestClient.get().uri(Constants.DEFAULT_API_DOCS_URL + "/group-actuator-as-code-check-backwards-compatibility").exchange() + .expectStatus().isOk() + .expectBody().json(getContent("results/3.0.1/app186.json"), true); + } + + @Test + void testGroupActuatorAsCode() { + webTestClient.get().uri(Constants.DEFAULT_API_DOCS_URL + "/group-actuator-as-code").exchange() + .expectStatus().isOk() + .expectBody().json(getContent("results/3.0.1/app186.json"), true); + } + + @Test + void testGroupActuatorAsProperties() { + webTestClient.get().uri(Constants.DEFAULT_API_DOCS_URL + "/group-actuator-as-properties").exchange() + .expectStatus().isOk() + .expectBody().json(getContent("results/3.0.1/app186.json"), true); + } + + @SpringBootApplication + @ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.v30.app186" }) + static class SpringDocTestApp { + + @Bean + public GroupedOpenApi asCodeCheckBackwardsCompatibility(OperationCustomizer actuatorCustomizer, WebEndpointProperties endpointProperties) { + return GroupedOpenApi.builder() + .group("group-actuator-as-code-check-backwards-compatibility") + .pathsToMatch(endpointProperties.getBasePath() + ALL_PATTERN) + .addOperationCustomizer(actuatorCustomizer) + .build(); + } + + @Bean + public GroupedOpenApi asCode(WebEndpointProperties endpointProperties) { + return GroupedOpenApi.builder() + .group("group-actuator-as-code") + .pathsToMatch(endpointProperties.getBasePath() + ALL_PATTERN) + .build(); + } + } +} + diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/v30/app76/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/v30/app76/HelloController.java new file mode 100644 index 000000000..9f73e3a5a --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/v30/app76/HelloController.java @@ -0,0 +1,52 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2020 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.app76; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; +import reactor.core.publisher.Mono; + +import org.springframework.http.MediaType; +import org.springframework.http.codec.multipart.FilePart; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.bind.annotation.RestController; + + +@RestController +public class HelloController { + + + @Operation(summary = "Parse Resume") + @PostMapping(value = "/parse-resume", produces = { MediaType.APPLICATION_JSON_VALUE }, consumes = { + MediaType.MULTIPART_FORM_DATA_VALUE }) + @ApiResponses({ @ApiResponse(responseCode = "400", description = "Invalid input") }) + public Mono parse( + @RequestPart(name = "resumeFile") @Parameter(description = "Resume file to be parsed", content = @Content(mediaType = MediaType.APPLICATION_OCTET_STREAM_VALUE)) FilePart resumeFile) { + return null; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/v30/app76/SpringDocApp76Test.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/v30/app76/SpringDocApp76Test.java new file mode 100644 index 000000000..c7206c094 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/v30/app76/SpringDocApp76Test.java @@ -0,0 +1,45 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2020 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.app76; + +import org.junit.jupiter.api.Test; +import org.springdoc.core.utils.Constants; +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.test.context.TestPropertySource; + +@TestPropertySource(properties = { + "springdoc.show-actuator=true", + "management.endpoints.enabled-by-default=true" +}) +public class SpringDocApp76Test extends AbstractSpringDocTest { + + @Test + protected void testApp() { + webTestClient.get().uri(Constants.DEFAULT_API_DOCS_URL + "/actuator").exchange().expectStatus().isOk().expectBody() + .jsonPath("$.openapi").isEqualTo("3.0.1") + .jsonPath("$.paths./actuator/health.get.operationId").exists(); + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/v30/app76/SpringDocTestApp.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/v30/app76/SpringDocTestApp.java new file mode 100644 index 000000000..ce3b20223 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/v30/app76/SpringDocTestApp.java @@ -0,0 +1,71 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2020 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.app76; + +import io.swagger.v3.oas.models.Components; +import io.swagger.v3.oas.models.OpenAPI; +import io.swagger.v3.oas.models.info.Info; +import io.swagger.v3.oas.models.info.License; +import io.swagger.v3.oas.models.security.SecurityScheme; +import org.springdoc.core.models.GroupedOpenApi; + +import org.springframework.boot.actuate.autoconfigure.endpoint.EndpointAutoConfiguration; +import org.springframework.boot.actuate.autoconfigure.endpoint.web.WebEndpointAutoConfiguration; +import org.springframework.boot.actuate.autoconfigure.endpoint.web.reactive.WebFluxEndpointManagementContextConfiguration; +import org.springframework.boot.actuate.autoconfigure.health.HealthEndpointAutoConfiguration; +import org.springframework.boot.actuate.autoconfigure.info.InfoEndpointAutoConfiguration; +import org.springframework.boot.actuate.autoconfigure.web.reactive.ReactiveManagementContextAutoConfiguration; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Import; + +@SpringBootApplication +@Import({ WebEndpointAutoConfiguration.class, + EndpointAutoConfiguration.class, + InfoEndpointAutoConfiguration.class, + HealthEndpointAutoConfiguration.class, + WebFluxEndpointManagementContextConfiguration.class, + ReactiveManagementContextAutoConfiguration.class }) +@ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.v30.app76" }) +public class SpringDocTestApp { + + @Bean + public OpenAPI customOpenAPI() { + return new OpenAPI() + .components(new Components().addSecuritySchemes("basicScheme", + new SecurityScheme().type(SecurityScheme.Type.HTTP).scheme("basic"))) + .info(new Info().title("Tweet API").version("v0") + .license(new License().name("Apache 2.0").url("http://springdoc.org"))); + } + + + @Bean + public GroupedOpenApi actuatorApi() { + return GroupedOpenApi.builder().group("actuator") + .pathsToMatch("/actuator/**") + .pathsToExclude("/actuator/health/*") + .build(); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/v31/AbstractCommonTest.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/v31/AbstractCommonTest.java new file mode 100644 index 000000000..72fdba6df --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/v31/AbstractCommonTest.java @@ -0,0 +1,82 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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; + +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springdoc.core.utils.Constants; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.reactive.AutoConfigureWebTestClient; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.context.TestPropertySource; +import org.springframework.test.web.reactive.server.EntityExchangeResult; +import org.springframework.test.web.reactive.server.WebTestClient; + +import static org.skyscreamer.jsonassert.JSONAssert.assertEquals; + +@AutoConfigureWebTestClient(timeout = "3600000") +@ActiveProfiles("test") +@TestPropertySource(properties = { "management.endpoints.enabled-by-default=false" }) +public abstract class AbstractCommonTest { + + protected static final Logger LOGGER = LoggerFactory.getLogger(AbstractCommonTest.class); + + @Autowired + protected WebTestClient webTestClient; + + protected String getContent(String fileName) { + try { + Path path = Paths.get(AbstractCommonTest.class.getClassLoader().getResource(fileName).toURI()); + byte[] fileBytes = Files.readAllBytes(path); + return new String(fileBytes, StandardCharsets.UTF_8); + } + catch (Exception e) { + throw new RuntimeException("Failed to read file: " + fileName, e); + } + } + + protected void testApp(String testId, String groupName) throws Exception{ + String result = null; + try { + EntityExchangeResult getResult = webTestClient.get().uri(Constants.DEFAULT_API_DOCS_URL + "/" + groupName).exchange() + .expectStatus().isOk().expectBody().returnResult(); + result = new String(getResult.getResponseBody()); + String expected = getContent("results/3.1.0/app" + testId + ".json"); + assertEquals(expected, result, true); + } + catch (AssertionError e) { + LOGGER.error(result); + throw e; + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/v31/AbstractSpringDocActuatorTest.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/v31/AbstractSpringDocActuatorTest.java new file mode 100644 index 000000000..f6c67f5be --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/v31/AbstractSpringDocActuatorTest.java @@ -0,0 +1,64 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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; + +import jakarta.annotation.PostConstruct; + +import org.springframework.boot.test.web.server.LocalManagementPort; +import org.springframework.test.context.TestPropertySource; +import org.springframework.web.reactive.function.client.WebClient; + +import static org.skyscreamer.jsonassert.JSONAssert.assertEquals; + +@TestPropertySource(properties = { "management.endpoints.enabled-by-default=true" }) +public abstract class AbstractSpringDocActuatorTest extends AbstractCommonTest { + + protected WebClient webClient; + + @LocalManagementPort + private int managementPort; + + @PostConstruct + void init() { + webClient = WebClient.builder().baseUrl("http://localhost:" + this.managementPort) + .build(); + } + + protected void testWithWebClient(String testId, String uri) throws Exception{ + String result = null; + try { + result = webClient.get().uri(uri).retrieve() + .bodyToMono(String.class).block(); + String expected = getContent("results/3.1.0/app"+testId+".json"); + assertEquals(expected, result, true); + } + catch (AssertionError e) { + LOGGER.error(result); + throw e; + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/v31/AbstractSpringDocTest.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/v31/AbstractSpringDocTest.java new file mode 100644 index 000000000..f2b629759 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/v31/AbstractSpringDocTest.java @@ -0,0 +1,45 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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; + +import org.apache.commons.lang3.StringUtils; +import org.junit.jupiter.api.Test; + +import org.springframework.boot.test.autoconfigure.web.reactive.WebFluxTest; + + +@WebFluxTest +public abstract class AbstractSpringDocTest extends AbstractCommonTest { + + @Test + protected void testApp() throws Exception { + String className = getClass().getSimpleName(); + String testId = className.replaceAll("[^0-9]", ""); + testApp(testId, StringUtils.EMPTY); + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/v31/app144/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/v31/app144/HelloController.java new file mode 100644 index 000000000..6fea3caac --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/v31/app144/HelloController.java @@ -0,0 +1,32 @@ +/* + * + * * Copyright 2019-2020 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.app144; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class HelloController { + + @GetMapping("/persons") + public String persons() { + return "OK"; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/v31/app144/SpringDocApp144Test.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/v31/app144/SpringDocApp144Test.java new file mode 100644 index 000000000..05740ac52 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/v31/app144/SpringDocApp144Test.java @@ -0,0 +1,58 @@ +/* + * + * * Copyright 2019-2020 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.app144; + +import org.junit.jupiter.api.Test; +import org.springdoc.core.utils.Constants; +import test.org.springdoc.api.v31.AbstractSpringDocActuatorTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; + +import static org.skyscreamer.jsonassert.JSONAssert.assertEquals; + + +@SpringBootTest(webEnvironment = WebEnvironment.DEFINED_PORT, + properties = { "management.endpoints.web.exposure.include=*", + "server.port=53355", + "springdoc.use-management-port=true", + "management.server.port=9389", + "management.endpoints.web.base-path=/application" }) +public class SpringDocApp144Test extends AbstractSpringDocActuatorTest { + + @Test + void testApp() { + webTestClient.get().uri(Constants.DEFAULT_API_DOCS_URL).exchange() + .expectStatus().isNotFound(); + } + + @Test + void testApp1() throws Exception { + String result = webClient.get().uri("/application/openapi").retrieve() + .bodyToMono(String.class) + .block(); + String expected = getContent("results/3.1.0/app144.json"); + assertEquals(expected, result, true); + } + + @SpringBootApplication + static class SpringDocTestApp {} + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/v31/app145/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/v31/app145/HelloController.java new file mode 100644 index 000000000..a0f2bfab3 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/v31/app145/HelloController.java @@ -0,0 +1,34 @@ +/* + * + * * Copyright 2019-2020 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.app145; + +import org.springframework.context.annotation.Configuration; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@Configuration +public class HelloController { + + @GetMapping("/persons") + public String persons() { + return "OK"; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/v31/app145/SpringDocApp1451Test.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/v31/app145/SpringDocApp1451Test.java new file mode 100644 index 000000000..2b0d0960b --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/v31/app145/SpringDocApp1451Test.java @@ -0,0 +1,77 @@ +/* + * + * * Copyright 2019-2020 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.app145; + +import org.junit.jupiter.api.Test; +import test.org.springdoc.api.v31.AbstractSpringDocActuatorTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; +import org.springframework.http.HttpStatus; +import org.springframework.test.annotation.DirtiesContext; +import org.springframework.web.reactive.function.client.WebClientResponseException; + +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; +import static org.skyscreamer.jsonassert.JSONAssert.assertEquals; + +@DirtiesContext +@SpringBootTest(webEnvironment = WebEnvironment.DEFINED_PORT, + properties = { "management.endpoints.web.exposure.include=*", + "server.port=53594", + "springdoc.use-management-port=true", + "springdoc.group-configs[0].group=users", + "springdoc.group-configs[0].packages-to-scan=test.org.springdoc.api.v31.app145", + "management.server.port=9394", + "management.endpoints.web.base-path=/application" }) +public class SpringDocApp1451Test extends AbstractSpringDocActuatorTest { + + @Test + void testApp() { + try { + webClient.get().uri("/application/openapi").retrieve() + .bodyToMono(String.class).block(); + fail(); + } + catch (WebClientResponseException ex) { + if (ex.getStatusCode() == HttpStatus.NOT_FOUND) + assertTrue(true); + else + fail(); + } + } + + @Test + void testApp2() throws Exception { + try { + String result = webClient.get().uri("/application/openapi/users").retrieve() + .bodyToMono(String.class).block(); + String expected = getContent("results/3.1.0/app145-1.json"); + assertEquals(expected, result, true); + } + catch (WebClientResponseException ex) { + fail(); + } + } + + @SpringBootApplication + static class SpringDocTestApp {} + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/v31/app145/SpringDocApp1452Test.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/v31/app145/SpringDocApp1452Test.java new file mode 100644 index 000000000..432a34960 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/v31/app145/SpringDocApp1452Test.java @@ -0,0 +1,59 @@ +/* + * + * * Copyright 2019-2020 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.app145; + +import org.junit.jupiter.api.Test; +import test.org.springdoc.api.v31.AbstractSpringDocActuatorTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; +import org.springframework.web.reactive.function.client.WebClientResponseException; + +import static org.junit.jupiter.api.Assertions.fail; +import static org.skyscreamer.jsonassert.JSONAssert.assertEquals; + + +@SpringBootTest(webEnvironment = WebEnvironment.DEFINED_PORT, + properties = { "management.endpoints.web.exposure.include=*", + "server.port=53595", + "springdoc.use-management-port=true", + "springdoc.group-configs[0].group=users", + "springdoc.group-configs[0].packages-to-scan=test.org.springdoc.api.v31.app145", + "management.server.port=9385", + "management.endpoints.web.base-path=/application" }) +public class SpringDocApp1452Test extends AbstractSpringDocActuatorTest { + + @Test + void testApp() throws Exception { + try { + String result = webClient.get().uri("/application/openapi/users").retrieve() + .bodyToMono(String.class).block(); + String expected = getContent("results/3.1.0/app145-2.json"); + assertEquals(expected, result, true); + } + catch (WebClientResponseException ex) { + fail(); + } + } + + @SpringBootApplication + static class SpringDocTestApp {} + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/v31/app145/SpringDocApp145Test.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/v31/app145/SpringDocApp145Test.java new file mode 100644 index 000000000..b02c6a551 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/v31/app145/SpringDocApp145Test.java @@ -0,0 +1,70 @@ +/* + * + * * 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.app145; + +import org.junit.jupiter.api.Test; +import org.springdoc.core.utils.Constants; +import test.org.springdoc.api.v31.AbstractSpringDocActuatorTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; +import org.springframework.http.HttpStatus; +import org.springframework.web.reactive.function.client.WebClientResponseException; + +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; + + +@SpringBootTest(webEnvironment = WebEnvironment.DEFINED_PORT, + properties = { "management.endpoints.web.exposure.include=*", + "server.port=52593", + "springdoc.use-management-port=true", + "springdoc.group-configs[0].group=users", + "springdoc.group-configs[0].packages-to-scan=test.org.springdoc.api.v31.app145", + "management.server.port=9300", + "management.endpoints.web.base-path=/application" }) +public class SpringDocApp145Test extends AbstractSpringDocActuatorTest { + + @Test + void testApp() { + webTestClient.get().uri(Constants.DEFAULT_API_DOCS_URL + "/users") + .exchange() + .expectStatus().isNotFound(); + } + + @Test + void testApp3() throws Exception { + try { + webClient.get().uri("/application/openapi" + "/" + Constants.DEFAULT_GROUP_NAME).retrieve() + .bodyToMono(String.class).block(); + fail(); + } + catch (WebClientResponseException ex) { + if (ex.getStatusCode() == HttpStatus.NOT_FOUND) + assertTrue(true); + else + fail(); + } + } + + @SpringBootApplication + static class SpringDocTestApp {} + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/v31/app146/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/v31/app146/HelloController.java new file mode 100644 index 000000000..5c4fd9873 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/v31/app146/HelloController.java @@ -0,0 +1,32 @@ +/* + * + * * Copyright 2019-2020 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.app146; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class HelloController { + + @GetMapping("/persons") + public String persons() { + return "OK"; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/v31/app146/SpringDocApp146Test.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/v31/app146/SpringDocApp146Test.java new file mode 100644 index 000000000..cfd9aec48 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/v31/app146/SpringDocApp146Test.java @@ -0,0 +1,52 @@ +/* + * + * * Copyright 2019-2020 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.app146; + +import org.junit.jupiter.api.Test; +import org.springdoc.core.utils.Constants; +import test.org.springdoc.api.v31.AbstractSpringDocActuatorTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.context.annotation.ComponentScan; + +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, + properties = { "management.endpoints.web.exposure.include=*", + "springdoc.show-actuator=true", + "management.server.port=9386", + "management.endpoints.web.exposure.exclude=functions, shutdown", + "management.server.base-path=/test", + "management.endpoints.web.base-path=/application" }) +public class SpringDocApp146Test extends AbstractSpringDocActuatorTest { + + @Test + void testApp() throws Exception { + super.testApp("146-1", Constants.ACTUATOR_DEFAULT_GROUP); + } + + @Test + void testApp1() throws Exception { + super.testApp("146-2", Constants.DEFAULT_GROUP_NAME); + } + + @SpringBootApplication + @ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.v31.app146" }) + static class SpringDocTestApp {} + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/v31/app147/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/v31/app147/HelloController.java new file mode 100644 index 000000000..e2ed42864 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/v31/app147/HelloController.java @@ -0,0 +1,43 @@ +/* + * + * * Copyright 2019-2020 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.app147; + +import org.springdoc.core.models.GroupedOpenApi; + +import org.springframework.context.annotation.Bean; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class HelloController { + + @GetMapping("/persons") + public String persons() { + return "OK"; + } + + @Bean + public GroupedOpenApi userOpenApi() { + return GroupedOpenApi.builder() + .group("users") + .packagesToScan("test.org.springdoc.api.v31.app147") + .build(); + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/v31/app147/SpringDocApp147Test.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/v31/app147/SpringDocApp147Test.java new file mode 100644 index 000000000..e18bd77e0 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/v31/app147/SpringDocApp147Test.java @@ -0,0 +1,59 @@ +/* + * + * * Copyright 2019-2020 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.app147; + +import org.junit.jupiter.api.Test; +import org.springdoc.core.utils.Constants; +import test.org.springdoc.api.v31.AbstractSpringDocActuatorTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.test.context.SpringBootTest; + + +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, + properties = { "management.endpoints.web.exposure.include=*", + "springdoc.show-actuator=true", + "management.endpoints.web.exposure.exclude=functions, shutdown", + "management.server.port=9397", + "management.server.base-path=/test", + "management.endpoints.web.base-path=/application" }) +public class SpringDocApp147Test extends AbstractSpringDocActuatorTest { + + @Test + void testApp() throws Exception { + super.testApp("147-1", Constants.ACTUATOR_DEFAULT_GROUP); + } + + @Test + void testApp1() throws Exception { + super.testApp("147-2", Constants.ACTUATOR_DEFAULT_GROUP); + + } + + @Test + void testApp2() throws Exception { + webTestClient.get().uri(Constants.DEFAULT_API_DOCS_URL + "/" + Constants.DEFAULT_GROUP_NAME) + .exchange() + .expectStatus().isNotFound(); + } + + @SpringBootApplication + static class SpringDocTestApp {} + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/v31/app148/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/v31/app148/HelloController.java new file mode 100644 index 000000000..cae08da76 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/v31/app148/HelloController.java @@ -0,0 +1,47 @@ +/* + * + * * Copyright 2019-2020 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.app148; + + +import org.springdoc.core.models.GroupedOpenApi; + +import org.springframework.context.annotation.Bean; +import org.springframework.core.Ordered; +import org.springframework.core.annotation.Order; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class HelloController { + + @GetMapping("/persons") + public String persons() { + return "OK"; + } + + @Bean + @Order(Ordered.HIGHEST_PRECEDENCE) + public GroupedOpenApi userOpenApi() { + return GroupedOpenApi.builder() + .group("users") + .packagesToScan("test.org.springdoc.api.v31.app148") + .build(); + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/v31/app148/SpringDocApp148Test.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/v31/app148/SpringDocApp148Test.java new file mode 100644 index 000000000..bc6a1a27d --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/v31/app148/SpringDocApp148Test.java @@ -0,0 +1,73 @@ +/* + * + * * Copyright 2019-2020 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.app148; + +import org.junit.jupiter.api.Test; +import org.springdoc.core.utils.Constants; +import test.org.springdoc.api.v31.AbstractSpringDocActuatorTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; +import org.springframework.http.HttpStatus; +import org.springframework.web.reactive.function.client.WebClientResponseException; + +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; + + +@SpringBootTest(webEnvironment = WebEnvironment.DEFINED_PORT, + properties = { "management.endpoints.web.exposure.include=*", + "springdoc.show-actuator=true", + "management.endpoints.web.exposure.exclude=functions, shutdown", + "management.server.port=9388", + "server.port=6366", + "springdoc.use-management-port=true", + "management.server.base-path=/test", + "management.endpoints.web.base-path=/application" }) +public class SpringDocApp148Test extends AbstractSpringDocActuatorTest { + + @Test + void testApp() throws Exception { + super.testWithWebClient("148-1","/test/application/openapi/users"); + } + + @Test + void testApp2() throws Exception { + super.testWithWebClient("148-2","/test/application/openapi/x-actuator"); + } + + @Test + void testApp3() throws Exception { + try { + webClient.get().uri("/test/application/openapi" + "/" + Constants.DEFAULT_GROUP_NAME).retrieve() + .bodyToMono(String.class).block(); + fail(); + } + catch (WebClientResponseException ex) { + if (ex.getStatusCode() == HttpStatus.NOT_FOUND) + assertTrue(true); + else + fail(); + } + } + + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/v31/app186/SpringDocApp186Test.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/v31/app186/SpringDocApp186Test.java new file mode 100644 index 000000000..c0c45c86b --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/v31/app186/SpringDocApp186Test.java @@ -0,0 +1,102 @@ +/* + * + * * + * * * + * * * * + * * * * * 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.app186; + + +import org.junit.jupiter.api.Test; +import org.springdoc.core.customizers.OperationCustomizer; +import org.springdoc.core.models.GroupedOpenApi; +import org.springdoc.core.utils.Constants; +import test.org.springdoc.api.v31.AbstractCommonTest; + +import org.springframework.boot.actuate.autoconfigure.endpoint.web.WebEndpointProperties; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.test.context.TestPropertySource; + +import static org.springdoc.core.utils.Constants.ALL_PATTERN; + +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) +@TestPropertySource(properties = { "springdoc.show-actuator=true", + "springdoc.group-configs[0].group=group-actuator-as-properties", + "springdoc.group-configs[0].paths-to-match=${management.endpoints.web.base-path:/actuator}/**", + "management.endpoints.enabled-by-default=true", + "management.endpoints.web.exposure.include=*", + "management.endpoints.web.exposure.exclude=functions, shutdown" }) +public class SpringDocApp186Test extends AbstractCommonTest { + + @Test + void testApp() throws Exception { + webTestClient.get().uri(Constants.DEFAULT_API_DOCS_URL).exchange() + .expectStatus().isOk() + .expectBody().json(getContent("results/3.1.0/app186.json"), true); + } + + @Test + void testGroupActuatorAsCodeCheckBackwardsCompatibility() { + webTestClient.get().uri(Constants.DEFAULT_API_DOCS_URL + "/group-actuator-as-code-check-backwards-compatibility").exchange() + .expectStatus().isOk() + .expectBody().json(getContent("results/3.1.0/app186.json"), true); + } + + @Test + void testGroupActuatorAsCode() { + webTestClient.get().uri(Constants.DEFAULT_API_DOCS_URL + "/group-actuator-as-code").exchange() + .expectStatus().isOk() + .expectBody().json(getContent("results/3.1.0/app186.json"), true); + } + + @Test + void testGroupActuatorAsProperties() { + webTestClient.get().uri(Constants.DEFAULT_API_DOCS_URL + "/group-actuator-as-properties").exchange() + .expectStatus().isOk() + .expectBody().json(getContent("results/3.1.0/app186.json"), true); + } + + @SpringBootApplication + @ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.v31.app186" }) + static class SpringDocTestApp { + + @Bean + public GroupedOpenApi asCodeCheckBackwardsCompatibility(OperationCustomizer actuatorCustomizer, WebEndpointProperties endpointProperties) { + return GroupedOpenApi.builder() + .group("group-actuator-as-code-check-backwards-compatibility") + .pathsToMatch(endpointProperties.getBasePath() + ALL_PATTERN) + .addOperationCustomizer(actuatorCustomizer) + .build(); + } + + @Bean + public GroupedOpenApi asCode(WebEndpointProperties endpointProperties) { + return GroupedOpenApi.builder() + .group("group-actuator-as-code") + .pathsToMatch(endpointProperties.getBasePath() + ALL_PATTERN) + .build(); + } + } +} + diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/v31/app76/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/v31/app76/HelloController.java new file mode 100644 index 000000000..86d4f01cd --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/v31/app76/HelloController.java @@ -0,0 +1,52 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2020 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.app76; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; +import reactor.core.publisher.Mono; + +import org.springframework.http.MediaType; +import org.springframework.http.codec.multipart.FilePart; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.bind.annotation.RestController; + + +@RestController +public class HelloController { + + + @Operation(summary = "Parse Resume") + @PostMapping(value = "/parse-resume", produces = { MediaType.APPLICATION_JSON_VALUE }, consumes = { + MediaType.MULTIPART_FORM_DATA_VALUE }) + @ApiResponses({ @ApiResponse(responseCode = "400", description = "Invalid input") }) + public Mono parse( + @RequestPart(name = "resumeFile") @Parameter(description = "Resume file to be parsed", content = @Content(mediaType = MediaType.APPLICATION_OCTET_STREAM_VALUE)) FilePart resumeFile) { + return null; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/v31/app76/SpringDocApp76Test.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/v31/app76/SpringDocApp76Test.java new file mode 100644 index 000000000..ee3ed0054 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/v31/app76/SpringDocApp76Test.java @@ -0,0 +1,45 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2020 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.app76; + +import org.junit.jupiter.api.Test; +import org.springdoc.core.utils.Constants; +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.test.context.TestPropertySource; + +@TestPropertySource(properties = { + "springdoc.show-actuator=true", + "management.endpoints.enabled-by-default=true" +}) +public class SpringDocApp76Test extends AbstractSpringDocTest { + + @Test + protected void testApp() { + webTestClient.get().uri(Constants.DEFAULT_API_DOCS_URL + "/actuator").exchange().expectStatus().isOk().expectBody() + .jsonPath("$.openapi").isEqualTo("3.1.0") + .jsonPath("$.paths./actuator/health.get.operationId").exists(); + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/v31/app76/SpringDocTestApp.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/v31/app76/SpringDocTestApp.java new file mode 100644 index 000000000..e3c869246 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/java/test/org/springdoc/api/v31/app76/SpringDocTestApp.java @@ -0,0 +1,71 @@ +/* + * + * * + * * * + * * * * Copyright 2019-2020 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.app76; + +import io.swagger.v3.oas.models.Components; +import io.swagger.v3.oas.models.OpenAPI; +import io.swagger.v3.oas.models.info.Info; +import io.swagger.v3.oas.models.info.License; +import io.swagger.v3.oas.models.security.SecurityScheme; +import org.springdoc.core.models.GroupedOpenApi; + +import org.springframework.boot.actuate.autoconfigure.endpoint.EndpointAutoConfiguration; +import org.springframework.boot.actuate.autoconfigure.endpoint.web.WebEndpointAutoConfiguration; +import org.springframework.boot.actuate.autoconfigure.endpoint.web.reactive.WebFluxEndpointManagementContextConfiguration; +import org.springframework.boot.actuate.autoconfigure.health.HealthEndpointAutoConfiguration; +import org.springframework.boot.actuate.autoconfigure.info.InfoEndpointAutoConfiguration; +import org.springframework.boot.actuate.autoconfigure.web.reactive.ReactiveManagementContextAutoConfiguration; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Import; + +@SpringBootApplication +@Import({ WebEndpointAutoConfiguration.class, + EndpointAutoConfiguration.class, + InfoEndpointAutoConfiguration.class, + HealthEndpointAutoConfiguration.class, + WebFluxEndpointManagementContextConfiguration.class, + ReactiveManagementContextAutoConfiguration.class }) +@ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.v31.app76" }) +public class SpringDocTestApp { + + @Bean + public OpenAPI customOpenAPI() { + return new OpenAPI() + .components(new Components().addSecuritySchemes("basicScheme", + new SecurityScheme().type(SecurityScheme.Type.HTTP).scheme("basic"))) + .info(new Info().title("Tweet API").version("v0") + .license(new License().name("Apache 2.0").url("http://springdoc.org"))); + } + + + @Bean + public GroupedOpenApi actuatorApi() { + return GroupedOpenApi.builder().group("actuator") + .pathsToMatch("/actuator/**") + .pathsToExclude("/actuator/health/*") + .build(); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/resources/results/app144.json b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/resources/results/3.0.1/app144.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/resources/results/app144.json rename to springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/resources/results/3.0.1/app144.json diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/resources/results/app145-1.json b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/resources/results/3.0.1/app145-1.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/resources/results/app145-1.json rename to springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/resources/results/3.0.1/app145-1.json diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/resources/results/app145-2.json b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/resources/results/3.0.1/app145-2.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/resources/results/app145-2.json rename to springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/resources/results/3.0.1/app145-2.json diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/resources/results/app145.json b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/resources/results/3.0.1/app145.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/resources/results/app145.json rename to springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/resources/results/3.0.1/app145.json diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/resources/results/app146-1.json b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/resources/results/3.0.1/app146-1.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/resources/results/app146-1.json rename to springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/resources/results/3.0.1/app146-1.json diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/resources/results/app146-2.json b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/resources/results/3.0.1/app146-2.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/resources/results/app146-2.json rename to springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/resources/results/3.0.1/app146-2.json diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/resources/results/3.0.1/app147-1.json b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/resources/results/3.0.1/app147-1.json new file mode 100644 index 000000000..63f747bca --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/resources/results/3.0.1/app147-1.json @@ -0,0 +1,891 @@ +{ + "openapi": "3.0.1", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost:9287/test", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "Actuator", + "description": "Monitor and interact", + "externalDocs": { + "description": "Spring Boot Actuator Web API Documentation", + "url": "https://docs.spring.io/spring-boot/docs/current/actuator-api/html/" + } + } + ], + "paths": { + "/application/loggers/{name}": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'loggers-name'", + "operationId": "loggerLevels", + "parameters": [ + { + "name": "name", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + }, + "404": { + "description": "Not Found" + } + } + }, + "post": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'loggers-name'", + "operationId": "configureLogLevel", + "parameters": [ + { + "name": "name", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "string", + "enum": [ + "TRACE", + "DEBUG", + "INFO", + "WARN", + "ERROR", + "FATAL", + "OFF" + ] + } + } + } + }, + "responses": { + "204": { + "description": "No Content" + }, + "400": { + "description": "Bad Request" + } + } + } + }, + "/application/threaddump": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'threaddump'", + "operationId": "threadDump", + "responses": { + "200": { + "description": "OK", + "content": { + "text/plain;charset=UTF-8": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/application/scheduledtasks": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'scheduledtasks'", + "operationId": "scheduledTasks", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/application/sbom/{id}": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'sbom-id'", + "operationId": "sbom", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/octet-stream": { + "schema": { + "type": "object" + } + } + } + }, + "404": { + "description": "Not Found" + } + } + } + }, + "/application/sbom": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'sbom'", + "operationId": "sboms", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/application/metrics/{requiredMetricName}": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'metrics-requiredMetricName'", + "operationId": "metric", + "parameters": [ + { + "name": "requiredMetricName", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "tag", + "in": "query", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + }, + "404": { + "description": "Not Found" + } + } + } + }, + "/application/metrics": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'metrics'", + "operationId": "listNames", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/application/mappings": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'mappings'", + "operationId": "mappings", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/application/loggers": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'loggers'", + "operationId": "loggers", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/application/info": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'info'", + "operationId": "info", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/application/heapdump": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'heapdump'", + "operationId": "heapDump", + "parameters": [ + { + "name": "live", + "in": "query", + "schema": { + "type": "boolean" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/octet-stream": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/application/health": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'health'", + "operationId": "health", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/application/env/{toMatch}": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'env-toMatch'", + "operationId": "environmentEntry", + "parameters": [ + { + "name": "toMatch", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + }, + "404": { + "description": "Not Found" + } + } + } + }, + "/application/env": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'env'", + "operationId": "environment", + "parameters": [ + { + "name": "pattern", + "in": "query", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/application/configprops/{prefix}": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'configprops-prefix'", + "operationId": "configurationPropertiesWithPrefix", + "parameters": [ + { + "name": "prefix", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + }, + "404": { + "description": "Not Found" + } + } + } + }, + "/application/configprops": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'configprops'", + "operationId": "configurationProperties", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/application/conditions": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'conditions'", + "operationId": "conditions", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/application/caches/{cache}": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'caches-cache'", + "operationId": "cache", + "parameters": [ + { + "name": "cache", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "cacheManager", + "in": "query", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + }, + "404": { + "description": "Not Found" + } + } + }, + "delete": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'caches-cache'", + "operationId": "clearCache", + "parameters": [ + { + "name": "cache", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "cacheManager", + "in": "query", + "schema": { + "type": "string" + } + } + ], + "responses": { + "204": { + "description": "No Content" + }, + "404": { + "description": "Not Found" + } + } + } + }, + "/application/caches": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'caches'", + "operationId": "caches", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + }, + "delete": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'caches'", + "operationId": "clearCaches", + "responses": { + "204": { + "description": "No Content" + } + } + } + }, + "/application/beans": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'beans'", + "operationId": "beans", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/application": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator root web endpoint", + "operationId": "links", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object", + "additionalProperties": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/Link" + } + } + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object", + "additionalProperties": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/Link" + } + } + } + }, + "application/json": { + "schema": { + "type": "object", + "additionalProperties": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/Link" + } + } + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "Link": { + "type": "object", + "properties": { + "href": { + "type": "string" + }, + "templated": { + "type": "boolean" + } + } + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/resources/results/3.0.1/app147-2.json b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/resources/results/3.0.1/app147-2.json new file mode 100644 index 000000000..63f747bca --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/resources/results/3.0.1/app147-2.json @@ -0,0 +1,891 @@ +{ + "openapi": "3.0.1", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost:9287/test", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "Actuator", + "description": "Monitor and interact", + "externalDocs": { + "description": "Spring Boot Actuator Web API Documentation", + "url": "https://docs.spring.io/spring-boot/docs/current/actuator-api/html/" + } + } + ], + "paths": { + "/application/loggers/{name}": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'loggers-name'", + "operationId": "loggerLevels", + "parameters": [ + { + "name": "name", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + }, + "404": { + "description": "Not Found" + } + } + }, + "post": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'loggers-name'", + "operationId": "configureLogLevel", + "parameters": [ + { + "name": "name", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "string", + "enum": [ + "TRACE", + "DEBUG", + "INFO", + "WARN", + "ERROR", + "FATAL", + "OFF" + ] + } + } + } + }, + "responses": { + "204": { + "description": "No Content" + }, + "400": { + "description": "Bad Request" + } + } + } + }, + "/application/threaddump": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'threaddump'", + "operationId": "threadDump", + "responses": { + "200": { + "description": "OK", + "content": { + "text/plain;charset=UTF-8": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/application/scheduledtasks": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'scheduledtasks'", + "operationId": "scheduledTasks", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/application/sbom/{id}": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'sbom-id'", + "operationId": "sbom", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/octet-stream": { + "schema": { + "type": "object" + } + } + } + }, + "404": { + "description": "Not Found" + } + } + } + }, + "/application/sbom": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'sbom'", + "operationId": "sboms", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/application/metrics/{requiredMetricName}": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'metrics-requiredMetricName'", + "operationId": "metric", + "parameters": [ + { + "name": "requiredMetricName", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "tag", + "in": "query", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + }, + "404": { + "description": "Not Found" + } + } + } + }, + "/application/metrics": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'metrics'", + "operationId": "listNames", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/application/mappings": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'mappings'", + "operationId": "mappings", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/application/loggers": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'loggers'", + "operationId": "loggers", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/application/info": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'info'", + "operationId": "info", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/application/heapdump": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'heapdump'", + "operationId": "heapDump", + "parameters": [ + { + "name": "live", + "in": "query", + "schema": { + "type": "boolean" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/octet-stream": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/application/health": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'health'", + "operationId": "health", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/application/env/{toMatch}": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'env-toMatch'", + "operationId": "environmentEntry", + "parameters": [ + { + "name": "toMatch", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + }, + "404": { + "description": "Not Found" + } + } + } + }, + "/application/env": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'env'", + "operationId": "environment", + "parameters": [ + { + "name": "pattern", + "in": "query", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/application/configprops/{prefix}": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'configprops-prefix'", + "operationId": "configurationPropertiesWithPrefix", + "parameters": [ + { + "name": "prefix", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + }, + "404": { + "description": "Not Found" + } + } + } + }, + "/application/configprops": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'configprops'", + "operationId": "configurationProperties", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/application/conditions": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'conditions'", + "operationId": "conditions", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/application/caches/{cache}": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'caches-cache'", + "operationId": "cache", + "parameters": [ + { + "name": "cache", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "cacheManager", + "in": "query", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + }, + "404": { + "description": "Not Found" + } + } + }, + "delete": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'caches-cache'", + "operationId": "clearCache", + "parameters": [ + { + "name": "cache", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "cacheManager", + "in": "query", + "schema": { + "type": "string" + } + } + ], + "responses": { + "204": { + "description": "No Content" + }, + "404": { + "description": "Not Found" + } + } + } + }, + "/application/caches": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'caches'", + "operationId": "caches", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + }, + "delete": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'caches'", + "operationId": "clearCaches", + "responses": { + "204": { + "description": "No Content" + } + } + } + }, + "/application/beans": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'beans'", + "operationId": "beans", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/application": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator root web endpoint", + "operationId": "links", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object", + "additionalProperties": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/Link" + } + } + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object", + "additionalProperties": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/Link" + } + } + } + }, + "application/json": { + "schema": { + "type": "object", + "additionalProperties": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/Link" + } + } + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "Link": { + "type": "object", + "properties": { + "href": { + "type": "string" + }, + "templated": { + "type": "boolean" + } + } + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/resources/results/app148-1.json b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/resources/results/3.0.1/app148-1.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/resources/results/app148-1.json rename to springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/resources/results/3.0.1/app148-1.json diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/resources/results/app148-2.json b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/resources/results/3.0.1/app148-2.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/resources/results/app148-2.json rename to springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/resources/results/3.0.1/app148-2.json diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/resources/results/app186.json b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/resources/results/3.0.1/app186.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/resources/results/app186.json rename to springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/resources/results/3.0.1/app186.json diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/resources/results/3.1.0/app144.json b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/resources/results/3.1.0/app144.json new file mode 100644 index 000000000..27fb1ca55 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/resources/results/3.1.0/app144.json @@ -0,0 +1,36 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost:53355", + "description": "Generated server url" + } + ], + "paths": { + "/persons": { + "get": { + "tags": [ + "hello-controller" + ], + "operationId": "persons", + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + } + }, + "components": {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/resources/results/3.1.0/app145-1.json b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/resources/results/3.1.0/app145-1.json new file mode 100644 index 000000000..db94c7193 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/resources/results/3.1.0/app145-1.json @@ -0,0 +1,36 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost:53594", + "description": "Generated server url" + } + ], + "paths": { + "/persons": { + "get": { + "tags": [ + "hello-controller" + ], + "operationId": "persons", + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + } + }, + "components": {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/resources/results/3.1.0/app145-2.json b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/resources/results/3.1.0/app145-2.json new file mode 100644 index 000000000..7d811e2ae --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/resources/results/3.1.0/app145-2.json @@ -0,0 +1,36 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost:53595", + "description": "Generated server url" + } + ], + "paths": { + "/persons": { + "get": { + "tags": [ + "hello-controller" + ], + "operationId": "persons", + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + } + }, + "components": {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/resources/results/3.1.0/app145.json b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/resources/results/3.1.0/app145.json new file mode 100644 index 000000000..2c1fea2c7 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/resources/results/3.1.0/app145.json @@ -0,0 +1,36 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost:52594", + "description": "Generated server url" + } + ], + "paths": { + "/persons": { + "get": { + "tags": [ + "hello-controller" + ], + "operationId": "persons", + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + } + }, + "components": {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/resources/results/3.1.0/app146-1.json b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/resources/results/3.1.0/app146-1.json new file mode 100644 index 000000000..c8d3ea0cc --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/resources/results/3.1.0/app146-1.json @@ -0,0 +1,891 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost:9386/test", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "Actuator", + "description": "Monitor and interact", + "externalDocs": { + "description": "Spring Boot Actuator Web API Documentation", + "url": "https://docs.spring.io/spring-boot/docs/current/actuator-api/html/" + } + } + ], + "paths": { + "/application/loggers/{name}": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'loggers-name'", + "operationId": "loggerLevels", + "parameters": [ + { + "name": "name", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + }, + "404": { + "description": "Not Found" + } + } + }, + "post": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'loggers-name'", + "operationId": "configureLogLevel", + "parameters": [ + { + "name": "name", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "string", + "enum": [ + "TRACE", + "DEBUG", + "INFO", + "WARN", + "ERROR", + "FATAL", + "OFF" + ] + } + } + } + }, + "responses": { + "204": { + "description": "No Content" + }, + "400": { + "description": "Bad Request" + } + } + } + }, + "/application/threaddump": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'threaddump'", + "operationId": "threadDump", + "responses": { + "200": { + "description": "OK", + "content": { + "text/plain;charset=UTF-8": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/application/scheduledtasks": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'scheduledtasks'", + "operationId": "scheduledTasks", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/application/sbom/{id}": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'sbom-id'", + "operationId": "sbom", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/octet-stream": { + "schema": { + "type": "object" + } + } + } + }, + "404": { + "description": "Not Found" + } + } + } + }, + "/application/sbom": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'sbom'", + "operationId": "sboms", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/application/metrics/{requiredMetricName}": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'metrics-requiredMetricName'", + "operationId": "metric", + "parameters": [ + { + "name": "requiredMetricName", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "tag", + "in": "query", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + }, + "404": { + "description": "Not Found" + } + } + } + }, + "/application/metrics": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'metrics'", + "operationId": "listNames", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/application/mappings": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'mappings'", + "operationId": "mappings", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/application/loggers": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'loggers'", + "operationId": "loggers", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/application/info": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'info'", + "operationId": "info", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/application/heapdump": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'heapdump'", + "operationId": "heapDump", + "parameters": [ + { + "name": "live", + "in": "query", + "schema": { + "type": "boolean" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/octet-stream": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/application/health": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'health'", + "operationId": "health", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/application/env/{toMatch}": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'env-toMatch'", + "operationId": "environmentEntry", + "parameters": [ + { + "name": "toMatch", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + }, + "404": { + "description": "Not Found" + } + } + } + }, + "/application/env": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'env'", + "operationId": "environment", + "parameters": [ + { + "name": "pattern", + "in": "query", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/application/configprops/{prefix}": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'configprops-prefix'", + "operationId": "configurationPropertiesWithPrefix", + "parameters": [ + { + "name": "prefix", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + }, + "404": { + "description": "Not Found" + } + } + } + }, + "/application/configprops": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'configprops'", + "operationId": "configurationProperties", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/application/conditions": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'conditions'", + "operationId": "conditions", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/application/caches/{cache}": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'caches-cache'", + "operationId": "cache", + "parameters": [ + { + "name": "cache", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "cacheManager", + "in": "query", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + }, + "404": { + "description": "Not Found" + } + } + }, + "delete": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'caches-cache'", + "operationId": "clearCache", + "parameters": [ + { + "name": "cache", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "cacheManager", + "in": "query", + "schema": { + "type": "string" + } + } + ], + "responses": { + "204": { + "description": "No Content" + }, + "404": { + "description": "Not Found" + } + } + } + }, + "/application/caches": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'caches'", + "operationId": "caches", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + }, + "delete": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'caches'", + "operationId": "clearCaches", + "responses": { + "204": { + "description": "No Content" + } + } + } + }, + "/application/beans": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'beans'", + "operationId": "beans", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/application": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator root web endpoint", + "operationId": "links", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object", + "additionalProperties": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/Link" + } + } + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object", + "additionalProperties": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/Link" + } + } + } + }, + "application/json": { + "schema": { + "type": "object", + "additionalProperties": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/Link" + } + } + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "Link": { + "type": "object", + "properties": { + "href": { + "type": "string" + }, + "templated": { + "type": "boolean" + } + } + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/resources/results/3.1.0/app146-2.json b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/resources/results/3.1.0/app146-2.json new file mode 100644 index 000000000..909227c33 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/resources/results/3.1.0/app146-2.json @@ -0,0 +1,36 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "", + "description": "Generated server url" + } + ], + "paths": { + "/persons": { + "get": { + "tags": [ + "hello-controller" + ], + "operationId": "persons", + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + } + }, + "components": {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/resources/results/3.1.0/app147-1.json b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/resources/results/3.1.0/app147-1.json new file mode 100644 index 000000000..9a9d79015 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/resources/results/3.1.0/app147-1.json @@ -0,0 +1,891 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost:9397/test", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "Actuator", + "description": "Monitor and interact", + "externalDocs": { + "description": "Spring Boot Actuator Web API Documentation", + "url": "https://docs.spring.io/spring-boot/docs/current/actuator-api/html/" + } + } + ], + "paths": { + "/application/loggers/{name}": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'loggers-name'", + "operationId": "loggerLevels", + "parameters": [ + { + "name": "name", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + }, + "404": { + "description": "Not Found" + } + } + }, + "post": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'loggers-name'", + "operationId": "configureLogLevel", + "parameters": [ + { + "name": "name", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "string", + "enum": [ + "TRACE", + "DEBUG", + "INFO", + "WARN", + "ERROR", + "FATAL", + "OFF" + ] + } + } + } + }, + "responses": { + "204": { + "description": "No Content" + }, + "400": { + "description": "Bad Request" + } + } + } + }, + "/application/threaddump": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'threaddump'", + "operationId": "threadDump", + "responses": { + "200": { + "description": "OK", + "content": { + "text/plain;charset=UTF-8": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/application/scheduledtasks": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'scheduledtasks'", + "operationId": "scheduledTasks", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/application/sbom/{id}": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'sbom-id'", + "operationId": "sbom", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/octet-stream": { + "schema": { + "type": "object" + } + } + } + }, + "404": { + "description": "Not Found" + } + } + } + }, + "/application/sbom": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'sbom'", + "operationId": "sboms", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/application/metrics/{requiredMetricName}": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'metrics-requiredMetricName'", + "operationId": "metric", + "parameters": [ + { + "name": "requiredMetricName", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "tag", + "in": "query", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + }, + "404": { + "description": "Not Found" + } + } + } + }, + "/application/metrics": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'metrics'", + "operationId": "listNames", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/application/mappings": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'mappings'", + "operationId": "mappings", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/application/loggers": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'loggers'", + "operationId": "loggers", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/application/info": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'info'", + "operationId": "info", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/application/heapdump": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'heapdump'", + "operationId": "heapDump", + "parameters": [ + { + "name": "live", + "in": "query", + "schema": { + "type": "boolean" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/octet-stream": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/application/health": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'health'", + "operationId": "health", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/application/env/{toMatch}": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'env-toMatch'", + "operationId": "environmentEntry", + "parameters": [ + { + "name": "toMatch", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + }, + "404": { + "description": "Not Found" + } + } + } + }, + "/application/env": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'env'", + "operationId": "environment", + "parameters": [ + { + "name": "pattern", + "in": "query", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/application/configprops/{prefix}": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'configprops-prefix'", + "operationId": "configurationPropertiesWithPrefix", + "parameters": [ + { + "name": "prefix", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + }, + "404": { + "description": "Not Found" + } + } + } + }, + "/application/configprops": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'configprops'", + "operationId": "configurationProperties", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/application/conditions": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'conditions'", + "operationId": "conditions", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/application/caches/{cache}": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'caches-cache'", + "operationId": "cache", + "parameters": [ + { + "name": "cache", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "cacheManager", + "in": "query", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + }, + "404": { + "description": "Not Found" + } + } + }, + "delete": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'caches-cache'", + "operationId": "clearCache", + "parameters": [ + { + "name": "cache", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "cacheManager", + "in": "query", + "schema": { + "type": "string" + } + } + ], + "responses": { + "204": { + "description": "No Content" + }, + "404": { + "description": "Not Found" + } + } + } + }, + "/application/caches": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'caches'", + "operationId": "caches", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + }, + "delete": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'caches'", + "operationId": "clearCaches", + "responses": { + "204": { + "description": "No Content" + } + } + } + }, + "/application/beans": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'beans'", + "operationId": "beans", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/application": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator root web endpoint", + "operationId": "links", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object", + "additionalProperties": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/Link" + } + } + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object", + "additionalProperties": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/Link" + } + } + } + }, + "application/json": { + "schema": { + "type": "object", + "additionalProperties": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/Link" + } + } + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "Link": { + "type": "object", + "properties": { + "href": { + "type": "string" + }, + "templated": { + "type": "boolean" + } + } + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/resources/results/3.1.0/app147-2.json b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/resources/results/3.1.0/app147-2.json new file mode 100644 index 000000000..9a9d79015 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/resources/results/3.1.0/app147-2.json @@ -0,0 +1,891 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost:9397/test", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "Actuator", + "description": "Monitor and interact", + "externalDocs": { + "description": "Spring Boot Actuator Web API Documentation", + "url": "https://docs.spring.io/spring-boot/docs/current/actuator-api/html/" + } + } + ], + "paths": { + "/application/loggers/{name}": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'loggers-name'", + "operationId": "loggerLevels", + "parameters": [ + { + "name": "name", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + }, + "404": { + "description": "Not Found" + } + } + }, + "post": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'loggers-name'", + "operationId": "configureLogLevel", + "parameters": [ + { + "name": "name", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "string", + "enum": [ + "TRACE", + "DEBUG", + "INFO", + "WARN", + "ERROR", + "FATAL", + "OFF" + ] + } + } + } + }, + "responses": { + "204": { + "description": "No Content" + }, + "400": { + "description": "Bad Request" + } + } + } + }, + "/application/threaddump": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'threaddump'", + "operationId": "threadDump", + "responses": { + "200": { + "description": "OK", + "content": { + "text/plain;charset=UTF-8": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/application/scheduledtasks": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'scheduledtasks'", + "operationId": "scheduledTasks", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/application/sbom/{id}": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'sbom-id'", + "operationId": "sbom", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/octet-stream": { + "schema": { + "type": "object" + } + } + } + }, + "404": { + "description": "Not Found" + } + } + } + }, + "/application/sbom": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'sbom'", + "operationId": "sboms", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/application/metrics/{requiredMetricName}": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'metrics-requiredMetricName'", + "operationId": "metric", + "parameters": [ + { + "name": "requiredMetricName", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "tag", + "in": "query", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + }, + "404": { + "description": "Not Found" + } + } + } + }, + "/application/metrics": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'metrics'", + "operationId": "listNames", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/application/mappings": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'mappings'", + "operationId": "mappings", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/application/loggers": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'loggers'", + "operationId": "loggers", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/application/info": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'info'", + "operationId": "info", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/application/heapdump": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'heapdump'", + "operationId": "heapDump", + "parameters": [ + { + "name": "live", + "in": "query", + "schema": { + "type": "boolean" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/octet-stream": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/application/health": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'health'", + "operationId": "health", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/application/env/{toMatch}": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'env-toMatch'", + "operationId": "environmentEntry", + "parameters": [ + { + "name": "toMatch", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + }, + "404": { + "description": "Not Found" + } + } + } + }, + "/application/env": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'env'", + "operationId": "environment", + "parameters": [ + { + "name": "pattern", + "in": "query", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/application/configprops/{prefix}": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'configprops-prefix'", + "operationId": "configurationPropertiesWithPrefix", + "parameters": [ + { + "name": "prefix", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + }, + "404": { + "description": "Not Found" + } + } + } + }, + "/application/configprops": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'configprops'", + "operationId": "configurationProperties", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/application/conditions": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'conditions'", + "operationId": "conditions", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/application/caches/{cache}": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'caches-cache'", + "operationId": "cache", + "parameters": [ + { + "name": "cache", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "cacheManager", + "in": "query", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + }, + "404": { + "description": "Not Found" + } + } + }, + "delete": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'caches-cache'", + "operationId": "clearCache", + "parameters": [ + { + "name": "cache", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "cacheManager", + "in": "query", + "schema": { + "type": "string" + } + } + ], + "responses": { + "204": { + "description": "No Content" + }, + "404": { + "description": "Not Found" + } + } + } + }, + "/application/caches": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'caches'", + "operationId": "caches", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + }, + "delete": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'caches'", + "operationId": "clearCaches", + "responses": { + "204": { + "description": "No Content" + } + } + } + }, + "/application/beans": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'beans'", + "operationId": "beans", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/application": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator root web endpoint", + "operationId": "links", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object", + "additionalProperties": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/Link" + } + } + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object", + "additionalProperties": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/Link" + } + } + } + }, + "application/json": { + "schema": { + "type": "object", + "additionalProperties": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/Link" + } + } + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "Link": { + "type": "object", + "properties": { + "href": { + "type": "string" + }, + "templated": { + "type": "boolean" + } + } + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/resources/results/3.1.0/app148-1.json b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/resources/results/3.1.0/app148-1.json new file mode 100644 index 000000000..9c3ceaeee --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/resources/results/3.1.0/app148-1.json @@ -0,0 +1,36 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost:6366", + "description": "Generated server url" + } + ], + "paths": { + "/persons": { + "get": { + "tags": [ + "hello-controller" + ], + "operationId": "persons", + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + } + }, + "components": {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/resources/results/3.1.0/app148-2.json b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/resources/results/3.1.0/app148-2.json new file mode 100644 index 000000000..84c6cc722 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/resources/results/3.1.0/app148-2.json @@ -0,0 +1,891 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost:9388/test", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "Actuator", + "description": "Monitor and interact", + "externalDocs": { + "description": "Spring Boot Actuator Web API Documentation", + "url": "https://docs.spring.io/spring-boot/docs/current/actuator-api/html/" + } + } + ], + "paths": { + "/application/loggers/{name}": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'loggers-name'", + "operationId": "loggerLevels", + "parameters": [ + { + "name": "name", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + }, + "404": { + "description": "Not Found" + } + } + }, + "post": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'loggers-name'", + "operationId": "configureLogLevel", + "parameters": [ + { + "name": "name", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "string", + "enum": [ + "TRACE", + "DEBUG", + "INFO", + "WARN", + "ERROR", + "FATAL", + "OFF" + ] + } + } + } + }, + "responses": { + "204": { + "description": "No Content" + }, + "400": { + "description": "Bad Request" + } + } + } + }, + "/application/threaddump": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'threaddump'", + "operationId": "threadDump", + "responses": { + "200": { + "description": "OK", + "content": { + "text/plain;charset=UTF-8": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/application/scheduledtasks": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'scheduledtasks'", + "operationId": "scheduledTasks", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/application/sbom/{id}": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'sbom-id'", + "operationId": "sbom", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/octet-stream": { + "schema": { + "type": "object" + } + } + } + }, + "404": { + "description": "Not Found" + } + } + } + }, + "/application/sbom": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'sbom'", + "operationId": "sboms", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/application/metrics/{requiredMetricName}": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'metrics-requiredMetricName'", + "operationId": "metric", + "parameters": [ + { + "name": "requiredMetricName", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "tag", + "in": "query", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + }, + "404": { + "description": "Not Found" + } + } + } + }, + "/application/metrics": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'metrics'", + "operationId": "listNames", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/application/mappings": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'mappings'", + "operationId": "mappings", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/application/loggers": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'loggers'", + "operationId": "loggers", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/application/info": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'info'", + "operationId": "info", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/application/heapdump": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'heapdump'", + "operationId": "heapDump", + "parameters": [ + { + "name": "live", + "in": "query", + "schema": { + "type": "boolean" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/octet-stream": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/application/health": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'health'", + "operationId": "health", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/application/env/{toMatch}": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'env-toMatch'", + "operationId": "environmentEntry", + "parameters": [ + { + "name": "toMatch", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + }, + "404": { + "description": "Not Found" + } + } + } + }, + "/application/env": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'env'", + "operationId": "environment", + "parameters": [ + { + "name": "pattern", + "in": "query", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/application/configprops/{prefix}": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'configprops-prefix'", + "operationId": "configurationPropertiesWithPrefix", + "parameters": [ + { + "name": "prefix", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + }, + "404": { + "description": "Not Found" + } + } + } + }, + "/application/configprops": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'configprops'", + "operationId": "configurationProperties", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/application/conditions": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'conditions'", + "operationId": "conditions", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/application/caches/{cache}": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'caches-cache'", + "operationId": "cache", + "parameters": [ + { + "name": "cache", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "cacheManager", + "in": "query", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + }, + "404": { + "description": "Not Found" + } + } + }, + "delete": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'caches-cache'", + "operationId": "clearCache", + "parameters": [ + { + "name": "cache", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "cacheManager", + "in": "query", + "schema": { + "type": "string" + } + } + ], + "responses": { + "204": { + "description": "No Content" + }, + "404": { + "description": "Not Found" + } + } + } + }, + "/application/caches": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'caches'", + "operationId": "caches", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + }, + "delete": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'caches'", + "operationId": "clearCaches", + "responses": { + "204": { + "description": "No Content" + } + } + } + }, + "/application/beans": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'beans'", + "operationId": "beans", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/application": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator root web endpoint", + "operationId": "links", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object", + "additionalProperties": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/Link" + } + } + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object", + "additionalProperties": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/Link" + } + } + } + }, + "application/json": { + "schema": { + "type": "object", + "additionalProperties": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/Link" + } + } + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "Link": { + "type": "object", + "properties": { + "href": { + "type": "string" + }, + "templated": { + "type": "boolean" + } + } + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/resources/results/3.1.0/app186.json b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/resources/results/3.1.0/app186.json new file mode 100644 index 000000000..d1e373988 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/resources/results/3.1.0/app186.json @@ -0,0 +1,938 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "Actuator", + "description": "Monitor and interact", + "externalDocs": { + "description": "Spring Boot Actuator Web API Documentation", + "url": "https://docs.spring.io/spring-boot/docs/current/actuator-api/html/" + } + } + ], + "paths": { + "/actuator/loggers/{name}": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'loggers-name'", + "operationId": "loggerLevels", + "parameters": [ + { + "name": "name", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + }, + "404": { + "description": "Not Found" + } + } + }, + "post": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'loggers-name'", + "operationId": "configureLogLevel", + "parameters": [ + { + "name": "name", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "string", + "enum": [ + "TRACE", + "DEBUG", + "INFO", + "WARN", + "ERROR", + "FATAL", + "OFF" + ] + } + } + } + }, + "responses": { + "204": { + "description": "No Content" + }, + "400": { + "description": "Bad Request" + } + } + } + }, + "/actuator/threaddump": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'threaddump'", + "operationId": "threadDump", + "responses": { + "200": { + "description": "OK", + "content": { + "text/plain;charset=UTF-8": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/actuator/scheduledtasks": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'scheduledtasks'", + "operationId": "scheduledTasks", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/actuator/sbom/{id}": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'sbom-id'", + "operationId": "sbom", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/octet-stream": { + "schema": { + "type": "object" + } + } + } + }, + "404": { + "description": "Not Found" + } + } + } + }, + "/actuator/sbom": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'sbom'", + "operationId": "sboms", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/actuator/metrics/{requiredMetricName}": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'metrics-requiredMetricName'", + "operationId": "metric", + "parameters": [ + { + "name": "requiredMetricName", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "tag", + "in": "query", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + }, + "404": { + "description": "Not Found" + } + } + } + }, + "/actuator/metrics": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'metrics'", + "operationId": "listNames", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/actuator/mappings": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'mappings'", + "operationId": "mappings", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/actuator/loggers": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'loggers'", + "operationId": "loggers", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/actuator/info": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'info'", + "operationId": "info", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/actuator/heapdump": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'heapdump'", + "operationId": "heapDump", + "parameters": [ + { + "name": "live", + "in": "query", + "schema": { + "type": "boolean" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/octet-stream": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/actuator/health/{path}": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'health-path'", + "operationId": "health", + "parameters": [ + { + "name": "path", + "in": "path", + "required": true, + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + }, + "404": { + "description": "Not Found" + } + } + } + }, + "/actuator/health": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'health'", + "operationId": "health_1", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/actuator/env/{toMatch}": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'env-toMatch'", + "operationId": "environmentEntry", + "parameters": [ + { + "name": "toMatch", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + }, + "404": { + "description": "Not Found" + } + } + } + }, + "/actuator/env": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'env'", + "operationId": "environment", + "parameters": [ + { + "name": "pattern", + "in": "query", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/actuator/configprops/{prefix}": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'configprops-prefix'", + "operationId": "configurationPropertiesWithPrefix", + "parameters": [ + { + "name": "prefix", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + }, + "404": { + "description": "Not Found" + } + } + } + }, + "/actuator/configprops": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'configprops'", + "operationId": "configurationProperties", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/actuator/conditions": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'conditions'", + "operationId": "conditions", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/actuator/caches/{cache}": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'caches-cache'", + "operationId": "cache", + "parameters": [ + { + "name": "cache", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "cacheManager", + "in": "query", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + }, + "404": { + "description": "Not Found" + } + } + }, + "delete": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'caches-cache'", + "operationId": "clearCache", + "parameters": [ + { + "name": "cache", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "cacheManager", + "in": "query", + "schema": { + "type": "string" + } + } + ], + "responses": { + "204": { + "description": "No Content" + }, + "404": { + "description": "Not Found" + } + } + } + }, + "/actuator/caches": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'caches'", + "operationId": "caches", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + }, + "delete": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'caches'", + "operationId": "clearCaches", + "responses": { + "204": { + "description": "No Content" + } + } + } + }, + "/actuator/beans": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'beans'", + "operationId": "beans", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/actuator": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator root web endpoint", + "operationId": "links", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object", + "additionalProperties": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/Link" + } + } + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object", + "additionalProperties": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/Link" + } + } + } + }, + "application/json": { + "schema": { + "type": "object", + "additionalProperties": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/Link" + } + } + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "Link": { + "type": "object", + "properties": { + "href": { + "type": "string" + }, + "templated": { + "type": "boolean" + } + } + } + } + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/resources/results/app147-1.json b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/resources/results/app147-1.json deleted file mode 100644 index 0c8297c8f..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/resources/results/app147-1.json +++ /dev/null @@ -1,891 +0,0 @@ -{ - "openapi": "3.0.1", - "info": { - "title": "OpenAPI definition", - "version": "v0" - }, - "servers": [ - { - "url": "http://localhost:9297/test", - "description": "Generated server url" - } - ], - "tags": [ - { - "name": "Actuator", - "description": "Monitor and interact", - "externalDocs": { - "description": "Spring Boot Actuator Web API Documentation", - "url": "https://docs.spring.io/spring-boot/docs/current/actuator-api/html/" - } - } - ], - "paths": { - "/application/loggers/{name}": { - "get": { - "tags": [ - "Actuator" - ], - "summary": "Actuator web endpoint 'loggers-name'", - "operationId": "loggerLevels", - "parameters": [ - { - "name": "name", - "in": "path", - "required": true, - "schema": { - "type": "string" - } - } - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/vnd.spring-boot.actuator.v3+json": { - "schema": { - "type": "object" - } - }, - "application/vnd.spring-boot.actuator.v2+json": { - "schema": { - "type": "object" - } - }, - "application/json": { - "schema": { - "type": "object" - } - } - } - }, - "404": { - "description": "Not Found" - } - } - }, - "post": { - "tags": [ - "Actuator" - ], - "summary": "Actuator web endpoint 'loggers-name'", - "operationId": "configureLogLevel", - "parameters": [ - { - "name": "name", - "in": "path", - "required": true, - "schema": { - "type": "string" - } - } - ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "type": "string", - "enum": [ - "TRACE", - "DEBUG", - "INFO", - "WARN", - "ERROR", - "FATAL", - "OFF" - ] - } - } - } - }, - "responses": { - "204": { - "description": "No Content" - }, - "400": { - "description": "Bad Request" - } - } - } - }, - "/application/threaddump": { - "get": { - "tags": [ - "Actuator" - ], - "summary": "Actuator web endpoint 'threaddump'", - "operationId": "threadDump", - "responses": { - "200": { - "description": "OK", - "content": { - "text/plain;charset=UTF-8": { - "schema": { - "type": "object" - } - }, - "application/vnd.spring-boot.actuator.v3+json": { - "schema": { - "type": "object" - } - }, - "application/vnd.spring-boot.actuator.v2+json": { - "schema": { - "type": "object" - } - }, - "application/json": { - "schema": { - "type": "object" - } - } - } - } - } - } - }, - "/application/scheduledtasks": { - "get": { - "tags": [ - "Actuator" - ], - "summary": "Actuator web endpoint 'scheduledtasks'", - "operationId": "scheduledTasks", - "responses": { - "200": { - "description": "OK", - "content": { - "application/vnd.spring-boot.actuator.v3+json": { - "schema": { - "type": "object" - } - }, - "application/vnd.spring-boot.actuator.v2+json": { - "schema": { - "type": "object" - } - }, - "application/json": { - "schema": { - "type": "object" - } - } - } - } - } - } - }, - "/application/sbom/{id}": { - "get": { - "tags": [ - "Actuator" - ], - "summary": "Actuator web endpoint 'sbom-id'", - "operationId": "sbom", - "parameters": [ - { - "name": "id", - "in": "path", - "required": true, - "schema": { - "type": "string" - } - } - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/octet-stream": { - "schema": { - "type": "object" - } - } - } - }, - "404": { - "description": "Not Found" - } - } - } - }, - "/application/sbom": { - "get": { - "tags": [ - "Actuator" - ], - "summary": "Actuator web endpoint 'sbom'", - "operationId": "sboms", - "responses": { - "200": { - "description": "OK", - "content": { - "application/vnd.spring-boot.actuator.v3+json": { - "schema": { - "type": "object" - } - }, - "application/vnd.spring-boot.actuator.v2+json": { - "schema": { - "type": "object" - } - }, - "application/json": { - "schema": { - "type": "object" - } - } - } - } - } - } - }, - "/application/metrics/{requiredMetricName}": { - "get": { - "tags": [ - "Actuator" - ], - "summary": "Actuator web endpoint 'metrics-requiredMetricName'", - "operationId": "metric", - "parameters": [ - { - "name": "requiredMetricName", - "in": "path", - "required": true, - "schema": { - "type": "string" - } - }, - { - "name": "tag", - "in": "query", - "schema": { - "type": "string" - } - } - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/vnd.spring-boot.actuator.v3+json": { - "schema": { - "type": "object" - } - }, - "application/vnd.spring-boot.actuator.v2+json": { - "schema": { - "type": "object" - } - }, - "application/json": { - "schema": { - "type": "object" - } - } - } - }, - "404": { - "description": "Not Found" - } - } - } - }, - "/application/metrics": { - "get": { - "tags": [ - "Actuator" - ], - "summary": "Actuator web endpoint 'metrics'", - "operationId": "listNames", - "responses": { - "200": { - "description": "OK", - "content": { - "application/vnd.spring-boot.actuator.v3+json": { - "schema": { - "type": "object" - } - }, - "application/vnd.spring-boot.actuator.v2+json": { - "schema": { - "type": "object" - } - }, - "application/json": { - "schema": { - "type": "object" - } - } - } - } - } - } - }, - "/application/mappings": { - "get": { - "tags": [ - "Actuator" - ], - "summary": "Actuator web endpoint 'mappings'", - "operationId": "mappings", - "responses": { - "200": { - "description": "OK", - "content": { - "application/vnd.spring-boot.actuator.v3+json": { - "schema": { - "type": "object" - } - }, - "application/vnd.spring-boot.actuator.v2+json": { - "schema": { - "type": "object" - } - }, - "application/json": { - "schema": { - "type": "object" - } - } - } - } - } - } - }, - "/application/loggers": { - "get": { - "tags": [ - "Actuator" - ], - "summary": "Actuator web endpoint 'loggers'", - "operationId": "loggers", - "responses": { - "200": { - "description": "OK", - "content": { - "application/vnd.spring-boot.actuator.v3+json": { - "schema": { - "type": "object" - } - }, - "application/vnd.spring-boot.actuator.v2+json": { - "schema": { - "type": "object" - } - }, - "application/json": { - "schema": { - "type": "object" - } - } - } - } - } - } - }, - "/application/info": { - "get": { - "tags": [ - "Actuator" - ], - "summary": "Actuator web endpoint 'info'", - "operationId": "info", - "responses": { - "200": { - "description": "OK", - "content": { - "application/vnd.spring-boot.actuator.v3+json": { - "schema": { - "type": "object" - } - }, - "application/vnd.spring-boot.actuator.v2+json": { - "schema": { - "type": "object" - } - }, - "application/json": { - "schema": { - "type": "object" - } - } - } - } - } - } - }, - "/application/heapdump": { - "get": { - "tags": [ - "Actuator" - ], - "summary": "Actuator web endpoint 'heapdump'", - "operationId": "heapDump", - "parameters": [ - { - "name": "live", - "in": "query", - "schema": { - "type": "boolean" - } - } - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/octet-stream": { - "schema": { - "type": "object" - } - } - } - } - } - } - }, - "/application/health": { - "get": { - "tags": [ - "Actuator" - ], - "summary": "Actuator web endpoint 'health'", - "operationId": "health", - "responses": { - "200": { - "description": "OK", - "content": { - "application/vnd.spring-boot.actuator.v3+json": { - "schema": { - "type": "object" - } - }, - "application/vnd.spring-boot.actuator.v2+json": { - "schema": { - "type": "object" - } - }, - "application/json": { - "schema": { - "type": "object" - } - } - } - } - } - } - }, - "/application/env/{toMatch}": { - "get": { - "tags": [ - "Actuator" - ], - "summary": "Actuator web endpoint 'env-toMatch'", - "operationId": "environmentEntry", - "parameters": [ - { - "name": "toMatch", - "in": "path", - "required": true, - "schema": { - "type": "string" - } - } - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/vnd.spring-boot.actuator.v3+json": { - "schema": { - "type": "object" - } - }, - "application/vnd.spring-boot.actuator.v2+json": { - "schema": { - "type": "object" - } - }, - "application/json": { - "schema": { - "type": "object" - } - } - } - }, - "404": { - "description": "Not Found" - } - } - } - }, - "/application/env": { - "get": { - "tags": [ - "Actuator" - ], - "summary": "Actuator web endpoint 'env'", - "operationId": "environment", - "parameters": [ - { - "name": "pattern", - "in": "query", - "schema": { - "type": "string" - } - } - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/vnd.spring-boot.actuator.v3+json": { - "schema": { - "type": "object" - } - }, - "application/vnd.spring-boot.actuator.v2+json": { - "schema": { - "type": "object" - } - }, - "application/json": { - "schema": { - "type": "object" - } - } - } - } - } - } - }, - "/application/configprops/{prefix}": { - "get": { - "tags": [ - "Actuator" - ], - "summary": "Actuator web endpoint 'configprops-prefix'", - "operationId": "configurationPropertiesWithPrefix", - "parameters": [ - { - "name": "prefix", - "in": "path", - "required": true, - "schema": { - "type": "string" - } - } - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/vnd.spring-boot.actuator.v3+json": { - "schema": { - "type": "object" - } - }, - "application/vnd.spring-boot.actuator.v2+json": { - "schema": { - "type": "object" - } - }, - "application/json": { - "schema": { - "type": "object" - } - } - } - }, - "404": { - "description": "Not Found" - } - } - } - }, - "/application/configprops": { - "get": { - "tags": [ - "Actuator" - ], - "summary": "Actuator web endpoint 'configprops'", - "operationId": "configurationProperties", - "responses": { - "200": { - "description": "OK", - "content": { - "application/vnd.spring-boot.actuator.v3+json": { - "schema": { - "type": "object" - } - }, - "application/vnd.spring-boot.actuator.v2+json": { - "schema": { - "type": "object" - } - }, - "application/json": { - "schema": { - "type": "object" - } - } - } - } - } - } - }, - "/application/conditions": { - "get": { - "tags": [ - "Actuator" - ], - "summary": "Actuator web endpoint 'conditions'", - "operationId": "conditions", - "responses": { - "200": { - "description": "OK", - "content": { - "application/vnd.spring-boot.actuator.v3+json": { - "schema": { - "type": "object" - } - }, - "application/vnd.spring-boot.actuator.v2+json": { - "schema": { - "type": "object" - } - }, - "application/json": { - "schema": { - "type": "object" - } - } - } - } - } - } - }, - "/application/caches/{cache}": { - "get": { - "tags": [ - "Actuator" - ], - "summary": "Actuator web endpoint 'caches-cache'", - "operationId": "cache", - "parameters": [ - { - "name": "cache", - "in": "path", - "required": true, - "schema": { - "type": "string" - } - }, - { - "name": "cacheManager", - "in": "query", - "schema": { - "type": "string" - } - } - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/vnd.spring-boot.actuator.v3+json": { - "schema": { - "type": "object" - } - }, - "application/vnd.spring-boot.actuator.v2+json": { - "schema": { - "type": "object" - } - }, - "application/json": { - "schema": { - "type": "object" - } - } - } - }, - "404": { - "description": "Not Found" - } - } - }, - "delete": { - "tags": [ - "Actuator" - ], - "summary": "Actuator web endpoint 'caches-cache'", - "operationId": "clearCache", - "parameters": [ - { - "name": "cache", - "in": "path", - "required": true, - "schema": { - "type": "string" - } - }, - { - "name": "cacheManager", - "in": "query", - "schema": { - "type": "string" - } - } - ], - "responses": { - "204": { - "description": "No Content" - }, - "404": { - "description": "Not Found" - } - } - } - }, - "/application/caches": { - "get": { - "tags": [ - "Actuator" - ], - "summary": "Actuator web endpoint 'caches'", - "operationId": "caches", - "responses": { - "200": { - "description": "OK", - "content": { - "application/vnd.spring-boot.actuator.v3+json": { - "schema": { - "type": "object" - } - }, - "application/vnd.spring-boot.actuator.v2+json": { - "schema": { - "type": "object" - } - }, - "application/json": { - "schema": { - "type": "object" - } - } - } - } - } - }, - "delete": { - "tags": [ - "Actuator" - ], - "summary": "Actuator web endpoint 'caches'", - "operationId": "clearCaches", - "responses": { - "204": { - "description": "No Content" - } - } - } - }, - "/application/beans": { - "get": { - "tags": [ - "Actuator" - ], - "summary": "Actuator web endpoint 'beans'", - "operationId": "beans", - "responses": { - "200": { - "description": "OK", - "content": { - "application/vnd.spring-boot.actuator.v3+json": { - "schema": { - "type": "object" - } - }, - "application/vnd.spring-boot.actuator.v2+json": { - "schema": { - "type": "object" - } - }, - "application/json": { - "schema": { - "type": "object" - } - } - } - } - } - } - }, - "/application": { - "get": { - "tags": [ - "Actuator" - ], - "summary": "Actuator root web endpoint", - "operationId": "links", - "responses": { - "200": { - "description": "OK", - "content": { - "application/vnd.spring-boot.actuator.v3+json": { - "schema": { - "type": "object", - "additionalProperties": { - "type": "object", - "additionalProperties": { - "$ref": "#/components/schemas/Link" - } - } - } - }, - "application/vnd.spring-boot.actuator.v2+json": { - "schema": { - "type": "object", - "additionalProperties": { - "type": "object", - "additionalProperties": { - "$ref": "#/components/schemas/Link" - } - } - } - }, - "application/json": { - "schema": { - "type": "object", - "additionalProperties": { - "type": "object", - "additionalProperties": { - "$ref": "#/components/schemas/Link" - } - } - } - } - } - } - } - } - } - }, - "components": { - "schemas": { - "Link": { - "type": "object", - "properties": { - "href": { - "type": "string" - }, - "templated": { - "type": "boolean" - } - } - } - } - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/resources/results/app147-2.json b/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/resources/results/app147-2.json deleted file mode 100644 index 0c8297c8f..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-actuator-webflux-tests/src/test/resources/results/app147-2.json +++ /dev/null @@ -1,891 +0,0 @@ -{ - "openapi": "3.0.1", - "info": { - "title": "OpenAPI definition", - "version": "v0" - }, - "servers": [ - { - "url": "http://localhost:9297/test", - "description": "Generated server url" - } - ], - "tags": [ - { - "name": "Actuator", - "description": "Monitor and interact", - "externalDocs": { - "description": "Spring Boot Actuator Web API Documentation", - "url": "https://docs.spring.io/spring-boot/docs/current/actuator-api/html/" - } - } - ], - "paths": { - "/application/loggers/{name}": { - "get": { - "tags": [ - "Actuator" - ], - "summary": "Actuator web endpoint 'loggers-name'", - "operationId": "loggerLevels", - "parameters": [ - { - "name": "name", - "in": "path", - "required": true, - "schema": { - "type": "string" - } - } - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/vnd.spring-boot.actuator.v3+json": { - "schema": { - "type": "object" - } - }, - "application/vnd.spring-boot.actuator.v2+json": { - "schema": { - "type": "object" - } - }, - "application/json": { - "schema": { - "type": "object" - } - } - } - }, - "404": { - "description": "Not Found" - } - } - }, - "post": { - "tags": [ - "Actuator" - ], - "summary": "Actuator web endpoint 'loggers-name'", - "operationId": "configureLogLevel", - "parameters": [ - { - "name": "name", - "in": "path", - "required": true, - "schema": { - "type": "string" - } - } - ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "type": "string", - "enum": [ - "TRACE", - "DEBUG", - "INFO", - "WARN", - "ERROR", - "FATAL", - "OFF" - ] - } - } - } - }, - "responses": { - "204": { - "description": "No Content" - }, - "400": { - "description": "Bad Request" - } - } - } - }, - "/application/threaddump": { - "get": { - "tags": [ - "Actuator" - ], - "summary": "Actuator web endpoint 'threaddump'", - "operationId": "threadDump", - "responses": { - "200": { - "description": "OK", - "content": { - "text/plain;charset=UTF-8": { - "schema": { - "type": "object" - } - }, - "application/vnd.spring-boot.actuator.v3+json": { - "schema": { - "type": "object" - } - }, - "application/vnd.spring-boot.actuator.v2+json": { - "schema": { - "type": "object" - } - }, - "application/json": { - "schema": { - "type": "object" - } - } - } - } - } - } - }, - "/application/scheduledtasks": { - "get": { - "tags": [ - "Actuator" - ], - "summary": "Actuator web endpoint 'scheduledtasks'", - "operationId": "scheduledTasks", - "responses": { - "200": { - "description": "OK", - "content": { - "application/vnd.spring-boot.actuator.v3+json": { - "schema": { - "type": "object" - } - }, - "application/vnd.spring-boot.actuator.v2+json": { - "schema": { - "type": "object" - } - }, - "application/json": { - "schema": { - "type": "object" - } - } - } - } - } - } - }, - "/application/sbom/{id}": { - "get": { - "tags": [ - "Actuator" - ], - "summary": "Actuator web endpoint 'sbom-id'", - "operationId": "sbom", - "parameters": [ - { - "name": "id", - "in": "path", - "required": true, - "schema": { - "type": "string" - } - } - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/octet-stream": { - "schema": { - "type": "object" - } - } - } - }, - "404": { - "description": "Not Found" - } - } - } - }, - "/application/sbom": { - "get": { - "tags": [ - "Actuator" - ], - "summary": "Actuator web endpoint 'sbom'", - "operationId": "sboms", - "responses": { - "200": { - "description": "OK", - "content": { - "application/vnd.spring-boot.actuator.v3+json": { - "schema": { - "type": "object" - } - }, - "application/vnd.spring-boot.actuator.v2+json": { - "schema": { - "type": "object" - } - }, - "application/json": { - "schema": { - "type": "object" - } - } - } - } - } - } - }, - "/application/metrics/{requiredMetricName}": { - "get": { - "tags": [ - "Actuator" - ], - "summary": "Actuator web endpoint 'metrics-requiredMetricName'", - "operationId": "metric", - "parameters": [ - { - "name": "requiredMetricName", - "in": "path", - "required": true, - "schema": { - "type": "string" - } - }, - { - "name": "tag", - "in": "query", - "schema": { - "type": "string" - } - } - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/vnd.spring-boot.actuator.v3+json": { - "schema": { - "type": "object" - } - }, - "application/vnd.spring-boot.actuator.v2+json": { - "schema": { - "type": "object" - } - }, - "application/json": { - "schema": { - "type": "object" - } - } - } - }, - "404": { - "description": "Not Found" - } - } - } - }, - "/application/metrics": { - "get": { - "tags": [ - "Actuator" - ], - "summary": "Actuator web endpoint 'metrics'", - "operationId": "listNames", - "responses": { - "200": { - "description": "OK", - "content": { - "application/vnd.spring-boot.actuator.v3+json": { - "schema": { - "type": "object" - } - }, - "application/vnd.spring-boot.actuator.v2+json": { - "schema": { - "type": "object" - } - }, - "application/json": { - "schema": { - "type": "object" - } - } - } - } - } - } - }, - "/application/mappings": { - "get": { - "tags": [ - "Actuator" - ], - "summary": "Actuator web endpoint 'mappings'", - "operationId": "mappings", - "responses": { - "200": { - "description": "OK", - "content": { - "application/vnd.spring-boot.actuator.v3+json": { - "schema": { - "type": "object" - } - }, - "application/vnd.spring-boot.actuator.v2+json": { - "schema": { - "type": "object" - } - }, - "application/json": { - "schema": { - "type": "object" - } - } - } - } - } - } - }, - "/application/loggers": { - "get": { - "tags": [ - "Actuator" - ], - "summary": "Actuator web endpoint 'loggers'", - "operationId": "loggers", - "responses": { - "200": { - "description": "OK", - "content": { - "application/vnd.spring-boot.actuator.v3+json": { - "schema": { - "type": "object" - } - }, - "application/vnd.spring-boot.actuator.v2+json": { - "schema": { - "type": "object" - } - }, - "application/json": { - "schema": { - "type": "object" - } - } - } - } - } - } - }, - "/application/info": { - "get": { - "tags": [ - "Actuator" - ], - "summary": "Actuator web endpoint 'info'", - "operationId": "info", - "responses": { - "200": { - "description": "OK", - "content": { - "application/vnd.spring-boot.actuator.v3+json": { - "schema": { - "type": "object" - } - }, - "application/vnd.spring-boot.actuator.v2+json": { - "schema": { - "type": "object" - } - }, - "application/json": { - "schema": { - "type": "object" - } - } - } - } - } - } - }, - "/application/heapdump": { - "get": { - "tags": [ - "Actuator" - ], - "summary": "Actuator web endpoint 'heapdump'", - "operationId": "heapDump", - "parameters": [ - { - "name": "live", - "in": "query", - "schema": { - "type": "boolean" - } - } - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/octet-stream": { - "schema": { - "type": "object" - } - } - } - } - } - } - }, - "/application/health": { - "get": { - "tags": [ - "Actuator" - ], - "summary": "Actuator web endpoint 'health'", - "operationId": "health", - "responses": { - "200": { - "description": "OK", - "content": { - "application/vnd.spring-boot.actuator.v3+json": { - "schema": { - "type": "object" - } - }, - "application/vnd.spring-boot.actuator.v2+json": { - "schema": { - "type": "object" - } - }, - "application/json": { - "schema": { - "type": "object" - } - } - } - } - } - } - }, - "/application/env/{toMatch}": { - "get": { - "tags": [ - "Actuator" - ], - "summary": "Actuator web endpoint 'env-toMatch'", - "operationId": "environmentEntry", - "parameters": [ - { - "name": "toMatch", - "in": "path", - "required": true, - "schema": { - "type": "string" - } - } - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/vnd.spring-boot.actuator.v3+json": { - "schema": { - "type": "object" - } - }, - "application/vnd.spring-boot.actuator.v2+json": { - "schema": { - "type": "object" - } - }, - "application/json": { - "schema": { - "type": "object" - } - } - } - }, - "404": { - "description": "Not Found" - } - } - } - }, - "/application/env": { - "get": { - "tags": [ - "Actuator" - ], - "summary": "Actuator web endpoint 'env'", - "operationId": "environment", - "parameters": [ - { - "name": "pattern", - "in": "query", - "schema": { - "type": "string" - } - } - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/vnd.spring-boot.actuator.v3+json": { - "schema": { - "type": "object" - } - }, - "application/vnd.spring-boot.actuator.v2+json": { - "schema": { - "type": "object" - } - }, - "application/json": { - "schema": { - "type": "object" - } - } - } - } - } - } - }, - "/application/configprops/{prefix}": { - "get": { - "tags": [ - "Actuator" - ], - "summary": "Actuator web endpoint 'configprops-prefix'", - "operationId": "configurationPropertiesWithPrefix", - "parameters": [ - { - "name": "prefix", - "in": "path", - "required": true, - "schema": { - "type": "string" - } - } - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/vnd.spring-boot.actuator.v3+json": { - "schema": { - "type": "object" - } - }, - "application/vnd.spring-boot.actuator.v2+json": { - "schema": { - "type": "object" - } - }, - "application/json": { - "schema": { - "type": "object" - } - } - } - }, - "404": { - "description": "Not Found" - } - } - } - }, - "/application/configprops": { - "get": { - "tags": [ - "Actuator" - ], - "summary": "Actuator web endpoint 'configprops'", - "operationId": "configurationProperties", - "responses": { - "200": { - "description": "OK", - "content": { - "application/vnd.spring-boot.actuator.v3+json": { - "schema": { - "type": "object" - } - }, - "application/vnd.spring-boot.actuator.v2+json": { - "schema": { - "type": "object" - } - }, - "application/json": { - "schema": { - "type": "object" - } - } - } - } - } - } - }, - "/application/conditions": { - "get": { - "tags": [ - "Actuator" - ], - "summary": "Actuator web endpoint 'conditions'", - "operationId": "conditions", - "responses": { - "200": { - "description": "OK", - "content": { - "application/vnd.spring-boot.actuator.v3+json": { - "schema": { - "type": "object" - } - }, - "application/vnd.spring-boot.actuator.v2+json": { - "schema": { - "type": "object" - } - }, - "application/json": { - "schema": { - "type": "object" - } - } - } - } - } - } - }, - "/application/caches/{cache}": { - "get": { - "tags": [ - "Actuator" - ], - "summary": "Actuator web endpoint 'caches-cache'", - "operationId": "cache", - "parameters": [ - { - "name": "cache", - "in": "path", - "required": true, - "schema": { - "type": "string" - } - }, - { - "name": "cacheManager", - "in": "query", - "schema": { - "type": "string" - } - } - ], - "responses": { - "200": { - "description": "OK", - "content": { - "application/vnd.spring-boot.actuator.v3+json": { - "schema": { - "type": "object" - } - }, - "application/vnd.spring-boot.actuator.v2+json": { - "schema": { - "type": "object" - } - }, - "application/json": { - "schema": { - "type": "object" - } - } - } - }, - "404": { - "description": "Not Found" - } - } - }, - "delete": { - "tags": [ - "Actuator" - ], - "summary": "Actuator web endpoint 'caches-cache'", - "operationId": "clearCache", - "parameters": [ - { - "name": "cache", - "in": "path", - "required": true, - "schema": { - "type": "string" - } - }, - { - "name": "cacheManager", - "in": "query", - "schema": { - "type": "string" - } - } - ], - "responses": { - "204": { - "description": "No Content" - }, - "404": { - "description": "Not Found" - } - } - } - }, - "/application/caches": { - "get": { - "tags": [ - "Actuator" - ], - "summary": "Actuator web endpoint 'caches'", - "operationId": "caches", - "responses": { - "200": { - "description": "OK", - "content": { - "application/vnd.spring-boot.actuator.v3+json": { - "schema": { - "type": "object" - } - }, - "application/vnd.spring-boot.actuator.v2+json": { - "schema": { - "type": "object" - } - }, - "application/json": { - "schema": { - "type": "object" - } - } - } - } - } - }, - "delete": { - "tags": [ - "Actuator" - ], - "summary": "Actuator web endpoint 'caches'", - "operationId": "clearCaches", - "responses": { - "204": { - "description": "No Content" - } - } - } - }, - "/application/beans": { - "get": { - "tags": [ - "Actuator" - ], - "summary": "Actuator web endpoint 'beans'", - "operationId": "beans", - "responses": { - "200": { - "description": "OK", - "content": { - "application/vnd.spring-boot.actuator.v3+json": { - "schema": { - "type": "object" - } - }, - "application/vnd.spring-boot.actuator.v2+json": { - "schema": { - "type": "object" - } - }, - "application/json": { - "schema": { - "type": "object" - } - } - } - } - } - } - }, - "/application": { - "get": { - "tags": [ - "Actuator" - ], - "summary": "Actuator root web endpoint", - "operationId": "links", - "responses": { - "200": { - "description": "OK", - "content": { - "application/vnd.spring-boot.actuator.v3+json": { - "schema": { - "type": "object", - "additionalProperties": { - "type": "object", - "additionalProperties": { - "$ref": "#/components/schemas/Link" - } - } - } - }, - "application/vnd.spring-boot.actuator.v2+json": { - "schema": { - "type": "object", - "additionalProperties": { - "type": "object", - "additionalProperties": { - "$ref": "#/components/schemas/Link" - } - } - } - }, - "application/json": { - "schema": { - "type": "object", - "additionalProperties": { - "type": "object", - "additionalProperties": { - "$ref": "#/components/schemas/Link" - } - } - } - } - } - } - } - } - } - }, - "components": { - "schemas": { - "Link": { - "type": "object", - "properties": { - "href": { - "type": "string" - }, - "templated": { - "type": "boolean" - } - } - } - } - } -} 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 c120c668c..c1864832e 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.1 + 2.8.2 4.0.0 diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/AbstractCommonTest.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/AbstractCommonTest.java deleted file mode 100644 index 3ecba115c..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/AbstractCommonTest.java +++ /dev/null @@ -1,32 +0,0 @@ -package test.org.springdoc.api; - -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; -import org.springframework.test.context.ActiveProfiles; -import org.springframework.test.context.TestPropertySource; -import org.springframework.test.web.servlet.MockMvc; - -@AutoConfigureMockMvc -@ActiveProfiles("test") -@TestPropertySource(properties = { "management.endpoints.enabled-by-default=false" , "springdoc.api-docs.version=openapi_3_0" }) -public abstract class AbstractCommonTest { - - @Autowired - protected MockMvc mockMvc; - - protected String getContent(String fileName) { - try { - Path path = Paths.get(AbstractCommonTest.class.getClassLoader().getResource(fileName).toURI()); - byte[] fileBytes = Files.readAllBytes(path); - return new String(fileBytes, StandardCharsets.UTF_8); - } - catch (Exception e) { - throw new RuntimeException("Failed to read file: " + fileName, e); - } - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/AbstractSpringDocActuatorTest.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/AbstractSpringDocActuatorTest.java deleted file mode 100644 index fb674a750..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/AbstractSpringDocActuatorTest.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * - * * - * * * - * * * * - * * * * * 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; - -import jakarta.annotation.PostConstruct; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.web.server.LocalManagementPort; -import org.springframework.boot.web.client.RestTemplateBuilder; -import org.springframework.test.context.TestPropertySource; -import org.springframework.web.client.RestTemplate; - -import static org.skyscreamer.jsonassert.JSONAssert.assertEquals; - -@TestPropertySource(properties = { "management.endpoints.enabled-by-default=true" }) -public abstract class AbstractSpringDocActuatorTest extends AbstractCommonTest { - - protected static final Logger LOGGER = LoggerFactory.getLogger(AbstractCommonTest.class); - - protected RestTemplate actuatorRestTemplate; - - @LocalManagementPort - private int managementPort; - - @Autowired - private RestTemplateBuilder restTemplateBuilder; - - @PostConstruct - void init() { - actuatorRestTemplate = restTemplateBuilder - .rootUri("http://localhost:" + this.managementPort).build(); - } - - protected void testWithRestTemplate(String testId, String uri) throws Exception { - String result = null; - try { - result = actuatorRestTemplate.getForObject(uri, String.class); - String expected = getContent("results/app" + testId + ".json"); - assertEquals(expected, result, true); - } - catch (AssertionError e) { - LOGGER.error(result); - throw e; - } - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/AbstractSpringDocTest.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/AbstractSpringDocTest.java deleted file mode 100644 index 5824868a0..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/AbstractSpringDocTest.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * - * * Copyright 2019-2020 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; - -import org.junit.jupiter.api.Test; -import org.springdoc.core.utils.Constants; - -import org.springframework.boot.test.context.SpringBootTest; -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; - -@SpringBootTest -public abstract class AbstractSpringDocTest extends AbstractCommonTest { - - public static String className; - - @Test - protected void testApp() throws Exception { - className = getClass().getSimpleName(); - String testNumber = className.replaceAll("[^0-9]", ""); - MvcResult mockMvcResult = mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL)).andExpect(status().isOk()) - .andExpect(jsonPath("$.openapi", is("3.0.1"))).andReturn(); - String result = mockMvcResult.getResponse().getContentAsString(); - String expected = getContent("results/app" + testNumber + ".json"); - assertEquals(expected, result, true); - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/app128/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/app128/HelloController.java deleted file mode 100644 index ea8209be8..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/app128/HelloController.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app128; - - -import org.springframework.boot.actuate.endpoint.web.annotation.RestControllerEndpoint; -import org.springframework.stereotype.Component; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; - -@RestControllerEndpoint(id = "tenant") -@Component -public class HelloController { - - @GetMapping("/customer/{id}") - public String getTenantById(@PathVariable("id") String customerId) { - return "Tenant_" + customerId; - } -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/app128/SpringDocApp128Test.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/app128/SpringDocApp128Test.java deleted file mode 100644 index c938ce64f..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/app128/SpringDocApp128Test.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * - * * - * * * - * * * * Copyright 2019-2020 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.app128; - -import org.junit.jupiter.api.Test; -import org.springdoc.core.utils.Constants; -import org.springdoc.core.utils.SpringDocUtils; -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController; -import org.springframework.test.context.TestPropertySource; - -import static org.hamcrest.Matchers.containsString; -import static org.hamcrest.Matchers.is; -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; - - -/** - * Tests Spring meta-annotations as method parameters - */ -@TestPropertySource(properties = { "springdoc.show-actuator=true", - "management.endpoints.enabled-by-default=true", - "management.endpoints.web.exposure.include = tenant" }) -public class SpringDocApp128Test extends AbstractSpringDocTest { - - static { - SpringDocUtils.getConfig().addHiddenRestControllers(BasicErrorController.class); - } - - @Test - protected void testApp() throws Exception { - mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL)).andExpect(status().isOk()) - .andExpect(jsonPath("$.openapi", is("3.0.1"))) - .andExpect(jsonPath("$.paths./actuator/tenant/customer/{id}.get.operationId", containsString("getTenantById"))) - .andExpect(jsonPath("$.paths./actuator/tenant/customer/{id}.get.parameters[0].in", is("path"))) - .andExpect(jsonPath("$.paths./actuator/tenant/customer/{id}.get.parameters[0].name", is("id"))); - } - - @SpringBootApplication - static class SpringDocTestApp {} - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/app144/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/app144/HelloController.java deleted file mode 100644 index 59fee7564..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/app144/HelloController.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app144; - -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -@RestController -public class HelloController { - - @GetMapping("/persons") - public String persons() { - return "OK"; - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/app144/SpringDocApp144Test.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/app144/SpringDocApp144Test.java deleted file mode 100644 index d80cb4239..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/app144/SpringDocApp144Test.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app144; - -import org.junit.jupiter.api.Test; -import org.springdoc.core.utils.Constants; -import test.org.springdoc.api.AbstractSpringDocActuatorTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; - -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.status; - - -@SpringBootTest(webEnvironment = WebEnvironment.DEFINED_PORT, - properties = { "management.endpoints.web.exposure.include=*", - "server.port=52554", - "springdoc.use-management-port=true", - "management.server.port=9290", - "management.endpoints.web.base-path=/application" }) -public class SpringDocApp144Test extends AbstractSpringDocActuatorTest { - - @Test - void testApp() throws Exception { - mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL)) - .andExpect(status().isNotFound()); - } - - @Test - void testApp1() throws Exception { - String result = actuatorRestTemplate.getForObject("/application/openapi", String.class); - String expected = getContent("results/app144.json"); - assertEquals(expected, result, true); - } - - @SpringBootApplication - static class SpringDocTestApp {} - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/app145/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/app145/HelloController.java deleted file mode 100644 index 12891a39e..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/app145/HelloController.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app145; - -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -@RestController -public class HelloController { - - @GetMapping("/persons") - public String persons() { - return "OK"; - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/app145/SpringDocApp145Test.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/app145/SpringDocApp145Test.java deleted file mode 100644 index b45e5135a..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/app145/SpringDocApp145Test.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * - * * 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.app145; - -import org.junit.jupiter.api.Test; -import org.springdoc.core.utils.Constants; -import test.org.springdoc.api.AbstractSpringDocActuatorTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; -import org.springframework.http.HttpStatus; -import org.springframework.web.client.HttpClientErrorException; -import org.springframework.web.client.HttpStatusCodeException; - -import static org.junit.jupiter.api.Assertions.assertTrue; -import static org.junit.jupiter.api.Assertions.fail; -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.status; - - -@SpringBootTest(webEnvironment = WebEnvironment.DEFINED_PORT, - properties = { "management.endpoints.web.exposure.include=*", - "server.port=52556", - "springdoc.use-management-port=true", - "springdoc.group-configs[0].group=users", - "springdoc.group-configs[0].packages-to-scan=test.org.springdoc.api.app145", - "management.server.port=9291", - "management.endpoints.web.base-path=/application" }) -public class SpringDocApp145Test extends AbstractSpringDocActuatorTest { - - @Test - void testApp() throws Exception { - mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL + "/users")) - .andExpect(status().isNotFound()); - } - - @Test - void testApp1() throws Exception { - try { - actuatorRestTemplate.getForObject("/application/openapi", String.class); - fail(); - } - catch (HttpClientErrorException ex) { - if (ex.getStatusCode() == HttpStatus.NOT_FOUND) - assertTrue(true); - else - fail(); - } - } - - @Test - void testApp2() throws Exception { - String result = actuatorRestTemplate.getForObject("/application/openapi/users", String.class); - String expected = getContent("results/app145.json"); - assertEquals(expected, result, true); - } - - @Test - void testApp3() throws Exception { - try { - actuatorRestTemplate.getForObject("/application/openapi" + "/" + Constants.DEFAULT_GROUP_NAME, String.class); - fail(); - } - catch (HttpStatusCodeException ex) { - if (ex.getStatusCode() == HttpStatus.NOT_FOUND) - assertTrue(true); - } - } - - @SpringBootApplication - static class SpringDocTestApp {} -} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/app147/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/app147/HelloController.java deleted file mode 100644 index 98af45e13..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/app147/HelloController.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app147; - - -import org.springdoc.core.models.GroupedOpenApi; - -import org.springframework.context.annotation.Bean; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -@RestController -public class HelloController { - - @GetMapping("/persons") - public String persons() { - return "OK"; - } - - @Bean - public GroupedOpenApi userOpenApi() { - return GroupedOpenApi.builder() - .group("users") - .packagesToScan("test.org.springdoc.api.app147") - .build(); - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/app147/SpringDocApp147Test.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/app147/SpringDocApp147Test.java deleted file mode 100644 index ff34a846c..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/app147/SpringDocApp147Test.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * - * * 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.app147; - -import org.junit.jupiter.api.Test; -import org.springdoc.core.utils.Constants; -import test.org.springdoc.api.AbstractSpringDocActuatorTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.test.context.SpringBootTest; - -import static org.hamcrest.Matchers.is; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; - - -@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, - properties = { "management.endpoints.web.exposure.include=*", - "springdoc.show-actuator=true", - "management.server.port=9287", - "management.endpoints.web.exposure.exclude=functions, shutdown", - "server.servlet.context-path=/sample", - "management.server.base-path=/test", - "management.endpoints.web.base-path=/application" }) -public class SpringDocApp147Test extends AbstractSpringDocActuatorTest { - - @Test - void testApp() throws Exception { - mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL + "/" + Constants.ACTUATOR_DEFAULT_GROUP)) - .andExpect(status().isOk()) - .andExpect(jsonPath("$.openapi", is("3.0.1"))) - .andExpect(content().json(getContent("results/app147-1.json"), true)); - } - - @Test - void testApp1() throws Exception { - mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL + "/users")) - .andExpect(status().isOk()) - .andExpect(jsonPath("$.openapi", is("3.0.1"))) - .andExpect(content().json(getContent("results/app147-2.json"), true)); - } - - @Test - void testApp2() throws Exception { - mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL + "/" + Constants.DEFAULT_GROUP_NAME)) - .andExpect(status().isNotFound()); - } - - @SpringBootApplication - static class SpringDocTestApp {} - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/app148/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/app148/HelloController.java deleted file mode 100644 index d4a7dd5a6..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/app148/HelloController.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app148; - - -import org.springdoc.core.models.GroupedOpenApi; - -import org.springframework.context.annotation.Bean; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -@RestController -public class HelloController { - - @GetMapping("/persons") - public String persons() { - return "OK"; - } - - @Bean - public GroupedOpenApi userOpenApi() { - return GroupedOpenApi.builder() - .group("users") - .packagesToScan("test.org.springdoc.api.app148") - .build(); - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/app148/SpringDocApp148Test.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/app148/SpringDocApp148Test.java deleted file mode 100644 index 089f9835c..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/app148/SpringDocApp148Test.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * - * * 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.app148; - -import org.junit.jupiter.api.Test; -import org.springdoc.core.utils.Constants; -import test.org.springdoc.api.AbstractSpringDocActuatorTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; -import org.springframework.http.HttpStatus; -import org.springframework.web.client.HttpStatusCodeException; - -import static org.junit.jupiter.api.Assertions.assertTrue; -import static org.junit.jupiter.api.Assertions.fail; - - -@SpringBootTest(webEnvironment = WebEnvironment.DEFINED_PORT, - properties = { "management.endpoints.web.exposure.include=*", - "springdoc.show-actuator=true", - "management.server.port=9298", - "server.port=6276", - "server.servlet.context-path=/toto", - "springdoc.use-management-port=true", - "spring.mvc.servlet.path=/titi", - "management.endpoints.web.exposure.exclude=functions, shutdown", - "management.server.base-path=/test", - "management.endpoints.web.base-path=/application" }) -public class SpringDocApp148Test extends AbstractSpringDocActuatorTest { - - @Test - void testApp() throws Exception { - super.testWithRestTemplate("148-1","/test/application/openapi/users"); - } - - @Test - void testApp2() throws Exception { - super.testWithRestTemplate("148-2","/test/application/openapi/x-actuator"); - } - - @Test - void testApp3() throws Exception { - try { - actuatorRestTemplate.getForObject("/test/application/openapi" + "/" + Constants.DEFAULT_GROUP_NAME, String.class); - fail(); - } - catch (HttpStatusCodeException ex) { - if (ex.getStatusCode() == HttpStatus.NOT_FOUND) - assertTrue(true); - } - } - - @SpringBootApplication - static class SpringDocTestApp {} - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/app186/SpringDocApp186Test.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/app186/SpringDocApp186Test.java deleted file mode 100644 index e448b6403..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/app186/SpringDocApp186Test.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * - * * - * * * - * * * * - * * * * * 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.app186; - -import org.junit.jupiter.api.Test; -import org.springdoc.core.customizers.OperationCustomizer; -import org.springdoc.core.models.GroupedOpenApi; -import org.springdoc.core.utils.Constants; -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.actuate.autoconfigure.endpoint.web.WebEndpointProperties; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.Bean; -import org.springframework.test.context.TestPropertySource; - -import static org.hamcrest.Matchers.is; -import static org.springdoc.core.utils.Constants.ALL_PATTERN; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; - -@TestPropertySource(properties = { "springdoc.show-actuator=true", - "springdoc.group-configs[0].group=group-actuator-as-properties", - "springdoc.group-configs[0].paths-to-match=${management.endpoints.web.base-path:/actuator}/**", - "management.endpoints.enabled-by-default=true", - "management.endpoints.web.exposure.include=*", - "management.endpoints.web.exposure.exclude=functions, shutdown" }) -public class SpringDocApp186Test extends AbstractSpringDocTest { - - @Test - protected void testApp() throws Exception { - mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL)) - .andExpect(jsonPath("$.openapi", is("3.0.1"))) - .andExpect(status().isOk()) - .andExpect(content().json(getContent("results/app186.json"), true)); - } - - @Test - void testGroupActuatorAsCodeCheckBackwardsCompatibility() throws Exception { - mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL + "/group-actuator-as-code-check-backwards-compatibility")) - .andExpect(jsonPath("$.openapi", is("3.0.1"))) - .andExpect(status().isOk()) - .andExpect(content().json(getContent("results/app186.json"), true)); - } - - @Test - void testGroupActuatorAsCode() throws Exception { - mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL + "/group-actuator-as-code")) - .andExpect(jsonPath("$.openapi", is("3.0.1"))) - .andExpect(status().isOk()) - .andExpect(content().json(getContent("results/app186.json"), true)); - } - - @Test - void testGroupActuatorAsProperties() throws Exception { - mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL + "/group-actuator-as-properties")) - .andExpect(jsonPath("$.openapi", is("3.0.1"))) - .andExpect(status().isOk()) - .andExpect(content().json(getContent("results/app186.json"), true)); - } - - @SpringBootApplication - static class SpringDocTestApp { - - @Bean - public GroupedOpenApi asCodeCheckBackwardsCompatibility(OperationCustomizer actuatorCustomizer, WebEndpointProperties endpointProperties) { - return GroupedOpenApi.builder() - .group("group-actuator-as-code-check-backwards-compatibility") - .pathsToMatch(endpointProperties.getBasePath() + ALL_PATTERN) - .addOperationCustomizer(actuatorCustomizer) - .build(); - } - - @Bean - public GroupedOpenApi asCode(WebEndpointProperties endpointProperties) { - return GroupedOpenApi.builder() - .group("group-actuator-as-code") - .pathsToMatch(endpointProperties.getBasePath() + ALL_PATTERN) - .build(); - } - } - -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/app36/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/app36/HelloController.java deleted file mode 100644 index b383255fc..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/app36/HelloController.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app36; - -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -@RestController -public class HelloController { - - @GetMapping("/persons") - public String persons() { - return "OK"; - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/app36/SpringDocApp36Test.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/app36/SpringDocApp36Test.java deleted file mode 100644 index e51e85383..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/app36/SpringDocApp36Test.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app36; - -import org.junit.jupiter.api.Test; -import org.springdoc.core.utils.Constants; -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.test.context.TestPropertySource; - -import static org.hamcrest.Matchers.containsString; -import static org.hamcrest.Matchers.is; -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.show-actuator=true", "management.endpoints.enabled-by-default=true", - "management.endpoints.web.exposure.include=*" }) -public class SpringDocApp36Test extends AbstractSpringDocTest { - - @Test - protected void testApp() throws Exception { - mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL)).andExpect(status().isOk()) - .andExpect(jsonPath("$.openapi", is("3.0.1"))) - .andExpect(jsonPath("$.paths./actuator/info.get.operationId", containsString("info"))) - .andExpect(jsonPath("$.paths./actuator/health.get.operationId", containsString("health"))) - .andExpect(jsonPath("$.paths./actuator/metrics/{requiredMetricName}.get.parameters[0].in", is("path"))) - .andExpect(jsonPath("$.paths./actuator/metrics/{requiredMetricName}.get.parameters[0].name", is("requiredMetricName"))); - } - - @SpringBootApplication - static class SpringDocTestApp {} - -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/app68/CustomizedOperation.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/app68/CustomizedOperation.java deleted file mode 100644 index 146b41c33..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/app68/CustomizedOperation.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app68; - -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; - -@Retention(RetentionPolicy.RUNTIME) -public @interface CustomizedOperation { - String addition() default "customized operation!"; -} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/app68/SpringDocApp68Test.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/app68/SpringDocApp68Test.java deleted file mode 100644 index 0cbbe9cf3..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/app68/SpringDocApp68Test.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app68; - -import org.hamcrest.Matchers; -import org.junit.jupiter.api.Test; -import org.springdoc.core.utils.Constants; -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.test.context.TestPropertySource; - -import static org.hamcrest.Matchers.contains; -import static org.hamcrest.Matchers.containsString; -import static org.hamcrest.Matchers.hasSize; -import static org.hamcrest.Matchers.is; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; - -@TestPropertySource(properties = { "management.endpoints.enabled-by-default=true", "springdoc.show-actuator=true" }) -public class SpringDocApp68Test extends AbstractSpringDocTest { - - - @Test - protected void testApp() throws Exception { - mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL + "/stores")) - .andExpect(status().isOk()) - .andExpect(jsonPath("$.openapi", is("3.0.1"))) - .andExpect(content().json(getContent("results/app68-1.json"), true)); - } - - @Test - void testApp2() throws Exception { - mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL + "/users")) - .andExpect(status().isOk()) - .andExpect(jsonPath("$.openapi", is("3.0.1"))) - .andExpect(content().json(getContent("results/app68-2.json"), true)); - } - - @Test - void testApp3() throws Exception { - mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL + "/pets")) - .andExpect(status().isOk()) - .andExpect(jsonPath("$.openapi", is("3.0.1"))) - .andExpect(content().json(getContent("results/app68-3.json"), true)); - } - - @Test - void testApp4() throws Exception { - mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL + "/groups test")) - .andExpect(status().isOk()) - .andExpect(jsonPath("$.openapi", is("3.0.1"))) - .andExpect(content().json(getContent("results/app68-4.json"), true)); - } - - @Test - void testActuator() throws Exception { - mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL)).andExpect(status().isOk()) - .andExpect(jsonPath("$.openapi", is("3.0.1"))) - .andExpect(jsonPath("$.paths./actuator/health.get.summary", Matchers.is("Actuator web endpoint 'health'"))) - .andExpect(jsonPath("$.paths./actuator/health.get.operationId", containsString("health"))); - } - - @Test - void testActuatorDescription() throws Exception { - mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL)).andExpect(status().isOk()) - .andExpect(jsonPath("$.openapi", is("3.0.1"))) - .andExpect(jsonPath("$.tags", hasSize(4))) - .andExpect(jsonPath("$.tags[?(@.name == '" + Constants.SPRINGDOC_ACTUATOR_TAG + "')].name", contains(Constants.SPRINGDOC_ACTUATOR_TAG))) - .andExpect(jsonPath("$.tags[?(@.name == '" + Constants.SPRINGDOC_ACTUATOR_TAG + "')].description", contains(Constants.SPRINGDOC_ACTUATOR_DESCRIPTION))) - .andExpect(jsonPath("$.tags[?(@.name == '" + Constants.SPRINGDOC_ACTUATOR_TAG + "')].externalDocs.description", contains(Constants.SPRINGDOC_ACTUATOR_DOC_DESCRIPTION))) - .andExpect(jsonPath("$.tags[?(@.name == '" + Constants.SPRINGDOC_ACTUATOR_TAG + "')].externalDocs.url", contains(Constants.SPRINGDOC_ACTUATOR_DOC_URL))); - } - - @Test - void testApp5() throws Exception { - mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL + "/user")) - .andExpect(status().isNotFound()); - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/app68/SpringDocConfiguration.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/app68/SpringDocConfiguration.java deleted file mode 100644 index 0dfedc891..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/app68/SpringDocConfiguration.java +++ /dev/null @@ -1,117 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app68; - -import java.util.ArrayList; -import java.util.List; - -import io.swagger.v3.oas.models.Components; -import io.swagger.v3.oas.models.OpenAPI; -import io.swagger.v3.oas.models.Operation; -import io.swagger.v3.oas.models.info.Info; -import io.swagger.v3.oas.models.info.License; -import io.swagger.v3.oas.models.security.SecurityScheme; -import io.swagger.v3.oas.models.servers.Server; -import org.apache.commons.lang3.StringUtils; -import org.springdoc.core.customizers.OpenApiCustomizer; -import org.springdoc.core.customizers.OperationCustomizer; -import org.springdoc.core.models.GroupedOpenApi; -import org.springdoc.core.utils.Constants; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.web.method.HandlerMethod; - -@Configuration -public class SpringDocConfiguration { - - @SpringBootApplication - static class SpringDocTestApp {} - - @Bean - public GroupedOpenApi storeOpenApi() { - return GroupedOpenApi.builder() - .group("stores") - .pathsToMatch("/store/**") - .build(); - } - - @Bean - public GroupedOpenApi userOpenApi() { - return GroupedOpenApi.builder() - .group("users") - .packagesToScan("test.org.springdoc.api.app68.api.user").addOpenApiCustomizer(serverOpenApiCustomizer1()) - .addOperationCustomizer(operationCustomizer()) - .build(); - } - - public OpenApiCustomizer serverOpenApiCustomizer1() { - Server server = new Server().url("http://toto.v1.com").description("myserver1"); - List servers = new ArrayList<>(); - servers.add(server); - return openApi -> openApi.setServers(servers); - } - - public OpenApiCustomizer serverOpenApiCustomizer2() { - Server server = new Server().url("http://toto.v2.com").description("myserver2"); - List servers = new ArrayList<>(); - servers.add(server); - return openApi -> openApi.setServers(servers); - } - - OperationCustomizer operationCustomizer() { - return (Operation operation, HandlerMethod handlerMethod) -> { - CustomizedOperation annotation = handlerMethod.getMethodAnnotation(CustomizedOperation.class); - if (annotation != null) { - operation.description(StringUtils.defaultIfBlank(operation.getDescription(), Constants.DEFAULT_DESCRIPTION) + ", " + annotation.addition()); - } - return operation; - }; - } - - @Bean - public GroupedOpenApi petOpenApi() { - return GroupedOpenApi.builder() - .group("pets") - .pathsToMatch("/pet/**").addOpenApiCustomizer(serverOpenApiCustomizer2()) - .build(); - } - - @Bean - public GroupedOpenApi groupOpenApi() { - return GroupedOpenApi.builder() - .group("groups test") - .pathsToMatch("/v1/**").pathsToExclude("/v1/users") - .packagesToScan("test.org.springdoc.api.app68.api.user", "test.org.springdoc.api.app68.api.store") - .build(); - } - - - @Bean - public OpenAPI customOpenAPI() { - return new OpenAPI() - .components(new Components().addSecuritySchemes("basicScheme", - new SecurityScheme().type(SecurityScheme.Type.HTTP).scheme("basic"))) - .info(new Info().title("Petstore API").version("v0").description( - "This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.") - .termsOfService("http://swagger.io/terms/") - .license(new License().name("Apache 2.0").url("http://springdoc.org"))); - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/app68/api/ApiUtil.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/app68/api/ApiUtil.java deleted file mode 100644 index 64657f7dc..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/app68/api/ApiUtil.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app68.api; - -import java.io.IOException; - -import jakarta.servlet.http.HttpServletResponse; - -import org.springframework.http.HttpStatus; -import org.springframework.web.context.request.NativeWebRequest; -import org.springframework.web.server.ResponseStatusException; - -public class ApiUtil { - - public static void setExampleResponse(NativeWebRequest req, String contentType, String example) { - try { - req.getNativeResponse(HttpServletResponse.class).addHeader("Content-Type", contentType); - req.getNativeResponse(HttpServletResponse.class).getOutputStream().print(example); - } - catch (IOException e) { - throw new RuntimeException(e); - } - } - - public static void checkApiKey(NativeWebRequest req) { - if (!"1".equals(System.getenv("DISABLE_API_KEY")) && !"special-key".equals(req.getHeader("api_key"))) { - throw new ResponseStatusException(HttpStatus.UNAUTHORIZED, "Missing API key!"); - } - } -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/app68/api/ExceptionTranslator.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/app68/api/ExceptionTranslator.java deleted file mode 100644 index 0c4fb85cb..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/app68/api/ExceptionTranslator.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app68.api; - -import java.util.Map; - -import jakarta.validation.ConstraintViolationException; - -import org.springframework.boot.web.error.ErrorAttributeOptions; -import org.springframework.boot.web.servlet.error.ErrorAttributes; -import org.springframework.http.HttpStatus; -import org.springframework.web.bind.annotation.ExceptionHandler; -import org.springframework.web.bind.annotation.ResponseStatus; -import org.springframework.web.bind.annotation.RestControllerAdvice; -import org.springframework.web.context.request.RequestAttributes; -import org.springframework.web.context.request.WebRequest; - -@RestControllerAdvice -public class ExceptionTranslator { - - private final ErrorAttributes errorAttributes; - - public ExceptionTranslator(ErrorAttributes errorAttributes) { - this.errorAttributes = errorAttributes; - } - - @ExceptionHandler(ConstraintViolationException.class) - @ResponseStatus(HttpStatus.BAD_REQUEST) - public Map processConstraintViolationException(WebRequest request) { - request.setAttribute("jakarta.servlet.error.status_code", HttpStatus.BAD_REQUEST.value(), RequestAttributes.SCOPE_REQUEST); - return errorAttributes.getErrorAttributes(request, ErrorAttributeOptions.defaults()); - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/app68/api/HomeController.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/app68/api/HomeController.java deleted file mode 100644 index 9476bf058..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/app68/api/HomeController.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app68.api; - -import org.springframework.beans.factory.annotation.Value; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.GetMapping; - -import static org.springdoc.core.utils.Constants.SWAGGER_UI_PATH; -import static org.springframework.util.AntPathMatcher.DEFAULT_PATH_SEPARATOR; -import static org.springframework.web.servlet.view.UrlBasedViewResolver.REDIRECT_URL_PREFIX; - -/** - * Home redirection to swagger api documentation - */ -@Controller -public class HomeController { - - @Value(SWAGGER_UI_PATH) - private String swaggerUiPath; - - @GetMapping(DEFAULT_PATH_SEPARATOR) - public String index() { - return REDIRECT_URL_PREFIX + swaggerUiPath; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/app68/api/pet/PetApi.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/app68/api/pet/PetApi.java deleted file mode 100644 index 76d849eb1..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/app68/api/pet/PetApi.java +++ /dev/null @@ -1,161 +0,0 @@ -/* - * - * * Copyright 2019-2020 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. - * - */ - -/** - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (3.0.0). - * https://openapi-generator.tech - * Do not edit the class manually. - */ -package test.org.springdoc.api.app68.api.pet; - -import java.util.List; - -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.enums.SecuritySchemeType; -import io.swagger.v3.oas.annotations.media.ArraySchema; -import io.swagger.v3.oas.annotations.media.Content; -import io.swagger.v3.oas.annotations.media.Schema; -import io.swagger.v3.oas.annotations.responses.ApiResponse; -import io.swagger.v3.oas.annotations.responses.ApiResponses; -import io.swagger.v3.oas.annotations.security.OAuthFlow; -import io.swagger.v3.oas.annotations.security.OAuthFlows; -import io.swagger.v3.oas.annotations.security.OAuthScope; -import io.swagger.v3.oas.annotations.security.SecurityRequirement; -import io.swagger.v3.oas.annotations.security.SecurityScheme; -import io.swagger.v3.oas.annotations.tags.Tag; -import jakarta.validation.Valid; -import jakarta.validation.constraints.NotNull; -import test.org.springdoc.api.app68.model.ModelApiResponse; -import test.org.springdoc.api.app68.model.Pet; - -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.DeleteMapping; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; -import org.springframework.web.bind.annotation.ResponseBody; -import org.springframework.web.multipart.MultipartFile; - -@SecurityScheme(name = "petstore_auth", type = SecuritySchemeType.OAUTH2, flows = @OAuthFlows(implicit = @OAuthFlow(authorizationUrl = "http://petstore.swagger.io/oauth/dialog", scopes = { - @OAuthScope(name = "write:pets", description = "modify pets in your account"), - @OAuthScope(name = "read:pets", description = "read your pets") }))) -@Tag(name = "pet", description = "the pet API") -@ResponseBody -public interface PetApi { - - default PetApiDelegate getDelegate() { - return new PetApiDelegate() { - }; - } - - @Operation(summary = "Add a new pet to the store", description = "", security = { - @SecurityRequirement(name = "petstore_auth", scopes = { "write:pets", "read:pets" }) }, tags = { "pet" }) - @ApiResponses(value = { @ApiResponse(responseCode = "405", description = "Invalid input") }) - @PostMapping(value = "/pet", consumes = { "application/json", "application/xml" }) - default void addPet( - @io.swagger.v3.oas.annotations.parameters.RequestBody(description = "Pet object that needs to be added to the store", required = true) @Valid @RequestBody Pet pet) { - // return getDelegate().addPet(pet); - } - - @Operation(summary = "Deletes a pet", description = "", security = { - @SecurityRequirement(name = "petstore_auth", scopes = { "write:pets", "read:pets" }) }, tags = { "pet" }) - @ApiResponses(value = { @ApiResponse(responseCode = "400", description = "Invalid ID supplied"), - @ApiResponse(responseCode = "404", description = "Pet not found") }) - @DeleteMapping(value = "/pet/{petId}") - default ResponseEntity deletePet( - @Parameter(description = "Pet id to delete", required = true) @PathVariable("petId") Long petId, - @Parameter(description = "") @RequestHeader(value = "api_key", required = false) String apiKey) { - return getDelegate().deletePet(petId, apiKey); - } - - @Operation(summary = "Finds Pets by status", description = "Multiple status values can be provided with comma separated strings", security = { - @SecurityRequirement(name = "petstore_auth", scopes = { "write:pets", "read:pets" }) }, tags = { "pet" }) - @ApiResponses(value = { - @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(array = @ArraySchema(schema = @Schema(implementation = Pet.class)))), - @ApiResponse(responseCode = "400", description = "Invalid status value") }) - @GetMapping(value = "/pet/findByStatus", produces = { "application/xml", "application/json" }) - default ResponseEntity> findPetsByStatus( - @NotNull @Parameter(description = "Status values that need to be considered for filter", required = true) @Valid @RequestParam(value = "status", required = true) List status) { - return getDelegate().findPetsByStatus(status); - } - - @Operation(summary = "Finds Pets by tags", description = "Muliple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.", security = { - @SecurityRequirement(name = "petstore_auth", scopes = { "write:pets", "read:pets" }) }, tags = { "pet" }) - @ApiResponses(value = { - @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(array = @ArraySchema(schema = @Schema(implementation = Pet.class)))), - @ApiResponse(responseCode = "400", description = "Invalid tag value") }) - @GetMapping(value = "/pet/findByTags", produces = { "application/xml", "application/json" }) - default ResponseEntity> findPetsByTags( - @NotNull @Parameter(description = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) List tags) { - return getDelegate().findPetsByTags(tags); - } - - @Operation(summary = "Find pet by ID", description = "Returns a single pet", security = { - @SecurityRequirement(name = "api_key") }, tags = { "pet" }) - @ApiResponses(value = { - @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(schema = @Schema(implementation = Pet.class))), - @ApiResponse(responseCode = "400", description = "Invalid ID supplied"), - @ApiResponse(responseCode = "404", description = "Pet not found") }) - @GetMapping(value = "/pet/{petId}", produces = { "application/xml", "application/json" }) - default ResponseEntity getPetById( - @Parameter(description = "ID of pet to return", required = true) @PathVariable("petId") Long petId) { - return getDelegate().getPetById(petId); - } - - @Operation(summary = "Update an existing pet", description = "", security = { - @SecurityRequirement(name = "petstore_auth", scopes = { "write:pets", "read:pets" }) }, tags = { "pet" }) - @ApiResponses(value = { @ApiResponse(responseCode = "400", description = "Invalid ID supplied"), - @ApiResponse(responseCode = "404", description = "Pet not found"), - @ApiResponse(responseCode = "405", description = "Validation exception") }) - @PutMapping(value = "/pet", consumes = { "application/json", "application/xml" }) - default ResponseEntity updatePet( - @io.swagger.v3.oas.annotations.parameters.RequestBody(description = "Pet object that needs to be added to the store", required = true) @Valid @RequestBody Pet pet) { - return getDelegate().updatePet(pet); - } - - @Operation(summary = "Updates a pet in the store with form data", description = "", security = { - @SecurityRequirement(name = "petstore_auth", scopes = { "write:pets", "read:pets" }) }, tags = { "pet" }) - @ApiResponses(value = { @ApiResponse(responseCode = "405", description = "Invalid input") }) - @PostMapping(value = "/pet/{petId}", consumes = { "application/x-www-form-urlencoded" }) - default ResponseEntity updatePetWithForm( - @Parameter(description = "ID of pet that needs to be updated", required = true) @PathVariable("petId") Long petId, - @Parameter(description = "Updated name of the pet") @RequestParam(value = "name", required = false) String name, - @Parameter(description = "Updated status of the pet") @RequestParam(value = "status", required = false) String status) { - return getDelegate().updatePetWithForm(petId, name, status); - } - - @Operation(summary = "uploads an image", description = "", security = { - @SecurityRequirement(name = "petstore_auth", scopes = { "write:pets", "read:pets" }) }, tags = { "pet" }) - @ApiResponses(value = { - @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(schema = @Schema(implementation = ModelApiResponse.class))) }) - @PostMapping(value = "/pet/{petId}/uploadImage", produces = { "application/json" }, consumes = { - "multipart/form-data" }) - default ResponseEntity uploadFile( - @Parameter(description = "ID of pet to update", required = true) @PathVariable("petId") Long petId, - @Parameter(description = "Additional data to pass to server") @RequestParam(value = "additionalMetadata", required = false) String additionalMetadata, - @Parameter(description = "file detail") @Valid @RequestPart("file") MultipartFile file) { - return getDelegate().uploadFile(petId, additionalMetadata, file); - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/app68/api/pet/PetApiController.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/app68/api/pet/PetApiController.java deleted file mode 100644 index 3b974cb0c..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/app68/api/pet/PetApiController.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app68.api.pet; - -import java.util.Optional; - -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -@jakarta.annotation.Generated(value = "org.springdoc.demo.app2.codegen.languages.SpringCodegen", date = "2019-07-11T00:09:29.839+02:00[Europe/Paris]") - -@RestController -@RequestMapping("${openapi.openAPIPetstore.base-path:/}") -public class PetApiController implements PetApi { - - private final PetApiDelegate delegate; - - public PetApiController(@org.springframework.beans.factory.annotation.Autowired(required = false) PetApiDelegate delegate) { - this.delegate = Optional.ofNullable(delegate).orElse(new PetApiDelegate() { - }); - } - - @Override - public PetApiDelegate getDelegate() { - return delegate; - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/app68/api/pet/PetApiDelegate.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/app68/api/pet/PetApiDelegate.java deleted file mode 100644 index 9f01a36e4..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/app68/api/pet/PetApiDelegate.java +++ /dev/null @@ -1,141 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app68.api.pet; - -import java.util.List; -import java.util.Optional; - -import jakarta.validation.Valid; -import test.org.springdoc.api.app68.api.ApiUtil; -import test.org.springdoc.api.app68.model.ModelApiResponse; -import test.org.springdoc.api.app68.model.Pet; - -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; -import org.springframework.web.context.request.NativeWebRequest; -import org.springframework.web.multipart.MultipartFile; - -/** - * A delegate to be called by the {@link PetApiController}}. - * Implement this interface with a {@link org.springframework.stereotype.Service} annotated class. - */ -@jakarta.annotation.Generated(value = "org.springdoc.demo.app2.codegen.languages.SpringCodegen", date = "2019-07-11T00:09:29.839+02:00[Europe/Paris]") - -public interface PetApiDelegate { - - default Optional getRequest() { - return Optional.empty(); - } - - /** - * @see PetApi#addPet - */ - default void addPet(Pet pet) { - - } - - /** - * @see PetApi#deletePet - */ - default ResponseEntity deletePet(Long petId, - String apiKey) { - return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); - - } - - /** - * @see PetApi#findPetsByStatus - */ - default ResponseEntity> findPetsByStatus(List status) { - extract(); - return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); - - } - - default void extract() { - getRequest().ifPresent(request -> { - for (MediaType mediaType : MediaType.parseMediaTypes(request.getHeader("Accept"))) { - if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { - ApiUtil.setExampleResponse(request, "application/json", "{ \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\"}"); - break; - } - if (mediaType.isCompatibleWith(MediaType.valueOf("application/xml"))) { - ApiUtil.setExampleResponse(request, "application/xml", " 123456789 doggie aeiou aeiou"); - break; - } - } - }); - } - - /** - * @see PetApi#findPetsByTags - */ - default ResponseEntity> findPetsByTags(List tags) { - extract(); - return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); - - } - - /** - * @see PetApi#getPetById - */ - default ResponseEntity getPetById(Long petId) { - extract(); - return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); - - } - - /** - * @see PetApi#updatePet - */ - default ResponseEntity updatePet(Pet pet) { - return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); - - } - - /** - * @see PetApi#updatePetWithForm - */ - default ResponseEntity updatePetWithForm(Long petId, - String name, - String status) { - return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); - - } - - /** - * @see PetApi#uploadFile - */ - default ResponseEntity uploadFile(Long petId, - String additionalMetadata, - @Valid MultipartFile file) { - getRequest().ifPresent(request -> { - for (MediaType mediaType : MediaType.parseMediaTypes(request.getHeader("Accept"))) { - if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { - ApiUtil.setExampleResponse(request, "application/json", "{ \"code\" : 0, \"type\" : \"type\", \"message\" : \"message\"}"); - break; - } - } - }); - return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); - - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/app68/api/pet/PetApiDelegateImpl.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/app68/api/pet/PetApiDelegateImpl.java deleted file mode 100644 index 5a70c357f..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/app68/api/pet/PetApiDelegateImpl.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app68.api.pet; - -import org.springframework.stereotype.Service; - -@Service -public class PetApiDelegateImpl implements PetApiDelegate { - - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/app68/api/store/StoreApi.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/app68/api/store/StoreApi.java deleted file mode 100644 index d026561f7..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/app68/api/store/StoreApi.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * - * * Copyright 2019-2020 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. - * - */ - -/** - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (3.0.0). - * https://openapi-generator.tech - * Do not edit the class manually. - */ -package test.org.springdoc.api.app68.api.store; - -import java.util.Map; - -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.media.ArraySchema; -import io.swagger.v3.oas.annotations.media.Content; -import io.swagger.v3.oas.annotations.media.Schema; -import io.swagger.v3.oas.annotations.responses.ApiResponse; -import io.swagger.v3.oas.annotations.responses.ApiResponses; -import io.swagger.v3.oas.annotations.security.SecurityRequirement; -import io.swagger.v3.oas.annotations.tags.Tag; -import jakarta.validation.Valid; -import jakarta.validation.constraints.Max; -import jakarta.validation.constraints.Min; -import jakarta.validation.constraints.NotBlank; -import test.org.springdoc.api.app68.model.Order; - -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.DeleteMapping; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; - -@jakarta.annotation.Generated(value = "org.springdoc.demo.app2.codegen.languages.SpringCodegen", date = "2019-07-11T00:09:29.839+02:00[Europe/Paris]") - -@Tag(name = "store", description = "the store API") -public interface StoreApi { - - default StoreApiDelegate getDelegate() { - return new StoreApiDelegate() { - }; - } - - @Operation(summary = "Delete purchase order by ID", tags = { "store" }) - @ApiResponses(value = { @ApiResponse(responseCode = "400", description = "Invalid ID supplied"), - @ApiResponse(responseCode = "404", description = "Order not found") }) - @DeleteMapping(value = "/store/order/{orderId}") - default ResponseEntity deleteOrder( - @Parameter(description = "ID of the order that needs to be deleted", required = true) @PathVariable("orderId") String orderId) { - return getDelegate().deleteOrder(orderId); - } - - @Operation(summary = "Returns pet inventories by status", description = "Returns a map of status codes to quantities", security = { - @SecurityRequirement(name = "api_key") }, tags = { "store" }) - @ApiResponses(value = { - @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(array = @ArraySchema(schema = @Schema(implementation = Map.class)))) }) - @GetMapping(value = "/store/inventory", produces = { "application/json" }) - default ResponseEntity> getInventory() { - return getDelegate().getInventory(); - } - - @Operation(summary = "Find purchase order by ID", tags = { "store" }) - @ApiResponses(value = { - @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(schema = @Schema(implementation = Order.class))), - @ApiResponse(responseCode = "400", description = "Invalid ID supplied"), - @ApiResponse(responseCode = "404", description = "Order not found") }) - @GetMapping(value = "/store/order/{orderId}", produces = { "application/xml", "application/json" }) - default ResponseEntity getOrderById( - @Min(1L) @Max(5L) @Parameter(description = "ID of pet that needs to be fetched", required = true) @PathVariable("orderId") Long orderId) { - return getDelegate().getOrderById(orderId); - } - - @Operation(summary = "Place an order for a pet", tags = { "store" }) - @ApiResponses(value = { - @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(schema = @Schema(implementation = Order.class))), - @ApiResponse(responseCode = "400", description = "Invalid Order") }) - @PostMapping(value = "/store/order", produces = { "application/xml", "application/json" }, consumes = { - "application/json" }) - default ResponseEntity placeOrder( - @Parameter(description = "order placed for purchasing the pet", required = true) @Valid @RequestBody Order order) { - return getDelegate().placeOrder(order); - } - - @GetMapping(value = "/v1/stores") - default void stores(@Valid @NotBlank String name) { - - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/app68/api/store/StoreApiController.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/app68/api/store/StoreApiController.java deleted file mode 100644 index d97bee1d6..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/app68/api/store/StoreApiController.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app68.api.store; - -import java.util.Optional; - -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -@jakarta.annotation.Generated(value = "org.springdoc.demo.app2.codegen.languages.SpringCodegen", date = "2019-07-11T00:09:29.839+02:00[Europe/Paris]") - -@RestController -@RequestMapping("${openapi.openAPIPetstore.base-path:/}") -public class StoreApiController implements StoreApi { - - private final StoreApiDelegate delegate; - - public StoreApiController(@org.springframework.beans.factory.annotation.Autowired(required = false) StoreApiDelegate delegate) { - this.delegate = Optional.ofNullable(delegate).orElse(new StoreApiDelegate() { - }); - } - - @Override - public StoreApiDelegate getDelegate() { - return delegate; - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/app68/api/store/StoreApiDelegate.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/app68/api/store/StoreApiDelegate.java deleted file mode 100644 index 3446bc839..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/app68/api/store/StoreApiDelegate.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app68.api.store; - -import java.util.Map; -import java.util.Optional; - -import test.org.springdoc.api.app68.api.ApiUtil; -import test.org.springdoc.api.app68.model.Order; - -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; -import org.springframework.web.context.request.NativeWebRequest; - -/** - * A delegate to be called by the {@link StoreApiController}}. - * Implement this interface with a {@link org.springframework.stereotype.Service} annotated class. - */ -@jakarta.annotation.Generated(value = "org.springdoc.demo.app2.codegen.languages.SpringCodegen", date = "2019-07-11T00:09:29.839+02:00[Europe/Paris]") - -public interface StoreApiDelegate { - - default Optional getRequest() { - return Optional.empty(); - } - - /** - * @see StoreApi#deleteOrder - */ - default ResponseEntity deleteOrder(String orderId) { - return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); - - } - - /** - * @see StoreApi#getInventory - */ - default ResponseEntity> getInventory() { - return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); - - } - - /** - * @see StoreApi#getOrderById - */ - default ResponseEntity getOrderById(Long orderId) { - extract(); - return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); - - } - - default void extract() { - getRequest().ifPresent(request -> { - for (MediaType mediaType : MediaType.parseMediaTypes(request.getHeader("Accept"))) { - if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { - ApiUtil.setExampleResponse(request, "application/json", "{ \"petId\" : 6, \"quantity\" : 1, \"id\" : 0, \"shipDate\" : \"2000-01-23T04:56:07.000+00:00\", \"complete\" : false, \"status\" : \"placed\"}"); - break; - } - if (mediaType.isCompatibleWith(MediaType.valueOf("application/xml"))) { - ApiUtil.setExampleResponse(request, "application/xml", " 123456789 123456789 123 2000-01-23T04:56:07.000Z aeiou true"); - break; - } - } - }); - } - - /** - * @see StoreApi#placeOrder - */ - default ResponseEntity placeOrder(Order order) { - extract(); - return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); - - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/app68/api/store/StoreApiDelegateImpl.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/app68/api/store/StoreApiDelegateImpl.java deleted file mode 100644 index 3e81c002b..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/app68/api/store/StoreApiDelegateImpl.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app68.api.store; - -import org.springframework.stereotype.Service; - -@Service -public class StoreApiDelegateImpl implements StoreApiDelegate { - - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/app68/api/user/UserApi.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/app68/api/user/UserApi.java deleted file mode 100644 index 12891ac4d..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/app68/api/user/UserApi.java +++ /dev/null @@ -1,132 +0,0 @@ -/* - * - * * Copyright 2019-2020 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. - * - */ - -/** - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (3.0.0). - * https://openapi-generator.tech - * Do not edit the class manually. - */ -package test.org.springdoc.api.app68.api.user; - -import java.util.List; - -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.media.Content; -import io.swagger.v3.oas.annotations.media.Schema; -import io.swagger.v3.oas.annotations.responses.ApiResponse; -import io.swagger.v3.oas.annotations.responses.ApiResponses; -import io.swagger.v3.oas.annotations.tags.Tag; -import jakarta.validation.Valid; -import jakarta.validation.constraints.NotNull; -import test.org.springdoc.api.app68.model.User; - -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.DeleteMapping; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestParam; - -@jakarta.annotation.Generated(value = "org.springdoc.demo.app2.codegen.languages.SpringCodegen", date = "2019-07-11T00:09:29.839+02:00[Europe/Paris]") - -@Tag(name = "user", description = "the user API") -public interface UserApi { - - default UserApiDelegate getDelegate() { - return new UserApiDelegate() { - }; - } - - @Operation(summary = "Create user", tags = { "user" }) - @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "successful operation") }) - @PostMapping(value = "/user", consumes = { "application/json" }) - default ResponseEntity createUser( - @io.swagger.v3.oas.annotations.parameters.RequestBody(description = "Created user object", required = true) @Valid @RequestBody User user) { - return getDelegate().createUser(user); - } - - @Operation(summary = "Creates list of users with given input array", tags = { "user" }) - @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "successful operation") }) - - @PostMapping(value = "/user/createWithArray", consumes = { "application/json" }) - default ResponseEntity createUsersWithArrayInput( - @io.swagger.v3.oas.annotations.parameters.RequestBody(description = "List of user object", required = true) @Valid @RequestBody List user) { - return getDelegate().createUsersWithArrayInput(user); - } - - @Operation(summary = "Creates list of users with given input array", tags = { "user" }) - @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "successful operation") }) - @PostMapping(value = "/user/createWithList", consumes = { "application/json" }) - default ResponseEntity createUsersWithListInput( - @io.swagger.v3.oas.annotations.parameters.RequestBody(description = "List of user object", required = true) @Valid @RequestBody List user) { - return getDelegate().createUsersWithListInput(user); - } - - @Operation(summary = "Creates list of users with given input array", tags = { "user" }) - @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "successful operation") }) - - @DeleteMapping(value = "/user/{username}") - default ResponseEntity deleteUser( - @io.swagger.v3.oas.annotations.parameters.RequestBody(description = "The name that needs to be deleted", required = true) @PathVariable("username") String username) { - return getDelegate().deleteUser(username); - } - - @Operation(summary = "Get user by user name", tags = { "user" }) - @ApiResponses(value = { - @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(schema = @Schema(implementation = User.class))), - @ApiResponse(responseCode = "400", description = "Invalid username supplied"), - @ApiResponse(responseCode = "404", description = "User not found") }) - - @GetMapping(value = "/user/{username}", produces = { "application/xml", "application/json" }) - default ResponseEntity getUserByName( - @Parameter(description = "The name that needs to be fetched. Use user1 for testing.", required = true) @PathVariable("username") String username) { - return getDelegate().getUserByName(username); - } - - @Operation(summary = "Logs user into the system", tags = { "user" }) - @ApiResponses(value = { - @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(schema = @Schema(implementation = String.class))), - @ApiResponse(responseCode = "400", description = "Invalid username/password supplied") }) - @GetMapping(value = "/user/login", produces = { "application/xml", "application/json" }) - default ResponseEntity loginUser( - @NotNull @Parameter(description = "The user name for login", required = true) @Valid @RequestParam(value = "username", required = true) String username, - @NotNull @Parameter(description = "The password for login in clear text", required = true) @Valid @RequestParam(value = "password", required = true) String password) { - return getDelegate().loginUser(username, password); - } - - @Operation(summary = "Logs out current logged in user session", tags = { "user" }) - @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "successful operation") }) - @GetMapping(value = "/user/logout") - default ResponseEntity logoutUser() { - return getDelegate().logoutUser(); - } - - @Operation(summary = "Updated user", tags = { "user" }) - @ApiResponses(value = { @ApiResponse(responseCode = "400", description = "Invalid user supplied"), - @ApiResponse(responseCode = "404", description = "User not found") }) - @PutMapping(value = "/user/{username}", consumes = { "application/json" }) - default ResponseEntity updateUser( - @Parameter(description = "name that need to be deleted", required = true) @PathVariable("username") String username, - @io.swagger.v3.oas.annotations.parameters.RequestBody(description = "Updated user object", required = true) @Valid @RequestBody User user) { - return getDelegate().updateUser(username, user); - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/app68/api/user/UserApiController.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/app68/api/user/UserApiController.java deleted file mode 100644 index d20572a65..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/app68/api/user/UserApiController.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app68.api.user; - -import java.util.Optional; - -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -@jakarta.annotation.Generated(value = "org.springdoc.demo.app2.codegen.languages.SpringCodegen", date = "2019-07-11T00:09:29.839+02:00[Europe/Paris]") - -@RestController -@RequestMapping("${openapi.openAPIPetstore.base-path:/}") -public class UserApiController implements UserApi { - - private final UserApiDelegate delegate; - - public UserApiController(@org.springframework.beans.factory.annotation.Autowired(required = false) UserApiDelegate delegate) { - this.delegate = Optional.ofNullable(delegate).orElse(new UserApiDelegate() { - }); - } - - @Override - public UserApiDelegate getDelegate() { - return delegate; - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/app68/api/user/UserApiDelegate.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/app68/api/user/UserApiDelegate.java deleted file mode 100644 index 7c98d9edd..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/app68/api/user/UserApiDelegate.java +++ /dev/null @@ -1,122 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app68.api.user; - -import java.util.List; -import java.util.Optional; - -import test.org.springdoc.api.app68.api.ApiUtil; -import test.org.springdoc.api.app68.model.User; - -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; -import org.springframework.web.context.request.NativeWebRequest; - -/** - * A delegate to be called by the {@link UserApiController}}. - * Implement this interface with a {@link org.springframework.stereotype.Service} annotated class. - */ -@jakarta.annotation.Generated(value = "org.springdoc.demo.app2.codegen.languages.SpringCodegen", date = "2019-07-11T00:09:29.839+02:00[Europe/Paris]") - -public interface UserApiDelegate { - - default Optional getRequest() { - return Optional.empty(); - } - - /** - * @see UserApi#createUser - */ - default ResponseEntity createUser(User user) { - return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); - - } - - /** - * @see UserApi#createUsersWithArrayInput - */ - default ResponseEntity createUsersWithArrayInput(List user) { - return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); - - } - - /** - * @see UserApi#createUsersWithListInput - */ - default ResponseEntity createUsersWithListInput(List user) { - return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); - - } - - /** - * @see UserApi#deleteUser - */ - default ResponseEntity deleteUser(String username) { - return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); - - } - - /** - * @see UserApi#getUserByName - */ - default ResponseEntity getUserByName(String username) { - getRequest().ifPresent(request -> { - for (MediaType mediaType : MediaType.parseMediaTypes(request.getHeader("Accept"))) { - if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { - ApiUtil.setExampleResponse(request, "application/json", "{ \"firstName\" : \"firstName\", \"lastName\" : \"lastName\", \"password\" : \"password\", \"userStatus\" : 6, \"phone\" : \"phone\", \"id\" : 0, \"email\" : \"email\", \"username\" : \"username\"}"); - break; - } - if (mediaType.isCompatibleWith(MediaType.valueOf("application/xml"))) { - ApiUtil.setExampleResponse(request, "application/xml", " 123456789 aeiou aeiou aeiou aeiou aeiou aeiou 123"); - break; - } - } - }); - return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); - - } - - /** - * @see UserApi#loginUser - */ - default ResponseEntity loginUser(String username, - String password) { - return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); - - } - - /** - * @see UserApi#logoutUser - */ - default ResponseEntity logoutUser() { - return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); - - } - - /** - * @see UserApi#updateUser - */ - default ResponseEntity updateUser(String username, - User user) { - return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); - - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/app68/api/user/UserApiDelegateImpl.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/app68/api/user/UserApiDelegateImpl.java deleted file mode 100644 index dee9cd208..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/app68/api/user/UserApiDelegateImpl.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app68.api.user; - -import org.springframework.stereotype.Service; - -@Service -public class UserApiDelegateImpl implements UserApiDelegate { - - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/app68/api/user/UserClient.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/app68/api/user/UserClient.java deleted file mode 100644 index 16ed71112..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/app68/api/user/UserClient.java +++ /dev/null @@ -1,18 +0,0 @@ -package test.org.springdoc.api.app68.api.user; - -import test.org.springdoc.api.app68.model.User; - -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestMapping; - -@RequestMapping(value = "/users", consumes = "application/json") -@Controller -public class UserClient { - - @GetMapping("/{id}") - public User findById(@PathVariable Integer id) { - return null; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/app68/model/Body.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/app68/model/Body.java deleted file mode 100644 index c2076e97f..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/app68/model/Body.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app68.model; - -import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.v3.oas.annotations.media.Schema; - -public class Body { - - @Schema(description = "Updated name of the pet") - /** - * Updated name of the pet - **/ - private String name = null; - - @Schema(description = "Updated status of the pet") - /** - * Updated status of the pet - **/ - private String status = null; - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private static String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } - - /** - * Updated name of the pet - * - * @return name - **/ - @JsonProperty("name") - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public Body name(String name) { - this.name = name; - return this; - } - - /** - * Updated status of the pet - * - * @return status - **/ - @JsonProperty("status") - public String getStatus() { - return status; - } - - public void setStatus(String status) { - this.status = status; - } - - public Body status(String status) { - this.status = status; - return this; - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class Body {\n"); - - sb.append(" name: ").append(toIndentedString(name)).append("\n"); - sb.append(" status: ").append(toIndentedString(status)).append("\n"); - sb.append("}"); - return sb.toString(); - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/app68/model/Body1.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/app68/model/Body1.java deleted file mode 100644 index 9fa7c2baf..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/app68/model/Body1.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app68.model; - -import java.io.File; - -import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.v3.oas.annotations.media.Schema; - -public class Body1 { - - @Schema(description = "Additional data to pass to server") - /** - * Additional data to pass to server - **/ - private String additionalMetadata = null; - - @Schema(description = "file to upload") - /** - * file to upload - **/ - private File file = null; - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private static String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } - - /** - * Additional data to pass to server - * - * @return additionalMetadata - **/ - @JsonProperty("additionalMetadata") - public String getAdditionalMetadata() { - return additionalMetadata; - } - - public void setAdditionalMetadata(String additionalMetadata) { - this.additionalMetadata = additionalMetadata; - } - - public Body1 additionalMetadata(String additionalMetadata) { - this.additionalMetadata = additionalMetadata; - return this; - } - - /** - * file to upload - * - * @return file - **/ - @JsonProperty("file") - public File getFile() { - return file; - } - - public void setFile(File file) { - this.file = file; - } - - public Body1 file(File file) { - this.file = file; - return this; - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class Body1 {\n"); - - sb.append(" additionalMetadata: ").append(toIndentedString(additionalMetadata)).append("\n"); - sb.append(" file: ").append(toIndentedString(file)).append("\n"); - sb.append("}"); - return sb.toString(); - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/app68/model/Category.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/app68/model/Category.java deleted file mode 100644 index d131574f9..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/app68/model/Category.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app68.model; - -import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.v3.oas.annotations.media.Schema; - -public class Category { - - @Schema(description = "") - private Long id = null; - - @Schema(description = "") - private String name = null; - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private static String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } - - /** - * Get id - * - * @return id - **/ - @JsonProperty("id") - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - public Category id(Long id) { - this.id = id; - return this; - } - - /** - * Get name - * - * @return name - **/ - @JsonProperty("name") - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public Category name(String name) { - this.name = name; - return this; - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class Category {\n"); - - sb.append(" id: ").append(toIndentedString(id)).append("\n"); - sb.append(" name: ").append(toIndentedString(name)).append("\n"); - sb.append("}"); - return sb.toString(); - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/app68/model/ModelApiResponse.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/app68/model/ModelApiResponse.java deleted file mode 100644 index 521ecb8e6..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/app68/model/ModelApiResponse.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app68.model; - -import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.v3.oas.annotations.media.Schema; - -public class ModelApiResponse { - - @Schema(description = "") - private Integer code = null; - - @Schema(description = "") - private String type = null; - - @Schema(description = "") - private String message = null; - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private static String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } - - /** - * Get code - * - * @return code - **/ - @JsonProperty("code") - public Integer getCode() { - return code; - } - - public void setCode(Integer code) { - this.code = code; - } - - public ModelApiResponse code(Integer code) { - this.code = code; - return this; - } - - /** - * Get type - * - * @return type - **/ - @JsonProperty("type") - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - - public ModelApiResponse type(String type) { - this.type = type; - return this; - } - - /** - * Get message - * - * @return message - **/ - @JsonProperty("message") - public String getMessage() { - return message; - } - - public void setMessage(String message) { - this.message = message; - } - - public ModelApiResponse message(String message) { - this.message = message; - return this; - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class ModelApiResponse {\n"); - - sb.append(" code: ").append(toIndentedString(code)).append("\n"); - sb.append(" type: ").append(toIndentedString(type)).append("\n"); - sb.append(" message: ").append(toIndentedString(message)).append("\n"); - sb.append("}"); - return sb.toString(); - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/app68/model/Order.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/app68/model/Order.java deleted file mode 100644 index feede5ec3..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/app68/model/Order.java +++ /dev/null @@ -1,226 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app68.model; - -import java.util.Date; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonValue; -import io.swagger.v3.oas.annotations.media.Schema; - -public class Order { - - @Schema(description = "") - private Long id = null; - - @Schema(description = "") - private Long petId = null; - - @Schema(description = "") - private Integer quantity = null; - - @Schema(description = "") - private Date shipDate = null; - - @Schema(description = "Order Status") - /** - * Order Status - **/ - private StatusEnum status = null; - - @Schema(description = "") - private Boolean complete = false; - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private static String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } - - /** - * Get id - * - * @return id - **/ - @JsonProperty("id") - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - public Order id(Long id) { - this.id = id; - return this; - } - - /** - * Get petId - * - * @return petId - **/ - @JsonProperty("petId") - public Long getPetId() { - return petId; - } - - public void setPetId(Long petId) { - this.petId = petId; - } - - public Order petId(Long petId) { - this.petId = petId; - return this; - } - - /** - * Get quantity - * - * @return quantity - **/ - @JsonProperty("quantity") - public Integer getQuantity() { - return quantity; - } - - public void setQuantity(Integer quantity) { - this.quantity = quantity; - } - - public Order quantity(Integer quantity) { - this.quantity = quantity; - return this; - } - - /** - * Get shipDate - * - * @return shipDate - **/ - @JsonProperty("shipDate") - public Date getShipDate() { - return shipDate; - } - - public void setShipDate(Date shipDate) { - this.shipDate = shipDate; - } - - public Order shipDate(Date shipDate) { - this.shipDate = shipDate; - return this; - } - - /** - * Order Status - * - * @return status - **/ - @JsonProperty("status") - public String getStatus() { - if (status == null) { - return null; - } - return status.getValue(); - } - - public void setStatus(StatusEnum status) { - this.status = status; - } - - public Order status(StatusEnum status) { - this.status = status; - return this; - } - - /** - * Get complete - * - * @return complete - **/ - @JsonProperty("complete") - public Boolean isisComplete() { - return complete; - } - - public void setComplete(Boolean complete) { - this.complete = complete; - } - - public Order complete(Boolean complete) { - this.complete = complete; - return this; - } - - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class Order {\n"); - - sb.append(" id: ").append(toIndentedString(id)).append("\n"); - sb.append(" petId: ").append(toIndentedString(petId)).append("\n"); - sb.append(" quantity: ").append(toIndentedString(quantity)).append("\n"); - sb.append(" shipDate: ").append(toIndentedString(shipDate)).append("\n"); - sb.append(" status: ").append(toIndentedString(status)).append("\n"); - sb.append(" complete: ").append(toIndentedString(complete)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - public enum StatusEnum { - PLACED("placed"), - APPROVED("approved"), - DELIVERED("delivered"); - - private String value; - - StatusEnum(String value) { - this.value = value; - } - - @JsonCreator - public static StatusEnum fromValue(String text) { - for (StatusEnum b : StatusEnum.values()) { - if (String.valueOf(b.value).equals(text)) { - return b; - } - } - return null; - } - - @JsonValue - public String getValue() { - return value; - } - - @Override - public String toString() { - return String.valueOf(value); - } - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/app68/model/Pet.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/app68/model/Pet.java deleted file mode 100644 index fc122c620..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/app68/model/Pet.java +++ /dev/null @@ -1,240 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app68.model; - -import java.util.ArrayList; -import java.util.List; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonValue; -import io.swagger.v3.oas.annotations.media.Schema; -import jakarta.validation.constraints.NotNull; - -public class Pet { - - @Schema(description = "") - private Long id = null; - - @Schema(description = "") - private Category category = null; - - @Schema(example = "doggie", required = true, description = "") - private String name = null; - - @Schema(required = true, description = "") - private List photoUrls = new ArrayList(); - - @Schema(description = "") - private List tags = null; - - @Schema(description = "pet status in the store") - /** - * pet status in the store - **/ - private StatusEnum status = null; - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private static String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } - - /** - * Get id - * - * @return id - **/ - @JsonProperty("id") - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - public Pet id(Long id) { - this.id = id; - return this; - } - - /** - * Get category - * - * @return category - **/ - @JsonProperty("category") - public Category getCategory() { - return category; - } - - public void setCategory(Category category) { - this.category = category; - } - - public Pet category(Category category) { - this.category = category; - return this; - } - - /** - * Get name - * - * @return name - **/ - @JsonProperty("name") - @NotNull - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public Pet name(String name) { - this.name = name; - return this; - } - - /** - * Get photoUrls - * - * @return photoUrls - **/ - @JsonProperty("photoUrls") - @NotNull - public List getPhotoUrls() { - return photoUrls; - } - - public void setPhotoUrls(List photoUrls) { - this.photoUrls = photoUrls; - } - - public Pet photoUrls(List photoUrls) { - this.photoUrls = photoUrls; - return this; - } - - public Pet addPhotoUrlsItem(String photoUrlsItem) { - this.photoUrls.add(photoUrlsItem); - return this; - } - - /** - * Get tags - * - * @return tags - **/ - @JsonProperty("tags") - public List getTags() { - return tags; - } - - public void setTags(List tags) { - this.tags = tags; - } - - public Pet tags(List tags) { - this.tags = tags; - return this; - } - - public Pet addTagsItem(Tag tagsItem) { - if (this.tags == null) { - this.tags = new ArrayList<>(); - } - this.tags.add(tagsItem); - return this; - } - - /** - * pet status in the store - * - * @return status - **/ - @JsonProperty("status") - public StatusEnum getStatus() { - if (status == null) { - return null; - } - return status; - } - - public void setStatus(StatusEnum status) { - this.status = status; - } - - public Pet status(StatusEnum status) { - this.status = status; - return this; - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class Pet {\n"); - - sb.append(" id: ").append(toIndentedString(id)).append("\n"); - sb.append(" category: ").append(toIndentedString(category)).append("\n"); - sb.append(" name: ").append(toIndentedString(name)).append("\n"); - sb.append(" photoUrls: ").append(toIndentedString(photoUrls)).append("\n"); - sb.append(" tags: ").append(toIndentedString(tags)).append("\n"); - sb.append(" status: ").append(toIndentedString(status)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - public enum StatusEnum { - AVAILABLE("available"), PENDING("pending"), SOLD("sold"); - - private String value; - - StatusEnum(String value) { - this.value = value; - } - - @JsonCreator - public static StatusEnum fromValue(String text) { - for (StatusEnum b : StatusEnum.values()) { - if (String.valueOf(b.value).equals(text)) { - return b; - } - } - return null; - } - - @JsonValue - public String getValue() { - return value; - } - - @Override - public String toString() { - return String.valueOf(value); - } - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/app68/model/Tag.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/app68/model/Tag.java deleted file mode 100644 index 585aec5db..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/app68/model/Tag.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app68.model; - -import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.v3.oas.annotations.media.Schema; - -public class Tag { - - @Schema(description = "") - private Long id = null; - - @Schema(description = "") - private String name = null; - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private static String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } - - /** - * Get id - * - * @return id - **/ - @JsonProperty("id") - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - public Tag id(Long id) { - this.id = id; - return this; - } - - /** - * Get name - * - * @return name - **/ - @JsonProperty("name") - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public Tag name(String name) { - this.name = name; - return this; - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class Tag {\n"); - - sb.append(" id: ").append(toIndentedString(id)).append("\n"); - sb.append(" name: ").append(toIndentedString(name)).append("\n"); - sb.append("}"); - return sb.toString(); - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/app68/model/User.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/app68/model/User.java deleted file mode 100644 index 0e3f8c6e2..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/app68/model/User.java +++ /dev/null @@ -1,232 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app68.model; - -import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.v3.oas.annotations.media.Schema; - -public class User { - - @Schema(description = "") - private Long id = null; - - @Schema(description = "") - private String username = null; - - @Schema(description = "") - private String firstName = null; - - @Schema(description = "") - private String lastName = null; - - @Schema(description = "") - private String email = null; - - @Schema(description = "") - private String password = null; - - @Schema(description = "") - private String phone = null; - - @Schema(description = "User Status") - /** - * User Status - **/ - private Integer userStatus = null; - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - */ - private static String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } - - /** - * Get id - * - * @return id - **/ - @JsonProperty("id") - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - public User id(Long id) { - this.id = id; - return this; - } - - /** - * Get username - * - * @return username - **/ - @JsonProperty("username") - public String getUsername() { - return username; - } - - public void setUsername(String username) { - this.username = username; - } - - public User username(String username) { - this.username = username; - return this; - } - - /** - * Get firstName - * - * @return firstName - **/ - @JsonProperty("firstName") - public String getFirstName() { - return firstName; - } - - public void setFirstName(String firstName) { - this.firstName = firstName; - } - - public User firstName(String firstName) { - this.firstName = firstName; - return this; - } - - /** - * Get lastName - * - * @return lastName - **/ - @JsonProperty("lastName") - public String getLastName() { - return lastName; - } - - public void setLastName(String lastName) { - this.lastName = lastName; - } - - public User lastName(String lastName) { - this.lastName = lastName; - return this; - } - - /** - * Get email - * - * @return email - **/ - @JsonProperty("email") - public String getEmail() { - return email; - } - - public void setEmail(String email) { - this.email = email; - } - - public User email(String email) { - this.email = email; - return this; - } - - /** - * Get password - * - * @return password - **/ - @JsonProperty("password") - public String getPassword() { - return password; - } - - public void setPassword(String password) { - this.password = password; - } - - public User password(String password) { - this.password = password; - return this; - } - - /** - * Get phone - * - * @return phone - **/ - @JsonProperty("phone") - public String getPhone() { - return phone; - } - - public void setPhone(String phone) { - this.phone = phone; - } - - public User phone(String phone) { - this.phone = phone; - return this; - } - - /** - * User Status - * - * @return userStatus - **/ - @JsonProperty("userStatus") - public Integer getUserStatus() { - return userStatus; - } - - public void setUserStatus(Integer userStatus) { - this.userStatus = userStatus; - } - - public User userStatus(Integer userStatus) { - this.userStatus = userStatus; - return this; - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class User {\n"); - - sb.append(" id: ").append(toIndentedString(id)).append("\n"); - sb.append(" username: ").append(toIndentedString(username)).append("\n"); - sb.append(" firstName: ").append(toIndentedString(firstName)).append("\n"); - sb.append(" lastName: ").append(toIndentedString(lastName)).append("\n"); - sb.append(" email: ").append(toIndentedString(email)).append("\n"); - sb.append(" password: ").append(toIndentedString(password)).append("\n"); - sb.append(" phone: ").append(toIndentedString(phone)).append("\n"); - sb.append(" userStatus: ").append(toIndentedString(userStatus)).append("\n"); - sb.append("}"); - return sb.toString(); - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/app72/BlockingAutoConfigurationTest.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/app72/BlockingAutoConfigurationTest.java deleted file mode 100644 index 50037fee8..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/app72/BlockingAutoConfigurationTest.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app72; - -import org.junit.jupiter.api.Test; -import org.springdoc.core.models.GroupedOpenApi; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.test.context.FilteredClassLoader; -import org.springframework.boot.test.context.runner.ApplicationContextRunner; -import org.springframework.boot.test.context.runner.WebApplicationContextRunner; -import org.springframework.context.annotation.Bean; - -import static org.assertj.core.api.Assertions.assertThat; - -class BlockingAutoConfigurationTest { - - private final WebApplicationContextRunner contextRunner = new WebApplicationContextRunner() - .withUserConfiguration(TestApp.class); - - @Test - void configurations_successfully_loaded() { - contextRunner - .withPropertyValues("springdoc.show-actuator=true") - .run(context -> assertThat(context) - .hasNotFailed() - .hasBean("openApiResource") - .hasBean("actuatorProvider") - .hasBean("multipleOpenApiResource") - ); - } - - @Test - void configurations_not_loaded_when_application_is_not_web() { - new ApplicationContextRunner() - .withUserConfiguration(TestApp.class) - .run(context -> assertThat(context) - .hasNotFailed() - .doesNotHaveBean("openApiResource") - .doesNotHaveBean("actuatorProvider") - .doesNotHaveBean("multipleOpenApiResource") - ); - } - - @Test - void actuator_configuration_not_loaded_when_not_enabled_explicitly() { - contextRunner - .run(context -> assertThat(context) - .hasNotFailed() - .hasBean("openApiResource") - .doesNotHaveBean("actuatorPprrovider") - .hasBean("multipleOpenApiResource") - ); - } - - @Test - void configurations_not_loaded_when_disabled() { - contextRunner - .withPropertyValues("springdoc.api-docs.enabled=false") - .run(context -> assertThat(context) - .hasNotFailed() - .doesNotHaveBean("openApiResource") - .doesNotHaveBean("actuatorProvider") - .doesNotHaveBean("multipleOpenApiResource") - ); - } - - @Test - void configurations_not_loaded_when_mvc_is_not_on_class_path() { - contextRunner - .withClassLoader(new FilteredClassLoader("org.springframework.web.context.support.GenericWebApplicationContext")) - .run(context -> assertThat(context) - .hasNotFailed() - .doesNotHaveBean("openApiResource") - .doesNotHaveBean("actuatorProvider") - .doesNotHaveBean("multipleOpenApiResource") - ); - - } - - @SpringBootApplication - static class TestApp { - @Bean - GroupedOpenApi testGroupedOpenApi() { - return GroupedOpenApi.builder() - .group("test-group") - .packagesToScan("org.test") - .build(); - } - } -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/app72/CacheAutoConfigurationTest1.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/app72/CacheAutoConfigurationTest1.java deleted file mode 100644 index d1b91cef0..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/app72/CacheAutoConfigurationTest1.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app72; - -import org.junit.jupiter.api.Test; - -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.boot.test.context.runner.WebApplicationContextRunner; - -import static org.assertj.core.api.Assertions.assertThat; - -public class CacheAutoConfigurationTest1 { - - private final WebApplicationContextRunner contextRunner = new WebApplicationContextRunner() - .withUserConfiguration(TestApp.class); - - @Test - void cache_configuration_loaded_when_not_disabled_explicitly() { - contextRunner - .run(context -> assertThat(context) - .hasNotFailed() - .hasBean("openApiResource") - .doesNotHaveBean("springdocBeanFactoryPostProcessor") - .doesNotHaveBean("multipleOpenApiResource") - ); - } - - @Test - void cache_configuration_loaded_when_disabled_explicitly() { - contextRunner - .withPropertyValues("springdoc.cache.disabled=false") - .run(context -> assertThat(context) - .hasNotFailed() - .hasBean("openApiResource") - .doesNotHaveBean("springdocBeanFactoryPostProcessor") - .doesNotHaveBean("multipleOpenApiResource") - ); - } - - @Test - void cache_configurations_successfully_disabled() { - contextRunner - .withPropertyValues("springdoc.cache.disabled=true") - .run(context -> assertThat(context) - .hasNotFailed() - .hasBean("openApiResource") - .hasBean("springdocBeanFactoryPostProcessor") - .doesNotHaveBean("multipleOpenApiResource") - ); - } - - @Test - void group_configuration_loaded() { - contextRunner - .withPropertyValues("springdoc.group-configs[0].group=stores", "springdoc.group-configs[0].paths-to-match=/store/**") - .run(context -> assertThat(context) - .hasNotFailed() - .hasBean("openApiResource") - .hasBean("multipleOpenApiResource") - .hasBean("springdocBeanFactoryPostProcessor") - ); - } - - - @EnableAutoConfiguration - static class TestApp { - - } -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/app72/GroupAutoConfigurationTest.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/app72/GroupAutoConfigurationTest.java deleted file mode 100644 index ef634e5a7..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/app72/GroupAutoConfigurationTest.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app72; - -import org.junit.jupiter.api.Test; -import org.springdoc.core.models.GroupedOpenApi; - -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.boot.test.context.runner.WebApplicationContextRunner; -import org.springframework.context.annotation.Bean; - -import static org.assertj.core.api.Assertions.assertThat; - -public class GroupAutoConfigurationTest { - - private final WebApplicationContextRunner contextRunner = new WebApplicationContextRunner() - .withUserConfiguration(TestApp.class); - - @Test - void group_configuration_loaded() { - contextRunner - .run(context -> assertThat(context) - .hasNotFailed() - .hasBean("openApiResource") - .hasBean("springdocBeanFactoryPostProcessor") - .hasBean("multipleOpenApiResource") - ); - } - - @EnableAutoConfiguration - static class TestApp { - @Bean - GroupedOpenApi testGroupedOpenApi() { - return GroupedOpenApi.builder() - .group("test-group") - .packagesToScan("org.test") - .build(); - } - } -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/AbstractCommonTest.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/AbstractCommonTest.java new file mode 100644 index 000000000..f3e9a665e --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/AbstractCommonTest.java @@ -0,0 +1,58 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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; + +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.context.TestPropertySource; +import org.springframework.test.web.servlet.MockMvc; + +@AutoConfigureMockMvc +@ActiveProfiles("test") +@TestPropertySource(properties = { "management.endpoints.enabled-by-default=false" , "springdoc.api-docs.version=openapi_3_0" }) +public abstract class AbstractCommonTest { + + @Autowired + protected MockMvc mockMvc; + + protected String getContent(String fileName) { + try { + Path path = Paths.get(AbstractCommonTest.class.getClassLoader().getResource(fileName).toURI()); + byte[] fileBytes = Files.readAllBytes(path); + return new String(fileBytes, StandardCharsets.UTF_8); + } + catch (Exception e) { + throw new RuntimeException("Failed to read file: " + fileName, e); + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/AbstractSpringDocActuatorTest.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/AbstractSpringDocActuatorTest.java new file mode 100644 index 000000000..9884a05b8 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/AbstractSpringDocActuatorTest.java @@ -0,0 +1,73 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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; + +import jakarta.annotation.PostConstruct; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.web.server.LocalManagementPort; +import org.springframework.boot.web.client.RestTemplateBuilder; +import org.springframework.test.context.TestPropertySource; +import org.springframework.web.client.RestTemplate; + +import static org.skyscreamer.jsonassert.JSONAssert.assertEquals; + +@TestPropertySource(properties = { "management.endpoints.enabled-by-default=true" }) +public abstract class AbstractSpringDocActuatorTest extends AbstractCommonTest { + + protected static final Logger LOGGER = LoggerFactory.getLogger(AbstractCommonTest.class); + + protected RestTemplate actuatorRestTemplate; + + @LocalManagementPort + private int managementPort; + + @Autowired + private RestTemplateBuilder restTemplateBuilder; + + @PostConstruct + void init() { + actuatorRestTemplate = restTemplateBuilder + .rootUri("http://localhost:" + this.managementPort).build(); + } + + protected void testWithRestTemplate(String testId, String uri) throws Exception { + String result = null; + try { + result = actuatorRestTemplate.getForObject(uri, String.class); + String expected = getContent("results/3.0.1/app" + testId + ".json"); + assertEquals(expected, result, true); + } + catch (AssertionError e) { + LOGGER.error(result); + throw e; + } + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/AbstractSpringDocTest.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/AbstractSpringDocTest.java new file mode 100644 index 000000000..a4e6f57e5 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/AbstractSpringDocTest.java @@ -0,0 +1,56 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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; + +import org.junit.jupiter.api.Test; +import org.springdoc.core.utils.Constants; + +import org.springframework.boot.test.context.SpringBootTest; +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; + +@SpringBootTest +public abstract class AbstractSpringDocTest extends AbstractCommonTest { + + public static String className; + + @Test + protected void testApp() throws Exception { + className = getClass().getSimpleName(); + String testNumber = className.replaceAll("[^0-9]", ""); + MvcResult mockMvcResult = mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL)).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 + ".json"); + assertEquals(expected, result, true); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app128/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app128/HelloController.java new file mode 100644 index 000000000..5431305c5 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app128/HelloController.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app128; + + +import org.springframework.boot.actuate.endpoint.web.annotation.RestControllerEndpoint; +import org.springframework.stereotype.Component; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; + +@RestControllerEndpoint(id = "tenant") +@Component +public class HelloController { + + @GetMapping("/customer/{id}") + public String getTenantById(@PathVariable("id") String customerId) { + return "Tenant_" + customerId; + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app128/SpringDocApp128Test.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app128/SpringDocApp128Test.java new file mode 100644 index 000000000..b1febbe53 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app128/SpringDocApp128Test.java @@ -0,0 +1,68 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app128; + +import org.junit.jupiter.api.Test; +import org.springdoc.core.utils.Constants; +import org.springdoc.core.utils.SpringDocUtils; +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController; +import org.springframework.test.context.TestPropertySource; + +import static org.hamcrest.Matchers.containsString; +import static org.hamcrest.Matchers.is; +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; + + +/** + * Tests Spring meta-annotations as method parameters + */ +@TestPropertySource(properties = { "springdoc.show-actuator=true", + "management.endpoints.enabled-by-default=true", + "management.endpoints.web.exposure.include = tenant" }) +public class SpringDocApp128Test extends AbstractSpringDocTest { + + static { + SpringDocUtils.getConfig().addHiddenRestControllers(BasicErrorController.class); + } + + @Test + protected void testApp() throws Exception { + mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL)).andExpect(status().isOk()) + .andExpect(jsonPath("$.openapi", is("3.0.1"))) + .andExpect(jsonPath("$.paths./actuator/tenant/customer/{id}.get.operationId", containsString("getTenantById"))) + .andExpect(jsonPath("$.paths./actuator/tenant/customer/{id}.get.parameters[0].in", is("path"))) + .andExpect(jsonPath("$.paths./actuator/tenant/customer/{id}.get.parameters[0].name", is("id"))); + } + + @SpringBootApplication + static class SpringDocTestApp {} + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app144/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app144/HelloController.java new file mode 100644 index 000000000..a5027a7c4 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app144/HelloController.java @@ -0,0 +1,32 @@ +/* + * + * * Copyright 2019-2020 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.app144; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class HelloController { + + @GetMapping("/persons") + public String persons() { + return "OK"; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app144/SpringDocApp144Test.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app144/SpringDocApp144Test.java new file mode 100644 index 000000000..1ea455b4f --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app144/SpringDocApp144Test.java @@ -0,0 +1,58 @@ +/* + * + * * Copyright 2019-2020 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.app144; + +import org.junit.jupiter.api.Test; +import org.springdoc.core.utils.Constants; +import test.org.springdoc.api.v30.AbstractSpringDocActuatorTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; + +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.status; + + +@SpringBootTest(webEnvironment = WebEnvironment.DEFINED_PORT, + properties = { "management.endpoints.web.exposure.include=*", + "server.port=52554", + "springdoc.use-management-port=true", + "management.server.port=9290", + "management.endpoints.web.base-path=/application" }) +public class SpringDocApp144Test extends AbstractSpringDocActuatorTest { + + @Test + void testApp() throws Exception { + mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL)) + .andExpect(status().isNotFound()); + } + + @Test + void testApp1() throws Exception { + String result = actuatorRestTemplate.getForObject("/application/openapi", String.class); + String expected = getContent("results/3.0.1/app144.json"); + assertEquals(expected, result, true); + } + + @SpringBootApplication + static class SpringDocTestApp {} + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app145/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app145/HelloController.java new file mode 100644 index 000000000..96e1706cc --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app145/HelloController.java @@ -0,0 +1,32 @@ +/* + * + * * Copyright 2019-2020 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.app145; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class HelloController { + + @GetMapping("/persons") + public String persons() { + return "OK"; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app145/SpringDocApp145Test.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app145/SpringDocApp145Test.java new file mode 100644 index 000000000..3ac609f88 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app145/SpringDocApp145Test.java @@ -0,0 +1,90 @@ +/* + * + * * 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.app145; + +import org.junit.jupiter.api.Test; +import org.springdoc.core.utils.Constants; +import test.org.springdoc.api.v30.AbstractSpringDocActuatorTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; +import org.springframework.http.HttpStatus; +import org.springframework.web.client.HttpClientErrorException; +import org.springframework.web.client.HttpStatusCodeException; + +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; +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.status; + + +@SpringBootTest(webEnvironment = WebEnvironment.DEFINED_PORT, + properties = { "management.endpoints.web.exposure.include=*", + "server.port=53556", + "springdoc.use-management-port=true", + "springdoc.group-configs[0].group=users", + "springdoc.group-configs[0].packages-to-scan=test.org.springdoc.api.v30.app145", + "management.server.port=9391", + "management.endpoints.web.base-path=/application" }) +public class SpringDocApp145Test extends AbstractSpringDocActuatorTest { + + @Test + void testApp() throws Exception { + mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL + "/users")) + .andExpect(status().isNotFound()); + } + + @Test + void testApp1() throws Exception { + try { + actuatorRestTemplate.getForObject("/application/openapi", String.class); + fail(); + } + catch (HttpClientErrorException ex) { + if (ex.getStatusCode() == HttpStatus.NOT_FOUND) + assertTrue(true); + else + fail(); + } + } + + @Test + void testApp2() throws Exception { + String result = actuatorRestTemplate.getForObject("/application/openapi/users", String.class); + String expected = getContent("results/3.0.1/app145.json"); + assertEquals(expected, result, true); + } + + @Test + void testApp3() throws Exception { + try { + actuatorRestTemplate.getForObject("/application/openapi" + "/" + Constants.DEFAULT_GROUP_NAME, String.class); + fail(); + } + catch (HttpStatusCodeException ex) { + if (ex.getStatusCode() == HttpStatus.NOT_FOUND) + assertTrue(true); + } + } + + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app147/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app147/HelloController.java new file mode 100644 index 000000000..edb329231 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app147/HelloController.java @@ -0,0 +1,44 @@ +/* + * + * * Copyright 2019-2020 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.app147; + + +import org.springdoc.core.models.GroupedOpenApi; + +import org.springframework.context.annotation.Bean; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class HelloController { + + @GetMapping("/persons") + public String persons() { + return "OK"; + } + + @Bean + public GroupedOpenApi userOpenApi() { + return GroupedOpenApi.builder() + .group("users") + .packagesToScan("test.org.springdoc.api.v30.app147") + .build(); + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app147/SpringDocApp147Test.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app147/SpringDocApp147Test.java new file mode 100644 index 000000000..24195e622 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app147/SpringDocApp147Test.java @@ -0,0 +1,70 @@ +/* + * + * * 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.app147; + +import org.junit.jupiter.api.Test; +import org.springdoc.core.utils.Constants; +import test.org.springdoc.api.v30.AbstractSpringDocActuatorTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.test.context.SpringBootTest; + +import static org.hamcrest.Matchers.is; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + + +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, + properties = { "management.endpoints.web.exposure.include=*", + "springdoc.show-actuator=true", + "management.server.port=9287", + "management.endpoints.web.exposure.exclude=functions, shutdown", + "server.servlet.context-path=/sample", + "management.server.base-path=/test", + "management.endpoints.web.base-path=/application" }) +public class SpringDocApp147Test extends AbstractSpringDocActuatorTest { + + @Test + void testApp() throws Exception { + mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL + "/" + Constants.ACTUATOR_DEFAULT_GROUP)) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.openapi", is("3.0.1"))) + .andExpect(content().json(getContent("results/3.0.1/app147-1.json"), true)); + } + + @Test + void testApp1() throws Exception { + mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL + "/users")) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.openapi", is("3.0.1"))) + .andExpect(content().json(getContent("results/3.0.1/app147-2.json"), true)); + } + + @Test + void testApp2() throws Exception { + mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL + "/" + Constants.DEFAULT_GROUP_NAME)) + .andExpect(status().isNotFound()); + } + + @SpringBootApplication + static class SpringDocTestApp {} + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app148/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app148/HelloController.java new file mode 100644 index 000000000..4bc86013a --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app148/HelloController.java @@ -0,0 +1,44 @@ +/* + * + * * Copyright 2019-2020 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.app148; + + +import org.springdoc.core.models.GroupedOpenApi; + +import org.springframework.context.annotation.Bean; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class HelloController { + + @GetMapping("/persons") + public String persons() { + return "OK"; + } + + @Bean + public GroupedOpenApi userOpenApi() { + return GroupedOpenApi.builder() + .group("users") + .packagesToScan("test.org.springdoc.api.v30.app148") + .build(); + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app148/SpringDocApp148Test.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app148/SpringDocApp148Test.java new file mode 100644 index 000000000..7723a6703 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app148/SpringDocApp148Test.java @@ -0,0 +1,73 @@ +/* + * + * * 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.app148; + +import org.junit.jupiter.api.Test; +import org.springdoc.core.utils.Constants; +import test.org.springdoc.api.v30.AbstractSpringDocActuatorTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; +import org.springframework.http.HttpStatus; +import org.springframework.web.client.HttpStatusCodeException; + +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; + + +@SpringBootTest(webEnvironment = WebEnvironment.DEFINED_PORT, + properties = { "management.endpoints.web.exposure.include=*", + "springdoc.show-actuator=true", + "management.server.port=9298", + "server.port=6276", + "server.servlet.context-path=/toto", + "springdoc.use-management-port=true", + "spring.mvc.servlet.path=/titi", + "management.endpoints.web.exposure.exclude=functions, shutdown", + "management.server.base-path=/test", + "management.endpoints.web.base-path=/application" }) +public class SpringDocApp148Test extends AbstractSpringDocActuatorTest { + + @Test + void testApp() throws Exception { + super.testWithRestTemplate("148-1","/test/application/openapi/users"); + } + + @Test + void testApp2() throws Exception { + super.testWithRestTemplate("148-2","/test/application/openapi/x-actuator"); + } + + @Test + void testApp3() throws Exception { + try { + actuatorRestTemplate.getForObject("/test/application/openapi" + "/" + Constants.DEFAULT_GROUP_NAME, String.class); + fail(); + } + catch (HttpStatusCodeException ex) { + if (ex.getStatusCode() == HttpStatus.NOT_FOUND) + assertTrue(true); + } + } + + @SpringBootApplication + static class SpringDocTestApp {} + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app186/SpringDocApp186Test.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app186/SpringDocApp186Test.java new file mode 100644 index 000000000..e8b773c45 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app186/SpringDocApp186Test.java @@ -0,0 +1,106 @@ +/* + * + * * + * * * + * * * * + * * * * * 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.app186; + +import org.junit.jupiter.api.Test; +import org.springdoc.core.customizers.OperationCustomizer; +import org.springdoc.core.models.GroupedOpenApi; +import org.springdoc.core.utils.Constants; +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.actuate.autoconfigure.endpoint.web.WebEndpointProperties; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; +import org.springframework.test.context.TestPropertySource; + +import static org.hamcrest.Matchers.is; +import static org.springdoc.core.utils.Constants.ALL_PATTERN; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + +@TestPropertySource(properties = { "springdoc.show-actuator=true", + "springdoc.group-configs[0].group=group-actuator-as-properties", + "springdoc.group-configs[0].paths-to-match=${management.endpoints.web.base-path:/actuator}/**", + "management.endpoints.enabled-by-default=true", + "management.endpoints.web.exposure.include=*", + "management.endpoints.web.exposure.exclude=functions, shutdown" }) +public class SpringDocApp186Test extends AbstractSpringDocTest { + + @Test + protected void testApp() throws Exception { + mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL)) + .andExpect(jsonPath("$.openapi", is("3.0.1"))) + .andExpect(status().isOk()) + .andExpect(content().json(getContent("results/3.0.1/app186.json"), true)); + } + + @Test + void testGroupActuatorAsCodeCheckBackwardsCompatibility() throws Exception { + mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL + "/group-actuator-as-code-check-backwards-compatibility")) + .andExpect(jsonPath("$.openapi", is("3.0.1"))) + .andExpect(status().isOk()) + .andExpect(content().json(getContent("results/3.0.1/app186.json"), true)); + } + + @Test + void testGroupActuatorAsCode() throws Exception { + mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL + "/group-actuator-as-code")) + .andExpect(jsonPath("$.openapi", is("3.0.1"))) + .andExpect(status().isOk()) + .andExpect(content().json(getContent("results/3.0.1/app186.json"), true)); + } + + @Test + void testGroupActuatorAsProperties() throws Exception { + mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL + "/group-actuator-as-properties")) + .andExpect(jsonPath("$.openapi", is("3.0.1"))) + .andExpect(status().isOk()) + .andExpect(content().json(getContent("results/3.0.1/app186.json"), true)); + } + + @SpringBootApplication + static class SpringDocTestApp { + + @Bean + public GroupedOpenApi asCodeCheckBackwardsCompatibility(OperationCustomizer actuatorCustomizer, WebEndpointProperties endpointProperties) { + return GroupedOpenApi.builder() + .group("group-actuator-as-code-check-backwards-compatibility") + .pathsToMatch(endpointProperties.getBasePath() + ALL_PATTERN) + .addOperationCustomizer(actuatorCustomizer) + .build(); + } + + @Bean + public GroupedOpenApi asCode(WebEndpointProperties endpointProperties) { + return GroupedOpenApi.builder() + .group("group-actuator-as-code") + .pathsToMatch(endpointProperties.getBasePath() + ALL_PATTERN) + .build(); + } + } + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app36/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app36/HelloController.java new file mode 100644 index 000000000..513fcfb32 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app36/HelloController.java @@ -0,0 +1,40 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app36; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class HelloController { + + @GetMapping("/persons") + public String persons() { + return "OK"; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app36/SpringDocApp36Test.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app36/SpringDocApp36Test.java new file mode 100644 index 000000000..b7f92e0a9 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app36/SpringDocApp36Test.java @@ -0,0 +1,60 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app36; + +import org.junit.jupiter.api.Test; +import org.springdoc.core.utils.Constants; +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.test.context.TestPropertySource; + +import static org.hamcrest.Matchers.containsString; +import static org.hamcrest.Matchers.is; +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.show-actuator=true", "management.endpoints.enabled-by-default=true", + "management.endpoints.web.exposure.include=*" }) +public class SpringDocApp36Test extends AbstractSpringDocTest { + + @Test + protected void testApp() throws Exception { + mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL)).andExpect(status().isOk()) + .andExpect(jsonPath("$.openapi", is("3.0.1"))) + .andExpect(jsonPath("$.paths./actuator/info.get.operationId", containsString("info"))) + .andExpect(jsonPath("$.paths./actuator/health.get.operationId", containsString("health"))) + .andExpect(jsonPath("$.paths./actuator/metrics/{requiredMetricName}.get.parameters[0].in", is("path"))) + .andExpect(jsonPath("$.paths./actuator/metrics/{requiredMetricName}.get.parameters[0].name", is("requiredMetricName"))); + } + + @SpringBootApplication + static class SpringDocTestApp {} + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app68/CustomizedOperation.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app68/CustomizedOperation.java new file mode 100644 index 000000000..d3bbb4377 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app68/CustomizedOperation.java @@ -0,0 +1,35 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app68; + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + +@Retention(RetentionPolicy.RUNTIME) +public @interface CustomizedOperation { + String addition() default "customized operation!"; +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app68/SpringDocApp68Test.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app68/SpringDocApp68Test.java new file mode 100644 index 000000000..59736e946 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app68/SpringDocApp68Test.java @@ -0,0 +1,105 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app68; + +import org.hamcrest.Matchers; +import org.junit.jupiter.api.Test; +import org.springdoc.core.utils.Constants; +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.test.context.TestPropertySource; + +import static org.hamcrest.Matchers.contains; +import static org.hamcrest.Matchers.containsString; +import static org.hamcrest.Matchers.hasSize; +import static org.hamcrest.Matchers.is; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + +@TestPropertySource(properties = { "management.endpoints.enabled-by-default=true", "springdoc.show-actuator=true" }) +public class SpringDocApp68Test extends AbstractSpringDocTest { + + + @Test + protected void testApp() throws Exception { + mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL + "/stores")) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.openapi", is("3.0.1"))) + .andExpect(content().json(getContent("results/3.0.1/app68-1.json"), true)); + } + + @Test + void testApp2() throws Exception { + mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL + "/users")) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.openapi", is("3.0.1"))) + .andExpect(content().json(getContent("results/3.0.1/app68-2.json"), true)); + } + + @Test + void testApp3() throws Exception { + mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL + "/pets")) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.openapi", is("3.0.1"))) + .andExpect(content().json(getContent("results/3.0.1/app68-3.json"), true)); + } + + @Test + void testApp4() throws Exception { + mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL + "/groups test")) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.openapi", is("3.0.1"))) + .andExpect(content().json(getContent("results/3.0.1/app68-4.json"), true)); + } + + @Test + void testActuator() throws Exception { + mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL)).andExpect(status().isOk()) + .andExpect(jsonPath("$.openapi", is("3.0.1"))) + .andExpect(jsonPath("$.paths./actuator/health.get.summary", Matchers.is("Actuator web endpoint 'health'"))) + .andExpect(jsonPath("$.paths./actuator/health.get.operationId", containsString("health"))); + } + + @Test + void testActuatorDescription() throws Exception { + mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL)).andExpect(status().isOk()) + .andExpect(jsonPath("$.openapi", is("3.0.1"))) + .andExpect(jsonPath("$.tags", hasSize(4))) + .andExpect(jsonPath("$.tags[?(@.name == '" + Constants.SPRINGDOC_ACTUATOR_TAG + "')].name", contains(Constants.SPRINGDOC_ACTUATOR_TAG))) + .andExpect(jsonPath("$.tags[?(@.name == '" + Constants.SPRINGDOC_ACTUATOR_TAG + "')].description", contains(Constants.SPRINGDOC_ACTUATOR_DESCRIPTION))) + .andExpect(jsonPath("$.tags[?(@.name == '" + Constants.SPRINGDOC_ACTUATOR_TAG + "')].externalDocs.description", contains(Constants.SPRINGDOC_ACTUATOR_DOC_DESCRIPTION))) + .andExpect(jsonPath("$.tags[?(@.name == '" + Constants.SPRINGDOC_ACTUATOR_TAG + "')].externalDocs.url", contains(Constants.SPRINGDOC_ACTUATOR_DOC_URL))); + } + + @Test + void testApp5() throws Exception { + mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL + "/user")) + .andExpect(status().isNotFound()); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app68/SpringDocConfiguration.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app68/SpringDocConfiguration.java new file mode 100644 index 000000000..0e9507d2d --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app68/SpringDocConfiguration.java @@ -0,0 +1,125 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app68; + +import java.util.ArrayList; +import java.util.List; + +import io.swagger.v3.oas.models.Components; +import io.swagger.v3.oas.models.OpenAPI; +import io.swagger.v3.oas.models.Operation; +import io.swagger.v3.oas.models.info.Info; +import io.swagger.v3.oas.models.info.License; +import io.swagger.v3.oas.models.security.SecurityScheme; +import io.swagger.v3.oas.models.servers.Server; +import org.apache.commons.lang3.StringUtils; +import org.springdoc.core.customizers.OpenApiCustomizer; +import org.springdoc.core.customizers.OperationCustomizer; +import org.springdoc.core.models.GroupedOpenApi; +import org.springdoc.core.utils.Constants; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.method.HandlerMethod; + +@Configuration +public class SpringDocConfiguration { + + @SpringBootApplication + static class SpringDocTestApp {} + + @Bean + public GroupedOpenApi storeOpenApi() { + return GroupedOpenApi.builder() + .group("stores") + .pathsToMatch("/store/**") + .build(); + } + + @Bean + public GroupedOpenApi userOpenApi() { + return GroupedOpenApi.builder() + .group("users") + .packagesToScan("test.org.springdoc.api.v30.app68.api.user").addOpenApiCustomizer(serverOpenApiCustomizer1()) + .addOperationCustomizer(operationCustomizer()) + .build(); + } + + public OpenApiCustomizer serverOpenApiCustomizer1() { + Server server = new Server().url("http://toto.v1.com").description("myserver1"); + List servers = new ArrayList<>(); + servers.add(server); + return openApi -> openApi.setServers(servers); + } + + public OpenApiCustomizer serverOpenApiCustomizer2() { + Server server = new Server().url("http://toto.v2.com").description("myserver2"); + List servers = new ArrayList<>(); + servers.add(server); + return openApi -> openApi.setServers(servers); + } + + OperationCustomizer operationCustomizer() { + return (Operation operation, HandlerMethod handlerMethod) -> { + CustomizedOperation annotation = handlerMethod.getMethodAnnotation(CustomizedOperation.class); + if (annotation != null) { + operation.description(StringUtils.defaultIfBlank(operation.getDescription(), Constants.DEFAULT_DESCRIPTION) + ", " + annotation.addition()); + } + return operation; + }; + } + + @Bean + public GroupedOpenApi petOpenApi() { + return GroupedOpenApi.builder() + .group("pets") + .pathsToMatch("/pet/**").addOpenApiCustomizer(serverOpenApiCustomizer2()) + .build(); + } + + @Bean + public GroupedOpenApi groupOpenApi() { + return GroupedOpenApi.builder() + .group("groups test") + .pathsToMatch("/v1/**").pathsToExclude("/v1/users") + .packagesToScan("test.org.springdoc.api.v30.app68.api.user", "test.org.springdoc.api.v30.app68.api.store") + .build(); + } + + + @Bean + public OpenAPI customOpenAPI() { + return new OpenAPI() + .components(new Components().addSecuritySchemes("basicScheme", + new SecurityScheme().type(SecurityScheme.Type.HTTP).scheme("basic"))) + .info(new Info().title("Petstore API").version("v0").description( + "This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.") + .termsOfService("http://swagger.io/terms/") + .license(new License().name("Apache 2.0").url("http://springdoc.org"))); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app68/api/ApiUtil.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app68/api/ApiUtil.java new file mode 100644 index 000000000..60e24fdae --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app68/api/ApiUtil.java @@ -0,0 +1,54 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app68.api; + +import java.io.IOException; + +import jakarta.servlet.http.HttpServletResponse; + +import org.springframework.http.HttpStatus; +import org.springframework.web.context.request.NativeWebRequest; +import org.springframework.web.server.ResponseStatusException; + +public class ApiUtil { + + public static void setExampleResponse(NativeWebRequest req, String contentType, String example) { + try { + req.getNativeResponse(HttpServletResponse.class).addHeader("Content-Type", contentType); + req.getNativeResponse(HttpServletResponse.class).getOutputStream().print(example); + } + catch (IOException e) { + throw new RuntimeException(e); + } + } + + public static void checkApiKey(NativeWebRequest req) { + if (!"1".equals(System.getenv("DISABLE_API_KEY")) && !"special-key".equals(req.getHeader("api_key"))) { + throw new ResponseStatusException(HttpStatus.UNAUTHORIZED, "Missing API key!"); + } + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app68/api/ExceptionTranslator.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app68/api/ExceptionTranslator.java new file mode 100644 index 000000000..cdb1592e2 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app68/api/ExceptionTranslator.java @@ -0,0 +1,57 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app68.api; + +import java.util.Map; + +import jakarta.validation.ConstraintViolationException; + +import org.springframework.boot.web.error.ErrorAttributeOptions; +import org.springframework.boot.web.servlet.error.ErrorAttributes; +import org.springframework.http.HttpStatus; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.ResponseStatus; +import org.springframework.web.bind.annotation.RestControllerAdvice; +import org.springframework.web.context.request.RequestAttributes; +import org.springframework.web.context.request.WebRequest; + +@RestControllerAdvice +public class ExceptionTranslator { + + private final ErrorAttributes errorAttributes; + + public ExceptionTranslator(ErrorAttributes errorAttributes) { + this.errorAttributes = errorAttributes; + } + + @ExceptionHandler(ConstraintViolationException.class) + @ResponseStatus(HttpStatus.BAD_REQUEST) + public Map processConstraintViolationException(WebRequest request) { + request.setAttribute("jakarta.servlet.error.status_code", HttpStatus.BAD_REQUEST.value(), RequestAttributes.SCOPE_REQUEST); + return errorAttributes.getErrorAttributes(request, ErrorAttributeOptions.defaults()); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app68/api/HomeController.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app68/api/HomeController.java new file mode 100644 index 000000000..91fabfb4e --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app68/api/HomeController.java @@ -0,0 +1,50 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app68.api; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.GetMapping; + +import static org.springdoc.core.utils.Constants.SWAGGER_UI_PATH; +import static org.springframework.util.AntPathMatcher.DEFAULT_PATH_SEPARATOR; +import static org.springframework.web.servlet.view.UrlBasedViewResolver.REDIRECT_URL_PREFIX; + +/** + * Home redirection to swagger api documentation + */ +@Controller +public class HomeController { + + @Value(SWAGGER_UI_PATH) + private String swaggerUiPath; + + @GetMapping(DEFAULT_PATH_SEPARATOR) + public String index() { + return REDIRECT_URL_PREFIX + swaggerUiPath; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app68/api/pet/PetApi.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app68/api/pet/PetApi.java new file mode 100644 index 000000000..95665ae15 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app68/api/pet/PetApi.java @@ -0,0 +1,169 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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. + * * * * * + * * * * + * * * + * * + * + */ + +/** + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (3.0.0). + * https://openapi-generator.tech + * Do not edit the class manually. + */ +package test.org.springdoc.api.v30.app68.api.pet; + +import java.util.List; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.enums.SecuritySchemeType; +import io.swagger.v3.oas.annotations.media.ArraySchema; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; +import io.swagger.v3.oas.annotations.security.OAuthFlow; +import io.swagger.v3.oas.annotations.security.OAuthFlows; +import io.swagger.v3.oas.annotations.security.OAuthScope; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.security.SecurityScheme; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.validation.Valid; +import jakarta.validation.constraints.NotNull; +import test.org.springdoc.api.v30.app68.model.ModelApiResponse; +import test.org.springdoc.api.v30.app68.model.Pet; + +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestHeader; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.multipart.MultipartFile; + +@SecurityScheme(name = "petstore_auth", type = SecuritySchemeType.OAUTH2, flows = @OAuthFlows(implicit = @OAuthFlow(authorizationUrl = "http://petstore.swagger.io/oauth/dialog", scopes = { + @OAuthScope(name = "write:pets", description = "modify pets in your account"), + @OAuthScope(name = "read:pets", description = "read your pets") }))) +@Tag(name = "pet", description = "the pet API") +@ResponseBody +public interface PetApi { + + default PetApiDelegate getDelegate() { + return new PetApiDelegate() { + }; + } + + @Operation(summary = "Add a new pet to the store", description = "", security = { + @SecurityRequirement(name = "petstore_auth", scopes = { "write:pets", "read:pets" }) }, tags = { "pet" }) + @ApiResponses(value = { @ApiResponse(responseCode = "405", description = "Invalid input") }) + @PostMapping(value = "/pet", consumes = { "application/json", "application/xml" }) + default void addPet( + @io.swagger.v3.oas.annotations.parameters.RequestBody(description = "Pet object that needs to be added to the store", required = true) @Valid @RequestBody Pet pet) { + // return getDelegate().addPet(pet); + } + + @Operation(summary = "Deletes a pet", description = "", security = { + @SecurityRequirement(name = "petstore_auth", scopes = { "write:pets", "read:pets" }) }, tags = { "pet" }) + @ApiResponses(value = { @ApiResponse(responseCode = "400", description = "Invalid ID supplied"), + @ApiResponse(responseCode = "404", description = "Pet not found") }) + @DeleteMapping(value = "/pet/{petId}") + default ResponseEntity deletePet( + @Parameter(description = "Pet id to delete", required = true) @PathVariable("petId") Long petId, + @Parameter(description = "") @RequestHeader(value = "api_key", required = false) String apiKey) { + return getDelegate().deletePet(petId, apiKey); + } + + @Operation(summary = "Finds Pets by status", description = "Multiple status values can be provided with comma separated strings", security = { + @SecurityRequirement(name = "petstore_auth", scopes = { "write:pets", "read:pets" }) }, tags = { "pet" }) + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(array = @ArraySchema(schema = @Schema(implementation = Pet.class)))), + @ApiResponse(responseCode = "400", description = "Invalid status value") }) + @GetMapping(value = "/pet/findByStatus", produces = { "application/xml", "application/json" }) + default ResponseEntity> findPetsByStatus( + @NotNull @Parameter(description = "Status values that need to be considered for filter", required = true) @Valid @RequestParam(value = "status", required = true) List status) { + return getDelegate().findPetsByStatus(status); + } + + @Operation(summary = "Finds Pets by tags", description = "Muliple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.", security = { + @SecurityRequirement(name = "petstore_auth", scopes = { "write:pets", "read:pets" }) }, tags = { "pet" }) + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(array = @ArraySchema(schema = @Schema(implementation = Pet.class)))), + @ApiResponse(responseCode = "400", description = "Invalid tag value") }) + @GetMapping(value = "/pet/findByTags", produces = { "application/xml", "application/json" }) + default ResponseEntity> findPetsByTags( + @NotNull @Parameter(description = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) List tags) { + return getDelegate().findPetsByTags(tags); + } + + @Operation(summary = "Find pet by ID", description = "Returns a single pet", security = { + @SecurityRequirement(name = "api_key") }, tags = { "pet" }) + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(schema = @Schema(implementation = Pet.class))), + @ApiResponse(responseCode = "400", description = "Invalid ID supplied"), + @ApiResponse(responseCode = "404", description = "Pet not found") }) + @GetMapping(value = "/pet/{petId}", produces = { "application/xml", "application/json" }) + default ResponseEntity getPetById( + @Parameter(description = "ID of pet to return", required = true) @PathVariable("petId") Long petId) { + return getDelegate().getPetById(petId); + } + + @Operation(summary = "Update an existing pet", description = "", security = { + @SecurityRequirement(name = "petstore_auth", scopes = { "write:pets", "read:pets" }) }, tags = { "pet" }) + @ApiResponses(value = { @ApiResponse(responseCode = "400", description = "Invalid ID supplied"), + @ApiResponse(responseCode = "404", description = "Pet not found"), + @ApiResponse(responseCode = "405", description = "Validation exception") }) + @PutMapping(value = "/pet", consumes = { "application/json", "application/xml" }) + default ResponseEntity updatePet( + @io.swagger.v3.oas.annotations.parameters.RequestBody(description = "Pet object that needs to be added to the store", required = true) @Valid @RequestBody Pet pet) { + return getDelegate().updatePet(pet); + } + + @Operation(summary = "Updates a pet in the store with form data", description = "", security = { + @SecurityRequirement(name = "petstore_auth", scopes = { "write:pets", "read:pets" }) }, tags = { "pet" }) + @ApiResponses(value = { @ApiResponse(responseCode = "405", description = "Invalid input") }) + @PostMapping(value = "/pet/{petId}", consumes = { "application/x-www-form-urlencoded" }) + default ResponseEntity updatePetWithForm( + @Parameter(description = "ID of pet that needs to be updated", required = true) @PathVariable("petId") Long petId, + @Parameter(description = "Updated name of the pet") @RequestParam(value = "name", required = false) String name, + @Parameter(description = "Updated status of the pet") @RequestParam(value = "status", required = false) String status) { + return getDelegate().updatePetWithForm(petId, name, status); + } + + @Operation(summary = "uploads an image", description = "", security = { + @SecurityRequirement(name = "petstore_auth", scopes = { "write:pets", "read:pets" }) }, tags = { "pet" }) + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(schema = @Schema(implementation = ModelApiResponse.class))) }) + @PostMapping(value = "/pet/{petId}/uploadImage", produces = { "application/json" }, consumes = { + "multipart/form-data" }) + default ResponseEntity uploadFile( + @Parameter(description = "ID of pet to update", required = true) @PathVariable("petId") Long petId, + @Parameter(description = "Additional data to pass to server") @RequestParam(value = "additionalMetadata", required = false) String additionalMetadata, + @Parameter(description = "file detail") @Valid @RequestPart("file") MultipartFile file) { + return getDelegate().uploadFile(petId, additionalMetadata, file); + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app68/api/pet/PetApiController.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app68/api/pet/PetApiController.java new file mode 100644 index 000000000..e3923c258 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app68/api/pet/PetApiController.java @@ -0,0 +1,52 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app68.api.pet; + +import java.util.Optional; + +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@jakarta.annotation.Generated(value = "org.springdoc.demo.app2.codegen.languages.SpringCodegen", date = "2019-07-11T00:09:29.839+02:00[Europe/Paris]") + +@RestController +@RequestMapping("${openapi.openAPIPetstore.base-path:/}") +public class PetApiController implements PetApi { + + private final PetApiDelegate delegate; + + public PetApiController(@org.springframework.beans.factory.annotation.Autowired(required = false) PetApiDelegate delegate) { + this.delegate = Optional.ofNullable(delegate).orElse(new PetApiDelegate() { + }); + } + + @Override + public PetApiDelegate getDelegate() { + return delegate; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app68/api/pet/PetApiDelegate.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app68/api/pet/PetApiDelegate.java new file mode 100644 index 000000000..0846d81bc --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app68/api/pet/PetApiDelegate.java @@ -0,0 +1,149 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app68.api.pet; + +import java.util.List; +import java.util.Optional; + +import jakarta.validation.Valid; +import test.org.springdoc.api.v30.app68.api.ApiUtil; +import test.org.springdoc.api.v30.app68.model.ModelApiResponse; +import test.org.springdoc.api.v30.app68.model.Pet; + +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.web.context.request.NativeWebRequest; +import org.springframework.web.multipart.MultipartFile; + +/** + * A delegate to be called by the {@link PetApiController}}. + * Implement this interface with a {@link org.springframework.stereotype.Service} annotated class. + */ +@jakarta.annotation.Generated(value = "org.springdoc.demo.app2.codegen.languages.SpringCodegen", date = "2019-07-11T00:09:29.839+02:00[Europe/Paris]") + +public interface PetApiDelegate { + + default Optional getRequest() { + return Optional.empty(); + } + + /** + * @see PetApi#addPet + */ + default void addPet(Pet pet) { + + } + + /** + * @see PetApi#deletePet + */ + default ResponseEntity deletePet(Long petId, + String apiKey) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * @see PetApi#findPetsByStatus + */ + default ResponseEntity> findPetsByStatus(List status) { + extract(); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + default void extract() { + getRequest().ifPresent(request -> { + for (MediaType mediaType : MediaType.parseMediaTypes(request.getHeader("Accept"))) { + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + ApiUtil.setExampleResponse(request, "application/json", "{ \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\"}"); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/xml"))) { + ApiUtil.setExampleResponse(request, "application/xml", " 123456789 doggie aeiou aeiou"); + break; + } + } + }); + } + + /** + * @see PetApi#findPetsByTags + */ + default ResponseEntity> findPetsByTags(List tags) { + extract(); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * @see PetApi#getPetById + */ + default ResponseEntity getPetById(Long petId) { + extract(); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * @see PetApi#updatePet + */ + default ResponseEntity updatePet(Pet pet) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * @see PetApi#updatePetWithForm + */ + default ResponseEntity updatePetWithForm(Long petId, + String name, + String status) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * @see PetApi#uploadFile + */ + default ResponseEntity uploadFile(Long petId, + String additionalMetadata, + @Valid MultipartFile file) { + getRequest().ifPresent(request -> { + for (MediaType mediaType : MediaType.parseMediaTypes(request.getHeader("Accept"))) { + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + ApiUtil.setExampleResponse(request, "application/json", "{ \"code\" : 0, \"type\" : \"type\", \"message\" : \"message\"}"); + break; + } + } + }); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app68/api/pet/PetApiDelegateImpl.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app68/api/pet/PetApiDelegateImpl.java new file mode 100644 index 000000000..4eb2fccc7 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app68/api/pet/PetApiDelegateImpl.java @@ -0,0 +1,35 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app68.api.pet; + +import org.springframework.stereotype.Service; + +@Service +public class PetApiDelegateImpl implements PetApiDelegate { + + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app68/api/store/StoreApi.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app68/api/store/StoreApi.java new file mode 100644 index 000000000..2f3cea9ab --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app68/api/store/StoreApi.java @@ -0,0 +1,112 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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. + * * * * * + * * * * + * * * + * * + * + */ + +/** + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (3.0.0). + * https://openapi-generator.tech + * Do not edit the class manually. + */ +package test.org.springdoc.api.v30.app68.api.store; + +import java.util.Map; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.media.ArraySchema; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.validation.Valid; +import jakarta.validation.constraints.Max; +import jakarta.validation.constraints.Min; +import jakarta.validation.constraints.NotBlank; +import test.org.springdoc.api.v30.app68.model.Order; + +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; + +@jakarta.annotation.Generated(value = "org.springdoc.demo.app2.codegen.languages.SpringCodegen", date = "2019-07-11T00:09:29.839+02:00[Europe/Paris]") + +@Tag(name = "store", description = "the store API") +public interface StoreApi { + + default StoreApiDelegate getDelegate() { + return new StoreApiDelegate() { + }; + } + + @Operation(summary = "Delete purchase order by ID", tags = { "store" }) + @ApiResponses(value = { @ApiResponse(responseCode = "400", description = "Invalid ID supplied"), + @ApiResponse(responseCode = "404", description = "Order not found") }) + @DeleteMapping(value = "/store/order/{orderId}") + default ResponseEntity deleteOrder( + @Parameter(description = "ID of the order that needs to be deleted", required = true) @PathVariable("orderId") String orderId) { + return getDelegate().deleteOrder(orderId); + } + + @Operation(summary = "Returns pet inventories by status", description = "Returns a map of status codes to quantities", security = { + @SecurityRequirement(name = "api_key") }, tags = { "store" }) + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(array = @ArraySchema(schema = @Schema(implementation = Map.class)))) }) + @GetMapping(value = "/store/inventory", produces = { "application/json" }) + default ResponseEntity> getInventory() { + return getDelegate().getInventory(); + } + + @Operation(summary = "Find purchase order by ID", tags = { "store" }) + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(schema = @Schema(implementation = Order.class))), + @ApiResponse(responseCode = "400", description = "Invalid ID supplied"), + @ApiResponse(responseCode = "404", description = "Order not found") }) + @GetMapping(value = "/store/order/{orderId}", produces = { "application/xml", "application/json" }) + default ResponseEntity getOrderById( + @Min(1L) @Max(5L) @Parameter(description = "ID of pet that needs to be fetched", required = true) @PathVariable("orderId") Long orderId) { + return getDelegate().getOrderById(orderId); + } + + @Operation(summary = "Place an order for a pet", tags = { "store" }) + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(schema = @Schema(implementation = Order.class))), + @ApiResponse(responseCode = "400", description = "Invalid Order") }) + @PostMapping(value = "/store/order", produces = { "application/xml", "application/json" }, consumes = { + "application/json" }) + default ResponseEntity placeOrder( + @Parameter(description = "order placed for purchasing the pet", required = true) @Valid @RequestBody Order order) { + return getDelegate().placeOrder(order); + } + + @GetMapping(value = "/v1/stores") + default void stores(@Valid @NotBlank String name) { + + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app68/api/store/StoreApiController.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app68/api/store/StoreApiController.java new file mode 100644 index 000000000..13da99064 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app68/api/store/StoreApiController.java @@ -0,0 +1,52 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app68.api.store; + +import java.util.Optional; + +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@jakarta.annotation.Generated(value = "org.springdoc.demo.app2.codegen.languages.SpringCodegen", date = "2019-07-11T00:09:29.839+02:00[Europe/Paris]") + +@RestController +@RequestMapping("${openapi.openAPIPetstore.base-path:/}") +public class StoreApiController implements StoreApi { + + private final StoreApiDelegate delegate; + + public StoreApiController(@org.springframework.beans.factory.annotation.Autowired(required = false) StoreApiDelegate delegate) { + this.delegate = Optional.ofNullable(delegate).orElse(new StoreApiDelegate() { + }); + } + + @Override + public StoreApiDelegate getDelegate() { + return delegate; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app68/api/store/StoreApiDelegate.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app68/api/store/StoreApiDelegate.java new file mode 100644 index 000000000..17cb050b3 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app68/api/store/StoreApiDelegate.java @@ -0,0 +1,101 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app68.api.store; + +import java.util.Map; +import java.util.Optional; + +import test.org.springdoc.api.v30.app68.api.ApiUtil; +import test.org.springdoc.api.v30.app68.model.Order; + +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.web.context.request.NativeWebRequest; + +/** + * A delegate to be called by the {@link StoreApiController}}. + * Implement this interface with a {@link org.springframework.stereotype.Service} annotated class. + */ +@jakarta.annotation.Generated(value = "org.springdoc.demo.app2.codegen.languages.SpringCodegen", date = "2019-07-11T00:09:29.839+02:00[Europe/Paris]") + +public interface StoreApiDelegate { + + default Optional getRequest() { + return Optional.empty(); + } + + /** + * @see StoreApi#deleteOrder + */ + default ResponseEntity deleteOrder(String orderId) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * @see StoreApi#getInventory + */ + default ResponseEntity> getInventory() { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * @see StoreApi#getOrderById + */ + default ResponseEntity getOrderById(Long orderId) { + extract(); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + default void extract() { + getRequest().ifPresent(request -> { + for (MediaType mediaType : MediaType.parseMediaTypes(request.getHeader("Accept"))) { + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + ApiUtil.setExampleResponse(request, "application/json", "{ \"petId\" : 6, \"quantity\" : 1, \"id\" : 0, \"shipDate\" : \"2000-01-23T04:56:07.000+00:00\", \"complete\" : false, \"status\" : \"placed\"}"); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/xml"))) { + ApiUtil.setExampleResponse(request, "application/xml", " 123456789 123456789 123 2000-01-23T04:56:07.000Z aeiou true"); + break; + } + } + }); + } + + /** + * @see StoreApi#placeOrder + */ + default ResponseEntity placeOrder(Order order) { + extract(); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app68/api/store/StoreApiDelegateImpl.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app68/api/store/StoreApiDelegateImpl.java new file mode 100644 index 000000000..1eb776ad8 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app68/api/store/StoreApiDelegateImpl.java @@ -0,0 +1,35 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app68.api.store; + +import org.springframework.stereotype.Service; + +@Service +public class StoreApiDelegateImpl implements StoreApiDelegate { + + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app68/api/user/UserApi.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app68/api/user/UserApi.java new file mode 100644 index 000000000..5545f62b3 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app68/api/user/UserApi.java @@ -0,0 +1,140 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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. + * * * * * + * * * * + * * * + * * + * + */ + +/** + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (3.0.0). + * https://openapi-generator.tech + * Do not edit the class manually. + */ +package test.org.springdoc.api.v30.app68.api.user; + +import java.util.List; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.validation.Valid; +import jakarta.validation.constraints.NotNull; +import test.org.springdoc.api.v30.app68.model.User; + +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestParam; + +@jakarta.annotation.Generated(value = "org.springdoc.demo.app2.codegen.languages.SpringCodegen", date = "2019-07-11T00:09:29.839+02:00[Europe/Paris]") + +@Tag(name = "user", description = "the user API") +public interface UserApi { + + default UserApiDelegate getDelegate() { + return new UserApiDelegate() { + }; + } + + @Operation(summary = "Create user", tags = { "user" }) + @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "successful operation") }) + @PostMapping(value = "/user", consumes = { "application/json" }) + default ResponseEntity createUser( + @io.swagger.v3.oas.annotations.parameters.RequestBody(description = "Created user object", required = true) @Valid @RequestBody User user) { + return getDelegate().createUser(user); + } + + @Operation(summary = "Creates list of users with given input array", tags = { "user" }) + @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "successful operation") }) + + @PostMapping(value = "/user/createWithArray", consumes = { "application/json" }) + default ResponseEntity createUsersWithArrayInput( + @io.swagger.v3.oas.annotations.parameters.RequestBody(description = "List of user object", required = true) @Valid @RequestBody List user) { + return getDelegate().createUsersWithArrayInput(user); + } + + @Operation(summary = "Creates list of users with given input array", tags = { "user" }) + @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "successful operation") }) + @PostMapping(value = "/user/createWithList", consumes = { "application/json" }) + default ResponseEntity createUsersWithListInput( + @io.swagger.v3.oas.annotations.parameters.RequestBody(description = "List of user object", required = true) @Valid @RequestBody List user) { + return getDelegate().createUsersWithListInput(user); + } + + @Operation(summary = "Creates list of users with given input array", tags = { "user" }) + @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "successful operation") }) + + @DeleteMapping(value = "/user/{username}") + default ResponseEntity deleteUser( + @io.swagger.v3.oas.annotations.parameters.RequestBody(description = "The name that needs to be deleted", required = true) @PathVariable("username") String username) { + return getDelegate().deleteUser(username); + } + + @Operation(summary = "Get user by user name", tags = { "user" }) + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(schema = @Schema(implementation = User.class))), + @ApiResponse(responseCode = "400", description = "Invalid username supplied"), + @ApiResponse(responseCode = "404", description = "User not found") }) + + @GetMapping(value = "/user/{username}", produces = { "application/xml", "application/json" }) + default ResponseEntity getUserByName( + @Parameter(description = "The name that needs to be fetched. Use user1 for testing.", required = true) @PathVariable("username") String username) { + return getDelegate().getUserByName(username); + } + + @Operation(summary = "Logs user into the system", tags = { "user" }) + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(schema = @Schema(implementation = String.class))), + @ApiResponse(responseCode = "400", description = "Invalid username/password supplied") }) + @GetMapping(value = "/user/login", produces = { "application/xml", "application/json" }) + default ResponseEntity loginUser( + @NotNull @Parameter(description = "The user name for login", required = true) @Valid @RequestParam(value = "username", required = true) String username, + @NotNull @Parameter(description = "The password for login in clear text", required = true) @Valid @RequestParam(value = "password", required = true) String password) { + return getDelegate().loginUser(username, password); + } + + @Operation(summary = "Logs out current logged in user session", tags = { "user" }) + @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "successful operation") }) + @GetMapping(value = "/user/logout") + default ResponseEntity logoutUser() { + return getDelegate().logoutUser(); + } + + @Operation(summary = "Updated user", tags = { "user" }) + @ApiResponses(value = { @ApiResponse(responseCode = "400", description = "Invalid user supplied"), + @ApiResponse(responseCode = "404", description = "User not found") }) + @PutMapping(value = "/user/{username}", consumes = { "application/json" }) + default ResponseEntity updateUser( + @Parameter(description = "name that need to be deleted", required = true) @PathVariable("username") String username, + @io.swagger.v3.oas.annotations.parameters.RequestBody(description = "Updated user object", required = true) @Valid @RequestBody User user) { + return getDelegate().updateUser(username, user); + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app68/api/user/UserApiController.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app68/api/user/UserApiController.java new file mode 100644 index 000000000..2e58ecb3a --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app68/api/user/UserApiController.java @@ -0,0 +1,52 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app68.api.user; + +import java.util.Optional; + +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@jakarta.annotation.Generated(value = "org.springdoc.demo.app2.codegen.languages.SpringCodegen", date = "2019-07-11T00:09:29.839+02:00[Europe/Paris]") + +@RestController +@RequestMapping("${openapi.openAPIPetstore.base-path:/}") +public class UserApiController implements UserApi { + + private final UserApiDelegate delegate; + + public UserApiController(@org.springframework.beans.factory.annotation.Autowired(required = false) UserApiDelegate delegate) { + this.delegate = Optional.ofNullable(delegate).orElse(new UserApiDelegate() { + }); + } + + @Override + public UserApiDelegate getDelegate() { + return delegate; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app68/api/user/UserApiDelegate.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app68/api/user/UserApiDelegate.java new file mode 100644 index 000000000..b16423c01 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app68/api/user/UserApiDelegate.java @@ -0,0 +1,130 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app68.api.user; + +import java.util.List; +import java.util.Optional; + +import test.org.springdoc.api.v30.app68.api.ApiUtil; +import test.org.springdoc.api.v30.app68.model.User; + +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.web.context.request.NativeWebRequest; + +/** + * A delegate to be called by the {@link UserApiController}}. + * Implement this interface with a {@link org.springframework.stereotype.Service} annotated class. + */ +@jakarta.annotation.Generated(value = "org.springdoc.demo.app2.codegen.languages.SpringCodegen", date = "2019-07-11T00:09:29.839+02:00[Europe/Paris]") + +public interface UserApiDelegate { + + default Optional getRequest() { + return Optional.empty(); + } + + /** + * @see UserApi#createUser + */ + default ResponseEntity createUser(User user) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * @see UserApi#createUsersWithArrayInput + */ + default ResponseEntity createUsersWithArrayInput(List user) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * @see UserApi#createUsersWithListInput + */ + default ResponseEntity createUsersWithListInput(List user) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * @see UserApi#deleteUser + */ + default ResponseEntity deleteUser(String username) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * @see UserApi#getUserByName + */ + default ResponseEntity getUserByName(String username) { + getRequest().ifPresent(request -> { + for (MediaType mediaType : MediaType.parseMediaTypes(request.getHeader("Accept"))) { + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + ApiUtil.setExampleResponse(request, "application/json", "{ \"firstName\" : \"firstName\", \"lastName\" : \"lastName\", \"password\" : \"password\", \"userStatus\" : 6, \"phone\" : \"phone\", \"id\" : 0, \"email\" : \"email\", \"username\" : \"username\"}"); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/xml"))) { + ApiUtil.setExampleResponse(request, "application/xml", " 123456789 aeiou aeiou aeiou aeiou aeiou aeiou 123"); + break; + } + } + }); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * @see UserApi#loginUser + */ + default ResponseEntity loginUser(String username, + String password) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * @see UserApi#logoutUser + */ + default ResponseEntity logoutUser() { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * @see UserApi#updateUser + */ + default ResponseEntity updateUser(String username, + User user) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app68/api/user/UserApiDelegateImpl.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app68/api/user/UserApiDelegateImpl.java new file mode 100644 index 000000000..864b26523 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app68/api/user/UserApiDelegateImpl.java @@ -0,0 +1,35 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app68.api.user; + +import org.springframework.stereotype.Service; + +@Service +public class UserApiDelegateImpl implements UserApiDelegate { + + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app68/api/user/UserClient.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app68/api/user/UserClient.java new file mode 100644 index 000000000..381c1656e --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app68/api/user/UserClient.java @@ -0,0 +1,44 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app68.api.user; + +import test.org.springdoc.api.v30.app68.model.User; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; + +@RequestMapping(value = "/users", consumes = "application/json") +@Controller +public class UserClient { + + @GetMapping("/{id}") + public User findById(@PathVariable Integer id) { + return null; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app68/model/Body.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app68/model/Body.java new file mode 100644 index 000000000..b97ad69b9 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app68/model/Body.java @@ -0,0 +1,105 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app68.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.v3.oas.annotations.media.Schema; + +public class Body { + + @Schema(description = "Updated name of the pet") + /** + * Updated name of the pet + **/ + private String name = null; + + @Schema(description = "Updated status of the pet") + /** + * Updated status of the pet + **/ + private String status = null; + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private static String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Updated name of the pet + * + * @return name + **/ + @JsonProperty("name") + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Body name(String name) { + this.name = name; + return this; + } + + /** + * Updated status of the pet + * + * @return status + **/ + @JsonProperty("status") + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public Body status(String status) { + this.status = status; + return this; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Body {\n"); + + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append("}"); + return sb.toString(); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app68/model/Body1.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app68/model/Body1.java new file mode 100644 index 000000000..ac8663f5e --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app68/model/Body1.java @@ -0,0 +1,107 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app68.model; + +import java.io.File; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.v3.oas.annotations.media.Schema; + +public class Body1 { + + @Schema(description = "Additional data to pass to server") + /** + * Additional data to pass to server + **/ + private String additionalMetadata = null; + + @Schema(description = "file to upload") + /** + * file to upload + **/ + private File file = null; + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private static String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Additional data to pass to server + * + * @return additionalMetadata + **/ + @JsonProperty("additionalMetadata") + public String getAdditionalMetadata() { + return additionalMetadata; + } + + public void setAdditionalMetadata(String additionalMetadata) { + this.additionalMetadata = additionalMetadata; + } + + public Body1 additionalMetadata(String additionalMetadata) { + this.additionalMetadata = additionalMetadata; + return this; + } + + /** + * file to upload + * + * @return file + **/ + @JsonProperty("file") + public File getFile() { + return file; + } + + public void setFile(File file) { + this.file = file; + } + + public Body1 file(File file) { + this.file = file; + return this; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Body1 {\n"); + + sb.append(" additionalMetadata: ").append(toIndentedString(additionalMetadata)).append("\n"); + sb.append(" file: ").append(toIndentedString(file)).append("\n"); + sb.append("}"); + return sb.toString(); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app68/model/Category.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app68/model/Category.java new file mode 100644 index 000000000..832005c87 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app68/model/Category.java @@ -0,0 +1,99 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app68.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.v3.oas.annotations.media.Schema; + +public class Category { + + @Schema(description = "") + private Long id = null; + + @Schema(description = "") + private String name = null; + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private static String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Get id + * + * @return id + **/ + @JsonProperty("id") + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public Category id(Long id) { + this.id = id; + return this; + } + + /** + * Get name + * + * @return name + **/ + @JsonProperty("name") + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Category name(String name) { + this.name = name; + return this; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Category {\n"); + + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append("}"); + return sb.toString(); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app68/model/ModelApiResponse.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app68/model/ModelApiResponse.java new file mode 100644 index 000000000..6412dee05 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app68/model/ModelApiResponse.java @@ -0,0 +1,122 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app68.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.v3.oas.annotations.media.Schema; + +public class ModelApiResponse { + + @Schema(description = "") + private Integer code = null; + + @Schema(description = "") + private String type = null; + + @Schema(description = "") + private String message = null; + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private static String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Get code + * + * @return code + **/ + @JsonProperty("code") + public Integer getCode() { + return code; + } + + public void setCode(Integer code) { + this.code = code; + } + + public ModelApiResponse code(Integer code) { + this.code = code; + return this; + } + + /** + * Get type + * + * @return type + **/ + @JsonProperty("type") + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public ModelApiResponse type(String type) { + this.type = type; + return this; + } + + /** + * Get message + * + * @return message + **/ + @JsonProperty("message") + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public ModelApiResponse message(String message) { + this.message = message; + return this; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ModelApiResponse {\n"); + + sb.append(" code: ").append(toIndentedString(code)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" message: ").append(toIndentedString(message)).append("\n"); + sb.append("}"); + return sb.toString(); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app68/model/Order.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app68/model/Order.java new file mode 100644 index 000000000..55c58ab09 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app68/model/Order.java @@ -0,0 +1,234 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app68.model; + +import java.util.Date; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.v3.oas.annotations.media.Schema; + +public class Order { + + @Schema(description = "") + private Long id = null; + + @Schema(description = "") + private Long petId = null; + + @Schema(description = "") + private Integer quantity = null; + + @Schema(description = "") + private Date shipDate = null; + + @Schema(description = "Order Status") + /** + * Order Status + **/ + private StatusEnum status = null; + + @Schema(description = "") + private Boolean complete = false; + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private static String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Get id + * + * @return id + **/ + @JsonProperty("id") + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public Order id(Long id) { + this.id = id; + return this; + } + + /** + * Get petId + * + * @return petId + **/ + @JsonProperty("petId") + public Long getPetId() { + return petId; + } + + public void setPetId(Long petId) { + this.petId = petId; + } + + public Order petId(Long petId) { + this.petId = petId; + return this; + } + + /** + * Get quantity + * + * @return quantity + **/ + @JsonProperty("quantity") + public Integer getQuantity() { + return quantity; + } + + public void setQuantity(Integer quantity) { + this.quantity = quantity; + } + + public Order quantity(Integer quantity) { + this.quantity = quantity; + return this; + } + + /** + * Get shipDate + * + * @return shipDate + **/ + @JsonProperty("shipDate") + public Date getShipDate() { + return shipDate; + } + + public void setShipDate(Date shipDate) { + this.shipDate = shipDate; + } + + public Order shipDate(Date shipDate) { + this.shipDate = shipDate; + return this; + } + + /** + * Order Status + * + * @return status + **/ + @JsonProperty("status") + public String getStatus() { + if (status == null) { + return null; + } + return status.getValue(); + } + + public void setStatus(StatusEnum status) { + this.status = status; + } + + public Order status(StatusEnum status) { + this.status = status; + return this; + } + + /** + * Get complete + * + * @return complete + **/ + @JsonProperty("complete") + public Boolean isisComplete() { + return complete; + } + + public void setComplete(Boolean complete) { + this.complete = complete; + } + + public Order complete(Boolean complete) { + this.complete = complete; + return this; + } + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Order {\n"); + + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" petId: ").append(toIndentedString(petId)).append("\n"); + sb.append(" quantity: ").append(toIndentedString(quantity)).append("\n"); + sb.append(" shipDate: ").append(toIndentedString(shipDate)).append("\n"); + sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append(" complete: ").append(toIndentedString(complete)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + public enum StatusEnum { + PLACED("placed"), + APPROVED("approved"), + DELIVERED("delivered"); + + private String value; + + StatusEnum(String value) { + this.value = value; + } + + @JsonCreator + public static StatusEnum fromValue(String text) { + for (StatusEnum b : StatusEnum.values()) { + if (String.valueOf(b.value).equals(text)) { + return b; + } + } + return null; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app68/model/Pet.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app68/model/Pet.java new file mode 100644 index 000000000..68e05dbb6 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app68/model/Pet.java @@ -0,0 +1,248 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app68.model; + +import java.util.ArrayList; +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotNull; + +public class Pet { + + @Schema(description = "") + private Long id = null; + + @Schema(description = "") + private Category category = null; + + @Schema(example = "doggie", required = true, description = "") + private String name = null; + + @Schema(required = true, description = "") + private List photoUrls = new ArrayList(); + + @Schema(description = "") + private List tags = null; + + @Schema(description = "pet status in the store") + /** + * pet status in the store + **/ + private StatusEnum status = null; + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private static String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Get id + * + * @return id + **/ + @JsonProperty("id") + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public Pet id(Long id) { + this.id = id; + return this; + } + + /** + * Get category + * + * @return category + **/ + @JsonProperty("category") + public Category getCategory() { + return category; + } + + public void setCategory(Category category) { + this.category = category; + } + + public Pet category(Category category) { + this.category = category; + return this; + } + + /** + * Get name + * + * @return name + **/ + @JsonProperty("name") + @NotNull + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Pet name(String name) { + this.name = name; + return this; + } + + /** + * Get photoUrls + * + * @return photoUrls + **/ + @JsonProperty("photoUrls") + @NotNull + public List getPhotoUrls() { + return photoUrls; + } + + public void setPhotoUrls(List photoUrls) { + this.photoUrls = photoUrls; + } + + public Pet photoUrls(List photoUrls) { + this.photoUrls = photoUrls; + return this; + } + + public Pet addPhotoUrlsItem(String photoUrlsItem) { + this.photoUrls.add(photoUrlsItem); + return this; + } + + /** + * Get tags + * + * @return tags + **/ + @JsonProperty("tags") + public List getTags() { + return tags; + } + + public void setTags(List tags) { + this.tags = tags; + } + + public Pet tags(List tags) { + this.tags = tags; + return this; + } + + public Pet addTagsItem(Tag tagsItem) { + if (this.tags == null) { + this.tags = new ArrayList<>(); + } + this.tags.add(tagsItem); + return this; + } + + /** + * pet status in the store + * + * @return status + **/ + @JsonProperty("status") + public StatusEnum getStatus() { + if (status == null) { + return null; + } + return status; + } + + public void setStatus(StatusEnum status) { + this.status = status; + } + + public Pet status(StatusEnum status) { + this.status = status; + return this; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Pet {\n"); + + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" category: ").append(toIndentedString(category)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" photoUrls: ").append(toIndentedString(photoUrls)).append("\n"); + sb.append(" tags: ").append(toIndentedString(tags)).append("\n"); + sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + public enum StatusEnum { + AVAILABLE("available"), PENDING("pending"), SOLD("sold"); + + private String value; + + StatusEnum(String value) { + this.value = value; + } + + @JsonCreator + public static StatusEnum fromValue(String text) { + for (StatusEnum b : StatusEnum.values()) { + if (String.valueOf(b.value).equals(text)) { + return b; + } + } + return null; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app68/model/Tag.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app68/model/Tag.java new file mode 100644 index 000000000..795b7445b --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app68/model/Tag.java @@ -0,0 +1,99 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app68.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.v3.oas.annotations.media.Schema; + +public class Tag { + + @Schema(description = "") + private Long id = null; + + @Schema(description = "") + private String name = null; + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private static String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Get id + * + * @return id + **/ + @JsonProperty("id") + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public Tag id(Long id) { + this.id = id; + return this; + } + + /** + * Get name + * + * @return name + **/ + @JsonProperty("name") + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Tag name(String name) { + this.name = name; + return this; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Tag {\n"); + + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append("}"); + return sb.toString(); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app68/model/User.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app68/model/User.java new file mode 100644 index 000000000..ed63e6134 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app68/model/User.java @@ -0,0 +1,240 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app68.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.v3.oas.annotations.media.Schema; + +public class User { + + @Schema(description = "") + private Long id = null; + + @Schema(description = "") + private String username = null; + + @Schema(description = "") + private String firstName = null; + + @Schema(description = "") + private String lastName = null; + + @Schema(description = "") + private String email = null; + + @Schema(description = "") + private String password = null; + + @Schema(description = "") + private String phone = null; + + @Schema(description = "User Status") + /** + * User Status + **/ + private Integer userStatus = null; + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private static String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Get id + * + * @return id + **/ + @JsonProperty("id") + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public User id(Long id) { + this.id = id; + return this; + } + + /** + * Get username + * + * @return username + **/ + @JsonProperty("username") + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + public User username(String username) { + this.username = username; + return this; + } + + /** + * Get firstName + * + * @return firstName + **/ + @JsonProperty("firstName") + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + public User firstName(String firstName) { + this.firstName = firstName; + return this; + } + + /** + * Get lastName + * + * @return lastName + **/ + @JsonProperty("lastName") + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } + + public User lastName(String lastName) { + this.lastName = lastName; + return this; + } + + /** + * Get email + * + * @return email + **/ + @JsonProperty("email") + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + public User email(String email) { + this.email = email; + return this; + } + + /** + * Get password + * + * @return password + **/ + @JsonProperty("password") + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + public User password(String password) { + this.password = password; + return this; + } + + /** + * Get phone + * + * @return phone + **/ + @JsonProperty("phone") + public String getPhone() { + return phone; + } + + public void setPhone(String phone) { + this.phone = phone; + } + + public User phone(String phone) { + this.phone = phone; + return this; + } + + /** + * User Status + * + * @return userStatus + **/ + @JsonProperty("userStatus") + public Integer getUserStatus() { + return userStatus; + } + + public void setUserStatus(Integer userStatus) { + this.userStatus = userStatus; + } + + public User userStatus(Integer userStatus) { + this.userStatus = userStatus; + return this; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class User {\n"); + + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" username: ").append(toIndentedString(username)).append("\n"); + sb.append(" firstName: ").append(toIndentedString(firstName)).append("\n"); + sb.append(" lastName: ").append(toIndentedString(lastName)).append("\n"); + sb.append(" email: ").append(toIndentedString(email)).append("\n"); + sb.append(" password: ").append(toIndentedString(password)).append("\n"); + sb.append(" phone: ").append(toIndentedString(phone)).append("\n"); + sb.append(" userStatus: ").append(toIndentedString(userStatus)).append("\n"); + sb.append("}"); + return sb.toString(); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app72/BlockingAutoConfigurationTest.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app72/BlockingAutoConfigurationTest.java new file mode 100644 index 000000000..e9ec70e8d --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app72/BlockingAutoConfigurationTest.java @@ -0,0 +1,115 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app72; + +import org.junit.jupiter.api.Test; +import org.springdoc.core.models.GroupedOpenApi; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.test.context.FilteredClassLoader; +import org.springframework.boot.test.context.runner.ApplicationContextRunner; +import org.springframework.boot.test.context.runner.WebApplicationContextRunner; +import org.springframework.context.annotation.Bean; + +import static org.assertj.core.api.Assertions.assertThat; + +class BlockingAutoConfigurationTest { + + private final WebApplicationContextRunner contextRunner = new WebApplicationContextRunner() + .withUserConfiguration(TestApp.class); + + @Test + void configurations_successfully_loaded() { + contextRunner + .withPropertyValues("springdoc.show-actuator=true") + .run(context -> assertThat(context) + .hasNotFailed() + .hasBean("openApiResource") + .hasBean("actuatorProvider") + .hasBean("multipleOpenApiResource") + ); + } + + @Test + void configurations_not_loaded_when_application_is_not_web() { + new ApplicationContextRunner() + .withUserConfiguration(TestApp.class) + .run(context -> assertThat(context) + .hasNotFailed() + .doesNotHaveBean("openApiResource") + .doesNotHaveBean("actuatorProvider") + .doesNotHaveBean("multipleOpenApiResource") + ); + } + + @Test + void actuator_configuration_not_loaded_when_not_enabled_explicitly() { + contextRunner + .run(context -> assertThat(context) + .hasNotFailed() + .hasBean("openApiResource") + .doesNotHaveBean("actuatorPprrovider") + .hasBean("multipleOpenApiResource") + ); + } + + @Test + void configurations_not_loaded_when_disabled() { + contextRunner + .withPropertyValues("springdoc.api-docs.enabled=false") + .run(context -> assertThat(context) + .hasNotFailed() + .doesNotHaveBean("openApiResource") + .doesNotHaveBean("actuatorProvider") + .doesNotHaveBean("multipleOpenApiResource") + ); + } + + @Test + void configurations_not_loaded_when_mvc_is_not_on_class_path() { + contextRunner + .withClassLoader(new FilteredClassLoader("org.springframework.web.context.support.GenericWebApplicationContext")) + .run(context -> assertThat(context) + .hasNotFailed() + .doesNotHaveBean("openApiResource") + .doesNotHaveBean("actuatorProvider") + .doesNotHaveBean("multipleOpenApiResource") + ); + + } + + @SpringBootApplication + static class TestApp { + @Bean + GroupedOpenApi testGroupedOpenApi() { + return GroupedOpenApi.builder() + .group("test-group") + .packagesToScan("org.test") + .build(); + } + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app72/CacheAutoConfigurationTest1.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app72/CacheAutoConfigurationTest1.java new file mode 100644 index 000000000..3dd7c0012 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app72/CacheAutoConfigurationTest1.java @@ -0,0 +1,93 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app72; + +import org.junit.jupiter.api.Test; + +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.boot.test.context.runner.WebApplicationContextRunner; + +import static org.assertj.core.api.Assertions.assertThat; + +public class CacheAutoConfigurationTest1 { + + private final WebApplicationContextRunner contextRunner = new WebApplicationContextRunner() + .withUserConfiguration(TestApp.class); + + @Test + void cache_configuration_loaded_when_not_disabled_explicitly() { + contextRunner + .run(context -> assertThat(context) + .hasNotFailed() + .hasBean("openApiResource") + .doesNotHaveBean("springdocBeanFactoryPostProcessor") + .doesNotHaveBean("multipleOpenApiResource") + ); + } + + @Test + void cache_configuration_loaded_when_disabled_explicitly() { + contextRunner + .withPropertyValues("springdoc.cache.disabled=false") + .run(context -> assertThat(context) + .hasNotFailed() + .hasBean("openApiResource") + .doesNotHaveBean("springdocBeanFactoryPostProcessor") + .doesNotHaveBean("multipleOpenApiResource") + ); + } + + @Test + void cache_configurations_successfully_disabled() { + contextRunner + .withPropertyValues("springdoc.cache.disabled=true") + .run(context -> assertThat(context) + .hasNotFailed() + .hasBean("openApiResource") + .hasBean("springdocBeanFactoryPostProcessor") + .doesNotHaveBean("multipleOpenApiResource") + ); + } + + @Test + void group_configuration_loaded() { + contextRunner + .withPropertyValues("springdoc.group-configs[0].group=stores", "springdoc.group-configs[0].paths-to-match=/store/**") + .run(context -> assertThat(context) + .hasNotFailed() + .hasBean("openApiResource") + .hasBean("multipleOpenApiResource") + .hasBean("springdocBeanFactoryPostProcessor") + ); + } + + + @EnableAutoConfiguration + static class TestApp { + + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app72/GroupAutoConfigurationTest.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app72/GroupAutoConfigurationTest.java new file mode 100644 index 000000000..05e9fb181 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app72/GroupAutoConfigurationTest.java @@ -0,0 +1,64 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app72; + +import org.junit.jupiter.api.Test; +import org.springdoc.core.models.GroupedOpenApi; + +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.boot.test.context.runner.WebApplicationContextRunner; +import org.springframework.context.annotation.Bean; + +import static org.assertj.core.api.Assertions.assertThat; + +public class GroupAutoConfigurationTest { + + private final WebApplicationContextRunner contextRunner = new WebApplicationContextRunner() + .withUserConfiguration(TestApp.class); + + @Test + void group_configuration_loaded() { + contextRunner + .run(context -> assertThat(context) + .hasNotFailed() + .hasBean("openApiResource") + .hasBean("springdocBeanFactoryPostProcessor") + .hasBean("multipleOpenApiResource") + ); + } + + @EnableAutoConfiguration + static class TestApp { + @Bean + GroupedOpenApi testGroupedOpenApi() { + return GroupedOpenApi.builder() + .group("test-group") + .packagesToScan("org.test") + .build(); + } + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/AbstractCommonTest.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/AbstractCommonTest.java new file mode 100644 index 000000000..fde99f3fb --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/AbstractCommonTest.java @@ -0,0 +1,58 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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; + +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.context.TestPropertySource; +import org.springframework.test.web.servlet.MockMvc; + +@AutoConfigureMockMvc +@ActiveProfiles("test") +@TestPropertySource(properties = { "management.endpoints.enabled-by-default=false"}) +public abstract class AbstractCommonTest { + + @Autowired + protected MockMvc mockMvc; + + protected String getContent(String fileName) { + try { + Path path = Paths.get(AbstractCommonTest.class.getClassLoader().getResource(fileName).toURI()); + byte[] fileBytes = Files.readAllBytes(path); + return new String(fileBytes, StandardCharsets.UTF_8); + } + catch (Exception e) { + throw new RuntimeException("Failed to read file: " + fileName, e); + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/AbstractSpringDocActuatorTest.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/AbstractSpringDocActuatorTest.java new file mode 100644 index 000000000..aed753fc1 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/AbstractSpringDocActuatorTest.java @@ -0,0 +1,73 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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; + +import jakarta.annotation.PostConstruct; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.web.server.LocalManagementPort; +import org.springframework.boot.web.client.RestTemplateBuilder; +import org.springframework.test.context.TestPropertySource; +import org.springframework.web.client.RestTemplate; + +import static org.skyscreamer.jsonassert.JSONAssert.assertEquals; + +@TestPropertySource(properties = { "management.endpoints.enabled-by-default=true" }) +public abstract class AbstractSpringDocActuatorTest extends AbstractCommonTest { + + protected static final Logger LOGGER = LoggerFactory.getLogger(AbstractCommonTest.class); + + protected RestTemplate actuatorRestTemplate; + + @LocalManagementPort + private int managementPort; + + @Autowired + private RestTemplateBuilder restTemplateBuilder; + + @PostConstruct + void init() { + actuatorRestTemplate = restTemplateBuilder + .rootUri("http://localhost:" + this.managementPort).build(); + } + + protected void testWithRestTemplate(String testId, String uri) throws Exception { + String result = null; + try { + result = actuatorRestTemplate.getForObject(uri, String.class); + String expected = getContent("results/3.1.0/app" + testId + ".json"); + assertEquals(expected, result, true); + } + catch (AssertionError e) { + LOGGER.error(result); + throw e; + } + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/AbstractSpringDocTest.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/AbstractSpringDocTest.java new file mode 100644 index 000000000..959c70cac --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/AbstractSpringDocTest.java @@ -0,0 +1,56 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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; + +import org.junit.jupiter.api.Test; +import org.springdoc.core.utils.Constants; + +import org.springframework.boot.test.context.SpringBootTest; +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; + +@SpringBootTest +public abstract class AbstractSpringDocTest extends AbstractCommonTest { + + public static String className; + + @Test + protected void testApp() throws Exception { + className = getClass().getSimpleName(); + String testNumber = className.replaceAll("[^0-9]", ""); + MvcResult mockMvcResult = mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL)).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 + ".json"); + assertEquals(expected, result, true); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app128/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app128/HelloController.java new file mode 100644 index 000000000..a60a93147 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app128/HelloController.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app128; + + +import org.springframework.boot.actuate.endpoint.web.annotation.RestControllerEndpoint; +import org.springframework.stereotype.Component; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; + +@RestControllerEndpoint(id = "tenant") +@Component +public class HelloController { + + @GetMapping("/customer/{id}") + public String getTenantById(@PathVariable("id") String customerId) { + return "Tenant_" + customerId; + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app128/SpringDocApp128Test.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app128/SpringDocApp128Test.java new file mode 100644 index 000000000..9f186b54f --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app128/SpringDocApp128Test.java @@ -0,0 +1,68 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app128; + +import org.junit.jupiter.api.Test; +import org.springdoc.core.utils.Constants; +import org.springdoc.core.utils.SpringDocUtils; +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController; +import org.springframework.test.context.TestPropertySource; + +import static org.hamcrest.Matchers.containsString; +import static org.hamcrest.Matchers.is; +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; + + +/** + * Tests Spring meta-annotations as method parameters + */ +@TestPropertySource(properties = { "springdoc.show-actuator=true", + "management.endpoints.enabled-by-default=true", + "management.endpoints.web.exposure.include = tenant" }) +public class SpringDocApp128Test extends AbstractSpringDocTest { + + static { + SpringDocUtils.getConfig().addHiddenRestControllers(BasicErrorController.class); + } + + @Test + protected void testApp() throws Exception { + mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL)).andExpect(status().isOk()) + .andExpect(jsonPath("$.openapi", is("3.1.0"))) + .andExpect(jsonPath("$.paths./actuator/tenant/customer/{id}.get.operationId", containsString("getTenantById"))) + .andExpect(jsonPath("$.paths./actuator/tenant/customer/{id}.get.parameters[0].in", is("path"))) + .andExpect(jsonPath("$.paths./actuator/tenant/customer/{id}.get.parameters[0].name", is("id"))); + } + + @SpringBootApplication + static class SpringDocTestApp {} + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app144/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app144/HelloController.java new file mode 100644 index 000000000..6fea3caac --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app144/HelloController.java @@ -0,0 +1,32 @@ +/* + * + * * Copyright 2019-2020 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.app144; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class HelloController { + + @GetMapping("/persons") + public String persons() { + return "OK"; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app144/SpringDocApp144Test.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app144/SpringDocApp144Test.java new file mode 100644 index 000000000..19c78b23e --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app144/SpringDocApp144Test.java @@ -0,0 +1,58 @@ +/* + * + * * Copyright 2019-2020 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.app144; + +import org.junit.jupiter.api.Test; +import org.springdoc.core.utils.Constants; +import test.org.springdoc.api.v31.AbstractSpringDocActuatorTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; + +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.status; + + +@SpringBootTest(webEnvironment = WebEnvironment.DEFINED_PORT, + properties = { "management.endpoints.web.exposure.include=*", + "server.port=53554", + "springdoc.use-management-port=true", + "management.server.port=9390", + "management.endpoints.web.base-path=/application" }) +public class SpringDocApp144Test extends AbstractSpringDocActuatorTest { + + @Test + void testApp() throws Exception { + mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL)) + .andExpect(status().isNotFound()); + } + + @Test + void testApp1() throws Exception { + String result = actuatorRestTemplate.getForObject("/application/openapi", String.class); + String expected = getContent("results/3.1.0/app144.json"); + assertEquals(expected, result, true); + } + + @SpringBootApplication + static class SpringDocTestApp {} + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app145/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app145/HelloController.java new file mode 100644 index 000000000..62cafda2f --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app145/HelloController.java @@ -0,0 +1,32 @@ +/* + * + * * Copyright 2019-2020 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.app145; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class HelloController { + + @GetMapping("/persons") + public String persons() { + return "OK"; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app145/SpringDocApp145Test.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app145/SpringDocApp145Test.java new file mode 100644 index 000000000..a2b9b22f1 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app145/SpringDocApp145Test.java @@ -0,0 +1,90 @@ +/* + * + * * 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.app145; + +import org.junit.jupiter.api.Test; +import org.springdoc.core.utils.Constants; +import test.org.springdoc.api.v31.AbstractSpringDocActuatorTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; +import org.springframework.http.HttpStatus; +import org.springframework.web.client.HttpClientErrorException; +import org.springframework.web.client.HttpStatusCodeException; + +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; +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.status; + + +@SpringBootTest(webEnvironment = WebEnvironment.DEFINED_PORT, + properties = { "management.endpoints.web.exposure.include=*", + "server.port=52556", + "springdoc.use-management-port=true", + "springdoc.group-configs[0].group=users", + "springdoc.group-configs[0].packages-to-scan=test.org.springdoc.api.v31.app145", + "management.server.port=9291", + "management.endpoints.web.base-path=/application" }) +public class SpringDocApp145Test extends AbstractSpringDocActuatorTest { + + @Test + void testApp() throws Exception { + mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL + "/users")) + .andExpect(status().isNotFound()); + } + + @Test + void testApp1() throws Exception { + try { + actuatorRestTemplate.getForObject("/application/openapi", String.class); + fail(); + } + catch (HttpClientErrorException ex) { + if (ex.getStatusCode() == HttpStatus.NOT_FOUND) + assertTrue(true); + else + fail(); + } + } + + @Test + void testApp2() throws Exception { + String result = actuatorRestTemplate.getForObject("/application/openapi/users", String.class); + String expected = getContent("results/3.1.0/app145.json"); + assertEquals(expected, result, true); + } + + @Test + void testApp3() throws Exception { + try { + actuatorRestTemplate.getForObject("/application/openapi" + "/" + Constants.DEFAULT_GROUP_NAME, String.class); + fail(); + } + catch (HttpStatusCodeException ex) { + if (ex.getStatusCode() == HttpStatus.NOT_FOUND) + assertTrue(true); + } + } + + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app147/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app147/HelloController.java new file mode 100644 index 000000000..816625454 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app147/HelloController.java @@ -0,0 +1,44 @@ +/* + * + * * Copyright 2019-2020 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.app147; + + +import org.springdoc.core.models.GroupedOpenApi; + +import org.springframework.context.annotation.Bean; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class HelloController { + + @GetMapping("/persons") + public String persons() { + return "OK"; + } + + @Bean + public GroupedOpenApi userOpenApi() { + return GroupedOpenApi.builder() + .group("users") + .packagesToScan("test.org.springdoc.api.v31.app147") + .build(); + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app147/SpringDocApp147Test.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app147/SpringDocApp147Test.java new file mode 100644 index 000000000..5fa24acca --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app147/SpringDocApp147Test.java @@ -0,0 +1,70 @@ +/* + * + * * 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.app147; + +import org.junit.jupiter.api.Test; +import org.springdoc.core.utils.Constants; +import test.org.springdoc.api.v31.AbstractSpringDocActuatorTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.test.context.SpringBootTest; + +import static org.hamcrest.Matchers.is; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + + +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, + properties = { "management.endpoints.web.exposure.include=*", + "springdoc.show-actuator=true", + "management.server.port=9387", + "management.endpoints.web.exposure.exclude=functions, shutdown", + "server.servlet.context-path=/sample", + "management.server.base-path=/test", + "management.endpoints.web.base-path=/application" }) +public class SpringDocApp147Test extends AbstractSpringDocActuatorTest { + + @Test + void testApp() throws Exception { + mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL + "/" + Constants.ACTUATOR_DEFAULT_GROUP)) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.openapi", is("3.1.0"))) + .andExpect(content().json(getContent("results/3.1.0/app147-1.json"), true)); + } + + @Test + void testApp1() throws Exception { + mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL + "/users")) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.openapi", is("3.1.0"))) + .andExpect(content().json(getContent("results/3.1.0/app147-2.json"), true)); + } + + @Test + void testApp2() throws Exception { + mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL + "/" + Constants.DEFAULT_GROUP_NAME)) + .andExpect(status().isNotFound()); + } + + @SpringBootApplication + static class SpringDocTestApp {} + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app148/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app148/HelloController.java new file mode 100644 index 000000000..1b6912bc3 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app148/HelloController.java @@ -0,0 +1,44 @@ +/* + * + * * Copyright 2019-2020 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.app148; + + +import org.springdoc.core.models.GroupedOpenApi; + +import org.springframework.context.annotation.Bean; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class HelloController { + + @GetMapping("/persons") + public String persons() { + return "OK"; + } + + @Bean + public GroupedOpenApi userOpenApi() { + return GroupedOpenApi.builder() + .group("users") + .packagesToScan("test.org.springdoc.api.v31.app148") + .build(); + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app148/SpringDocApp148Test.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app148/SpringDocApp148Test.java new file mode 100644 index 000000000..740c1951f --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app148/SpringDocApp148Test.java @@ -0,0 +1,73 @@ +/* + * + * * 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.app148; + +import org.junit.jupiter.api.Test; +import org.springdoc.core.utils.Constants; +import test.org.springdoc.api.v31.AbstractSpringDocActuatorTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; +import org.springframework.http.HttpStatus; +import org.springframework.web.client.HttpStatusCodeException; + +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; + + +@SpringBootTest(webEnvironment = WebEnvironment.DEFINED_PORT, + properties = { "management.endpoints.web.exposure.include=*", + "springdoc.show-actuator=true", + "management.server.port=9398", + "server.port=6376", + "server.servlet.context-path=/toto", + "springdoc.use-management-port=true", + "spring.mvc.servlet.path=/titi", + "management.endpoints.web.exposure.exclude=functions, shutdown", + "management.server.base-path=/test", + "management.endpoints.web.base-path=/application" }) +public class SpringDocApp148Test extends AbstractSpringDocActuatorTest { + + @Test + void testApp() throws Exception { + super.testWithRestTemplate("148-1","/test/application/openapi/users"); + } + + @Test + void testApp2() throws Exception { + super.testWithRestTemplate("148-2","/test/application/openapi/x-actuator"); + } + + @Test + void testApp3() throws Exception { + try { + actuatorRestTemplate.getForObject("/test/application/openapi" + "/" + Constants.DEFAULT_GROUP_NAME, String.class); + fail(); + } + catch (HttpStatusCodeException ex) { + if (ex.getStatusCode() == HttpStatus.NOT_FOUND) + assertTrue(true); + } + } + + @SpringBootApplication + static class SpringDocTestApp {} + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app186/SpringDocApp186Test.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app186/SpringDocApp186Test.java new file mode 100644 index 000000000..b8204437f --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app186/SpringDocApp186Test.java @@ -0,0 +1,106 @@ +/* + * + * * + * * * + * * * * + * * * * * 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.app186; + +import org.junit.jupiter.api.Test; +import org.springdoc.core.customizers.OperationCustomizer; +import org.springdoc.core.models.GroupedOpenApi; +import org.springdoc.core.utils.Constants; +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.actuate.autoconfigure.endpoint.web.WebEndpointProperties; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; +import org.springframework.test.context.TestPropertySource; + +import static org.hamcrest.Matchers.is; +import static org.springdoc.core.utils.Constants.ALL_PATTERN; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + +@TestPropertySource(properties = { "springdoc.show-actuator=true", + "springdoc.group-configs[0].group=group-actuator-as-properties", + "springdoc.group-configs[0].paths-to-match=${management.endpoints.web.base-path:/actuator}/**", + "management.endpoints.enabled-by-default=true", + "management.endpoints.web.exposure.include=*", + "management.endpoints.web.exposure.exclude=functions, shutdown" }) +public class SpringDocApp186Test extends AbstractSpringDocTest { + + @Test + protected void testApp() throws Exception { + mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL)) + .andExpect(jsonPath("$.openapi", is("3.1.0"))) + .andExpect(status().isOk()) + .andExpect(content().json(getContent("results/3.1.0/app186.json"), true)); + } + + @Test + void testGroupActuatorAsCodeCheckBackwardsCompatibility() throws Exception { + mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL + "/group-actuator-as-code-check-backwards-compatibility")) + .andExpect(jsonPath("$.openapi", is("3.1.0"))) + .andExpect(status().isOk()) + .andExpect(content().json(getContent("results/3.1.0/app186.json"), true)); + } + + @Test + void testGroupActuatorAsCode() throws Exception { + mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL + "/group-actuator-as-code")) + .andExpect(jsonPath("$.openapi", is("3.1.0"))) + .andExpect(status().isOk()) + .andExpect(content().json(getContent("results/3.1.0/app186.json"), true)); + } + + @Test + void testGroupActuatorAsProperties() throws Exception { + mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL + "/group-actuator-as-properties")) + .andExpect(jsonPath("$.openapi", is("3.1.0"))) + .andExpect(status().isOk()) + .andExpect(content().json(getContent("results/3.1.0/app186.json"), true)); + } + + @SpringBootApplication + static class SpringDocTestApp { + + @Bean + public GroupedOpenApi asCodeCheckBackwardsCompatibility(OperationCustomizer actuatorCustomizer, WebEndpointProperties endpointProperties) { + return GroupedOpenApi.builder() + .group("group-actuator-as-code-check-backwards-compatibility") + .pathsToMatch(endpointProperties.getBasePath() + ALL_PATTERN) + .addOperationCustomizer(actuatorCustomizer) + .build(); + } + + @Bean + public GroupedOpenApi asCode(WebEndpointProperties endpointProperties) { + return GroupedOpenApi.builder() + .group("group-actuator-as-code") + .pathsToMatch(endpointProperties.getBasePath() + ALL_PATTERN) + .build(); + } + } + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app36/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app36/HelloController.java new file mode 100644 index 000000000..b44dd6ba2 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app36/HelloController.java @@ -0,0 +1,40 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app36; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class HelloController { + + @GetMapping("/persons") + public String persons() { + return "OK"; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app36/SpringDocApp36Test.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app36/SpringDocApp36Test.java new file mode 100644 index 000000000..4ea433bf2 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app36/SpringDocApp36Test.java @@ -0,0 +1,60 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app36; + +import org.junit.jupiter.api.Test; +import org.springdoc.core.utils.Constants; +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.test.context.TestPropertySource; + +import static org.hamcrest.Matchers.containsString; +import static org.hamcrest.Matchers.is; +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.show-actuator=true", "management.endpoints.enabled-by-default=true", + "management.endpoints.web.exposure.include=*" }) +public class SpringDocApp36Test extends AbstractSpringDocTest { + + @Test + protected void testApp() throws Exception { + mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL)).andExpect(status().isOk()) + .andExpect(jsonPath("$.openapi", is("3.1.0"))) + .andExpect(jsonPath("$.paths./actuator/info.get.operationId", containsString("info"))) + .andExpect(jsonPath("$.paths./actuator/health.get.operationId", containsString("health"))) + .andExpect(jsonPath("$.paths./actuator/metrics/{requiredMetricName}.get.parameters[0].in", is("path"))) + .andExpect(jsonPath("$.paths./actuator/metrics/{requiredMetricName}.get.parameters[0].name", is("requiredMetricName"))); + } + + @SpringBootApplication + static class SpringDocTestApp {} + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app68/CustomizedOperation.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app68/CustomizedOperation.java new file mode 100644 index 000000000..79d64bb21 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app68/CustomizedOperation.java @@ -0,0 +1,35 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app68; + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + +@Retention(RetentionPolicy.RUNTIME) +public @interface CustomizedOperation { + String addition() default "customized operation!"; +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app68/SpringDocApp68Test.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app68/SpringDocApp68Test.java new file mode 100644 index 000000000..0c45fcf17 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app68/SpringDocApp68Test.java @@ -0,0 +1,105 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app68; + +import org.hamcrest.Matchers; +import org.junit.jupiter.api.Test; +import org.springdoc.core.utils.Constants; +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.test.context.TestPropertySource; + +import static org.hamcrest.Matchers.contains; +import static org.hamcrest.Matchers.containsString; +import static org.hamcrest.Matchers.hasSize; +import static org.hamcrest.Matchers.is; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + +@TestPropertySource(properties = { "management.endpoints.enabled-by-default=true", "springdoc.show-actuator=true" }) +public class SpringDocApp68Test extends AbstractSpringDocTest { + + + @Test + protected void testApp() throws Exception { + mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL + "/stores")) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.openapi", is("3.1.0"))) + .andExpect(content().json(getContent("results/3.1.0/app68-1.json"), true)); + } + + @Test + void testApp2() throws Exception { + mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL + "/users")) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.openapi", is("3.1.0"))) + .andExpect(content().json(getContent("results/3.1.0/app68-2.json"), true)); + } + + @Test + void testApp3() throws Exception { + mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL + "/pets")) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.openapi", is("3.1.0"))) + .andExpect(content().json(getContent("results/3.1.0/app68-3.json"), true)); + } + + @Test + void testApp4() throws Exception { + mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL + "/groups test")) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.openapi", is("3.1.0"))) + .andExpect(content().json(getContent("results/3.1.0/app68-4.json"), true)); + } + + @Test + void testActuator() throws Exception { + mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL)).andExpect(status().isOk()) + .andExpect(jsonPath("$.openapi", is("3.1.0"))) + .andExpect(jsonPath("$.paths./actuator/health.get.summary", Matchers.is("Actuator web endpoint 'health'"))) + .andExpect(jsonPath("$.paths./actuator/health.get.operationId", containsString("health"))); + } + + @Test + void testActuatorDescription() throws Exception { + mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL)).andExpect(status().isOk()) + .andExpect(jsonPath("$.openapi", is("3.1.0"))) + .andExpect(jsonPath("$.tags", hasSize(4))) + .andExpect(jsonPath("$.tags[?(@.name == '" + Constants.SPRINGDOC_ACTUATOR_TAG + "')].name", contains(Constants.SPRINGDOC_ACTUATOR_TAG))) + .andExpect(jsonPath("$.tags[?(@.name == '" + Constants.SPRINGDOC_ACTUATOR_TAG + "')].description", contains(Constants.SPRINGDOC_ACTUATOR_DESCRIPTION))) + .andExpect(jsonPath("$.tags[?(@.name == '" + Constants.SPRINGDOC_ACTUATOR_TAG + "')].externalDocs.description", contains(Constants.SPRINGDOC_ACTUATOR_DOC_DESCRIPTION))) + .andExpect(jsonPath("$.tags[?(@.name == '" + Constants.SPRINGDOC_ACTUATOR_TAG + "')].externalDocs.url", contains(Constants.SPRINGDOC_ACTUATOR_DOC_URL))); + } + + @Test + void testApp5() throws Exception { + mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL + "/user")) + .andExpect(status().isNotFound()); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app68/SpringDocConfiguration.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app68/SpringDocConfiguration.java new file mode 100644 index 000000000..8265a1f94 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app68/SpringDocConfiguration.java @@ -0,0 +1,125 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app68; + +import java.util.ArrayList; +import java.util.List; + +import io.swagger.v3.oas.models.Components; +import io.swagger.v3.oas.models.OpenAPI; +import io.swagger.v3.oas.models.Operation; +import io.swagger.v3.oas.models.info.Info; +import io.swagger.v3.oas.models.info.License; +import io.swagger.v3.oas.models.security.SecurityScheme; +import io.swagger.v3.oas.models.servers.Server; +import org.apache.commons.lang3.StringUtils; +import org.springdoc.core.customizers.OpenApiCustomizer; +import org.springdoc.core.customizers.OperationCustomizer; +import org.springdoc.core.models.GroupedOpenApi; +import org.springdoc.core.utils.Constants; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.method.HandlerMethod; + +@Configuration +public class SpringDocConfiguration { + + @SpringBootApplication + static class SpringDocTestApp {} + + @Bean + public GroupedOpenApi storeOpenApi() { + return GroupedOpenApi.builder() + .group("stores") + .pathsToMatch("/store/**") + .build(); + } + + @Bean + public GroupedOpenApi userOpenApi() { + return GroupedOpenApi.builder() + .group("users") + .packagesToScan("test.org.springdoc.api.v31.app68.api.user").addOpenApiCustomizer(serverOpenApiCustomizer1()) + .addOperationCustomizer(operationCustomizer()) + .build(); + } + + public OpenApiCustomizer serverOpenApiCustomizer1() { + Server server = new Server().url("http://toto.v1.com").description("myserver1"); + List servers = new ArrayList<>(); + servers.add(server); + return openApi -> openApi.setServers(servers); + } + + public OpenApiCustomizer serverOpenApiCustomizer2() { + Server server = new Server().url("http://toto.v2.com").description("myserver2"); + List servers = new ArrayList<>(); + servers.add(server); + return openApi -> openApi.setServers(servers); + } + + OperationCustomizer operationCustomizer() { + return (Operation operation, HandlerMethod handlerMethod) -> { + CustomizedOperation annotation = handlerMethod.getMethodAnnotation(CustomizedOperation.class); + if (annotation != null) { + operation.description(StringUtils.defaultIfBlank(operation.getDescription(), Constants.DEFAULT_DESCRIPTION) + ", " + annotation.addition()); + } + return operation; + }; + } + + @Bean + public GroupedOpenApi petOpenApi() { + return GroupedOpenApi.builder() + .group("pets") + .pathsToMatch("/pet/**").addOpenApiCustomizer(serverOpenApiCustomizer2()) + .build(); + } + + @Bean + public GroupedOpenApi groupOpenApi() { + return GroupedOpenApi.builder() + .group("groups test") + .pathsToMatch("/v1/**").pathsToExclude("/v1/users") + .packagesToScan("test.org.springdoc.api.v31.app68.api.user", "test.org.springdoc.api.v31.app68.api.store") + .build(); + } + + + @Bean + public OpenAPI customOpenAPI() { + return new OpenAPI() + .components(new Components().addSecuritySchemes("basicScheme", + new SecurityScheme().type(SecurityScheme.Type.HTTP).scheme("basic"))) + .info(new Info().title("Petstore API").version("v0").description( + "This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.") + .termsOfService("http://swagger.io/terms/") + .license(new License().name("Apache 2.0").url("http://springdoc.org"))); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app68/api/ApiUtil.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app68/api/ApiUtil.java new file mode 100644 index 000000000..a225320c3 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app68/api/ApiUtil.java @@ -0,0 +1,54 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app68.api; + +import java.io.IOException; + +import jakarta.servlet.http.HttpServletResponse; + +import org.springframework.http.HttpStatus; +import org.springframework.web.context.request.NativeWebRequest; +import org.springframework.web.server.ResponseStatusException; + +public class ApiUtil { + + public static void setExampleResponse(NativeWebRequest req, String contentType, String example) { + try { + req.getNativeResponse(HttpServletResponse.class).addHeader("Content-Type", contentType); + req.getNativeResponse(HttpServletResponse.class).getOutputStream().print(example); + } + catch (IOException e) { + throw new RuntimeException(e); + } + } + + public static void checkApiKey(NativeWebRequest req) { + if (!"1".equals(System.getenv("DISABLE_API_KEY")) && !"special-key".equals(req.getHeader("api_key"))) { + throw new ResponseStatusException(HttpStatus.UNAUTHORIZED, "Missing API key!"); + } + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app68/api/ExceptionTranslator.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app68/api/ExceptionTranslator.java new file mode 100644 index 000000000..0d9c3513b --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app68/api/ExceptionTranslator.java @@ -0,0 +1,57 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app68.api; + +import java.util.Map; + +import jakarta.validation.ConstraintViolationException; + +import org.springframework.boot.web.error.ErrorAttributeOptions; +import org.springframework.boot.web.servlet.error.ErrorAttributes; +import org.springframework.http.HttpStatus; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.ResponseStatus; +import org.springframework.web.bind.annotation.RestControllerAdvice; +import org.springframework.web.context.request.RequestAttributes; +import org.springframework.web.context.request.WebRequest; + +@RestControllerAdvice +public class ExceptionTranslator { + + private final ErrorAttributes errorAttributes; + + public ExceptionTranslator(ErrorAttributes errorAttributes) { + this.errorAttributes = errorAttributes; + } + + @ExceptionHandler(ConstraintViolationException.class) + @ResponseStatus(HttpStatus.BAD_REQUEST) + public Map processConstraintViolationException(WebRequest request) { + request.setAttribute("jakarta.servlet.error.status_code", HttpStatus.BAD_REQUEST.value(), RequestAttributes.SCOPE_REQUEST); + return errorAttributes.getErrorAttributes(request, ErrorAttributeOptions.defaults()); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app68/api/HomeController.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app68/api/HomeController.java new file mode 100644 index 000000000..911050848 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app68/api/HomeController.java @@ -0,0 +1,50 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app68.api; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.GetMapping; + +import static org.springdoc.core.utils.Constants.SWAGGER_UI_PATH; +import static org.springframework.util.AntPathMatcher.DEFAULT_PATH_SEPARATOR; +import static org.springframework.web.servlet.view.UrlBasedViewResolver.REDIRECT_URL_PREFIX; + +/** + * Home redirection to swagger api documentation + */ +@Controller +public class HomeController { + + @Value(SWAGGER_UI_PATH) + private String swaggerUiPath; + + @GetMapping(DEFAULT_PATH_SEPARATOR) + public String index() { + return REDIRECT_URL_PREFIX + swaggerUiPath; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app68/api/pet/PetApi.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app68/api/pet/PetApi.java new file mode 100644 index 000000000..40ef935aa --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app68/api/pet/PetApi.java @@ -0,0 +1,169 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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. + * * * * * + * * * * + * * * + * * + * + */ + +/** + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (3.0.0). + * https://openapi-generator.tech + * Do not edit the class manually. + */ +package test.org.springdoc.api.v31.app68.api.pet; + +import java.util.List; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.enums.SecuritySchemeType; +import io.swagger.v3.oas.annotations.media.ArraySchema; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; +import io.swagger.v3.oas.annotations.security.OAuthFlow; +import io.swagger.v3.oas.annotations.security.OAuthFlows; +import io.swagger.v3.oas.annotations.security.OAuthScope; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.security.SecurityScheme; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.validation.Valid; +import jakarta.validation.constraints.NotNull; +import test.org.springdoc.api.v31.app68.model.ModelApiResponse; +import test.org.springdoc.api.v31.app68.model.Pet; + +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestHeader; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.multipart.MultipartFile; + +@SecurityScheme(name = "petstore_auth", type = SecuritySchemeType.OAUTH2, flows = @OAuthFlows(implicit = @OAuthFlow(authorizationUrl = "http://petstore.swagger.io/oauth/dialog", scopes = { + @OAuthScope(name = "write:pets", description = "modify pets in your account"), + @OAuthScope(name = "read:pets", description = "read your pets") }))) +@Tag(name = "pet", description = "the pet API") +@ResponseBody +public interface PetApi { + + default PetApiDelegate getDelegate() { + return new PetApiDelegate() { + }; + } + + @Operation(summary = "Add a new pet to the store", description = "", security = { + @SecurityRequirement(name = "petstore_auth", scopes = { "write:pets", "read:pets" }) }, tags = { "pet" }) + @ApiResponses(value = { @ApiResponse(responseCode = "405", description = "Invalid input") }) + @PostMapping(value = "/pet", consumes = { "application/json", "application/xml" }) + default void addPet( + @io.swagger.v3.oas.annotations.parameters.RequestBody(description = "Pet object that needs to be added to the store", required = true) @Valid @RequestBody Pet pet) { + // return getDelegate().addPet(pet); + } + + @Operation(summary = "Deletes a pet", description = "", security = { + @SecurityRequirement(name = "petstore_auth", scopes = { "write:pets", "read:pets" }) }, tags = { "pet" }) + @ApiResponses(value = { @ApiResponse(responseCode = "400", description = "Invalid ID supplied"), + @ApiResponse(responseCode = "404", description = "Pet not found") }) + @DeleteMapping(value = "/pet/{petId}") + default ResponseEntity deletePet( + @Parameter(description = "Pet id to delete", required = true) @PathVariable("petId") Long petId, + @Parameter(description = "") @RequestHeader(value = "api_key", required = false) String apiKey) { + return getDelegate().deletePet(petId, apiKey); + } + + @Operation(summary = "Finds Pets by status", description = "Multiple status values can be provided with comma separated strings", security = { + @SecurityRequirement(name = "petstore_auth", scopes = { "write:pets", "read:pets" }) }, tags = { "pet" }) + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(array = @ArraySchema(schema = @Schema(implementation = Pet.class)))), + @ApiResponse(responseCode = "400", description = "Invalid status value") }) + @GetMapping(value = "/pet/findByStatus", produces = { "application/xml", "application/json" }) + default ResponseEntity> findPetsByStatus( + @NotNull @Parameter(description = "Status values that need to be considered for filter", required = true) @Valid @RequestParam(value = "status", required = true) List status) { + return getDelegate().findPetsByStatus(status); + } + + @Operation(summary = "Finds Pets by tags", description = "Muliple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.", security = { + @SecurityRequirement(name = "petstore_auth", scopes = { "write:pets", "read:pets" }) }, tags = { "pet" }) + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(array = @ArraySchema(schema = @Schema(implementation = Pet.class)))), + @ApiResponse(responseCode = "400", description = "Invalid tag value") }) + @GetMapping(value = "/pet/findByTags", produces = { "application/xml", "application/json" }) + default ResponseEntity> findPetsByTags( + @NotNull @Parameter(description = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) List tags) { + return getDelegate().findPetsByTags(tags); + } + + @Operation(summary = "Find pet by ID", description = "Returns a single pet", security = { + @SecurityRequirement(name = "api_key") }, tags = { "pet" }) + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(schema = @Schema(implementation = Pet.class))), + @ApiResponse(responseCode = "400", description = "Invalid ID supplied"), + @ApiResponse(responseCode = "404", description = "Pet not found") }) + @GetMapping(value = "/pet/{petId}", produces = { "application/xml", "application/json" }) + default ResponseEntity getPetById( + @Parameter(description = "ID of pet to return", required = true) @PathVariable("petId") Long petId) { + return getDelegate().getPetById(petId); + } + + @Operation(summary = "Update an existing pet", description = "", security = { + @SecurityRequirement(name = "petstore_auth", scopes = { "write:pets", "read:pets" }) }, tags = { "pet" }) + @ApiResponses(value = { @ApiResponse(responseCode = "400", description = "Invalid ID supplied"), + @ApiResponse(responseCode = "404", description = "Pet not found"), + @ApiResponse(responseCode = "405", description = "Validation exception") }) + @PutMapping(value = "/pet", consumes = { "application/json", "application/xml" }) + default ResponseEntity updatePet( + @io.swagger.v3.oas.annotations.parameters.RequestBody(description = "Pet object that needs to be added to the store", required = true) @Valid @RequestBody Pet pet) { + return getDelegate().updatePet(pet); + } + + @Operation(summary = "Updates a pet in the store with form data", description = "", security = { + @SecurityRequirement(name = "petstore_auth", scopes = { "write:pets", "read:pets" }) }, tags = { "pet" }) + @ApiResponses(value = { @ApiResponse(responseCode = "405", description = "Invalid input") }) + @PostMapping(value = "/pet/{petId}", consumes = { "application/x-www-form-urlencoded" }) + default ResponseEntity updatePetWithForm( + @Parameter(description = "ID of pet that needs to be updated", required = true) @PathVariable("petId") Long petId, + @Parameter(description = "Updated name of the pet") @RequestParam(value = "name", required = false) String name, + @Parameter(description = "Updated status of the pet") @RequestParam(value = "status", required = false) String status) { + return getDelegate().updatePetWithForm(petId, name, status); + } + + @Operation(summary = "uploads an image", description = "", security = { + @SecurityRequirement(name = "petstore_auth", scopes = { "write:pets", "read:pets" }) }, tags = { "pet" }) + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(schema = @Schema(implementation = ModelApiResponse.class))) }) + @PostMapping(value = "/pet/{petId}/uploadImage", produces = { "application/json" }, consumes = { + "multipart/form-data" }) + default ResponseEntity uploadFile( + @Parameter(description = "ID of pet to update", required = true) @PathVariable("petId") Long petId, + @Parameter(description = "Additional data to pass to server") @RequestParam(value = "additionalMetadata", required = false) String additionalMetadata, + @Parameter(description = "file detail") @Valid @RequestPart("file") MultipartFile file) { + return getDelegate().uploadFile(petId, additionalMetadata, file); + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app68/api/pet/PetApiController.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app68/api/pet/PetApiController.java new file mode 100644 index 000000000..7a5089d2c --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app68/api/pet/PetApiController.java @@ -0,0 +1,52 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app68.api.pet; + +import java.util.Optional; + +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@jakarta.annotation.Generated(value = "org.springdoc.demo.app2.codegen.languages.SpringCodegen", date = "2019-07-11T00:09:29.839+02:00[Europe/Paris]") + +@RestController +@RequestMapping("${openapi.openAPIPetstore.base-path:/}") +public class PetApiController implements PetApi { + + private final PetApiDelegate delegate; + + public PetApiController(@org.springframework.beans.factory.annotation.Autowired(required = false) PetApiDelegate delegate) { + this.delegate = Optional.ofNullable(delegate).orElse(new PetApiDelegate() { + }); + } + + @Override + public PetApiDelegate getDelegate() { + return delegate; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app68/api/pet/PetApiDelegate.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app68/api/pet/PetApiDelegate.java new file mode 100644 index 000000000..665775682 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app68/api/pet/PetApiDelegate.java @@ -0,0 +1,149 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app68.api.pet; + +import java.util.List; +import java.util.Optional; + +import jakarta.validation.Valid; +import test.org.springdoc.api.v31.app68.api.ApiUtil; +import test.org.springdoc.api.v31.app68.model.ModelApiResponse; +import test.org.springdoc.api.v31.app68.model.Pet; + +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.web.context.request.NativeWebRequest; +import org.springframework.web.multipart.MultipartFile; + +/** + * A delegate to be called by the {@link PetApiController}}. + * Implement this interface with a {@link org.springframework.stereotype.Service} annotated class. + */ +@jakarta.annotation.Generated(value = "org.springdoc.demo.app2.codegen.languages.SpringCodegen", date = "2019-07-11T00:09:29.839+02:00[Europe/Paris]") + +public interface PetApiDelegate { + + default Optional getRequest() { + return Optional.empty(); + } + + /** + * @see PetApi#addPet + */ + default void addPet(Pet pet) { + + } + + /** + * @see PetApi#deletePet + */ + default ResponseEntity deletePet(Long petId, + String apiKey) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * @see PetApi#findPetsByStatus + */ + default ResponseEntity> findPetsByStatus(List status) { + extract(); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + default void extract() { + getRequest().ifPresent(request -> { + for (MediaType mediaType : MediaType.parseMediaTypes(request.getHeader("Accept"))) { + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + ApiUtil.setExampleResponse(request, "application/json", "{ \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\"}"); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/xml"))) { + ApiUtil.setExampleResponse(request, "application/xml", " 123456789 doggie aeiou aeiou"); + break; + } + } + }); + } + + /** + * @see PetApi#findPetsByTags + */ + default ResponseEntity> findPetsByTags(List tags) { + extract(); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * @see PetApi#getPetById + */ + default ResponseEntity getPetById(Long petId) { + extract(); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * @see PetApi#updatePet + */ + default ResponseEntity updatePet(Pet pet) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * @see PetApi#updatePetWithForm + */ + default ResponseEntity updatePetWithForm(Long petId, + String name, + String status) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * @see PetApi#uploadFile + */ + default ResponseEntity uploadFile(Long petId, + String additionalMetadata, + @Valid MultipartFile file) { + getRequest().ifPresent(request -> { + for (MediaType mediaType : MediaType.parseMediaTypes(request.getHeader("Accept"))) { + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + ApiUtil.setExampleResponse(request, "application/json", "{ \"code\" : 0, \"type\" : \"type\", \"message\" : \"message\"}"); + break; + } + } + }); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app68/api/pet/PetApiDelegateImpl.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app68/api/pet/PetApiDelegateImpl.java new file mode 100644 index 000000000..24d1da938 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app68/api/pet/PetApiDelegateImpl.java @@ -0,0 +1,35 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app68.api.pet; + +import org.springframework.stereotype.Service; + +@Service +public class PetApiDelegateImpl implements PetApiDelegate { + + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app68/api/store/StoreApi.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app68/api/store/StoreApi.java new file mode 100644 index 000000000..9c89eec98 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app68/api/store/StoreApi.java @@ -0,0 +1,112 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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. + * * * * * + * * * * + * * * + * * + * + */ + +/** + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (3.0.0). + * https://openapi-generator.tech + * Do not edit the class manually. + */ +package test.org.springdoc.api.v31.app68.api.store; + +import java.util.Map; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.media.ArraySchema; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.validation.Valid; +import jakarta.validation.constraints.Max; +import jakarta.validation.constraints.Min; +import jakarta.validation.constraints.NotBlank; +import test.org.springdoc.api.v31.app68.model.Order; + +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; + +@jakarta.annotation.Generated(value = "org.springdoc.demo.app2.codegen.languages.SpringCodegen", date = "2019-07-11T00:09:29.839+02:00[Europe/Paris]") + +@Tag(name = "store", description = "the store API") +public interface StoreApi { + + default StoreApiDelegate getDelegate() { + return new StoreApiDelegate() { + }; + } + + @Operation(summary = "Delete purchase order by ID", tags = { "store" }) + @ApiResponses(value = { @ApiResponse(responseCode = "400", description = "Invalid ID supplied"), + @ApiResponse(responseCode = "404", description = "Order not found") }) + @DeleteMapping(value = "/store/order/{orderId}") + default ResponseEntity deleteOrder( + @Parameter(description = "ID of the order that needs to be deleted", required = true) @PathVariable("orderId") String orderId) { + return getDelegate().deleteOrder(orderId); + } + + @Operation(summary = "Returns pet inventories by status", description = "Returns a map of status codes to quantities", security = { + @SecurityRequirement(name = "api_key") }, tags = { "store" }) + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(array = @ArraySchema(schema = @Schema(implementation = Map.class)))) }) + @GetMapping(value = "/store/inventory", produces = { "application/json" }) + default ResponseEntity> getInventory() { + return getDelegate().getInventory(); + } + + @Operation(summary = "Find purchase order by ID", tags = { "store" }) + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(schema = @Schema(implementation = Order.class))), + @ApiResponse(responseCode = "400", description = "Invalid ID supplied"), + @ApiResponse(responseCode = "404", description = "Order not found") }) + @GetMapping(value = "/store/order/{orderId}", produces = { "application/xml", "application/json" }) + default ResponseEntity getOrderById( + @Min(1L) @Max(5L) @Parameter(description = "ID of pet that needs to be fetched", required = true) @PathVariable("orderId") Long orderId) { + return getDelegate().getOrderById(orderId); + } + + @Operation(summary = "Place an order for a pet", tags = { "store" }) + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(schema = @Schema(implementation = Order.class))), + @ApiResponse(responseCode = "400", description = "Invalid Order") }) + @PostMapping(value = "/store/order", produces = { "application/xml", "application/json" }, consumes = { + "application/json" }) + default ResponseEntity placeOrder( + @Parameter(description = "order placed for purchasing the pet", required = true) @Valid @RequestBody Order order) { + return getDelegate().placeOrder(order); + } + + @GetMapping(value = "/v1/stores") + default void stores(@Valid @NotBlank String name) { + + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app68/api/store/StoreApiController.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app68/api/store/StoreApiController.java new file mode 100644 index 000000000..40929f9a6 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app68/api/store/StoreApiController.java @@ -0,0 +1,52 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app68.api.store; + +import java.util.Optional; + +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@jakarta.annotation.Generated(value = "org.springdoc.demo.app2.codegen.languages.SpringCodegen", date = "2019-07-11T00:09:29.839+02:00[Europe/Paris]") + +@RestController +@RequestMapping("${openapi.openAPIPetstore.base-path:/}") +public class StoreApiController implements StoreApi { + + private final StoreApiDelegate delegate; + + public StoreApiController(@org.springframework.beans.factory.annotation.Autowired(required = false) StoreApiDelegate delegate) { + this.delegate = Optional.ofNullable(delegate).orElse(new StoreApiDelegate() { + }); + } + + @Override + public StoreApiDelegate getDelegate() { + return delegate; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app68/api/store/StoreApiDelegate.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app68/api/store/StoreApiDelegate.java new file mode 100644 index 000000000..5d181918d --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app68/api/store/StoreApiDelegate.java @@ -0,0 +1,101 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app68.api.store; + +import java.util.Map; +import java.util.Optional; + +import test.org.springdoc.api.v31.app68.api.ApiUtil; +import test.org.springdoc.api.v31.app68.model.Order; + +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.web.context.request.NativeWebRequest; + +/** + * A delegate to be called by the {@link StoreApiController}}. + * Implement this interface with a {@link org.springframework.stereotype.Service} annotated class. + */ +@jakarta.annotation.Generated(value = "org.springdoc.demo.app2.codegen.languages.SpringCodegen", date = "2019-07-11T00:09:29.839+02:00[Europe/Paris]") + +public interface StoreApiDelegate { + + default Optional getRequest() { + return Optional.empty(); + } + + /** + * @see StoreApi#deleteOrder + */ + default ResponseEntity deleteOrder(String orderId) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * @see StoreApi#getInventory + */ + default ResponseEntity> getInventory() { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * @see StoreApi#getOrderById + */ + default ResponseEntity getOrderById(Long orderId) { + extract(); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + default void extract() { + getRequest().ifPresent(request -> { + for (MediaType mediaType : MediaType.parseMediaTypes(request.getHeader("Accept"))) { + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + ApiUtil.setExampleResponse(request, "application/json", "{ \"petId\" : 6, \"quantity\" : 1, \"id\" : 0, \"shipDate\" : \"2000-01-23T04:56:07.000+00:00\", \"complete\" : false, \"status\" : \"placed\"}"); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/xml"))) { + ApiUtil.setExampleResponse(request, "application/xml", " 123456789 123456789 123 2000-01-23T04:56:07.000Z aeiou true"); + break; + } + } + }); + } + + /** + * @see StoreApi#placeOrder + */ + default ResponseEntity placeOrder(Order order) { + extract(); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app68/api/store/StoreApiDelegateImpl.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app68/api/store/StoreApiDelegateImpl.java new file mode 100644 index 000000000..e2f1b8787 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app68/api/store/StoreApiDelegateImpl.java @@ -0,0 +1,35 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app68.api.store; + +import org.springframework.stereotype.Service; + +@Service +public class StoreApiDelegateImpl implements StoreApiDelegate { + + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app68/api/user/UserApi.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app68/api/user/UserApi.java new file mode 100644 index 000000000..b4eddbc31 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app68/api/user/UserApi.java @@ -0,0 +1,140 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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. + * * * * * + * * * * + * * * + * * + * + */ + +/** + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (3.0.0). + * https://openapi-generator.tech + * Do not edit the class manually. + */ +package test.org.springdoc.api.v31.app68.api.user; + +import java.util.List; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.validation.Valid; +import jakarta.validation.constraints.NotNull; +import test.org.springdoc.api.v31.app68.model.User; + +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestParam; + +@jakarta.annotation.Generated(value = "org.springdoc.demo.app2.codegen.languages.SpringCodegen", date = "2019-07-11T00:09:29.839+02:00[Europe/Paris]") + +@Tag(name = "user", description = "the user API") +public interface UserApi { + + default UserApiDelegate getDelegate() { + return new UserApiDelegate() { + }; + } + + @Operation(summary = "Create user", tags = { "user" }) + @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "successful operation") }) + @PostMapping(value = "/user", consumes = { "application/json" }) + default ResponseEntity createUser( + @io.swagger.v3.oas.annotations.parameters.RequestBody(description = "Created user object", required = true) @Valid @RequestBody User user) { + return getDelegate().createUser(user); + } + + @Operation(summary = "Creates list of users with given input array", tags = { "user" }) + @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "successful operation") }) + + @PostMapping(value = "/user/createWithArray", consumes = { "application/json" }) + default ResponseEntity createUsersWithArrayInput( + @io.swagger.v3.oas.annotations.parameters.RequestBody(description = "List of user object", required = true) @Valid @RequestBody List user) { + return getDelegate().createUsersWithArrayInput(user); + } + + @Operation(summary = "Creates list of users with given input array", tags = { "user" }) + @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "successful operation") }) + @PostMapping(value = "/user/createWithList", consumes = { "application/json" }) + default ResponseEntity createUsersWithListInput( + @io.swagger.v3.oas.annotations.parameters.RequestBody(description = "List of user object", required = true) @Valid @RequestBody List user) { + return getDelegate().createUsersWithListInput(user); + } + + @Operation(summary = "Creates list of users with given input array", tags = { "user" }) + @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "successful operation") }) + + @DeleteMapping(value = "/user/{username}") + default ResponseEntity deleteUser( + @io.swagger.v3.oas.annotations.parameters.RequestBody(description = "The name that needs to be deleted", required = true) @PathVariable("username") String username) { + return getDelegate().deleteUser(username); + } + + @Operation(summary = "Get user by user name", tags = { "user" }) + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(schema = @Schema(implementation = User.class))), + @ApiResponse(responseCode = "400", description = "Invalid username supplied"), + @ApiResponse(responseCode = "404", description = "User not found") }) + + @GetMapping(value = "/user/{username}", produces = { "application/xml", "application/json" }) + default ResponseEntity getUserByName( + @Parameter(description = "The name that needs to be fetched. Use user1 for testing.", required = true) @PathVariable("username") String username) { + return getDelegate().getUserByName(username); + } + + @Operation(summary = "Logs user into the system", tags = { "user" }) + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(schema = @Schema(implementation = String.class))), + @ApiResponse(responseCode = "400", description = "Invalid username/password supplied") }) + @GetMapping(value = "/user/login", produces = { "application/xml", "application/json" }) + default ResponseEntity loginUser( + @NotNull @Parameter(description = "The user name for login", required = true) @Valid @RequestParam(value = "username", required = true) String username, + @NotNull @Parameter(description = "The password for login in clear text", required = true) @Valid @RequestParam(value = "password", required = true) String password) { + return getDelegate().loginUser(username, password); + } + + @Operation(summary = "Logs out current logged in user session", tags = { "user" }) + @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "successful operation") }) + @GetMapping(value = "/user/logout") + default ResponseEntity logoutUser() { + return getDelegate().logoutUser(); + } + + @Operation(summary = "Updated user", tags = { "user" }) + @ApiResponses(value = { @ApiResponse(responseCode = "400", description = "Invalid user supplied"), + @ApiResponse(responseCode = "404", description = "User not found") }) + @PutMapping(value = "/user/{username}", consumes = { "application/json" }) + default ResponseEntity updateUser( + @Parameter(description = "name that need to be deleted", required = true) @PathVariable("username") String username, + @io.swagger.v3.oas.annotations.parameters.RequestBody(description = "Updated user object", required = true) @Valid @RequestBody User user) { + return getDelegate().updateUser(username, user); + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app68/api/user/UserApiController.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app68/api/user/UserApiController.java new file mode 100644 index 000000000..26f8d55d0 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app68/api/user/UserApiController.java @@ -0,0 +1,52 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app68.api.user; + +import java.util.Optional; + +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@jakarta.annotation.Generated(value = "org.springdoc.demo.app2.codegen.languages.SpringCodegen", date = "2019-07-11T00:09:29.839+02:00[Europe/Paris]") + +@RestController +@RequestMapping("${openapi.openAPIPetstore.base-path:/}") +public class UserApiController implements UserApi { + + private final UserApiDelegate delegate; + + public UserApiController(@org.springframework.beans.factory.annotation.Autowired(required = false) UserApiDelegate delegate) { + this.delegate = Optional.ofNullable(delegate).orElse(new UserApiDelegate() { + }); + } + + @Override + public UserApiDelegate getDelegate() { + return delegate; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app68/api/user/UserApiDelegate.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app68/api/user/UserApiDelegate.java new file mode 100644 index 000000000..08d4d25f2 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app68/api/user/UserApiDelegate.java @@ -0,0 +1,130 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app68.api.user; + +import java.util.List; +import java.util.Optional; + +import test.org.springdoc.api.v31.app68.api.ApiUtil; +import test.org.springdoc.api.v31.app68.model.User; + +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.web.context.request.NativeWebRequest; + +/** + * A delegate to be called by the {@link UserApiController}}. + * Implement this interface with a {@link org.springframework.stereotype.Service} annotated class. + */ +@jakarta.annotation.Generated(value = "org.springdoc.demo.app2.codegen.languages.SpringCodegen", date = "2019-07-11T00:09:29.839+02:00[Europe/Paris]") + +public interface UserApiDelegate { + + default Optional getRequest() { + return Optional.empty(); + } + + /** + * @see UserApi#createUser + */ + default ResponseEntity createUser(User user) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * @see UserApi#createUsersWithArrayInput + */ + default ResponseEntity createUsersWithArrayInput(List user) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * @see UserApi#createUsersWithListInput + */ + default ResponseEntity createUsersWithListInput(List user) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * @see UserApi#deleteUser + */ + default ResponseEntity deleteUser(String username) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * @see UserApi#getUserByName + */ + default ResponseEntity getUserByName(String username) { + getRequest().ifPresent(request -> { + for (MediaType mediaType : MediaType.parseMediaTypes(request.getHeader("Accept"))) { + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + ApiUtil.setExampleResponse(request, "application/json", "{ \"firstName\" : \"firstName\", \"lastName\" : \"lastName\", \"password\" : \"password\", \"userStatus\" : 6, \"phone\" : \"phone\", \"id\" : 0, \"email\" : \"email\", \"username\" : \"username\"}"); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/xml"))) { + ApiUtil.setExampleResponse(request, "application/xml", " 123456789 aeiou aeiou aeiou aeiou aeiou aeiou 123"); + break; + } + } + }); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * @see UserApi#loginUser + */ + default ResponseEntity loginUser(String username, + String password) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * @see UserApi#logoutUser + */ + default ResponseEntity logoutUser() { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * @see UserApi#updateUser + */ + default ResponseEntity updateUser(String username, + User user) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app68/api/user/UserApiDelegateImpl.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app68/api/user/UserApiDelegateImpl.java new file mode 100644 index 000000000..f533ac10f --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app68/api/user/UserApiDelegateImpl.java @@ -0,0 +1,35 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app68.api.user; + +import org.springframework.stereotype.Service; + +@Service +public class UserApiDelegateImpl implements UserApiDelegate { + + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app68/api/user/UserClient.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app68/api/user/UserClient.java new file mode 100644 index 000000000..5c644c4ed --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app68/api/user/UserClient.java @@ -0,0 +1,44 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app68.api.user; + +import test.org.springdoc.api.v31.app68.model.User; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; + +@RequestMapping(value = "/users", consumes = "application/json") +@Controller +public class UserClient { + + @GetMapping("/{id}") + public User findById(@PathVariable Integer id) { + return null; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app68/model/Body.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app68/model/Body.java new file mode 100644 index 000000000..dc3c20294 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app68/model/Body.java @@ -0,0 +1,105 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app68.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.v3.oas.annotations.media.Schema; + +public class Body { + + @Schema(description = "Updated name of the pet") + /** + * Updated name of the pet + **/ + private String name = null; + + @Schema(description = "Updated status of the pet") + /** + * Updated status of the pet + **/ + private String status = null; + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private static String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Updated name of the pet + * + * @return name + **/ + @JsonProperty("name") + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Body name(String name) { + this.name = name; + return this; + } + + /** + * Updated status of the pet + * + * @return status + **/ + @JsonProperty("status") + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public Body status(String status) { + this.status = status; + return this; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Body {\n"); + + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append("}"); + return sb.toString(); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app68/model/Body1.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app68/model/Body1.java new file mode 100644 index 000000000..93e2f621b --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app68/model/Body1.java @@ -0,0 +1,107 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app68.model; + +import java.io.File; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.v3.oas.annotations.media.Schema; + +public class Body1 { + + @Schema(description = "Additional data to pass to server") + /** + * Additional data to pass to server + **/ + private String additionalMetadata = null; + + @Schema(description = "file to upload") + /** + * file to upload + **/ + private File file = null; + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private static String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Additional data to pass to server + * + * @return additionalMetadata + **/ + @JsonProperty("additionalMetadata") + public String getAdditionalMetadata() { + return additionalMetadata; + } + + public void setAdditionalMetadata(String additionalMetadata) { + this.additionalMetadata = additionalMetadata; + } + + public Body1 additionalMetadata(String additionalMetadata) { + this.additionalMetadata = additionalMetadata; + return this; + } + + /** + * file to upload + * + * @return file + **/ + @JsonProperty("file") + public File getFile() { + return file; + } + + public void setFile(File file) { + this.file = file; + } + + public Body1 file(File file) { + this.file = file; + return this; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Body1 {\n"); + + sb.append(" additionalMetadata: ").append(toIndentedString(additionalMetadata)).append("\n"); + sb.append(" file: ").append(toIndentedString(file)).append("\n"); + sb.append("}"); + return sb.toString(); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app68/model/Category.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app68/model/Category.java new file mode 100644 index 000000000..e22f47224 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app68/model/Category.java @@ -0,0 +1,99 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app68.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.v3.oas.annotations.media.Schema; + +public class Category { + + @Schema(description = "") + private Long id = null; + + @Schema(description = "") + private String name = null; + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private static String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Get id + * + * @return id + **/ + @JsonProperty("id") + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public Category id(Long id) { + this.id = id; + return this; + } + + /** + * Get name + * + * @return name + **/ + @JsonProperty("name") + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Category name(String name) { + this.name = name; + return this; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Category {\n"); + + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append("}"); + return sb.toString(); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app68/model/ModelApiResponse.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app68/model/ModelApiResponse.java new file mode 100644 index 000000000..09dbc8b62 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app68/model/ModelApiResponse.java @@ -0,0 +1,122 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app68.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.v3.oas.annotations.media.Schema; + +public class ModelApiResponse { + + @Schema(description = "") + private Integer code = null; + + @Schema(description = "") + private String type = null; + + @Schema(description = "") + private String message = null; + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private static String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Get code + * + * @return code + **/ + @JsonProperty("code") + public Integer getCode() { + return code; + } + + public void setCode(Integer code) { + this.code = code; + } + + public ModelApiResponse code(Integer code) { + this.code = code; + return this; + } + + /** + * Get type + * + * @return type + **/ + @JsonProperty("type") + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public ModelApiResponse type(String type) { + this.type = type; + return this; + } + + /** + * Get message + * + * @return message + **/ + @JsonProperty("message") + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public ModelApiResponse message(String message) { + this.message = message; + return this; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ModelApiResponse {\n"); + + sb.append(" code: ").append(toIndentedString(code)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" message: ").append(toIndentedString(message)).append("\n"); + sb.append("}"); + return sb.toString(); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app68/model/Order.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app68/model/Order.java new file mode 100644 index 000000000..9fc6753f5 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app68/model/Order.java @@ -0,0 +1,234 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app68.model; + +import java.util.Date; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.v3.oas.annotations.media.Schema; + +public class Order { + + @Schema(description = "") + private Long id = null; + + @Schema(description = "") + private Long petId = null; + + @Schema(description = "") + private Integer quantity = null; + + @Schema(description = "") + private Date shipDate = null; + + @Schema(description = "Order Status") + /** + * Order Status + **/ + private StatusEnum status = null; + + @Schema(description = "") + private Boolean complete = false; + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private static String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Get id + * + * @return id + **/ + @JsonProperty("id") + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public Order id(Long id) { + this.id = id; + return this; + } + + /** + * Get petId + * + * @return petId + **/ + @JsonProperty("petId") + public Long getPetId() { + return petId; + } + + public void setPetId(Long petId) { + this.petId = petId; + } + + public Order petId(Long petId) { + this.petId = petId; + return this; + } + + /** + * Get quantity + * + * @return quantity + **/ + @JsonProperty("quantity") + public Integer getQuantity() { + return quantity; + } + + public void setQuantity(Integer quantity) { + this.quantity = quantity; + } + + public Order quantity(Integer quantity) { + this.quantity = quantity; + return this; + } + + /** + * Get shipDate + * + * @return shipDate + **/ + @JsonProperty("shipDate") + public Date getShipDate() { + return shipDate; + } + + public void setShipDate(Date shipDate) { + this.shipDate = shipDate; + } + + public Order shipDate(Date shipDate) { + this.shipDate = shipDate; + return this; + } + + /** + * Order Status + * + * @return status + **/ + @JsonProperty("status") + public String getStatus() { + if (status == null) { + return null; + } + return status.getValue(); + } + + public void setStatus(StatusEnum status) { + this.status = status; + } + + public Order status(StatusEnum status) { + this.status = status; + return this; + } + + /** + * Get complete + * + * @return complete + **/ + @JsonProperty("complete") + public Boolean isisComplete() { + return complete; + } + + public void setComplete(Boolean complete) { + this.complete = complete; + } + + public Order complete(Boolean complete) { + this.complete = complete; + return this; + } + + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Order {\n"); + + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" petId: ").append(toIndentedString(petId)).append("\n"); + sb.append(" quantity: ").append(toIndentedString(quantity)).append("\n"); + sb.append(" shipDate: ").append(toIndentedString(shipDate)).append("\n"); + sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append(" complete: ").append(toIndentedString(complete)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + public enum StatusEnum { + PLACED("placed"), + APPROVED("approved"), + DELIVERED("delivered"); + + private String value; + + StatusEnum(String value) { + this.value = value; + } + + @JsonCreator + public static StatusEnum fromValue(String text) { + for (StatusEnum b : StatusEnum.values()) { + if (String.valueOf(b.value).equals(text)) { + return b; + } + } + return null; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app68/model/Pet.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app68/model/Pet.java new file mode 100644 index 000000000..d6bb64560 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app68/model/Pet.java @@ -0,0 +1,248 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app68.model; + +import java.util.ArrayList; +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotNull; + +public class Pet { + + @Schema(description = "") + private Long id = null; + + @Schema(description = "") + private Category category = null; + + @Schema(example = "doggie", required = true, description = "") + private String name = null; + + @Schema(required = true, description = "") + private List photoUrls = new ArrayList(); + + @Schema(description = "") + private List tags = null; + + @Schema(description = "pet status in the store") + /** + * pet status in the store + **/ + private StatusEnum status = null; + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private static String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Get id + * + * @return id + **/ + @JsonProperty("id") + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public Pet id(Long id) { + this.id = id; + return this; + } + + /** + * Get category + * + * @return category + **/ + @JsonProperty("category") + public Category getCategory() { + return category; + } + + public void setCategory(Category category) { + this.category = category; + } + + public Pet category(Category category) { + this.category = category; + return this; + } + + /** + * Get name + * + * @return name + **/ + @JsonProperty("name") + @NotNull + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Pet name(String name) { + this.name = name; + return this; + } + + /** + * Get photoUrls + * + * @return photoUrls + **/ + @JsonProperty("photoUrls") + @NotNull + public List getPhotoUrls() { + return photoUrls; + } + + public void setPhotoUrls(List photoUrls) { + this.photoUrls = photoUrls; + } + + public Pet photoUrls(List photoUrls) { + this.photoUrls = photoUrls; + return this; + } + + public Pet addPhotoUrlsItem(String photoUrlsItem) { + this.photoUrls.add(photoUrlsItem); + return this; + } + + /** + * Get tags + * + * @return tags + **/ + @JsonProperty("tags") + public List getTags() { + return tags; + } + + public void setTags(List tags) { + this.tags = tags; + } + + public Pet tags(List tags) { + this.tags = tags; + return this; + } + + public Pet addTagsItem(Tag tagsItem) { + if (this.tags == null) { + this.tags = new ArrayList<>(); + } + this.tags.add(tagsItem); + return this; + } + + /** + * pet status in the store + * + * @return status + **/ + @JsonProperty("status") + public StatusEnum getStatus() { + if (status == null) { + return null; + } + return status; + } + + public void setStatus(StatusEnum status) { + this.status = status; + } + + public Pet status(StatusEnum status) { + this.status = status; + return this; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Pet {\n"); + + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" category: ").append(toIndentedString(category)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" photoUrls: ").append(toIndentedString(photoUrls)).append("\n"); + sb.append(" tags: ").append(toIndentedString(tags)).append("\n"); + sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + public enum StatusEnum { + AVAILABLE("available"), PENDING("pending"), SOLD("sold"); + + private String value; + + StatusEnum(String value) { + this.value = value; + } + + @JsonCreator + public static StatusEnum fromValue(String text) { + for (StatusEnum b : StatusEnum.values()) { + if (String.valueOf(b.value).equals(text)) { + return b; + } + } + return null; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app68/model/Tag.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app68/model/Tag.java new file mode 100644 index 000000000..01a25f667 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app68/model/Tag.java @@ -0,0 +1,99 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app68.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.v3.oas.annotations.media.Schema; + +public class Tag { + + @Schema(description = "") + private Long id = null; + + @Schema(description = "") + private String name = null; + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private static String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Get id + * + * @return id + **/ + @JsonProperty("id") + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public Tag id(Long id) { + this.id = id; + return this; + } + + /** + * Get name + * + * @return name + **/ + @JsonProperty("name") + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Tag name(String name) { + this.name = name; + return this; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Tag {\n"); + + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append("}"); + return sb.toString(); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app68/model/User.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app68/model/User.java new file mode 100644 index 000000000..878ce721a --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app68/model/User.java @@ -0,0 +1,240 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app68.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.v3.oas.annotations.media.Schema; + +public class User { + + @Schema(description = "") + private Long id = null; + + @Schema(description = "") + private String username = null; + + @Schema(description = "") + private String firstName = null; + + @Schema(description = "") + private String lastName = null; + + @Schema(description = "") + private String email = null; + + @Schema(description = "") + private String password = null; + + @Schema(description = "") + private String phone = null; + + @Schema(description = "User Status") + /** + * User Status + **/ + private Integer userStatus = null; + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private static String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Get id + * + * @return id + **/ + @JsonProperty("id") + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public User id(Long id) { + this.id = id; + return this; + } + + /** + * Get username + * + * @return username + **/ + @JsonProperty("username") + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + public User username(String username) { + this.username = username; + return this; + } + + /** + * Get firstName + * + * @return firstName + **/ + @JsonProperty("firstName") + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + public User firstName(String firstName) { + this.firstName = firstName; + return this; + } + + /** + * Get lastName + * + * @return lastName + **/ + @JsonProperty("lastName") + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } + + public User lastName(String lastName) { + this.lastName = lastName; + return this; + } + + /** + * Get email + * + * @return email + **/ + @JsonProperty("email") + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + public User email(String email) { + this.email = email; + return this; + } + + /** + * Get password + * + * @return password + **/ + @JsonProperty("password") + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + public User password(String password) { + this.password = password; + return this; + } + + /** + * Get phone + * + * @return phone + **/ + @JsonProperty("phone") + public String getPhone() { + return phone; + } + + public void setPhone(String phone) { + this.phone = phone; + } + + public User phone(String phone) { + this.phone = phone; + return this; + } + + /** + * User Status + * + * @return userStatus + **/ + @JsonProperty("userStatus") + public Integer getUserStatus() { + return userStatus; + } + + public void setUserStatus(Integer userStatus) { + this.userStatus = userStatus; + } + + public User userStatus(Integer userStatus) { + this.userStatus = userStatus; + return this; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class User {\n"); + + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" username: ").append(toIndentedString(username)).append("\n"); + sb.append(" firstName: ").append(toIndentedString(firstName)).append("\n"); + sb.append(" lastName: ").append(toIndentedString(lastName)).append("\n"); + sb.append(" email: ").append(toIndentedString(email)).append("\n"); + sb.append(" password: ").append(toIndentedString(password)).append("\n"); + sb.append(" phone: ").append(toIndentedString(phone)).append("\n"); + sb.append(" userStatus: ").append(toIndentedString(userStatus)).append("\n"); + sb.append("}"); + return sb.toString(); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app72/BlockingAutoConfigurationTest.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app72/BlockingAutoConfigurationTest.java new file mode 100644 index 000000000..891be31f3 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app72/BlockingAutoConfigurationTest.java @@ -0,0 +1,115 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app72; + +import org.junit.jupiter.api.Test; +import org.springdoc.core.models.GroupedOpenApi; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.test.context.FilteredClassLoader; +import org.springframework.boot.test.context.runner.ApplicationContextRunner; +import org.springframework.boot.test.context.runner.WebApplicationContextRunner; +import org.springframework.context.annotation.Bean; + +import static org.assertj.core.api.Assertions.assertThat; + +class BlockingAutoConfigurationTest { + + private final WebApplicationContextRunner contextRunner = new WebApplicationContextRunner() + .withUserConfiguration(TestApp.class); + + @Test + void configurations_successfully_loaded() { + contextRunner + .withPropertyValues("springdoc.show-actuator=true") + .run(context -> assertThat(context) + .hasNotFailed() + .hasBean("openApiResource") + .hasBean("actuatorProvider") + .hasBean("multipleOpenApiResource") + ); + } + + @Test + void configurations_not_loaded_when_application_is_not_web() { + new ApplicationContextRunner() + .withUserConfiguration(TestApp.class) + .run(context -> assertThat(context) + .hasNotFailed() + .doesNotHaveBean("openApiResource") + .doesNotHaveBean("actuatorProvider") + .doesNotHaveBean("multipleOpenApiResource") + ); + } + + @Test + void actuator_configuration_not_loaded_when_not_enabled_explicitly() { + contextRunner + .run(context -> assertThat(context) + .hasNotFailed() + .hasBean("openApiResource") + .doesNotHaveBean("actuatorPprrovider") + .hasBean("multipleOpenApiResource") + ); + } + + @Test + void configurations_not_loaded_when_disabled() { + contextRunner + .withPropertyValues("springdoc.api-docs.enabled=false") + .run(context -> assertThat(context) + .hasNotFailed() + .doesNotHaveBean("openApiResource") + .doesNotHaveBean("actuatorProvider") + .doesNotHaveBean("multipleOpenApiResource") + ); + } + + @Test + void configurations_not_loaded_when_mvc_is_not_on_class_path() { + contextRunner + .withClassLoader(new FilteredClassLoader("org.springframework.web.context.support.GenericWebApplicationContext")) + .run(context -> assertThat(context) + .hasNotFailed() + .doesNotHaveBean("openApiResource") + .doesNotHaveBean("actuatorProvider") + .doesNotHaveBean("multipleOpenApiResource") + ); + + } + + @SpringBootApplication + static class TestApp { + @Bean + GroupedOpenApi testGroupedOpenApi() { + return GroupedOpenApi.builder() + .group("test-group") + .packagesToScan("org.test") + .build(); + } + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app72/CacheAutoConfigurationTest1.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app72/CacheAutoConfigurationTest1.java new file mode 100644 index 000000000..488aa20aa --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app72/CacheAutoConfigurationTest1.java @@ -0,0 +1,93 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app72; + +import org.junit.jupiter.api.Test; + +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.boot.test.context.runner.WebApplicationContextRunner; + +import static org.assertj.core.api.Assertions.assertThat; + +public class CacheAutoConfigurationTest1 { + + private final WebApplicationContextRunner contextRunner = new WebApplicationContextRunner() + .withUserConfiguration(TestApp.class); + + @Test + void cache_configuration_loaded_when_not_disabled_explicitly() { + contextRunner + .run(context -> assertThat(context) + .hasNotFailed() + .hasBean("openApiResource") + .doesNotHaveBean("springdocBeanFactoryPostProcessor") + .doesNotHaveBean("multipleOpenApiResource") + ); + } + + @Test + void cache_configuration_loaded_when_disabled_explicitly() { + contextRunner + .withPropertyValues("springdoc.cache.disabled=false") + .run(context -> assertThat(context) + .hasNotFailed() + .hasBean("openApiResource") + .doesNotHaveBean("springdocBeanFactoryPostProcessor") + .doesNotHaveBean("multipleOpenApiResource") + ); + } + + @Test + void cache_configurations_successfully_disabled() { + contextRunner + .withPropertyValues("springdoc.cache.disabled=true") + .run(context -> assertThat(context) + .hasNotFailed() + .hasBean("openApiResource") + .hasBean("springdocBeanFactoryPostProcessor") + .doesNotHaveBean("multipleOpenApiResource") + ); + } + + @Test + void group_configuration_loaded() { + contextRunner + .withPropertyValues("springdoc.group-configs[0].group=stores", "springdoc.group-configs[0].paths-to-match=/store/**") + .run(context -> assertThat(context) + .hasNotFailed() + .hasBean("openApiResource") + .hasBean("multipleOpenApiResource") + .hasBean("springdocBeanFactoryPostProcessor") + ); + } + + + @EnableAutoConfiguration + static class TestApp { + + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app72/GroupAutoConfigurationTest.java b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app72/GroupAutoConfigurationTest.java new file mode 100644 index 000000000..c425f0be6 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app72/GroupAutoConfigurationTest.java @@ -0,0 +1,64 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app72; + +import org.junit.jupiter.api.Test; +import org.springdoc.core.models.GroupedOpenApi; + +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.boot.test.context.runner.WebApplicationContextRunner; +import org.springframework.context.annotation.Bean; + +import static org.assertj.core.api.Assertions.assertThat; + +public class GroupAutoConfigurationTest { + + private final WebApplicationContextRunner contextRunner = new WebApplicationContextRunner() + .withUserConfiguration(TestApp.class); + + @Test + void group_configuration_loaded() { + contextRunner + .run(context -> assertThat(context) + .hasNotFailed() + .hasBean("openApiResource") + .hasBean("springdocBeanFactoryPostProcessor") + .hasBean("multipleOpenApiResource") + ); + } + + @EnableAutoConfiguration + static class TestApp { + @Bean + GroupedOpenApi testGroupedOpenApi() { + return GroupedOpenApi.builder() + .group("test-group") + .packagesToScan("org.test") + .build(); + } + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/resources/results/app128.json b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/resources/results/3.0.1/app128.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/resources/results/app128.json rename to springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/resources/results/3.0.1/app128.json diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/resources/results/app144.json b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/resources/results/3.0.1/app144.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/resources/results/app144.json rename to springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/resources/results/3.0.1/app144.json diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/resources/results/3.0.1/app145.json b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/resources/results/3.0.1/app145.json new file mode 100644 index 000000000..c88631044 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/resources/results/3.0.1/app145.json @@ -0,0 +1,36 @@ +{ + "openapi": "3.0.1", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost:53556", + "description": "Generated server url" + } + ], + "paths": { + "/persons": { + "get": { + "tags": [ + "hello-controller" + ], + "operationId": "persons", + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + } + }, + "components": {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/resources/results/app146-1.json b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/resources/results/3.0.1/app146-1.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/resources/results/app146-1.json rename to springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/resources/results/3.0.1/app146-1.json diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/resources/results/app146-2.json b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/resources/results/3.0.1/app146-2.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/resources/results/app146-2.json rename to springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/resources/results/3.0.1/app146-2.json diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/resources/results/app147-1.json b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/resources/results/3.0.1/app147-1.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/resources/results/app147-1.json rename to springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/resources/results/3.0.1/app147-1.json diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/resources/results/app147-2.json b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/resources/results/3.0.1/app147-2.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/resources/results/app147-2.json rename to springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/resources/results/3.0.1/app147-2.json diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/resources/results/app148-1.json b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/resources/results/3.0.1/app148-1.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/resources/results/app148-1.json rename to springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/resources/results/3.0.1/app148-1.json diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/resources/results/app148-2.json b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/resources/results/3.0.1/app148-2.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/resources/results/app148-2.json rename to springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/resources/results/3.0.1/app148-2.json diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/resources/results/app186.json b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/resources/results/3.0.1/app186.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/resources/results/app186.json rename to springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/resources/results/3.0.1/app186.json diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/resources/results/app68-1.json b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/resources/results/3.0.1/app68-1.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/resources/results/app68-1.json rename to springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/resources/results/3.0.1/app68-1.json diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/resources/results/app68-2.json b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/resources/results/3.0.1/app68-2.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/resources/results/app68-2.json rename to springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/resources/results/3.0.1/app68-2.json diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/resources/results/app68-3.json b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/resources/results/3.0.1/app68-3.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/resources/results/app68-3.json rename to springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/resources/results/3.0.1/app68-3.json diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/resources/results/app68-4.json b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/resources/results/3.0.1/app68-4.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/resources/results/app68-4.json rename to springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/resources/results/3.0.1/app68-4.json diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/resources/results/3.1.0/app128.json b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/resources/results/3.1.0/app128.json new file mode 100644 index 000000000..c21957aa0 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/resources/results/3.1.0/app128.json @@ -0,0 +1,98 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "Actuator", + "description": "Monitor and interact", + "externalDocs": { + "description": "Spring Boot Actuator Web API Documentation", + "url": "https://docs.spring.io/spring-boot/docs/current/actuator-api/html/" + } + } + ], + "paths": { + "/actuator/tenant/customer/{id}": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "test.org.springdoc.api.app128.HelloController#getTenantById(String)", + "operationId": "getTenantById_0", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/actuator": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator root web endpoint", + "operationId": "links_1", + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "object", + "additionalProperties": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/Link" + } + } + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "Link": { + "type": "object", + "properties": { + "href": { + "type": "string" + }, + "templated": { + "type": "boolean" + } + } + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/resources/results/3.1.0/app144.json b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/resources/results/3.1.0/app144.json new file mode 100644 index 000000000..bd7dd826b --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/resources/results/3.1.0/app144.json @@ -0,0 +1,36 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost:53554", + "description": "Generated server url" + } + ], + "paths": { + "/persons": { + "get": { + "tags": [ + "hello-controller" + ], + "operationId": "persons", + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + } + }, + "components": {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/resources/results/3.1.0/app145.json b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/resources/results/3.1.0/app145.json new file mode 100644 index 000000000..0ca407319 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/resources/results/3.1.0/app145.json @@ -0,0 +1,36 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost:52556", + "description": "Generated server url" + } + ], + "paths": { + "/persons": { + "get": { + "tags": [ + "hello-controller" + ], + "operationId": "persons", + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + } + }, + "components": {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/resources/results/3.1.0/app146-1.json b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/resources/results/3.1.0/app146-1.json new file mode 100644 index 000000000..05b8c14a2 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/resources/results/3.1.0/app146-1.json @@ -0,0 +1,797 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost:9299/test", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "Actuator", + "description": "Monitor and interact", + "externalDocs": { + "description": "Spring Boot Actuator Web API Documentation", + "url": "https://docs.spring.io/spring-boot/docs/current/actuator-api/html/" + } + } + ], + "paths": { + "/application/loggers/{name}": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'loggers-name'", + "operationId": "loggers-name", + "parameters": [ + { + "name": "name", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + }, + "post": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'loggers-name'", + "operationId": "loggers-name_2", + "parameters": [ + { + "name": "name", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "string", + "enum": [ + "TRACE", + "DEBUG", + "INFO", + "WARN", + "ERROR", + "FATAL", + "OFF" + ] + } + } + } + }, + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/application": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator root web endpoint", + "operationId": "links", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object", + "additionalProperties": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/Link" + } + } + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object", + "additionalProperties": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/Link" + } + } + } + }, + "application/json": { + "schema": { + "type": "object", + "additionalProperties": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/Link" + } + } + } + } + } + } + } + } + }, + "/application/threaddump": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'threaddump'", + "operationId": "threaddump", + "responses": { + "200": { + "description": "OK", + "content": { + "text/plain;charset=UTF-8": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/application/scheduledtasks": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'scheduledtasks'", + "operationId": "scheduledtasks", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/application/metrics": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'metrics'", + "operationId": "metrics", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/application/metrics/{requiredMetricName}": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'metrics-requiredMetricName'", + "operationId": "metrics-requiredMetricName", + "parameters": [ + { + "name": "requiredMetricName", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/application/mappings": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'mappings'", + "operationId": "mappings", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/application/loggers": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'loggers'", + "operationId": "loggers", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/application/info": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'info'", + "operationId": "info", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/application/heapdump": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'heapdump'", + "operationId": "heapdump", + "responses": { + "200": { + "description": "OK", + "content": { + "application/octet-stream": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/application/health": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'health'", + "operationId": "health", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/application/env": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'env'", + "operationId": "env", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/application/env/{toMatch}": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'env-toMatch'", + "operationId": "env-toMatch", + "parameters": [ + { + "name": "toMatch", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/application/configprops": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'configprops'", + "operationId": "configprops", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/application/configprops/{prefix}": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'configprops-prefix'", + "operationId": "configprops-prefix", + "parameters": [ + { + "name": "prefix", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/application/conditions": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'conditions'", + "operationId": "conditions", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/application/caches": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'caches'", + "operationId": "caches", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + }, + "delete": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'caches'", + "operationId": "caches_2", + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/application/caches/{cache}": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'caches-cache'", + "operationId": "caches-cache", + "parameters": [ + { + "name": "cache", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + }, + "delete": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'caches-cache'", + "operationId": "caches-cache_2", + "parameters": [ + { + "name": "cache", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/application/beans": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'beans'", + "operationId": "beans", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "Link": { + "type": "object", + "properties": { + "href": { + "type": "string" + }, + "templated": { + "type": "boolean" + } + } + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/resources/results/3.1.0/app146-2.json b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/resources/results/3.1.0/app146-2.json new file mode 100644 index 000000000..b6c792e3a --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/resources/results/3.1.0/app146-2.json @@ -0,0 +1,36 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/persons": { + "get": { + "tags": [ + "hello-controller" + ], + "operationId": "persons", + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + } + }, + "components": {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/resources/results/3.1.0/app147-1.json b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/resources/results/3.1.0/app147-1.json new file mode 100644 index 000000000..7ecc6396b --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/resources/results/3.1.0/app147-1.json @@ -0,0 +1,891 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost:9387/test", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "Actuator", + "description": "Monitor and interact", + "externalDocs": { + "description": "Spring Boot Actuator Web API Documentation", + "url": "https://docs.spring.io/spring-boot/docs/current/actuator-api/html/" + } + } + ], + "paths": { + "/application/loggers/{name}": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'loggers-name'", + "operationId": "loggerLevels", + "parameters": [ + { + "name": "name", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + }, + "404": { + "description": "Not Found" + } + } + }, + "post": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'loggers-name'", + "operationId": "configureLogLevel", + "parameters": [ + { + "name": "name", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "string", + "enum": [ + "TRACE", + "DEBUG", + "INFO", + "WARN", + "ERROR", + "FATAL", + "OFF" + ] + } + } + } + }, + "responses": { + "204": { + "description": "No Content" + }, + "400": { + "description": "Bad Request" + } + } + } + }, + "/application": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator root web endpoint", + "operationId": "links", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object", + "additionalProperties": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/Link" + } + } + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object", + "additionalProperties": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/Link" + } + } + } + }, + "application/json": { + "schema": { + "type": "object", + "additionalProperties": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/Link" + } + } + } + } + } + } + } + } + }, + "/application/threaddump": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'threaddump'", + "operationId": "threadDump", + "responses": { + "200": { + "description": "OK", + "content": { + "text/plain;charset=UTF-8": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/application/scheduledtasks": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'scheduledtasks'", + "operationId": "scheduledTasks", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/application/sbom": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'sbom'", + "operationId": "sboms", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/application/sbom/{id}": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'sbom-id'", + "operationId": "sbom", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/octet-stream": { + "schema": { + "type": "object" + } + } + } + }, + "404": { + "description": "Not Found" + } + } + } + }, + "/application/metrics": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'metrics'", + "operationId": "listNames", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/application/metrics/{requiredMetricName}": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'metrics-requiredMetricName'", + "operationId": "metric", + "parameters": [ + { + "name": "requiredMetricName", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "tag", + "in": "query", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + }, + "404": { + "description": "Not Found" + } + } + } + }, + "/application/mappings": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'mappings'", + "operationId": "mappings", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/application/loggers": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'loggers'", + "operationId": "loggers", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/application/info": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'info'", + "operationId": "info", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/application/heapdump": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'heapdump'", + "operationId": "heapDump", + "parameters": [ + { + "name": "live", + "in": "query", + "schema": { + "type": "boolean" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/octet-stream": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/application/health": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'health'", + "operationId": "health", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/application/env": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'env'", + "operationId": "environment", + "parameters": [ + { + "name": "pattern", + "in": "query", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/application/env/{toMatch}": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'env-toMatch'", + "operationId": "environmentEntry", + "parameters": [ + { + "name": "toMatch", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + }, + "404": { + "description": "Not Found" + } + } + } + }, + "/application/configprops": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'configprops'", + "operationId": "configurationProperties", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/application/configprops/{prefix}": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'configprops-prefix'", + "operationId": "configurationPropertiesWithPrefix", + "parameters": [ + { + "name": "prefix", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + }, + "404": { + "description": "Not Found" + } + } + } + }, + "/application/conditions": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'conditions'", + "operationId": "conditions", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/application/caches": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'caches'", + "operationId": "caches", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + }, + "delete": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'caches'", + "operationId": "clearCaches", + "responses": { + "204": { + "description": "No Content" + } + } + } + }, + "/application/caches/{cache}": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'caches-cache'", + "operationId": "cache", + "parameters": [ + { + "name": "cache", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "cacheManager", + "in": "query", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + }, + "404": { + "description": "Not Found" + } + } + }, + "delete": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'caches-cache'", + "operationId": "clearCache", + "parameters": [ + { + "name": "cache", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "cacheManager", + "in": "query", + "schema": { + "type": "string" + } + } + ], + "responses": { + "204": { + "description": "No Content" + }, + "404": { + "description": "Not Found" + } + } + } + }, + "/application/beans": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'beans'", + "operationId": "beans", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "Link": { + "type": "object", + "properties": { + "href": { + "type": "string" + }, + "templated": { + "type": "boolean" + } + } + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/resources/results/3.1.0/app147-2.json b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/resources/results/3.1.0/app147-2.json new file mode 100644 index 000000000..b6c792e3a --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/resources/results/3.1.0/app147-2.json @@ -0,0 +1,36 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/persons": { + "get": { + "tags": [ + "hello-controller" + ], + "operationId": "persons", + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + } + }, + "components": {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/resources/results/3.1.0/app148-1.json b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/resources/results/3.1.0/app148-1.json new file mode 100644 index 000000000..d8887780c --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/resources/results/3.1.0/app148-1.json @@ -0,0 +1,36 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost:6376/toto/titi", + "description": "Generated server url" + } + ], + "paths": { + "/persons": { + "get": { + "tags": [ + "hello-controller" + ], + "operationId": "persons", + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + } + }, + "components": {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/resources/results/3.1.0/app148-2.json b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/resources/results/3.1.0/app148-2.json new file mode 100644 index 000000000..8681210a7 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/resources/results/3.1.0/app148-2.json @@ -0,0 +1,891 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost:9398/test", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "Actuator", + "description": "Monitor and interact", + "externalDocs": { + "description": "Spring Boot Actuator Web API Documentation", + "url": "https://docs.spring.io/spring-boot/docs/current/actuator-api/html/" + } + } + ], + "paths": { + "/application/loggers/{name}": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'loggers-name'", + "operationId": "loggerLevels", + "parameters": [ + { + "name": "name", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + }, + "404": { + "description": "Not Found" + } + } + }, + "post": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'loggers-name'", + "operationId": "configureLogLevel", + "parameters": [ + { + "name": "name", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "string", + "enum": [ + "TRACE", + "DEBUG", + "INFO", + "WARN", + "ERROR", + "FATAL", + "OFF" + ] + } + } + } + }, + "responses": { + "204": { + "description": "No Content" + }, + "400": { + "description": "Bad Request" + } + } + } + }, + "/application": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator root web endpoint", + "operationId": "links", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object", + "additionalProperties": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/Link" + } + } + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object", + "additionalProperties": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/Link" + } + } + } + }, + "application/json": { + "schema": { + "type": "object", + "additionalProperties": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/Link" + } + } + } + } + } + } + } + } + }, + "/application/threaddump": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'threaddump'", + "operationId": "threadDump", + "responses": { + "200": { + "description": "OK", + "content": { + "text/plain;charset=UTF-8": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/application/scheduledtasks": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'scheduledtasks'", + "operationId": "scheduledTasks", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/application/sbom": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'sbom'", + "operationId": "sboms", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/application/sbom/{id}": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'sbom-id'", + "operationId": "sbom", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/octet-stream": { + "schema": { + "type": "object" + } + } + } + }, + "404": { + "description": "Not Found" + } + } + } + }, + "/application/metrics": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'metrics'", + "operationId": "listNames", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/application/metrics/{requiredMetricName}": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'metrics-requiredMetricName'", + "operationId": "metric", + "parameters": [ + { + "name": "requiredMetricName", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "tag", + "in": "query", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + }, + "404": { + "description": "Not Found" + } + } + } + }, + "/application/mappings": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'mappings'", + "operationId": "mappings", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/application/loggers": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'loggers'", + "operationId": "loggers", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/application/info": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'info'", + "operationId": "info", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/application/heapdump": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'heapdump'", + "operationId": "heapDump", + "parameters": [ + { + "name": "live", + "in": "query", + "schema": { + "type": "boolean" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/octet-stream": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/application/health": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'health'", + "operationId": "health", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/application/env": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'env'", + "operationId": "environment", + "parameters": [ + { + "name": "pattern", + "in": "query", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/application/env/{toMatch}": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'env-toMatch'", + "operationId": "environmentEntry", + "parameters": [ + { + "name": "toMatch", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + }, + "404": { + "description": "Not Found" + } + } + } + }, + "/application/configprops": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'configprops'", + "operationId": "configurationProperties", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/application/configprops/{prefix}": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'configprops-prefix'", + "operationId": "configurationPropertiesWithPrefix", + "parameters": [ + { + "name": "prefix", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + }, + "404": { + "description": "Not Found" + } + } + } + }, + "/application/conditions": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'conditions'", + "operationId": "conditions", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/application/caches": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'caches'", + "operationId": "caches", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + }, + "delete": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'caches'", + "operationId": "clearCaches", + "responses": { + "204": { + "description": "No Content" + } + } + } + }, + "/application/caches/{cache}": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'caches-cache'", + "operationId": "cache", + "parameters": [ + { + "name": "cache", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "cacheManager", + "in": "query", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + }, + "404": { + "description": "Not Found" + } + } + }, + "delete": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'caches-cache'", + "operationId": "clearCache", + "parameters": [ + { + "name": "cache", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "cacheManager", + "in": "query", + "schema": { + "type": "string" + } + } + ], + "responses": { + "204": { + "description": "No Content" + }, + "404": { + "description": "Not Found" + } + } + } + }, + "/application/beans": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'beans'", + "operationId": "beans", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "Link": { + "type": "object", + "properties": { + "href": { + "type": "string" + }, + "templated": { + "type": "boolean" + } + } + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/resources/results/3.1.0/app186.json b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/resources/results/3.1.0/app186.json new file mode 100644 index 000000000..18314bb45 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/resources/results/3.1.0/app186.json @@ -0,0 +1,891 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "Actuator", + "description": "Monitor and interact", + "externalDocs": { + "description": "Spring Boot Actuator Web API Documentation", + "url": "https://docs.spring.io/spring-boot/docs/current/actuator-api/html/" + } + } + ], + "paths": { + "/actuator/loggers/{name}": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'loggers-name'", + "operationId": "loggerLevels", + "parameters": [ + { + "name": "name", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + }, + "404": { + "description": "Not Found" + } + } + }, + "post": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'loggers-name'", + "operationId": "configureLogLevel", + "parameters": [ + { + "name": "name", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "string", + "enum": [ + "TRACE", + "DEBUG", + "INFO", + "WARN", + "ERROR", + "FATAL", + "OFF" + ] + } + } + } + }, + "responses": { + "204": { + "description": "No Content" + }, + "400": { + "description": "Bad Request" + } + } + } + }, + "/actuator": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator root web endpoint", + "operationId": "links", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object", + "additionalProperties": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/Link" + } + } + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object", + "additionalProperties": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/Link" + } + } + } + }, + "application/json": { + "schema": { + "type": "object", + "additionalProperties": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/Link" + } + } + } + } + } + } + } + } + }, + "/actuator/threaddump": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'threaddump'", + "operationId": "threadDump", + "responses": { + "200": { + "description": "OK", + "content": { + "text/plain;charset=UTF-8": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/actuator/scheduledtasks": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'scheduledtasks'", + "operationId": "scheduledTasks", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/actuator/sbom": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'sbom'", + "operationId": "sboms", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/actuator/sbom/{id}": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'sbom-id'", + "operationId": "sbom", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/octet-stream": { + "schema": { + "type": "object" + } + } + } + }, + "404": { + "description": "Not Found" + } + } + } + }, + "/actuator/metrics": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'metrics'", + "operationId": "listNames", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/actuator/metrics/{requiredMetricName}": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'metrics-requiredMetricName'", + "operationId": "metric", + "parameters": [ + { + "name": "requiredMetricName", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "tag", + "in": "query", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + }, + "404": { + "description": "Not Found" + } + } + } + }, + "/actuator/mappings": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'mappings'", + "operationId": "mappings", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/actuator/loggers": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'loggers'", + "operationId": "loggers", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/actuator/info": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'info'", + "operationId": "info", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/actuator/heapdump": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'heapdump'", + "operationId": "heapDump", + "parameters": [ + { + "name": "live", + "in": "query", + "schema": { + "type": "boolean" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/octet-stream": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/actuator/health": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'health'", + "operationId": "health", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/actuator/env": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'env'", + "operationId": "environment", + "parameters": [ + { + "name": "pattern", + "in": "query", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/actuator/env/{toMatch}": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'env-toMatch'", + "operationId": "environmentEntry", + "parameters": [ + { + "name": "toMatch", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + }, + "404": { + "description": "Not Found" + } + } + } + }, + "/actuator/configprops": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'configprops'", + "operationId": "configurationProperties", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/actuator/configprops/{prefix}": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'configprops-prefix'", + "operationId": "configurationPropertiesWithPrefix", + "parameters": [ + { + "name": "prefix", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + }, + "404": { + "description": "Not Found" + } + } + } + }, + "/actuator/conditions": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'conditions'", + "operationId": "conditions", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/actuator/caches": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'caches'", + "operationId": "caches", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + }, + "delete": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'caches'", + "operationId": "clearCaches", + "responses": { + "204": { + "description": "No Content" + } + } + } + }, + "/actuator/caches/{cache}": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'caches-cache'", + "operationId": "cache", + "parameters": [ + { + "name": "cache", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "cacheManager", + "in": "query", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + }, + "404": { + "description": "Not Found" + } + } + }, + "delete": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'caches-cache'", + "operationId": "clearCache", + "parameters": [ + { + "name": "cache", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "cacheManager", + "in": "query", + "schema": { + "type": "string" + } + } + ], + "responses": { + "204": { + "description": "No Content" + }, + "404": { + "description": "Not Found" + } + } + } + }, + "/actuator/beans": { + "get": { + "tags": [ + "Actuator" + ], + "summary": "Actuator web endpoint 'beans'", + "operationId": "beans", + "responses": { + "200": { + "description": "OK", + "content": { + "application/vnd.spring-boot.actuator.v3+json": { + "schema": { + "type": "object" + } + }, + "application/vnd.spring-boot.actuator.v2+json": { + "schema": { + "type": "object" + } + }, + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "Link": { + "type": "object", + "properties": { + "href": { + "type": "string" + }, + "templated": { + "type": "boolean" + } + } + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/resources/results/3.1.0/app68-1.json b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/resources/results/3.1.0/app68-1.json new file mode 100644 index 000000000..32ec4b6aa --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/resources/results/3.1.0/app68-1.json @@ -0,0 +1,273 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "Petstore API", + "description": "This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.", + "termsOfService": "http://swagger.io/terms/", + "license": { + "name": "Apache 2.0", + "url": "http://springdoc.org" + }, + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "store", + "description": "the store API" + } + ], + "paths": { + "/store/order/{orderId}": { + "get": { + "tags": [ + "store" + ], + "summary": "Find purchase order by ID", + "operationId": "getOrderById", + "parameters": [ + { + "name": "orderId", + "in": "path", + "description": "ID of pet that needs to be fetched", + "required": true, + "schema": { + "maximum": 5, + "minimum": 1, + "type": "integer", + "format": "int64" + } + } + ], + "responses": { + "400": { + "description": "Invalid ID supplied", + "content": { + "*/*": { + "schema": { + "type": "object", + "additionalProperties": { + "type": "object" + } + } + } + } + }, + "404": { + "description": "Order not found", + "content": { + "application/xml": { + "schema": { + "$ref": "#/components/schemas/Order" + } + }, + "application/json": { + "schema": { + "$ref": "#/components/schemas/Order" + } + } + } + }, + "200": { + "description": "successful operation", + "content": { + "application/xml": { + "schema": { + "$ref": "#/components/schemas/Order" + } + }, + "application/json": { + "schema": { + "$ref": "#/components/schemas/Order" + } + } + } + } + } + }, + "delete": { + "tags": [ + "store" + ], + "summary": "Delete purchase order by ID", + "operationId": "deleteOrder", + "parameters": [ + { + "name": "orderId", + "in": "path", + "description": "ID of the order that needs to be deleted", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "400": { + "description": "Invalid ID supplied", + "content": { + "*/*": { + "schema": { + "type": "object", + "additionalProperties": { + "type": "object" + } + } + } + } + }, + "404": { + "description": "Order not found" + } + } + } + }, + "/store/inventory": { + "get": { + "tags": [ + "store" + ], + "summary": "Returns pet inventories by status", + "description": "Returns a map of status codes to quantities", + "operationId": "getInventory", + "responses": { + "400": { + "description": "Bad Request", + "content": { + "*/*": { + "schema": { + "type": "object", + "additionalProperties": { + "type": "object" + } + } + } + } + }, + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + } + } + } + }, + "security": [ + { + "api_key": [] + } + ] + } + }, + "/store/order": { + "post": { + "tags": [ + "store" + ], + "summary": "Place an order for a pet", + "operationId": "placeOrder", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Order" + } + } + }, + "required": true + }, + "responses": { + "400": { + "description": "Invalid Order", + "content": { + "*/*": { + "schema": { + "type": "object", + "additionalProperties": { + "type": "object" + } + } + } + } + }, + "200": { + "description": "successful operation", + "content": { + "application/xml": { + "schema": { + "$ref": "#/components/schemas/Order" + } + }, + "application/json": { + "schema": { + "$ref": "#/components/schemas/Order" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "Order": { + "type": "object", + "properties": { + "complete": { + "type": "boolean" + }, + "id": { + "type": "integer", + "format": "int64" + }, + "petId": { + "type": "integer", + "format": "int64" + }, + "quantity": { + "type": "integer", + "format": "int32" + }, + "shipDate": { + "type": "string", + "format": "date-time" + }, + "status": { + "type": "string", + "description": "Order Status" + } + } + } + }, + "securitySchemes": { + "basicScheme": { + "type": "http", + "scheme": "basic" + }, + "petstore_auth": { + "type": "oauth2", + "flows": { + "implicit": { + "authorizationUrl": "http://petstore.swagger.io/oauth/dialog", + "scopes": { + "write:pets": "modify pets in your account", + "read:pets": "read your pets" + } + } + } + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/resources/results/3.1.0/app68-2.json b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/resources/results/3.1.0/app68-2.json new file mode 100644 index 000000000..572726ca3 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/resources/results/3.1.0/app68-2.json @@ -0,0 +1,434 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "Petstore API", + "description": "This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.", + "termsOfService": "http://swagger.io/terms/", + "license": { + "name": "Apache 2.0", + "url": "http://springdoc.org" + }, + "version": "v0" + }, + "servers": [ + { + "url": "http://toto.v1.com", + "description": "myserver1" + } + ], + "tags": [ + { + "name": "user", + "description": "the user API" + } + ], + "paths": { + "/user/{username}": { + "get": { + "tags": [ + "user" + ], + "summary": "Get user by user name", + "operationId": "getUserByName", + "parameters": [ + { + "name": "username", + "in": "path", + "description": "The name that needs to be fetched. Use user1 for testing.", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "400": { + "description": "Invalid username supplied", + "content": { + "*/*": { + "schema": { + "type": "object", + "additionalProperties": { + "type": "object" + } + } + } + } + }, + "200": { + "description": "successful operation", + "content": { + "application/xml": { + "schema": { + "$ref": "#/components/schemas/User" + } + }, + "application/json": { + "schema": { + "$ref": "#/components/schemas/User" + } + } + } + }, + "404": { + "description": "User not found", + "content": { + "application/xml": { + "schema": { + "$ref": "#/components/schemas/User" + } + }, + "application/json": { + "schema": { + "$ref": "#/components/schemas/User" + } + } + } + } + } + }, + "put": { + "tags": [ + "user" + ], + "summary": "Updated user", + "operationId": "updateUser", + "parameters": [ + { + "name": "username", + "in": "path", + "description": "name that need to be deleted", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "description": "Updated user object", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/User" + } + } + }, + "required": true + }, + "responses": { + "400": { + "description": "Invalid user supplied", + "content": { + "*/*": { + "schema": { + "type": "object", + "additionalProperties": { + "type": "object" + } + } + } + } + }, + "404": { + "description": "User not found" + } + } + }, + "delete": { + "tags": [ + "user" + ], + "summary": "Creates list of users with given input array", + "operationId": "deleteUser", + "parameters": [ + { + "name": "username", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "400": { + "description": "Bad Request", + "content": { + "*/*": { + "schema": { + "type": "object", + "additionalProperties": { + "type": "object" + } + } + } + } + }, + "200": { + "description": "successful operation" + } + } + } + }, + "/user/login": { + "get": { + "tags": [ + "user" + ], + "summary": "Logs user into the system", + "operationId": "loginUser", + "parameters": [ + { + "name": "username", + "in": "query", + "description": "The user name for login", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "password", + "in": "query", + "description": "The password for login in clear text", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "400": { + "description": "Invalid username/password supplied", + "content": { + "*/*": { + "schema": { + "type": "object", + "additionalProperties": { + "type": "object" + } + } + } + } + }, + "200": { + "description": "successful operation", + "content": { + "application/xml": { + "schema": { + "type": "string" + } + }, + "application/json": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/user": { + "post": { + "tags": [ + "user" + ], + "summary": "Create user", + "operationId": "createUser", + "requestBody": { + "description": "Created user object", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/User" + } + } + }, + "required": true + }, + "responses": { + "400": { + "description": "Bad Request", + "content": { + "*/*": { + "schema": { + "type": "object", + "additionalProperties": { + "type": "object" + } + } + } + } + }, + "200": { + "description": "successful operation" + } + } + } + }, + "/user/logout": { + "get": { + "tags": [ + "user" + ], + "summary": "Logs out current logged in user session", + "operationId": "logoutUser", + "responses": { + "400": { + "description": "Bad Request", + "content": { + "*/*": { + "schema": { + "type": "object", + "additionalProperties": { + "type": "object" + } + } + } + } + }, + "200": { + "description": "successful operation" + } + } + } + }, + "/user/createWithList": { + "post": { + "tags": [ + "user" + ], + "summary": "Creates list of users with given input array", + "operationId": "createUsersWithListInput", + "requestBody": { + "description": "List of user object", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/User" + } + } + } + }, + "required": true + }, + "responses": { + "400": { + "description": "Bad Request", + "content": { + "*/*": { + "schema": { + "type": "object", + "additionalProperties": { + "type": "object" + } + } + } + } + }, + "200": { + "description": "successful operation" + } + } + } + }, + "/user/createWithArray": { + "post": { + "tags": [ + "user" + ], + "summary": "Creates list of users with given input array", + "operationId": "createUsersWithArrayInput", + "requestBody": { + "description": "List of user object", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/User" + } + } + } + }, + "required": true + }, + "responses": { + "400": { + "description": "Bad Request", + "content": { + "*/*": { + "schema": { + "type": "object", + "additionalProperties": { + "type": "object" + } + } + } + } + }, + "200": { + "description": "successful operation" + } + } + } + } + }, + "components": { + "schemas": { + "User": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "username": { + "type": "string" + }, + "firstName": { + "type": "string" + }, + "lastName": { + "type": "string" + }, + "email": { + "type": "string" + }, + "password": { + "type": "string" + }, + "phone": { + "type": "string" + }, + "userStatus": { + "type": "integer", + "description": "User Status", + "format": "int32" + } + } + } + }, + "securitySchemes": { + "basicScheme": { + "type": "http", + "scheme": "basic" + }, + "petstore_auth": { + "type": "oauth2", + "flows": { + "implicit": { + "authorizationUrl": "http://petstore.swagger.io/oauth/dialog", + "scopes": { + "write:pets": "modify pets in your account", + "read:pets": "read your pets" + } + } + } + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/resources/results/3.1.0/app68-3.json b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/resources/results/3.1.0/app68-3.json new file mode 100644 index 000000000..a99ca2d3f --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/resources/results/3.1.0/app68-3.json @@ -0,0 +1,639 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "Petstore API", + "description": "This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.", + "termsOfService": "http://swagger.io/terms/", + "license": { + "name": "Apache 2.0", + "url": "http://springdoc.org" + }, + "version": "v0" + }, + "servers": [ + { + "url": "http://toto.v2.com", + "description": "myserver2" + } + ], + "tags": [ + { + "name": "pet", + "description": "the pet API" + } + ], + "paths": { + "/pet": { + "put": { + "tags": [ + "pet" + ], + "summary": "Update an existing pet", + "operationId": "updatePet", + "requestBody": { + "description": "Pet object that needs to be added to the store", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Pet" + } + }, + "application/xml": { + "schema": { + "$ref": "#/components/schemas/Pet" + } + } + }, + "required": true + }, + "responses": { + "400": { + "description": "Invalid ID supplied", + "content": { + "*/*": { + "schema": { + "type": "object", + "additionalProperties": { + "type": "object" + } + } + } + } + }, + "404": { + "description": "Pet not found" + }, + "405": { + "description": "Validation exception" + } + }, + "security": [ + { + "petstore_auth": [ + "write:pets", + "read:pets" + ] + } + ] + }, + "post": { + "tags": [ + "pet" + ], + "summary": "Add a new pet to the store", + "operationId": "addPet", + "requestBody": { + "description": "Pet object that needs to be added to the store", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Pet" + } + }, + "application/xml": { + "schema": { + "$ref": "#/components/schemas/Pet" + } + } + }, + "required": true + }, + "responses": { + "400": { + "description": "Bad Request", + "content": { + "*/*": { + "schema": { + "type": "object", + "additionalProperties": { + "type": "object" + } + } + } + } + }, + "405": { + "description": "Invalid input" + } + }, + "security": [ + { + "petstore_auth": [ + "write:pets", + "read:pets" + ] + } + ] + } + }, + "/pet/{petId}": { + "get": { + "tags": [ + "pet" + ], + "summary": "Find pet by ID", + "description": "Returns a single pet", + "operationId": "getPetById", + "parameters": [ + { + "name": "petId", + "in": "path", + "description": "ID of pet to return", + "required": true, + "schema": { + "type": "integer", + "format": "int64" + } + } + ], + "responses": { + "400": { + "description": "Invalid ID supplied", + "content": { + "*/*": { + "schema": { + "type": "object", + "additionalProperties": { + "type": "object" + } + } + } + } + }, + "404": { + "description": "Pet not found", + "content": { + "application/xml": { + "schema": { + "$ref": "#/components/schemas/Pet" + } + }, + "application/json": { + "schema": { + "$ref": "#/components/schemas/Pet" + } + } + } + }, + "200": { + "description": "successful operation", + "content": { + "application/xml": { + "schema": { + "$ref": "#/components/schemas/Pet" + } + }, + "application/json": { + "schema": { + "$ref": "#/components/schemas/Pet" + } + } + } + } + }, + "security": [ + { + "api_key": [] + } + ] + }, + "post": { + "tags": [ + "pet" + ], + "summary": "Updates a pet in the store with form data", + "operationId": "updatePetWithForm", + "parameters": [ + { + "name": "petId", + "in": "path", + "description": "ID of pet that needs to be updated", + "required": true, + "schema": { + "type": "integer", + "format": "int64" + } + } + ], + "requestBody": { + "content": { + "application/x-www-form-urlencoded": { + "schema": { + "type": "object", + "properties": { + "name": { + "type": "string", + "description": "Updated name of the pet" + }, + "status": { + "type": "string", + "description": "Updated status of the pet" + } + } + } + } + } + }, + "responses": { + "400": { + "description": "Bad Request", + "content": { + "*/*": { + "schema": { + "type": "object", + "additionalProperties": { + "type": "object" + } + } + } + } + }, + "405": { + "description": "Invalid input" + } + }, + "security": [ + { + "petstore_auth": [ + "write:pets", + "read:pets" + ] + } + ] + }, + "delete": { + "tags": [ + "pet" + ], + "summary": "Deletes a pet", + "operationId": "deletePet", + "parameters": [ + { + "name": "petId", + "in": "path", + "description": "Pet id to delete", + "required": true, + "schema": { + "type": "integer", + "format": "int64" + } + }, + { + "name": "api_key", + "in": "header", + "required": false, + "schema": { + "type": "string" + } + } + ], + "responses": { + "400": { + "description": "Invalid ID supplied", + "content": { + "*/*": { + "schema": { + "type": "object", + "additionalProperties": { + "type": "object" + } + } + } + } + }, + "404": { + "description": "Pet not found" + } + }, + "security": [ + { + "petstore_auth": [ + "write:pets", + "read:pets" + ] + } + ] + } + }, + "/pet/{petId}/uploadImage": { + "post": { + "tags": [ + "pet" + ], + "summary": "uploads an image", + "operationId": "uploadFile", + "parameters": [ + { + "name": "petId", + "in": "path", + "description": "ID of pet to update", + "required": true, + "schema": { + "type": "integer", + "format": "int64" + } + }, + { + "name": "additionalMetadata", + "in": "query", + "description": "Additional data to pass to server", + "required": false, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "multipart/form-data": { + "schema": { + "required": [ + "file" + ], + "type": "object", + "properties": { + "file": { + "type": "string", + "description": "file detail", + "format": "binary" + } + } + } + } + } + }, + "responses": { + "400": { + "description": "Bad Request", + "content": { + "*/*": { + "schema": { + "type": "object", + "additionalProperties": { + "type": "object" + } + } + } + } + }, + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ModelApiResponse" + } + } + } + } + }, + "security": [ + { + "petstore_auth": [ + "write:pets", + "read:pets" + ] + } + ] + } + }, + "/pet/findByTags": { + "get": { + "tags": [ + "pet" + ], + "summary": "Finds Pets by tags", + "description": "Muliple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.", + "operationId": "findPetsByTags", + "parameters": [ + { + "name": "tags", + "in": "query", + "description": "Tags to filter by", + "required": true, + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + } + ], + "responses": { + "400": { + "description": "Invalid tag value", + "content": { + "*/*": { + "schema": { + "type": "object", + "additionalProperties": { + "type": "object" + } + } + } + } + }, + "200": { + "description": "successful operation", + "content": { + "application/xml": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Pet" + } + } + }, + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Pet" + } + } + } + } + } + }, + "security": [ + { + "petstore_auth": [ + "write:pets", + "read:pets" + ] + } + ] + } + }, + "/pet/findByStatus": { + "get": { + "tags": [ + "pet" + ], + "summary": "Finds Pets by status", + "description": "Multiple status values can be provided with comma separated strings", + "operationId": "findPetsByStatus", + "parameters": [ + { + "name": "status", + "in": "query", + "description": "Status values that need to be considered for filter", + "required": true, + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + } + ], + "responses": { + "400": { + "description": "Invalid status value", + "content": { + "*/*": { + "schema": { + "type": "object", + "additionalProperties": { + "type": "object" + } + } + } + } + }, + "200": { + "description": "successful operation", + "content": { + "application/xml": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Pet" + } + } + }, + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Pet" + } + } + } + } + } + }, + "security": [ + { + "petstore_auth": [ + "write:pets", + "read:pets" + ] + } + ] + } + } + }, + "components": { + "schemas": { + "Category": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "name": { + "type": "string" + } + } + }, + "Pet": { + "required": [ + "name", + "photoUrls" + ], + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "category": { + "$ref": "#/components/schemas/Category" + }, + "name": { + "type": "string", + "example": "doggie" + }, + "photoUrls": { + "type": "array", + "items": { + "type": "string" + } + }, + "tags": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Tag" + } + }, + "status": { + "type": "string", + "description": "pet status in the store", + "enum": [ + "available", + "pending", + "sold" + ] + } + } + }, + "Tag": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "name": { + "type": "string" + } + } + }, + "ModelApiResponse": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "type": { + "type": "string" + }, + "message": { + "type": "string" + } + } + } + }, + "securitySchemes": { + "basicScheme": { + "type": "http", + "scheme": "basic" + }, + "petstore_auth": { + "type": "oauth2", + "flows": { + "implicit": { + "authorizationUrl": "http://petstore.swagger.io/oauth/dialog", + "scopes": { + "write:pets": "modify pets in your account", + "read:pets": "read your pets" + } + } + } + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/resources/results/3.1.0/app68-4.json b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/resources/results/3.1.0/app68-4.json new file mode 100644 index 000000000..f393a5154 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/resources/results/3.1.0/app68-4.json @@ -0,0 +1,83 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "Petstore API", + "description": "This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.", + "termsOfService": "http://swagger.io/terms/", + "license": { + "name": "Apache 2.0", + "url": "http://springdoc.org" + }, + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "store", + "description": "the store API" + } + ], + "paths": { + "/v1/stores": { + "get": { + "tags": [ + "store" + ], + "operationId": "stores", + "parameters": [ + { + "name": "name", + "in": "query", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "400": { + "description": "Bad Request", + "content": { + "*/*": { + "schema": { + "type": "object", + "additionalProperties": { + "type": "object" + } + } + } + } + }, + "200": { + "description": "OK" + } + } + } + } + }, + "components": { + "securitySchemes": { + "basicScheme": { + "type": "http", + "scheme": "basic" + }, + "petstore_auth": { + "type": "oauth2", + "flows": { + "implicit": { + "authorizationUrl": "http://petstore.swagger.io/oauth/dialog", + "scopes": { + "write:pets": "modify pets in your account", + "read:pets": "read your pets" + } + } + } + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/resources/results/app145.json b/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/resources/results/app145.json deleted file mode 100644 index 8f45f3ad4..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-actuator-webmvc-tests/src/test/resources/results/app145.json +++ /dev/null @@ -1,36 +0,0 @@ -{ - "openapi": "3.0.1", - "info": { - "title": "OpenAPI definition", - "version": "v0" - }, - "servers": [ - { - "url": "http://localhost:52556", - "description": "Generated server url" - } - ], - "paths": { - "/persons": { - "get": { - "tags": [ - "hello-controller" - ], - "operationId": "persons", - "responses": { - "200": { - "description": "OK", - "content": { - "*/*": { - "schema": { - "type": "string" - } - } - } - } - } - } - } - }, - "components": {} -} 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 15fa7aef7..a4e997646 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.1 + 2.8.2 4.0.0 springdoc-openapi-data-rest-tests diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/AbstractSpringDocTest.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/AbstractSpringDocTest.java deleted file mode 100644 index ae5f08e1b..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/AbstractSpringDocTest.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * - * * Copyright 2019-2020 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; - -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; - -import org.junit.jupiter.api.Test; -import org.springdoc.core.utils.Constants; - -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.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; - -@ActiveProfiles("test") -@SpringBootTest -@AutoConfigureMockMvc -@TestPropertySource(properties = "springdoc.api-docs.version=openapi_3_0" ) -public abstract class AbstractSpringDocTest { - - public static String className; - - @Autowired - protected MockMvc mockMvc; - - public static String getContent(String fileName) { - try { - Path path = Paths.get(AbstractSpringDocTest.class.getClassLoader().getResource(fileName).toURI()); - byte[] fileBytes = Files.readAllBytes(path); - return new String(fileBytes, StandardCharsets.UTF_8); - } - catch (Exception e) { - throw new RuntimeException("Failed to read file: " + fileName, e); - } - } - - @Test - void testApp() throws Exception { - className = getClass().getSimpleName(); - String testNumber = className.replaceAll("[^0-9]", ""); - MvcResult mockMvcResult = mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL)).andExpect(status().isOk()) - .andExpect(jsonPath("$.openapi", is("3.0.1"))).andReturn(); - String result = mockMvcResult.getResponse().getContentAsString(); - Path path = Paths.get(getClass().getClassLoader().getResource("results/app" + testNumber + ".json").toURI()); - byte[] fileBytes = Files.readAllBytes(path); - String expected = new String(fileBytes); - assertEquals(expected, result, true); - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app10/Account.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app10/Account.java deleted file mode 100644 index d6d67d96d..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app10/Account.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * - * * - * * * - * * * * Copyright 2019-2020 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.app10; - -import java.util.Date; - -import jakarta.persistence.Entity; -import jakarta.persistence.GeneratedValue; -import jakarta.persistence.GenerationType; -import jakarta.persistence.Id; -import jakarta.persistence.ManyToOne; -import jakarta.persistence.Temporal; -import jakarta.persistence.TemporalType; - -@Entity -public class Account { - - @Id - @GeneratedValue(strategy = GenerationType.AUTO) - private Long id; - - @ManyToOne - private Customer customer; - - @Temporal(TemporalType.DATE) - private Date expiryDate; - - public Long getId() { - return id; - } - - public Customer getCustomer() { - return customer; - } - - public Date getExpiryDate() { - return expiryDate; - } -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app10/AccountRepository.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app10/AccountRepository.java deleted file mode 100644 index 68c733f3e..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app10/AccountRepository.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * - * * - * * * - * * * * Copyright 2019-2020 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.app10; - - -import java.util.List; - -import org.springframework.data.repository.CrudRepository; -import org.springframework.data.repository.query.Param; -import org.springframework.data.rest.core.annotation.RepositoryRestResource; - -/** - * Repository to manage {@link Account} instances. - * - */ -@RepositoryRestResource -public interface AccountRepository extends CrudRepository { - - /** - * Returns all accounts belonging to the given {@link Customer}. - * - * @param customer - * @return - */ - List findByCustomer(@Param("customer") Customer customer); -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app10/Customer.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app10/Customer.java deleted file mode 100644 index 7efc70c7e..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app10/Customer.java +++ /dev/null @@ -1,34 +0,0 @@ -package test.org.springdoc.api.app10; - - -import jakarta.persistence.Entity; -import jakarta.persistence.GeneratedValue; -import jakarta.persistence.GenerationType; -import jakarta.persistence.Id; - -/** - * @author Oliver Gierke - */ -@Entity -public class Customer { - - @Id - @GeneratedValue(strategy = GenerationType.AUTO) - private Long id; - - private String firstname; - - private String lastname; - - public Long getId() { - return id; - } - - public String getFirstname() { - return firstname; - } - - public String getLastname() { - return lastname; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app10/CustomerRepository.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app10/CustomerRepository.java deleted file mode 100644 index da7c7609b..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app10/CustomerRepository.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * - * * - * * * - * * * * Copyright 2019-2020 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.app10; - -import java.util.List; -import java.util.Optional; - -import org.springframework.data.domain.Page; -import org.springframework.data.domain.Pageable; -import org.springframework.data.jpa.repository.JpaSpecificationExecutor; -import org.springframework.data.repository.CrudRepository; -import org.springframework.data.repository.query.Param; -import org.springframework.data.rest.core.annotation.RepositoryRestResource; -import org.springframework.data.rest.core.annotation.RestResource; - -/** - * Repository to manage {@link Customer} instances. - * - * @author Oliver Gierke - */ -@RepositoryRestResource -public interface CustomerRepository extends CrudRepository, JpaSpecificationExecutor { - - /** - * Returns a page of {@link Customer}s with the given lastname. - * - * @param lastname - * @param pageable - * @return - */ - Page findByLastname(@Param("lastname") String lastname, Pageable pageable); - - @Override - @RestResource(exported = false) - void deleteById(Long id); - - @Override - @RestResource(exported = false) - void delete(Customer entity); - - @Override - @RestResource - List findAll(); - - @Override - @RestResource(exported = false) - Optional findById(Long aLong); - - @Override - @RestResource(exported = false) - S save(S entity); -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app10/SpringDocApp10Test.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app10/SpringDocApp10Test.java deleted file mode 100644 index 2e2a805f8..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app10/SpringDocApp10Test.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * - * * - * * * - * * * * Copyright 2019-2020 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.app10; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -public class SpringDocApp10Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp {} -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app11/Person.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app11/Person.java deleted file mode 100644 index 08dcf2865..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app11/Person.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * - * * - * * * - * * * * Copyright 2019-2020 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.app11; - -import jakarta.persistence.Entity; -import jakarta.persistence.GeneratedValue; -import jakarta.persistence.GenerationType; -import jakarta.persistence.Id; - -@Entity -public class Person { - - @Id - @GeneratedValue(strategy = GenerationType.AUTO) - private long id; - - private String firstName; - - private String lastName; - - public String getFirstName() { - return firstName; - } - - public void setFirstName(String firstName) { - this.firstName = firstName; - } - - public String getLastName() { - return lastName; - } - - public void setLastName(String lastName) { - this.lastName = lastName; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app11/PersonRepository.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app11/PersonRepository.java deleted file mode 100644 index 87029cbdf..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app11/PersonRepository.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * - * * - * * * - * * * * Copyright 2019-2020 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.app11; - -import java.util.List; - -import org.springframework.data.repository.PagingAndSortingRepository; -import org.springframework.data.repository.query.Param; -import org.springframework.data.rest.core.annotation.RepositoryRestResource; - -@RepositoryRestResource(collectionResourceRel = "people", path = "peopleme") -public interface PersonRepository extends PagingAndSortingRepository { - - List findByLastName(@Param("name") String name); - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app11/SpringDocApp11Test.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app11/SpringDocApp11Test.java deleted file mode 100644 index 83d58a1aa..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app11/SpringDocApp11Test.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * - * * - * * * - * * * * Copyright 2019-2020 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.app11; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -public class SpringDocApp11Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp {} -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app12/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app12/HelloController.java deleted file mode 100644 index b17b8a771..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app12/HelloController.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app12; - -import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.media.Content; -import io.swagger.v3.oas.annotations.media.Schema; -import io.swagger.v3.oas.annotations.responses.ApiResponse; - -import org.springframework.hateoas.EntityModel; -import org.springframework.hateoas.MediaTypes; -import org.springframework.hateoas.server.mvc.WebMvcLinkBuilder; -import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - - -@RequestMapping("/demo") -@RestController -public class HelloController { - - @Operation(summary = "GetMyData", operationId = "gettt", - responses = @ApiResponse(responseCode = "204", - content = @Content(mediaType = "application/vnd.something"))) - @GetMapping(produces = "application/vnd.something") - public ResponseEntity getSomethingElse() { - return ResponseEntity.noContent().build(); - } - - @GetMapping(produces = MediaType.TEXT_PLAIN_VALUE) - public String get() { - return "some text"; - } - - @GetMapping(produces = MediaTypes.HAL_JSON_VALUE) - public EntityModel getHal() { - return EntityModel.of(new JsonResponse(), - WebMvcLinkBuilder.linkTo(HelloController.class).slash("somelink").withSelfRel() - ); - } - - @GetMapping(produces = MediaType.APPLICATION_JSON_VALUE) - public JsonResponse getJson() { - return new JsonResponse(); - } - - @GetMapping(produces = MediaType.APPLICATION_XML_VALUE) - @ApiResponse(responseCode = "202", - content = @Content(mediaType = MediaType.APPLICATION_XML_VALUE, schema = @Schema(implementation = JsonResponse.class))) - public JsonResponse getXML() { - return new JsonResponse(); - } - - public class JsonResponse { - @JsonProperty - private String field; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app12/SpringDocApp12Test.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app12/SpringDocApp12Test.java deleted file mode 100644 index 386ae591a..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app12/SpringDocApp12Test.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * - * * - * * * - * * * * Copyright 2019-2020 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.app12; - -import io.swagger.v3.oas.models.Operation; -import org.springdoc.core.customizers.OperationCustomizer; -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.Bean; -import org.springframework.web.method.HandlerMethod; - -public class SpringDocApp12Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp { - @Bean - OperationCustomizer operationCustomizer() { - return (Operation operation, HandlerMethod handlerMethod) -> { - if (operation.getOperationId().startsWith("gettt")) - operation.setOperationId("gettt"); - return operation; - }; - } - } - -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app13/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app13/HelloController.java deleted file mode 100644 index 98c914111..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app13/HelloController.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app13; - -import java.util.List; - -import org.springdoc.core.annotations.ParameterObject; - -import org.springframework.data.domain.Pageable; -import org.springframework.data.domain.Sort.Direction; -import org.springframework.data.web.PageableDefault; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -@RestController -public class HelloController { - - @GetMapping(value = "/search", produces = { "application/xml", "application/json" }) - public ResponseEntity> getAllPets(@PageableDefault(size = 5, sort = "name") @ParameterObject Pageable pageable) { - return null; - } - - - @GetMapping("/test1") - public String getPatientList1(@PageableDefault(size = 100, sort = { "someField", "someoTHER" }, - direction = Direction.DESC) - @ParameterObject Pageable pageable) { - return "bla"; - } - - @GetMapping("/test2") - public String getPatientList2(@PageableDefault(size = 100, sort = "someField", - direction = Direction.DESC) - @ParameterObject Pageable pageable) { - return "bla"; - } - - @GetMapping("/test3") - public String getPatientList3(@PageableDefault(size = 100) - @ParameterObject Pageable pageable) { - return "bla"; - } - - @GetMapping("/test4") - public String getPatientList4(@PageableDefault(100) - @ParameterObject Pageable pageable) { - return "bla"; - } - - @GetMapping("/test5") - public void read( - @PageableDefault(sort = { - "some,desc", - "other,asc", - "another.that,desc" - }) - @ParameterObject final Pageable pageable) { - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app13/PersonDTO.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app13/PersonDTO.java deleted file mode 100644 index b71b02438..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app13/PersonDTO.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app13; - -import io.swagger.v3.oas.annotations.media.Schema; - -@Schema -public class PersonDTO { - private String email; - - private String firstName; - - private String lastName; - - public PersonDTO() { - } - - public PersonDTO(final String email, final String firstName, final String lastName) { - this.email = email; - this.firstName = firstName; - this.lastName = lastName; - } - - public String getEmail() { - return email; - } - - public void setEmail(final String email) { - this.email = email; - } - - public String getFirstName() { - return firstName; - } - - public void setFirstName(final String firstName) { - this.firstName = firstName; - } - - public String getLastName() { - return lastName; - } - - public void setLastName(final String lastName) { - this.lastName = lastName; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app13/SpringDocApp13Test.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app13/SpringDocApp13Test.java deleted file mode 100644 index 0a0f2efaa..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app13/SpringDocApp13Test.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * - * * - * * * - * * * * Copyright 2019-2020 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.app13; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -public class SpringDocApp13Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp {} - -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app14/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app14/HelloController.java deleted file mode 100644 index 2a8021b9b..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app14/HelloController.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app14; - -import java.util.List; - -import org.springdoc.core.annotations.ParameterObject; - -import org.springframework.data.domain.Pageable; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -@RestController -public class HelloController { - - @GetMapping(value = "/search", produces = { "application/xml", "application/json" }) - public ResponseEntity> getAllPets(@ParameterObject Pageable pageable) { - return null; - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app14/PersonDTO.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app14/PersonDTO.java deleted file mode 100644 index 6cd5f2bde..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app14/PersonDTO.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app14; - -import io.swagger.v3.oas.annotations.media.Schema; - -@Schema -public class PersonDTO { - private String email; - - private String firstName; - - private String lastName; - - public PersonDTO() { - } - - public PersonDTO(final String email, final String firstName, final String lastName) { - this.email = email; - this.firstName = firstName; - this.lastName = lastName; - } - - public String getEmail() { - return email; - } - - public void setEmail(final String email) { - this.email = email; - } - - public String getFirstName() { - return firstName; - } - - public void setFirstName(final String firstName) { - this.firstName = firstName; - } - - public String getLastName() { - return lastName; - } - - public void setLastName(final String lastName) { - this.lastName = lastName; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app14/SpringDocApp14Test.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app14/SpringDocApp14Test.java deleted file mode 100644 index 39c01662a..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app14/SpringDocApp14Test.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * - * * - * * * - * * * * Copyright 2019-2020 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.app14; - -import java.util.Optional; - -import org.springdoc.core.configuration.SpringDocDataRestConfiguration; -import org.springdoc.core.customizers.DataRestDelegatingMethodParameterCustomizer; -import org.springdoc.core.providers.RepositoryRestConfigurationProvider; -import org.springdoc.core.providers.SpringDataWebPropertiesProvider; -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; -import org.springframework.boot.autoconfigure.data.rest.RepositoryRestMvcAutoConfiguration; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Lazy; -import org.springframework.test.context.TestPropertySource; - -@TestPropertySource(properties = { "spring.data.web.pageable.default-page-size=25", - "spring.data.web.pageable.page-parameter=pages", - "spring.data.web.pageable.size-parameter=sizes", - "spring.data.web.pageable.one-indexed-parameters=true", - "spring.data.web.pageable.prefix=prefix_", - "spring.data.web.sort.sort-parameter=sorts" }) -@EnableAutoConfiguration(exclude = { - RepositoryRestMvcAutoConfiguration.class, SpringDocDataRestConfiguration.class -}) -public class SpringDocApp14Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp { - // We only need to test spring-web with Pageable, without the use of spring-data-rest-starter - @Bean - @ConditionalOnMissingBean - @Lazy(false) - DataRestDelegatingMethodParameterCustomizer dataRestDelegatingMethodParameterCustomizer(Optional optionalSpringDataWebPropertiesProvider, Optional optionalRepositoryRestConfiguration) { - return new DataRestDelegatingMethodParameterCustomizer(optionalSpringDataWebPropertiesProvider, optionalRepositoryRestConfiguration); - } - } - -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app15/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app15/HelloController.java deleted file mode 100644 index 0f44ebe1f..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app15/HelloController.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app15; - -import java.util.List; - -import org.springdoc.core.annotations.ParameterObject; - -import org.springframework.data.domain.Pageable; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -@RestController -public class HelloController { - - @GetMapping(value = "/search", produces = { "application/xml", "application/json" }) - public ResponseEntity> getAllPets(@ParameterObject Pageable pageable) { - return null; - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app15/PersonDTO.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app15/PersonDTO.java deleted file mode 100644 index 31ed71d36..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app15/PersonDTO.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app15; - -import io.swagger.v3.oas.annotations.media.Schema; - -@Schema -public class PersonDTO { - private String email; - - private String firstName; - - private String lastName; - - public PersonDTO() { - } - - public PersonDTO(final String email, final String firstName, final String lastName) { - this.email = email; - this.firstName = firstName; - this.lastName = lastName; - } - - public String getEmail() { - return email; - } - - public void setEmail(final String email) { - this.email = email; - } - - public String getFirstName() { - return firstName; - } - - public void setFirstName(final String firstName) { - this.firstName = firstName; - } - - public String getLastName() { - return lastName; - } - - public void setLastName(final String lastName) { - this.lastName = lastName; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app15/SpringDocApp15Test.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app15/SpringDocApp15Test.java deleted file mode 100644 index 4f01a58c9..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app15/SpringDocApp15Test.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * - * * - * * * - * * * * Copyright 2019-2020 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.app15; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.test.context.TestPropertySource; - -@TestPropertySource(properties = "spring.data.rest.default-page-size=50") -public class SpringDocApp15Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp {} - -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app16/Account.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app16/Account.java deleted file mode 100644 index 0dccfe830..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app16/Account.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * - * * - * * * - * * * * Copyright 2019-2020 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.app16; - -import java.util.Date; - -import jakarta.persistence.Entity; -import jakarta.persistence.GeneratedValue; -import jakarta.persistence.GenerationType; -import jakarta.persistence.Id; -import jakarta.persistence.ManyToOne; -import jakarta.persistence.Temporal; -import jakarta.persistence.TemporalType; - -@Entity -public class Account { - - @Id - @GeneratedValue(strategy = GenerationType.AUTO) - private Long id; - - @ManyToOne - private Customer customer; - - @Temporal(TemporalType.DATE) - private Date expiryDate; - - public Long getId() { - return id; - } - - public Customer getCustomer() { - return customer; - } - - public Date getExpiryDate() { - return expiryDate; - } -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app16/AccountRepository.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app16/AccountRepository.java deleted file mode 100644 index 11f20a658..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app16/AccountRepository.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * - * * - * * * - * * * * Copyright 2019-2020 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.app16; - - -import java.util.List; - -import io.swagger.v3.oas.annotations.security.SecurityRequirement; -import io.swagger.v3.oas.annotations.tags.Tag; - -import org.springframework.data.repository.CrudRepository; -import org.springframework.data.repository.query.Param; -import org.springframework.data.rest.core.annotation.RepositoryRestResource; - -/** - * Repository to manage {@link Account} instances. - * - */ -@RepositoryRestResource -@Tag(name = "The account Repository") -@SecurityRequirement(name = "bearer") -public interface AccountRepository extends CrudRepository { - - /** - * Returns all accounts belonging to the given {@link Customer}. - * - * @param customer - * @return - */ - List findByCustomer(@Param("customer") Customer customer); -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app16/Customer.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app16/Customer.java deleted file mode 100644 index 864a6d91a..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app16/Customer.java +++ /dev/null @@ -1,34 +0,0 @@ -package test.org.springdoc.api.app16; - - -import jakarta.persistence.Entity; -import jakarta.persistence.GeneratedValue; -import jakarta.persistence.GenerationType; -import jakarta.persistence.Id; - -/** - * @author Oliver Gierke - */ -@Entity -public class Customer { - - @Id - @GeneratedValue(strategy = GenerationType.AUTO) - private Long id; - - private String firstname; - - private String lastname; - - public Long getId() { - return id; - } - - public String getFirstname() { - return firstname; - } - - public String getLastname() { - return lastname; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app16/CustomerRepository.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app16/CustomerRepository.java deleted file mode 100644 index f61137c1e..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app16/CustomerRepository.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * - * * - * * * - * * * * Copyright 2019-2020 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.app16; - -import io.swagger.v3.oas.annotations.security.SecurityRequirement; -import io.swagger.v3.oas.annotations.tags.Tag; - -import org.springframework.data.domain.Page; -import org.springframework.data.domain.Pageable; -import org.springframework.data.jpa.repository.JpaSpecificationExecutor; -import org.springframework.data.repository.CrudRepository; -import org.springframework.data.repository.query.Param; -import org.springframework.data.rest.core.annotation.RepositoryRestResource; -import org.springframework.data.rest.core.annotation.RestResource; - -/** - * Repository to manage {@link Customer} instances. - * - * @author Oliver Gierke - */ -@RepositoryRestResource -@Tag(name = "The customer Repository") -public interface CustomerRepository extends CrudRepository, JpaSpecificationExecutor { - - /** - * Returns a page of {@link Customer}s with the given lastname. - * - * @param lastname - * @param pageable - * @return - */ - @SecurityRequirement(name = "bearer") - Page findByLastname(@Param("lastname") String lastname, Pageable pageable); - - @Override - @RestResource(exported = false) - void deleteById(Long id); - - @Override - @RestResource(exported = false) - void delete(Customer entity); -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app16/OpenApiConfig.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app16/OpenApiConfig.java deleted file mode 100644 index f7939932e..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app16/OpenApiConfig.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app16; - -import io.swagger.v3.oas.annotations.OpenAPIDefinition; -import io.swagger.v3.oas.annotations.enums.SecuritySchemeType; -import io.swagger.v3.oas.annotations.info.Info; -import io.swagger.v3.oas.annotations.info.License; -import io.swagger.v3.oas.annotations.security.SecurityScheme; - -@OpenAPIDefinition(info = @Info(title = "My App", description = "Some long and useful description", version = "v1", license = @License(name = "Apache 2.0", url = "https://www.apache.org/licenses/LICENSE-2.0"))) -@SecurityScheme(name = "bearer", type = SecuritySchemeType.HTTP, scheme = "bearer", bearerFormat = "JWT") -public class OpenApiConfig { -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app16/SpringDocApp16Test.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app16/SpringDocApp16Test.java deleted file mode 100644 index 56d2a5c06..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app16/SpringDocApp16Test.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * - * * - * * * - * * * * Copyright 2019-2020 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.app16; - -import io.swagger.v3.oas.models.Operation; -import org.springdoc.core.customizers.DataRestRouterOperationCustomizer; -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.Bean; - -public class SpringDocApp16Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp { - @Bean - public DataRestRouterOperationCustomizer addRouterOperationCustomizer() { - return (routerOperation) -> { - Operation operation = routerOperation.getOperationModel(); - operation.setSummary(operation.getOperationId()); - return routerOperation; - }; - } - } -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app17/ChildProperty.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app17/ChildProperty.java deleted file mode 100644 index 077a1798b..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app17/ChildProperty.java +++ /dev/null @@ -1,34 +0,0 @@ -package test.org.springdoc.api.app17; - -import jakarta.persistence.Entity; -import jakarta.persistence.GeneratedValue; -import jakarta.persistence.GenerationType; -import jakarta.persistence.Id; -import lombok.Data; - -@Entity -public @Data -class ChildProperty { - - @Id - @GeneratedValue(strategy = GenerationType.AUTO) - private long id; - - private String name; - - public long getId() { - return id; - } - - public void setId(long id) { - this.id = id; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app17/ChildPropertyRepository.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app17/ChildPropertyRepository.java deleted file mode 100644 index f9572893c..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app17/ChildPropertyRepository.java +++ /dev/null @@ -1,6 +0,0 @@ -package test.org.springdoc.api.app17; - -import org.springframework.data.repository.PagingAndSortingRepository; - -public interface ChildPropertyRepository extends PagingAndSortingRepository { -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app17/Property.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app17/Property.java deleted file mode 100644 index 1e969ded9..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app17/Property.java +++ /dev/null @@ -1,48 +0,0 @@ -package test.org.springdoc.api.app17; - -import jakarta.persistence.Entity; -import jakarta.persistence.GeneratedValue; -import jakarta.persistence.GenerationType; -import jakarta.persistence.Id; -import jakarta.persistence.JoinColumn; -import jakarta.persistence.ManyToOne; -import lombok.Data; - -@Entity -public @Data -class Property { - - @Id - @GeneratedValue(strategy = GenerationType.AUTO) - private long id; - - private String name; - - @ManyToOne - @JoinColumn(name = "child_property_id") - private ChildProperty myChildPropertyName; - - public long getId() { - return id; - } - - public void setId(long id) { - this.id = id; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public ChildProperty getMyChildPropertyName() { - return myChildPropertyName; - } - - public void setMyChildPropertyName(ChildProperty myChildPropertyName) { - this.myChildPropertyName = myChildPropertyName; - } -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app17/PropertyRepository.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app17/PropertyRepository.java deleted file mode 100644 index 51da75c24..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app17/PropertyRepository.java +++ /dev/null @@ -1,6 +0,0 @@ -package test.org.springdoc.api.app17; - -import org.springframework.data.repository.PagingAndSortingRepository; - -public interface PropertyRepository extends PagingAndSortingRepository { -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app17/SpringDocApp17Test.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app17/SpringDocApp17Test.java deleted file mode 100644 index 91f369ed2..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app17/SpringDocApp17Test.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * - * * - * * * - * * * * Copyright 2019-2020 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.app17; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -public class SpringDocApp17Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp {} -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app18/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app18/HelloController.java deleted file mode 100644 index df702f150..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app18/HelloController.java +++ /dev/null @@ -1,27 +0,0 @@ -package test.org.springdoc.api.app18; - -import io.swagger.v3.oas.annotations.Operation; -import jakarta.servlet.http.HttpServletRequest; -import jakarta.validation.Valid; -import org.springdoc.core.annotations.ParameterObject; - -import org.springframework.http.MediaType; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -@Validated -@RestController -@RequestMapping(value = { HelloController.VERSION + "/helloWorld", "latest/helloWorld" }, produces = MediaType.APPLICATION_JSON_VALUE) -public class HelloController { - - public static final String VERSION = "v1"; - - @Operation(summary = "Example endpoint") - @GetMapping("/helloWorld") - public HelloWorldModel helloWorld(@Valid @ParameterObject HelloWorldModel helloWorldModel, HttpServletRequest request) { - return new HelloWorldModel(); - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app18/HelloWorldModel.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app18/HelloWorldModel.java deleted file mode 100644 index 3afc09d10..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app18/HelloWorldModel.java +++ /dev/null @@ -1,37 +0,0 @@ -package test.org.springdoc.api.app18; - -import java.time.LocalDate; - -import io.swagger.v3.oas.annotations.Parameter; -import jakarta.validation.constraints.NotBlank; -import jakarta.validation.constraints.NotNull; - -import org.springframework.format.annotation.DateTimeFormat; - -public class HelloWorldModel { - - @Parameter(description = "Description for abc", example = "def") - @NotBlank - private String abc; - - @Parameter(description = "Description of this date", example = "2020-10-25") - @NotNull - @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) - private LocalDate thisDate; - - public String getAbc() { - return abc; - } - - public void setAbc(String abc) { - this.abc = abc; - } - - public LocalDate getThisDate() { - return thisDate; - } - - public void setThisDate(LocalDate thisDate) { - this.thisDate = thisDate; - } -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app18/SpringDocApp18Test.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app18/SpringDocApp18Test.java deleted file mode 100644 index 2c235e339..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app18/SpringDocApp18Test.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * - * * - * * * - * * * * Copyright 2019-2020 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.app18; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -public class SpringDocApp18Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp {} -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app19/Application.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app19/Application.java deleted file mode 100644 index eff19d5c6..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app19/Application.java +++ /dev/null @@ -1,80 +0,0 @@ -package test.org.springdoc.api.app19; - -import java.io.Serializable; -import java.time.LocalDateTime; - -import io.swagger.v3.oas.annotations.media.Schema; -import jakarta.persistence.Column; -import jakarta.persistence.Entity; -import jakarta.persistence.EntityListeners; -import jakarta.persistence.EnumType; -import jakarta.persistence.Enumerated; -import jakarta.persistence.GeneratedValue; -import jakarta.persistence.Id; -import jakarta.persistence.Table; -import lombok.Data; - -import org.springframework.data.annotation.CreatedDate; -import org.springframework.data.jpa.domain.support.AuditingEntityListener; - -@Data -@Entity -@Table(schema = "application", name = "application") -@Schema(description = "app") -@EntityListeners(AuditingEntityListener.class) -public class Application implements Serializable { - private static final long serialVersionUID = 6582562282311194139L; - - @Id - @Column(length = 64) - @GeneratedValue - @Schema(description = "id") - private String id; - - @Column(nullable = false, length = 64) - @Schema(description = "name") - private String name; - - @Column(length = 1024) - @Schema(description = "description") - private String description; - - @Column(length = 32) - @Schema(description = "app type") - @Enumerated(EnumType.STRING) - private AppType type = AppType.EXTERNAL; - - @Column - @Schema(description = "icon") - private String icon; - - @Column(nullable = false) - @CreatedDate - @Schema(description = "createTime") - private LocalDateTime createTime; - - @Column(length = 1024) - @Schema(description = "rsa-publicKey") - private String publicKey; - - @Column(length = 16, nullable = false) - @Enumerated(EnumType.STRING) - @Schema(description = "status") - private AuditStatus auditStatus = AuditStatus.UN_SUBMITTED; - - @Column - @Schema(description = "auditTime") - private LocalDateTime auditTime; - - public enum AuditStatus { - UN_SUBMITTED, - PENDING, - APPROVED, - FAILED - } - - public enum AppType { - INNER, - EXTERNAL - } -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app19/ApplicationPredicate.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app19/ApplicationPredicate.java deleted file mode 100644 index 87eb55761..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app19/ApplicationPredicate.java +++ /dev/null @@ -1,18 +0,0 @@ -package test.org.springdoc.api.app19; - -import com.querydsl.core.types.dsl.StringExpression; - -import org.springframework.data.querydsl.binding.QuerydslBinderCustomizer; -import org.springframework.data.querydsl.binding.QuerydslBindings; - -public class ApplicationPredicate implements QuerydslBinderCustomizer { - - @Override - public void customize(QuerydslBindings bindings, QApplication root) { - bindings.excludeUnlistedProperties(true); - bindings.bind(root.name).first(StringExpression::containsIgnoreCase); - bindings.including(root.icon); - bindings.including(root.name); - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app19/GreetingController.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app19/GreetingController.java deleted file mode 100644 index 4d29e645f..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app19/GreetingController.java +++ /dev/null @@ -1,19 +0,0 @@ -package test.org.springdoc.api.app19; - -import com.querydsl.core.types.Predicate; - -import org.springframework.data.querydsl.binding.QuerydslPredicate; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -@RestController -public class GreetingController { - - @GetMapping("/test2") - public ResponseEntity sayHello2(@QuerydslPredicate(root = Application.class, bindings = ApplicationPredicate.class) Predicate predicate, - @RequestParam String test) { - return ResponseEntity.ok().build(); - } -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app19/QApplication.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app19/QApplication.java deleted file mode 100644 index fac3afc5f..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app19/QApplication.java +++ /dev/null @@ -1,55 +0,0 @@ -package test.org.springdoc.api.app19; - -import com.querydsl.core.types.Path; -import com.querydsl.core.types.PathMetadata; -import com.querydsl.core.types.dsl.DateTimePath; -import com.querydsl.core.types.dsl.EntityPathBase; -import com.querydsl.core.types.dsl.EnumPath; -import com.querydsl.core.types.dsl.StringPath; -import jakarta.annotation.Generated; - -import static com.querydsl.core.types.PathMetadataFactory.forVariable; - - -/** - * QApplication is a Querydsl query type for Application - */ -@Generated("com.querydsl.codegen.EntitySerializer") -public class QApplication extends EntityPathBase { - - public static final QApplication application = new QApplication("application"); - - private static final long serialVersionUID = 2120388982L; - - public final EnumPath auditStatus = createEnum("auditStatus", Application.AuditStatus.class); - - public final DateTimePath auditTime = createDateTime("auditTime", java.time.LocalDateTime.class); - - public final DateTimePath createTime = createDateTime("createTime", java.time.LocalDateTime.class); - - public final StringPath description = createString("description"); - - public final StringPath icon = createString("icon"); - - public final StringPath id = createString("id"); - - public final StringPath name = createString("name"); - - public final StringPath publicKey = createString("publicKey"); - - public final EnumPath type = createEnum("type", Application.AppType.class); - - public QApplication(String variable) { - super(Application.class, forVariable(variable)); - } - - public QApplication(Path path) { - super(path.getType(), path.getMetadata()); - } - - public QApplication(PathMetadata metadata) { - super(Application.class, metadata); - } - -} - diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app19/SpringDocApp19Test.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app19/SpringDocApp19Test.java deleted file mode 100644 index 06e1e6da7..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app19/SpringDocApp19Test.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * - * * - * * * - * * * * Copyright 2019-2020 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.app19; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -public class SpringDocApp19Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp {} -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app2/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app2/HelloController.java deleted file mode 100644 index 58bc9420b..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app2/HelloController.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app2; - -import java.util.List; - -import jakarta.validation.constraints.NotNull; - -import org.springframework.data.domain.Pageable; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -@RestController -public class HelloController { - - @GetMapping(value = "/search", produces = { "application/xml", "application/json" }) - public ResponseEntity> getAllPets(@NotNull Pageable pageable) { - return null; - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app2/PersonDTO.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app2/PersonDTO.java deleted file mode 100644 index 28c4282bf..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app2/PersonDTO.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app2; - -import io.swagger.v3.oas.annotations.media.Schema; - -@Schema -public class PersonDTO { - private String email; - - private String firstName; - - private String lastName; - - public PersonDTO() { - } - - public PersonDTO(final String email, final String firstName, final String lastName) { - this.email = email; - this.firstName = firstName; - this.lastName = lastName; - } - - public String getEmail() { - return email; - } - - public void setEmail(final String email) { - this.email = email; - } - - public String getFirstName() { - return firstName; - } - - public void setFirstName(final String firstName) { - this.firstName = firstName; - } - - public String getLastName() { - return lastName; - } - - public void setLastName(final String lastName) { - this.lastName = lastName; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app2/SpringDocApp2Test.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app2/SpringDocApp2Test.java deleted file mode 100644 index bd1d90c53..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app2/SpringDocApp2Test.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app2; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -public class SpringDocApp2Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp {} - -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app20/Bank.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app20/Bank.java deleted file mode 100644 index 7683e9d52..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app20/Bank.java +++ /dev/null @@ -1,81 +0,0 @@ -package test.org.springdoc.api.app20; - -import java.util.Objects; - -import jakarta.persistence.Column; -import jakarta.persistence.Entity; -import jakarta.persistence.GeneratedValue; -import jakarta.persistence.GenerationType; -import jakarta.persistence.Id; -import jakarta.persistence.SequenceGenerator; -import jakarta.persistence.Table; -import org.hibernate.annotations.NaturalId; - -@Entity -@Table(name = "bank") -public class Bank implements EntityDefinition { - - @Id - @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "bnk_seq") - @SequenceGenerator(name = "bnk_seq", sequenceName = "bnk_seq", allocationSize = 1) - private Long id; - - @Column(unique = true) - @NaturalId - private String code; - - @Column(unique = true, nullable = false) - private String name; - - public Long getId() { - return this.id; - } - - public String getCode() { - return this.code; - } - - public String getName() { - return this.name; - } - - public void setName(String name) { - this.name = name; - } - - @Override - public int hashCode() { - return Objects.hash(getCode()); - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (!(o instanceof Bank)) { - return false; - } - Bank bank = (Bank) o; - return Objects.equals(getCode(), bank.getCode()); - } - - @Override - public String toString() { - return "Bank{" + - "id=" + id + - ", code='" + code + '\'' + - ", name='" + name + '\'' + - '}'; - } - - @Override - public String getKey() { - return code; - } - - @Override - public String getDescription() { - return name; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app20/BankRepository.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app20/BankRepository.java deleted file mode 100644 index 81d8e8db3..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app20/BankRepository.java +++ /dev/null @@ -1,10 +0,0 @@ -package test.org.springdoc.api.app20; - -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.data.rest.core.annotation.RepositoryRestResource; -import org.springframework.stereotype.Repository; - -@Repository -@RepositoryRestResource(path = "banks") -public interface BankRepository extends JpaRepository, CodeLookupRepository { -} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app20/CodeLookupRepository.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app20/CodeLookupRepository.java deleted file mode 100644 index 01e6e8792..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app20/CodeLookupRepository.java +++ /dev/null @@ -1,12 +0,0 @@ -package test.org.springdoc.api.app20; - -import org.springframework.data.repository.NoRepositoryBean; -import org.springframework.data.repository.query.Param; - -@NoRepositoryBean -public interface CodeLookupRepository { - EntityT findOneByCode(@Param("code") KeyT code); - - Long countByCode(KeyT code); -} - diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app20/DemoApplication.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app20/DemoApplication.java deleted file mode 100644 index 811426b39..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app20/DemoApplication.java +++ /dev/null @@ -1,21 +0,0 @@ -package test.org.springdoc.api.app20; - -import io.swagger.v3.oas.annotations.OpenAPIDefinition; -import io.swagger.v3.oas.annotations.info.Info; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -@SpringBootApplication -@OpenAPIDefinition( - info = @Info( - title = "Core API" - ) -) -public class DemoApplication { - - public static void main(String[] args) { - SpringApplication.run(DemoApplication.class, args); - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app20/EntityDefinition.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app20/EntityDefinition.java deleted file mode 100644 index 98c9f2aae..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app20/EntityDefinition.java +++ /dev/null @@ -1,12 +0,0 @@ -package test.org.springdoc.api.app20; - -import com.fasterxml.jackson.annotation.JsonIgnore; - -public interface EntityDefinition { - - @JsonIgnore - String getKey(); - - @JsonIgnore - String getDescription(); -} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app20/SpringDocApp20Test.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app20/SpringDocApp20Test.java deleted file mode 100644 index efe2a13b4..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app20/SpringDocApp20Test.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * - * * - * * * - * * * * Copyright 2019-2020 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.app20; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -public class SpringDocApp20Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp {} -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app21/Person.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app21/Person.java deleted file mode 100644 index f26012737..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app21/Person.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * - * * - * * * - * * * * Copyright 2019-2020 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.app21; - -import jakarta.persistence.Entity; -import jakarta.persistence.GeneratedValue; -import jakarta.persistence.GenerationType; -import jakarta.persistence.Id; - -@Entity -public class Person { - - @Id - @GeneratedValue(strategy = GenerationType.AUTO) - private long id; - - private String firstName; - - private String lastName; - - public String getFirstName() { - return firstName; - } - - public void setFirstName(String firstName) { - this.firstName = firstName; - } - - public String getLastName() { - return lastName; - } - - public void setLastName(String lastName) { - this.lastName = lastName; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app21/PersonRepository.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app21/PersonRepository.java deleted file mode 100644 index 309112fd0..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app21/PersonRepository.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * - * * - * * * - * * * * Copyright 2019-2020 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.app21; - -import java.util.List; - -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.responses.ApiResponse; -import io.swagger.v3.oas.annotations.responses.ApiResponses; - -import org.springframework.data.repository.PagingAndSortingRepository; -import org.springframework.data.repository.query.Param; -import org.springframework.data.rest.core.annotation.RepositoryRestResource; - -@RepositoryRestResource(collectionResourceRel = "people", path = "peopleme") -public interface PersonRepository extends PagingAndSortingRepository { - - @Operation(description = "this is my test") - @ApiResponses( - value = { - @ApiResponse(responseCode = "200", description = "successful operation"), - @ApiResponse(responseCode = "400", description = "Invalid ID supplied"), - @ApiResponse(responseCode = "404", description = "Contact not found"), - @ApiResponse(responseCode = "405", description = "Validation exception") } - ) - List findByLastName(@Param("lastName") String name); - - @Operation(description = "this is another test", responses = { - @ApiResponse(responseCode = "200", description = "another successful operation"), - @ApiResponse(responseCode = "404", description = "another Contact not found") } - ) - List findByFirstName(@Param("firstName") @Parameter(description = "this is for first Name") String name); - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app21/SpringDocApp21Test.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app21/SpringDocApp21Test.java deleted file mode 100644 index 2c502c7bb..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app21/SpringDocApp21Test.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * - * * - * * * - * * * * Copyright 2019-2020 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.app21; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -public class SpringDocApp21Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp {} -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app22/Person.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app22/Person.java deleted file mode 100644 index e5b2f8094..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app22/Person.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * - * * - * * * - * * * * Copyright 2019-2020 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.app22; - -import jakarta.persistence.Entity; -import jakarta.persistence.GeneratedValue; -import jakarta.persistence.GenerationType; -import jakarta.persistence.Id; - -@Entity -public class Person { - - @Id - @GeneratedValue(strategy = GenerationType.AUTO) - private long id; - - private String firstName; - - private String lastName; - - public String getFirstName() { - return firstName; - } - - public void setFirstName(String firstName) { - this.firstName = firstName; - } - - public String getLastName() { - return lastName; - } - - public void setLastName(String lastName) { - this.lastName = lastName; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app22/PersonApi.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app22/PersonApi.java deleted file mode 100644 index e81a6633b..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app22/PersonApi.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * - * * - * * * - * * * * Copyright 2019-2020 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.app22; - -import org.springframework.data.rest.webmvc.RepositoryRestController; -import org.springframework.web.bind.annotation.GetMapping; - -@RepositoryRestController -public class PersonApi { - - @GetMapping("/people/test") - public Person test() { - return new Person(); - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app22/PersonRepository.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app22/PersonRepository.java deleted file mode 100644 index 352bc248a..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app22/PersonRepository.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * - * * - * * * - * * * * Copyright 2019-2020 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.app22; - -import org.springframework.data.repository.PagingAndSortingRepository; -import org.springframework.data.rest.core.annotation.RepositoryRestResource; - -@RepositoryRestResource(path = "people", collectionResourceRel = "people") -public interface PersonRepository extends PagingAndSortingRepository { - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app22/SpringDocApp22Test.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app22/SpringDocApp22Test.java deleted file mode 100644 index 6e2605c35..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app22/SpringDocApp22Test.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * - * * - * * * - * * * * Copyright 2019-2020 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.app22; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -public class SpringDocApp22Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp {} - -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app23/Clinic.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app23/Clinic.java deleted file mode 100644 index 255be21d4..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app23/Clinic.java +++ /dev/null @@ -1,31 +0,0 @@ -package test.org.springdoc.api.app23; - -import jakarta.persistence.Entity; -import jakarta.persistence.GeneratedValue; -import jakarta.persistence.GenerationType; -import jakarta.persistence.Id; -import jakarta.validation.constraints.NotBlank; -import jakarta.validation.constraints.NotNull; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.NoArgsConstructor; - -@Data -@Entity -@NoArgsConstructor -@AllArgsConstructor -@EqualsAndHashCode(callSuper = false) -@Builder -public class Clinic { - - @Id - @GeneratedValue(strategy = GenerationType.AUTO) - private Long id; - - @NotNull - @NotBlank - private String name; - -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app23/ClinicRepo.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app23/ClinicRepo.java deleted file mode 100644 index 42be7d85a..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app23/ClinicRepo.java +++ /dev/null @@ -1,8 +0,0 @@ -package test.org.springdoc.api.app23; - -import org.springframework.data.repository.CrudRepository; -import org.springframework.web.bind.annotation.CrossOrigin; - -@CrossOrigin -public interface ClinicRepo extends CrudRepository { -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app23/Doctor.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app23/Doctor.java deleted file mode 100644 index bccdd6c9a..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app23/Doctor.java +++ /dev/null @@ -1,40 +0,0 @@ -package test.org.springdoc.api.app23; - -import java.util.Set; - -import io.swagger.v3.oas.annotations.media.ArraySchema; -import io.swagger.v3.oas.annotations.media.Schema; -import io.swagger.v3.oas.annotations.media.Schema.AccessMode; -import jakarta.persistence.Entity; -import jakarta.persistence.GeneratedValue; -import jakarta.persistence.GenerationType; -import jakarta.persistence.Id; -import jakarta.persistence.ManyToMany; -import jakarta.validation.constraints.Size; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.NoArgsConstructor; - -@Data -@Entity -@NoArgsConstructor -@AllArgsConstructor -@EqualsAndHashCode(callSuper = false) -@Builder -public class Doctor { - - @Id - @GeneratedValue(strategy = GenerationType.AUTO) - private Long id; - - @ManyToMany - @Size(min = 1) - @ArraySchema( - schema = @Schema( - implementation = String.class, - accessMode = AccessMode.WRITE_ONLY - )) - private Set clinics; -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app23/DoctorRepo.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app23/DoctorRepo.java deleted file mode 100644 index e83ecea3b..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app23/DoctorRepo.java +++ /dev/null @@ -1,8 +0,0 @@ -package test.org.springdoc.api.app23; - -import org.springframework.data.repository.CrudRepository; -import org.springframework.web.bind.annotation.CrossOrigin; - -@CrossOrigin -public interface DoctorRepo extends CrudRepository { -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app23/SpringDocApp23Test.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app23/SpringDocApp23Test.java deleted file mode 100644 index 2a5d19e48..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app23/SpringDocApp23Test.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * - * * - * * * - * * * * Copyright 2019-2020 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.app23; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -public class SpringDocApp23Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp {} - -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app24/QUser.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app24/QUser.java deleted file mode 100644 index 32327b42b..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app24/QUser.java +++ /dev/null @@ -1,44 +0,0 @@ -package test.org.springdoc.api.app24; - -import com.querydsl.core.types.Path; -import com.querydsl.core.types.PathMetadata; -import com.querydsl.core.types.dsl.EntityPathBase; -import com.querydsl.core.types.dsl.NumberPath; -import com.querydsl.core.types.dsl.StringPath; -import jakarta.annotation.Generated; - -import static com.querydsl.core.types.PathMetadataFactory.forVariable; - - -/** - * QUser is a Querydsl query type for User - */ -@Generated("com.querydsl.codegen.EntitySerializer") -public class QUser extends EntityPathBase { - - public static final QUser user = new QUser("user"); - - private static final long serialVersionUID = 222331676L; - - public final StringPath email = createString("email"); - - public final StringPath firstName = createString("firstName"); - - public final NumberPath id = createNumber("id", Long.class); - - public final StringPath lastName = createString("lastName"); - - public QUser(String variable) { - super(User.class, forVariable(variable)); - } - - public QUser(Path path) { - super(path.getType(), path.getMetadata()); - } - - public QUser(PathMetadata metadata) { - super(User.class, metadata); - } - -} - diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app24/SpringDocApp24Test.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app24/SpringDocApp24Test.java deleted file mode 100644 index b05806fbd..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app24/SpringDocApp24Test.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * - * * - * * * - * * * * Copyright 2019-2020 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.app24; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -public class SpringDocApp24Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp {} - -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app24/TesteResource.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app24/TesteResource.java deleted file mode 100644 index 6f8b8f80c..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app24/TesteResource.java +++ /dev/null @@ -1,21 +0,0 @@ -package test.org.springdoc.api.app24; - -import com.querydsl.core.types.Predicate; -import lombok.AllArgsConstructor; - -import org.springframework.data.domain.Page; -import org.springframework.data.domain.Pageable; -import org.springframework.data.querydsl.binding.QuerydslPredicate; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - - -@RestController -@AllArgsConstructor -public class TesteResource { - - @GetMapping("/") - public Page testeQueryDslAndSpringDoc(@QuerydslPredicate(root = User.class, bindings = UserPredicate.class) Predicate predicate, Pageable pageable) { - return null; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app24/User.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app24/User.java deleted file mode 100644 index cbf085035..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app24/User.java +++ /dev/null @@ -1,24 +0,0 @@ -package test.org.springdoc.api.app24; - -import jakarta.persistence.Entity; -import jakarta.persistence.GeneratedValue; -import jakarta.persistence.GenerationType; -import jakarta.persistence.Id; -import lombok.Getter; -import lombok.Setter; - -@Entity -@Getter -@Setter -public class User { - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - private Long id; - - private String firstName; - - private String lastName; - - private String email; -} - diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app24/UserPredicate.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app24/UserPredicate.java deleted file mode 100644 index 41a36132f..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app24/UserPredicate.java +++ /dev/null @@ -1,15 +0,0 @@ -package test.org.springdoc.api.app24; - -import org.springframework.data.querydsl.binding.QuerydslBinderCustomizer; -import org.springframework.data.querydsl.binding.QuerydslBindings; - -public class UserPredicate implements QuerydslBinderCustomizer { - - - @Override - public void customize(QuerydslBindings bindings, QUser user) { - bindings.excludeUnlistedProperties(true); - bindings.including(user.email); - bindings.bind(user.firstName).as("name").withDefaultBinding(); - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app25/SpringDocApp25Test.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app25/SpringDocApp25Test.java deleted file mode 100644 index f748d7787..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app25/SpringDocApp25Test.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * - * * - * * * - * * * * Copyright 2019-2020 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.app25; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -public class SpringDocApp25Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp {} - -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app25/model/Address.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app25/model/Address.java deleted file mode 100644 index 28db53d32..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app25/model/Address.java +++ /dev/null @@ -1,28 +0,0 @@ -package test.org.springdoc.api.app25.model; - -import jakarta.persistence.Embeddable; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; - -@Embeddable -@Data -@Builder -@AllArgsConstructor -@NoArgsConstructor -public class Address { - - private String name; - - private String street; - - private String number; - - private String zipcode; - - private String city; - - private String country; - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app25/model/BaseEntity.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app25/model/BaseEntity.java deleted file mode 100644 index 07c2a5118..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app25/model/BaseEntity.java +++ /dev/null @@ -1,30 +0,0 @@ -package test.org.springdoc.api.app25.model; - -import java.util.UUID; - -import jakarta.persistence.Id; -import jakarta.persistence.MappedSuperclass; -import jakarta.persistence.PrePersist; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import org.hibernate.annotations.JdbcTypeCode; -import org.hibernate.type.SqlTypes; - -@Getter -@Setter -@NoArgsConstructor -@MappedSuperclass -public abstract class BaseEntity { - - @Id - @JdbcTypeCode(SqlTypes.CHAR) - private UUID id; - - @PrePersist - private void generateId() { - if (id == null) - id = UUID.randomUUID(); - } - -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app25/model/Cat.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app25/model/Cat.java deleted file mode 100644 index 2c2fed252..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app25/model/Cat.java +++ /dev/null @@ -1,33 +0,0 @@ -package test.org.springdoc.api.app25.model; - -import jakarta.persistence.Entity; -import jakarta.persistence.EnumType; -import jakarta.persistence.Enumerated; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.NoArgsConstructor; - -@Entity -@Data -@EqualsAndHashCode(callSuper = false) -@Builder -@AllArgsConstructor -@NoArgsConstructor -public class Cat extends Pet { - - @Enumerated(EnumType.STRING) - private CoatType coat; - - @Builder - public Cat(String name, Owner owner, CoatType coat) { - super(name, owner); - this.coat = coat; - } - - public static enum CoatType { - TABBY, TOROISE, COLORPOINT, BICOLOR, TRICOLOR, SOLID - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app25/model/Clinic.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app25/model/Clinic.java deleted file mode 100644 index 7e4345cd5..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app25/model/Clinic.java +++ /dev/null @@ -1,30 +0,0 @@ -package test.org.springdoc.api.app25.model; - -import java.util.Set; - -import jakarta.persistence.ElementCollection; -import jakarta.persistence.Entity; -import jakarta.validation.constraints.NotNull; -import jakarta.validation.constraints.Size; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.NoArgsConstructor; - -@Entity -@Data -@EqualsAndHashCode(callSuper = false) -@Builder -@AllArgsConstructor -@NoArgsConstructor -public class Clinic extends BaseEntity { - - @NotNull - private String name; - - @Size(min = 1) - @ElementCollection - private Set
addresses; - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app25/model/Doctor.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app25/model/Doctor.java deleted file mode 100644 index 353c8323b..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app25/model/Doctor.java +++ /dev/null @@ -1,38 +0,0 @@ -package test.org.springdoc.api.app25.model; - -import java.util.Set; - -import jakarta.persistence.Entity; -import jakarta.persistence.EnumType; -import jakarta.persistence.Enumerated; -import jakarta.persistence.ManyToMany; -import jakarta.validation.constraints.NotNull; -import jakarta.validation.constraints.Size; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.NoArgsConstructor; - -@Entity -@Data -@EqualsAndHashCode(callSuper = false) -@Builder -@AllArgsConstructor -@NoArgsConstructor -public class Doctor extends BaseEntity { - - @NotNull - private String firstname; - - @NotNull - private String lastname; - - @Enumerated(EnumType.STRING) - private Specialty specialty; - - @Size(min = 1) - @ManyToMany - private Set clinics; - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app25/model/Dog.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app25/model/Dog.java deleted file mode 100644 index 02f907a23..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app25/model/Dog.java +++ /dev/null @@ -1,32 +0,0 @@ -package test.org.springdoc.api.app25.model; - -import jakarta.persistence.Entity; -import jakarta.persistence.EnumType; -import jakarta.persistence.Enumerated; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.NoArgsConstructor; - -@Entity -@Data -@EqualsAndHashCode(callSuper = false) -@AllArgsConstructor -@NoArgsConstructor -public class Dog extends Pet { - - @Enumerated(EnumType.STRING) - private CoatType coat; - - @Builder - public Dog(String name, Owner owner, CoatType coat) { - super(name, owner); - this.coat = coat; - } - - public static enum CoatType { - SMOOTH, SHORT, COMBINATION, DOUBLE, HEAVY, SILKY, LONG, CURLY, WIRE, HAIRLESS - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app25/model/Owner.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app25/model/Owner.java deleted file mode 100644 index efb94f4fc..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app25/model/Owner.java +++ /dev/null @@ -1,37 +0,0 @@ -package test.org.springdoc.api.app25.model; - -import java.util.Set; - -import jakarta.persistence.CascadeType; -import jakarta.persistence.Embedded; -import jakarta.persistence.Entity; -import jakarta.persistence.OneToMany; -import jakarta.validation.constraints.NotNull; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.NoArgsConstructor; - -@Entity -@Data -@EqualsAndHashCode(callSuper = false) -@Builder -@AllArgsConstructor -@NoArgsConstructor -public class Owner extends BaseEntity { - - private String firstname; - - @NotNull - private String lastname; - - @NotNull - @Embedded - private Address addresses; - - @EqualsAndHashCode.Exclude - @OneToMany(mappedBy = "owner", cascade = { CascadeType.ALL }) - private Set pets; - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app25/model/Pet.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app25/model/Pet.java deleted file mode 100644 index d6502e69b..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app25/model/Pet.java +++ /dev/null @@ -1,44 +0,0 @@ -package test.org.springdoc.api.app25.model; - -import com.fasterxml.jackson.annotation.JsonSubTypes; -import com.fasterxml.jackson.annotation.JsonSubTypes.Type; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import jakarta.persistence.Entity; -import jakarta.persistence.Inheritance; -import jakarta.persistence.InheritanceType; -import jakarta.persistence.ManyToOne; -import jakarta.validation.constraints.NotNull; -import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.NoArgsConstructor; -import lombok.NonNull; -import lombok.RequiredArgsConstructor; - -@Entity - -@EqualsAndHashCode(callSuper = false) -@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS) - -@Data -@NoArgsConstructor -@RequiredArgsConstructor - -@JsonTypeInfo( - use = JsonTypeInfo.Id.NAME, - include = JsonTypeInfo.As.PROPERTY, - property = "_type") -@JsonSubTypes({ - @Type(value = Dog.class, name = "dog"), - @Type(value = Cat.class, name = "cat") -}) -public class Pet extends BaseEntity { - - @NonNull - @NotNull - private String name; - - @NonNull - @ManyToOne - private Owner owner; - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app25/model/Specialty.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app25/model/Specialty.java deleted file mode 100644 index b1a3874ef..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app25/model/Specialty.java +++ /dev/null @@ -1,79 +0,0 @@ -package test.org.springdoc.api.app25.model; - -public enum Specialty { - - ALLERGY_AND_IMMUNOLOGY, - ADOLESCENT_MEDICINE, - ANESTHESIOLOGY, - AEROSPACE_MEDICINE, - BARIATRICS, - CARDIOLOGY, - CARDIOTHORACIC_SURGERY, - CHILD_AND_ADOLESCENT_PSYCHIATRY, - CLINICAL_NEUROPHYSIOLOGY, - COLORECTAL_SURGERY, - DERMATOLOGY, - DEVELOPMENTAL_PEDIATRICS, - EMERGENCY_MEDICINE, - ENDOCRINOLOGY, - FAMILY_MEDICINE, - FORENSIC_PATHOLOGY, - FORENSIC_PSYCHIATRY, - GASTROENTEROLOGY, - GENERAL_SURGERY, - GENERAL_SURGICAL_ONCOLOGY, - GERIATRICS, - GERIATRIC_PSYCHIATRY, - GYNECOLOGIC_ONCOLOGY, - HEMATOLOGY, - HEMATOLOGIC_PATHOLOGY, - INFECTIOUS_DISEASE, - INTERNAL_MEDICINE, - INTERVENTIONAL_RADIOLOGY, - INTENSIVE_CARE_MEDICINE, - MATERNAL_FETAL_MEDICINE, - MEDICAL_BIOCHEMISTRY, - MEDICAL_GENETICS, - MEDICAL_ONCOLOGY, - NEONATOLOGY, - NEPHROLOGY, - NEUROLOGY, - NEUROPATHOLOGY, - NEUROSURGERY, - NUCLEAR_MEDICINE, - OBSTETRICS_AND_GYNECOLOGY, - OCCUPATIONAL_MEDICINE, - OPHTHALMOLOGY, - ORTHOPEDIC_SURGERY, - ORAL_AND_MAXILLOFACIAL_SURGERY, - OTORHINOLARYNGOLOGY, - PALLIATIVE_CARE, - PATHOLOGY, - PEDIATRICS, - PEDIATRIC_ALLERGY_AND_IMMUNOLOGY, - PEDIATRIC_CARDIOLOGY, - PEDIATRIC_EMERGENCY_MEDICINE, - PEDIATRIC_ENDOCRINOLOGY, - PEDIATRIC_GASTROENTEROLOGY, - PEDIATRIC_HEMATOLOGY_AND_ONCOLOGY, - PEDIATRIC_INFECTIOUS_DISEASE, - PEDIATRIC_NEPHROLOGY, - PEDIATRIC_RESPIRATORY_MEDICINE, - PEDIATRIC_RHEUMATOLOGY, - PEDIATRIC_SURGERY, - PHYSICAL_MEDICINE_AND_REHABILITATION, - PLASTIC_RECONSTRUCTIVE_AND_AESTHETIC_SURGERY, - PSYCHIATRY, - PUBLIC_HEALTH, - RADIATION_ONCOLOGY, - RADIOLOGY, - REPRODUCTIVE_ENDOCRINOLOGY_AND_INFERTILITY, - RESPIRATORY_MEDICINE, - RHEUMATOLOGY, - SPORTS_MEDICINE, - THORACIC_SURGERY, - NEURORADIOLOGY, - UROLOGY, - VASCULAR_SURGERY; - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app25/repo/ClinicRepo.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app25/repo/ClinicRepo.java deleted file mode 100644 index 65c5a1585..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app25/repo/ClinicRepo.java +++ /dev/null @@ -1,13 +0,0 @@ -package test.org.springdoc.api.app25.repo; - -import java.util.UUID; - -import test.org.springdoc.api.app25.model.Clinic; - -import org.springframework.data.repository.CrudRepository; -import org.springframework.web.bind.annotation.CrossOrigin; - -@CrossOrigin -public interface ClinicRepo extends CrudRepository { - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app25/repo/DoctorRepo.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app25/repo/DoctorRepo.java deleted file mode 100644 index 3c939ec3d..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app25/repo/DoctorRepo.java +++ /dev/null @@ -1,16 +0,0 @@ -package test.org.springdoc.api.app25.repo; - -import java.util.UUID; - -import test.org.springdoc.api.app25.model.Clinic; -import test.org.springdoc.api.app25.model.Doctor; - -import org.springframework.data.repository.CrudRepository; -import org.springframework.web.bind.annotation.CrossOrigin; - -@CrossOrigin -public interface DoctorRepo extends CrudRepository { - - Iterable findByClinicsContains(Clinic clinic); - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app25/repo/OwnerRepo.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app25/repo/OwnerRepo.java deleted file mode 100644 index 6b9a2737a..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app25/repo/OwnerRepo.java +++ /dev/null @@ -1,13 +0,0 @@ -package test.org.springdoc.api.app25.repo; - -import java.util.UUID; - -import test.org.springdoc.api.app25.model.Owner; - -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.web.bind.annotation.CrossOrigin; - -@CrossOrigin -public interface OwnerRepo extends JpaRepository { - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app25/repo/PetRepo.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app25/repo/PetRepo.java deleted file mode 100644 index d65663a94..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app25/repo/PetRepo.java +++ /dev/null @@ -1,13 +0,0 @@ -package test.org.springdoc.api.app25.repo; - -import java.util.UUID; - -import test.org.springdoc.api.app25.model.Pet; - -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.web.bind.annotation.CrossOrigin; - -@CrossOrigin -public interface PetRepo extends JpaRepository { - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app26/Person.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app26/Person.java deleted file mode 100644 index c33e239c8..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app26/Person.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * - * * - * * * - * * * * Copyright 2019-2020 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.app26; - -import jakarta.persistence.Entity; -import jakarta.persistence.GeneratedValue; -import jakarta.persistence.GenerationType; -import jakarta.persistence.Id; - -@Entity -public class Person { - - @Id - @GeneratedValue(strategy = GenerationType.AUTO) - private long id; - - private String firstName; - - private String lastName; - - public long getId() { - return id; - } - - public void setId(long id) { - this.id = id; - } - - public String getFirstName() { - return firstName; - } - - public void setFirstName(String firstName) { - this.firstName = firstName; - } - - public String getLastName() { - return lastName; - } - - public void setLastName(String lastName) { - this.lastName = lastName; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app26/PersonRepository.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app26/PersonRepository.java deleted file mode 100644 index 050f10d34..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app26/PersonRepository.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * - * * - * * * - * * * * Copyright 2019-2020 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.app26; - -import java.util.List; - -import org.springframework.data.jpa.repository.Query; -import org.springframework.data.repository.PagingAndSortingRepository; -import org.springframework.data.repository.query.Param; -import org.springframework.data.rest.core.annotation.RepositoryRestResource; - -@RepositoryRestResource(collectionResourceRel = "people", path = "peopleme") -public interface PersonRepository extends PagingAndSortingRepository { - - List findByLastName(@Param("name") String name); - - @Query(value = "select 1 from dual", nativeQuery = true) - void testQuery(); - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app26/SpringDocApp26Test.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app26/SpringDocApp26Test.java deleted file mode 100644 index f78005bf4..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app26/SpringDocApp26Test.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * - * * - * * * - * * * * Copyright 2019-2020 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.app26; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -public class SpringDocApp26Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp { - } - -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app26/SpringRestConfiguration.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app26/SpringRestConfiguration.java deleted file mode 100644 index da217f749..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app26/SpringRestConfiguration.java +++ /dev/null @@ -1,14 +0,0 @@ -package test.org.springdoc.api.app26; - -import org.springframework.context.annotation.Configuration; -import org.springframework.data.rest.core.config.RepositoryRestConfiguration; -import org.springframework.data.rest.webmvc.config.RepositoryRestConfigurer; -import org.springframework.web.servlet.config.annotation.CorsRegistry; - -@Configuration -public class SpringRestConfiguration implements RepositoryRestConfigurer { - @Override - public void configureRepositoryRestConfiguration(RepositoryRestConfiguration config, CorsRegistry cors) { - config.exposeIdsFor(Person.class); - } -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app27/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app27/HelloController.java deleted file mode 100644 index 818dfacfa..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app27/HelloController.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app27; - -import java.util.List; - -import jakarta.validation.constraints.NotNull; - -import org.springframework.data.domain.Pageable; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -@RestController -public class HelloController { - - @GetMapping(value = "/search", produces = { "application/xml", "application/json" }) - public ResponseEntity> getAllPets(@NotNull Pageable pageable) { - return null; - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app27/PersonDTO.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app27/PersonDTO.java deleted file mode 100644 index 53863d19c..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app27/PersonDTO.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app27; - -import io.swagger.v3.oas.annotations.media.Schema; - -@Schema -public class PersonDTO { - private String email; - - private String firstName; - - private String lastName; - - public PersonDTO() { - } - - public PersonDTO(final String email, final String firstName, final String lastName) { - this.email = email; - this.firstName = firstName; - this.lastName = lastName; - } - - public String getEmail() { - return email; - } - - public void setEmail(final String email) { - this.email = email; - } - - public String getFirstName() { - return firstName; - } - - public void setFirstName(final String firstName) { - this.firstName = firstName; - } - - public String getLastName() { - return lastName; - } - - public void setLastName(final String lastName) { - this.lastName = lastName; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app27/SpringDocApp27Test.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app27/SpringDocApp27Test.java deleted file mode 100644 index cfed1c2ef..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app27/SpringDocApp27Test.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app27; - -import java.util.Optional; - -import io.swagger.v3.core.converter.ModelConverter; -import io.swagger.v3.core.converter.ModelConverters; -import org.springdoc.core.converters.PageableOpenAPIConverter; -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.test.context.TestPropertySource; - -@TestPropertySource(properties = "springdoc.model-converters.pageable-converter.enabled=false") -public class SpringDocApp27Test extends AbstractSpringDocTest { - - static { - Optional pageabeConverter = - ModelConverters.getInstance().getConverters() - .stream().filter(modelConverter -> modelConverter instanceof PageableOpenAPIConverter).findAny(); - pageabeConverter.ifPresent(ModelConverters.getInstance()::removeConverter); - } - - @SpringBootApplication - static class SpringDocTestApp {} -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app28/ExamplePageable.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app28/ExamplePageable.java deleted file mode 100644 index 1dd15c8b1..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app28/ExamplePageable.java +++ /dev/null @@ -1,59 +0,0 @@ -package test.org.springdoc.api.app28; - -import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.v3.oas.annotations.Parameter; - -import org.springframework.data.domain.Pageable; -import org.springframework.data.domain.Sort; - -public class ExamplePageable implements Pageable { - - @Parameter(description = "Anything") - @JsonProperty - private int something; - - @Override - public int getPageNumber() { - return 0; - } - - @Override - public int getPageSize() { - return 0; - } - - @Override - public long getOffset() { - return 0; - } - - @Override - public Sort getSort() { - return null; - } - - @Override - public Pageable next() { - return null; - } - - @Override - public Pageable previousOrFirst() { - return null; - } - - @Override - public Pageable first() { - return null; - } - - @Override - public Pageable withPage(int pageNumber) { - return null; - } - - @Override - public boolean hasPrevious() { - return false; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app28/ExamplePageableReplacement.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app28/ExamplePageableReplacement.java deleted file mode 100644 index cb7412c4c..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app28/ExamplePageableReplacement.java +++ /dev/null @@ -1,30 +0,0 @@ -package test.org.springdoc.api.app28; - -import java.util.List; - -import io.swagger.v3.oas.annotations.Parameter; -import org.springdoc.core.converters.models.Pageable; - -public class ExamplePageableReplacement extends Pageable { - - @Parameter(description = "Anything") - private int something; - - /** - * Instantiates a new Pageable. - * @param page the page - * @param size the size - * @param sort the sort - */ - public ExamplePageableReplacement(int page, int size, List sort) { - super(page, size, sort); - } - - public int getSomething() { - return something; - } - - public void setSomething(int something) { - this.something = something; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app28/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app28/HelloController.java deleted file mode 100644 index 65cc30014..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app28/HelloController.java +++ /dev/null @@ -1,21 +0,0 @@ -package test.org.springdoc.api.app28; - -import org.springdoc.core.annotations.ParameterObject; - -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * @author bnasslahsen - */ -@RestController -@RequestMapping("/api") -public class HelloController { - - - @GetMapping("/items/nested") - public void showNestedItem(@ParameterObject ExamplePageable examplePageable) { - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app28/SpringDocApp28Test.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app28/SpringDocApp28Test.java deleted file mode 100644 index 02445483a..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app28/SpringDocApp28Test.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app28; - -import org.springdoc.core.utils.SpringDocUtils; -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -public class SpringDocApp28Test extends AbstractSpringDocTest { - - static { - SpringDocUtils.getConfig().replaceParameterObjectWithClass(ExamplePageable.class, ExamplePageableReplacement.class); - } - - @SpringBootApplication - static class SpringDocTestApp {} -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app29/Person.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app29/Person.java deleted file mode 100644 index 1cd2d4f92..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app29/Person.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * - * * - * * * - * * * * Copyright 2019-2020 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.app29; - -import jakarta.persistence.Entity; -import jakarta.persistence.GeneratedValue; -import jakarta.persistence.GenerationType; -import jakarta.persistence.Id; - -@Entity -public class Person { - - @Id - @GeneratedValue(strategy = GenerationType.AUTO) - private long id; - - private String firstName; - - private String lastName; - - public String getFirstName() { - return firstName; - } - - public void setFirstName(String firstName) { - this.firstName = firstName; - } - - public String getLastName() { - return lastName; - } - - public void setLastName(String lastName) { - this.lastName = lastName; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app29/PersonApi.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app29/PersonApi.java deleted file mode 100644 index 45fcc70be..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app29/PersonApi.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * - * * - * * * - * * * * Copyright 2019-2020 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.app29; - -import org.springframework.data.rest.webmvc.BasePathAwareController; -import org.springframework.web.bind.annotation.GetMapping; - -@BasePathAwareController -public class PersonApi { - - @GetMapping("/people/test") - public Person test() { - return new Person(); - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app29/PersonRepository.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app29/PersonRepository.java deleted file mode 100644 index e13df1b0c..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app29/PersonRepository.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * - * * - * * * - * * * * Copyright 2019-2020 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.app29; - -import org.springframework.data.repository.PagingAndSortingRepository; -import org.springframework.data.rest.core.annotation.RepositoryRestResource; - -@RepositoryRestResource(path = "people", collectionResourceRel = "people") -public interface PersonRepository extends PagingAndSortingRepository { - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app29/SpringDocApp29Test.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app29/SpringDocApp29Test.java deleted file mode 100644 index ed6a0bc0b..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app29/SpringDocApp29Test.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * - * * - * * * - * * * * Copyright 2019-2020 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.app29; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -public class SpringDocApp29Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp {} - -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app3/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app3/HelloController.java deleted file mode 100644 index d49db78f1..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app3/HelloController.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app3; - -import org.springdoc.core.converters.models.PageableAsQueryParam; -import org.springdoc.core.converters.models.SortAsQueryParam; - -import org.springframework.http.MediaType; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -@RestController -@RequestMapping(path = "/demo", - produces = MediaType.TEXT_PLAIN_VALUE) -public class HelloController { - - @GetMapping("operation4") - @PageableAsQueryParam - public String operation4() { - return "operation4"; - } - - @GetMapping("operation5") - @SortAsQueryParam - public String operation5() { - return "operation5"; - } - -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app3/SpringDocApp3Test.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app3/SpringDocApp3Test.java deleted file mode 100644 index b5399787c..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app3/SpringDocApp3Test.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app3; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -public class SpringDocApp3Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp {} - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app30/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app30/HelloController.java deleted file mode 100644 index 191d63c96..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app30/HelloController.java +++ /dev/null @@ -1,17 +0,0 @@ -package test.org.springdoc.api.app30; - -import com.querydsl.core.types.Predicate; - -import org.springframework.data.querydsl.binding.QuerydslPredicate; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - - -@RestController -public class HelloController { - - @GetMapping("/") - public User testQueryDslAndSpringDoc(@QuerydslPredicate(root = User.class, bindings = UserPredicate.class) Predicate predicate) { - return null; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app30/QUser.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app30/QUser.java deleted file mode 100644 index 999ab5a4b..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app30/QUser.java +++ /dev/null @@ -1,42 +0,0 @@ -package test.org.springdoc.api.app30; - - -import com.querydsl.core.types.Path; -import com.querydsl.core.types.PathMetadata; -import com.querydsl.core.types.dsl.EntityPathBase; -import com.querydsl.core.types.dsl.NumberPath; -import com.querydsl.core.types.dsl.StringPath; - -import static com.querydsl.core.types.PathMetadataFactory.forVariable; - - -/** - * QUser is a Querydsl query type for User - */ -public class QUser extends EntityPathBase { - - public static final QUser user = new QUser("user"); - - private static final long serialVersionUID = 222331676L; - - public final StringPath email = createString("email"); - - public final StringPath firstName = createString("firstName"); - - public final NumberPath id = createNumber("id", Long.class); - - public final StringPath lastName = createString("lastName"); - - public QUser(String variable) { - super(User.class, forVariable(variable)); - } - - public QUser(Path path) { - super(path.getType(), path.getMetadata()); - } - - public QUser(PathMetadata metadata) { - super(User.class, metadata); - } - -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app30/SpringDocApp30Test.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app30/SpringDocApp30Test.java deleted file mode 100644 index ae34d87df..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app30/SpringDocApp30Test.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * - * * - * * * - * * * * Copyright 2019-2020 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.app30; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -public class SpringDocApp30Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp {} - -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app30/User.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app30/User.java deleted file mode 100644 index ac8446a3d..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app30/User.java +++ /dev/null @@ -1,24 +0,0 @@ -package test.org.springdoc.api.app30; - - -import jakarta.persistence.Entity; -import jakarta.persistence.GeneratedValue; -import jakarta.persistence.GenerationType; -import jakarta.persistence.Id; -import lombok.Getter; -import lombok.Setter; - -@Entity -@Getter -@Setter -public class User { - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - private Long id; - - private String firstName; - - private String lastName; - - private String email; -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app30/UserPredicate.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app30/UserPredicate.java deleted file mode 100644 index f30e85663..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app30/UserPredicate.java +++ /dev/null @@ -1,16 +0,0 @@ -package test.org.springdoc.api.app30; - - -import org.springframework.data.querydsl.binding.QuerydslBinderCustomizer; -import org.springframework.data.querydsl.binding.QuerydslBindings; - -public class UserPredicate implements QuerydslBinderCustomizer { - - - @Override - public void customize(QuerydslBindings bindings, QUser user) { - bindings.excludeUnlistedProperties(true); - bindings.including(user.email); - bindings.bind(user.firstName).as("name").withDefaultBinding(); - } -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app301/Person.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app301/Person.java deleted file mode 100644 index 483d7998f..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app301/Person.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * - * * - * * * - * * * * Copyright 2019-2020 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.app301; - -import jakarta.persistence.Entity; -import jakarta.persistence.GeneratedValue; -import jakarta.persistence.GenerationType; -import jakarta.persistence.Id; - -@Entity -public class Person { - - @Id - @GeneratedValue(strategy = GenerationType.AUTO) - private long id; - - private String firstName; - - private String lastName; - - public String getFirstName() { - return firstName; - } - - public void setFirstName(String firstName) { - this.firstName = firstName; - } - - public String getLastName() { - return lastName; - } - - public void setLastName(String lastName) { - this.lastName = lastName; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app301/PersonApi.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app301/PersonApi.java deleted file mode 100644 index 2ee3695df..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app301/PersonApi.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * - * * - * * * - * * * * Copyright 2019-2020 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.app301; - -import org.springframework.data.rest.webmvc.BasePathAwareController; -import org.springframework.web.bind.annotation.GetMapping; - -@BasePathAwareController -public class PersonApi { - - @GetMapping("/people/test") - public Person test() { - return new Person(); - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app301/PersonRepository.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app301/PersonRepository.java deleted file mode 100644 index cbc4365bd..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app301/PersonRepository.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * - * * - * * * - * * * * Copyright 2019-2020 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.app301; - -import org.springframework.data.repository.PagingAndSortingRepository; -import org.springframework.data.rest.core.annotation.RepositoryRestResource; - -@RepositoryRestResource(path = "people", collectionResourceRel = "people") -public interface PersonRepository extends PagingAndSortingRepository { - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app301/SpringDocApp301Test.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app301/SpringDocApp301Test.java deleted file mode 100644 index 2dbbb1436..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app301/SpringDocApp301Test.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * - * * - * * * - * * * * - * * * * * 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.app301; - -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; -import java.util.Map.Entry; - -import com.fasterxml.jackson.databind.introspect.SimpleMixInResolver; -import com.fasterxml.jackson.databind.type.ClassKey; -import org.apache.commons.lang3.reflect.FieldUtils; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeEach; -import org.springdoc.core.providers.ObjectMapperProvider; -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.test.context.TestPropertySource; - -@TestPropertySource(properties = "springdoc.enable-data-rest=false") -public class SpringDocApp301Test extends AbstractSpringDocTest { - - private final Map> springMixins = new HashMap<>(); - - @Autowired - ObjectMapperProvider objectMapperProvider; - - @BeforeEach - void init() throws IllegalAccessException { - SimpleMixInResolver _mixIns = (SimpleMixInResolver) FieldUtils.readDeclaredField(objectMapperProvider.jsonMapper(), "_mixIns", true); - Map> _localMixIns = (Map>) FieldUtils.readDeclaredField(_mixIns, "_localMixIns", true); - Iterator>> it = _localMixIns.entrySet().iterator(); - while (it.hasNext()) { - Map.Entry> entry = it.next(); - if (entry.getKey().toString().startsWith("org.springframework")) { - springMixins.put(entry.getKey(), entry.getValue()); - it.remove(); - } - } - - } - - @AfterEach - void clean() throws IllegalAccessException { - SimpleMixInResolver _mixIns = (SimpleMixInResolver) FieldUtils.readDeclaredField(objectMapperProvider.jsonMapper(), "_mixIns", true); - Map> _localMixIns = (Map>) FieldUtils.readDeclaredField(_mixIns, "_localMixIns", true); - _localMixIns.putAll(springMixins); - } - - @SpringBootApplication - static class SpringDocTestApp {} -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app31/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app31/HelloController.java deleted file mode 100644 index 19bf81cb2..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app31/HelloController.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app31; - -import java.util.List; - -import org.springdoc.core.annotations.ParameterObject; - -import org.springframework.data.domain.Pageable; -import org.springframework.data.domain.Sort; -import org.springframework.data.domain.Sort.Direction; -import org.springframework.data.web.SortDefault; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -@RestController -public class HelloController { - - @GetMapping(value = "/search", produces = { "application/xml", "application/json" }) - public ResponseEntity> getAllPets(@SortDefault("name") @ParameterObject Sort sort) { - return null; - } - - - @GetMapping("/test1") - public String getPatientList1(@SortDefault(sort = { "someField", "someoTHER" }, - direction = Direction.DESC) - @ParameterObject Sort sort) { - return "bla"; - } - - @GetMapping("/test2") - public String getPatientList2(@SortDefault(sort = "someField", - direction = Direction.DESC) - @ParameterObject Sort sort) { - return "bla"; - } - - @GetMapping("/test3") - public String getPatientList3(@SortDefault(sort = { "someField", "someoTHER" }, - direction = Direction.DESC) - @ParameterObject Pageable pageable) { - return "bla"; - } - - @GetMapping("/test4") - public String getPatientList4(@SortDefault(sort = "someField", - direction = Direction.DESC) - @ParameterObject Pageable pageable) { - return "bla"; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app31/PersonDTO.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app31/PersonDTO.java deleted file mode 100644 index 203895d69..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app31/PersonDTO.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app31; - -import io.swagger.v3.oas.annotations.media.Schema; - -@Schema -public class PersonDTO { - private String email; - - private String firstName; - - private String lastName; - - public PersonDTO() { - } - - public PersonDTO(final String email, final String firstName, final String lastName) { - this.email = email; - this.firstName = firstName; - this.lastName = lastName; - } - - public String getEmail() { - return email; - } - - public void setEmail(final String email) { - this.email = email; - } - - public String getFirstName() { - return firstName; - } - - public void setFirstName(final String firstName) { - this.firstName = firstName; - } - - public String getLastName() { - return lastName; - } - - public void setLastName(final String lastName) { - this.lastName = lastName; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app31/SpringDocApp31Test.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app31/SpringDocApp31Test.java deleted file mode 100644 index 353d61813..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app31/SpringDocApp31Test.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * - * * - * * * - * * * * Copyright 2019-2020 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.app31; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -public class SpringDocApp31Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp {} - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app32/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app32/HelloController.java deleted file mode 100644 index bb2c6d8b9..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app32/HelloController.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app32; - -import java.util.List; - -import org.springdoc.core.annotations.ParameterObject; - -import org.springframework.data.domain.Sort; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -@RestController -public class HelloController { - - @GetMapping(value = "/search", produces = { "application/xml", "application/json" }) - public ResponseEntity> getAllPets(@ParameterObject Sort sort) { - return null; - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app32/PersonDTO.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app32/PersonDTO.java deleted file mode 100644 index 519f89a37..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app32/PersonDTO.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app32; - -import io.swagger.v3.oas.annotations.media.Schema; - -@Schema -public class PersonDTO { - private String email; - - private String firstName; - - private String lastName; - - public PersonDTO() { - } - - public PersonDTO(final String email, final String firstName, final String lastName) { - this.email = email; - this.firstName = firstName; - this.lastName = lastName; - } - - public String getEmail() { - return email; - } - - public void setEmail(final String email) { - this.email = email; - } - - public String getFirstName() { - return firstName; - } - - public void setFirstName(final String firstName) { - this.firstName = firstName; - } - - public String getLastName() { - return lastName; - } - - public void setLastName(final String lastName) { - this.lastName = lastName; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app32/SpringDocApp32Test.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app32/SpringDocApp32Test.java deleted file mode 100644 index 5c8ef96af..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app32/SpringDocApp32Test.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * - * * - * * * - * * * * Copyright 2019-2020 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.app32; - -import java.util.Optional; - -import org.springdoc.core.configuration.SpringDocDataRestConfiguration; -import org.springdoc.core.customizers.DataRestDelegatingMethodParameterCustomizer; -import org.springdoc.core.providers.RepositoryRestConfigurationProvider; -import org.springdoc.core.providers.SpringDataWebPropertiesProvider; -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; -import org.springframework.boot.autoconfigure.data.rest.RepositoryRestMvcAutoConfiguration; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Lazy; -import org.springframework.test.context.TestPropertySource; - -@TestPropertySource(properties = "spring.data.web.sort.sort-parameter=sorts") -@EnableAutoConfiguration(exclude = { - RepositoryRestMvcAutoConfiguration.class, SpringDocDataRestConfiguration.class -}) -public class SpringDocApp32Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp { - // We only need to test spring-web with Sort, without the use of spring-data-rest-starter - @Bean - @ConditionalOnMissingBean - @Lazy(false) - DataRestDelegatingMethodParameterCustomizer dataRestDelegatingMethodParameterCustomizer(Optional optionalSpringDataWebPropertiesProvider, Optional optionalRepositoryRestConfiguration) { - return new DataRestDelegatingMethodParameterCustomizer(optionalSpringDataWebPropertiesProvider, optionalRepositoryRestConfiguration); - } - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app33/ExampleSort.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app33/ExampleSort.java deleted file mode 100644 index e1252c277..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app33/ExampleSort.java +++ /dev/null @@ -1,19 +0,0 @@ -package test.org.springdoc.api.app33; - -import java.util.List; - -import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.v3.oas.annotations.Parameter; - -import org.springframework.data.domain.Sort; - -public class ExampleSort extends Sort { - - @Parameter(description = "Anything") - @JsonProperty - private int something; - - protected ExampleSort(List orders) { - super(orders); - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app33/ExampleSortReplacement.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app33/ExampleSortReplacement.java deleted file mode 100644 index 88f1771e1..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app33/ExampleSortReplacement.java +++ /dev/null @@ -1,28 +0,0 @@ -package test.org.springdoc.api.app33; - -import java.util.List; - -import io.swagger.v3.oas.annotations.Parameter; -import org.springdoc.core.converters.models.Sort; - -public class ExampleSortReplacement extends Sort { - - @Parameter(description = "Anything") - private int something; - - /** - * Instantiates a new Sort. - * @param sort the sort - */ - public ExampleSortReplacement(List sort) { - super(sort); - } - - public int getSomething() { - return something; - } - - public void setSomething(int something) { - this.something = something; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app33/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app33/HelloController.java deleted file mode 100644 index 797917d34..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app33/HelloController.java +++ /dev/null @@ -1,18 +0,0 @@ -package test.org.springdoc.api.app33; - -import org.springdoc.core.annotations.ParameterObject; - -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -@RestController -@RequestMapping("/api") -public class HelloController { - - - @GetMapping("/items/nested") - public void showNestedItem(@ParameterObject ExampleSort exampleSort) { - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app33/SpringDocApp33Test.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app33/SpringDocApp33Test.java deleted file mode 100644 index b5dd2ea81..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app33/SpringDocApp33Test.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app33; - -import org.springdoc.core.utils.SpringDocUtils; -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -public class SpringDocApp33Test extends AbstractSpringDocTest { - - static { - SpringDocUtils.getConfig().replaceParameterObjectWithClass(ExampleSort.class, ExampleSortReplacement.class); - } - - @SpringBootApplication - static class SpringDocTestApp {} -} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app34/Account.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app34/Account.java deleted file mode 100644 index 354d5c94b..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app34/Account.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * - * * - * * * - * * * * Copyright 2019-2020 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.app34; - -import java.util.Date; - -import jakarta.persistence.Entity; -import jakarta.persistence.GeneratedValue; -import jakarta.persistence.GenerationType; -import jakarta.persistence.Id; -import jakarta.persistence.ManyToOne; -import jakarta.persistence.Temporal; -import jakarta.persistence.TemporalType; - - -@Entity -public class Account { - - @Id - @GeneratedValue(strategy = GenerationType.AUTO) - private Long id; - - @ManyToOne - private Customer customer; - - @Temporal(TemporalType.DATE) - private Date expiryDate; - - public Long getId() { - return id; - } - - public Customer getCustomer() { - return customer; - } - - public Date getExpiryDate() { - return expiryDate; - } -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app34/AccountRepository.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app34/AccountRepository.java deleted file mode 100644 index 29103f58b..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app34/AccountRepository.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * - * * - * * * - * * * * Copyright 2019-2020 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.app34; - - -import java.util.List; - -import io.swagger.v3.oas.annotations.security.SecurityRequirement; -import io.swagger.v3.oas.annotations.tags.Tag; - -import org.springframework.data.repository.CrudRepository; -import org.springframework.data.repository.query.Param; -import org.springframework.data.rest.core.annotation.RepositoryRestResource; - -/** - * Repository to manage {@link Account} instances. - * - */ -@RepositoryRestResource -@Tag(name = "The account Repository") -@SecurityRequirement(name = "bearer") -public interface AccountRepository extends CrudRepository { - - /** - * Returns all accounts belonging to the given {@link Customer}. - * - * @param customer - * @return - */ - List findByCustomer(@Param("customer") Customer customer); -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app34/Customer.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app34/Customer.java deleted file mode 100644 index 2c3cf609b..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app34/Customer.java +++ /dev/null @@ -1,49 +0,0 @@ -package test.org.springdoc.api.app34; - - -import java.util.Collection; - -import jakarta.persistence.Entity; -import jakarta.persistence.GeneratedValue; -import jakarta.persistence.GenerationType; -import jakarta.persistence.Id; -import jakarta.persistence.OneToMany; - - -/** - * @author Oliver Gierke - */ -@Entity -public class Customer { - - @Id - @GeneratedValue(strategy = GenerationType.AUTO) - private Long id; - - private String firstname; - - private String lastname; - - @OneToMany(mappedBy = "customer") - private Collection accounts; - - public Long getId() { - return id; - } - - public String getFirstname() { - return firstname; - } - - public String getLastname() { - return lastname; - } - - public Collection getAccounts() { - return accounts; - } - - public void setAccounts(Collection accounts) { - this.accounts = accounts; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app34/CustomerRepository.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app34/CustomerRepository.java deleted file mode 100644 index b476408f5..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app34/CustomerRepository.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * - * * - * * * - * * * * Copyright 2019-2020 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.app34; - -import io.swagger.v3.oas.annotations.security.SecurityRequirement; -import io.swagger.v3.oas.annotations.tags.Tag; - -import org.springframework.data.domain.Page; -import org.springframework.data.domain.Pageable; -import org.springframework.data.jpa.repository.JpaSpecificationExecutor; -import org.springframework.data.repository.CrudRepository; -import org.springframework.data.repository.query.Param; -import org.springframework.data.rest.core.annotation.RepositoryRestResource; -import org.springframework.data.rest.core.annotation.RestResource; - -/** - * Repository to manage {@link Customer} instances. - * - * @author Oliver Gierke - */ -@RepositoryRestResource -@Tag(name = "The customer Repository") -public interface CustomerRepository extends CrudRepository, JpaSpecificationExecutor { - - /** - * Returns a page of {@link Customer}s with the given lastname. - * - * @param lastname - * @param pageable - * @return - */ - @SecurityRequirement(name = "bearer") - Page findByLastname(@Param("lastname") String lastname, Pageable pageable); - - @Override - @RestResource(exported = false) - void deleteById(Long id); - - @Override - @RestResource(exported = false) - void delete(Customer entity); -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app34/OpenApiConfig.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app34/OpenApiConfig.java deleted file mode 100644 index 8002eed57..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app34/OpenApiConfig.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app34; - -import io.swagger.v3.oas.annotations.OpenAPIDefinition; -import io.swagger.v3.oas.annotations.enums.SecuritySchemeType; -import io.swagger.v3.oas.annotations.info.Info; -import io.swagger.v3.oas.annotations.info.License; -import io.swagger.v3.oas.annotations.security.SecurityScheme; - -@OpenAPIDefinition(info = @Info(title = "My App", description = "Some long and useful description", version = "v1", license = @License(name = "Apache 2.0", url = "https://www.apache.org/licenses/LICENSE-2.0"))) -@SecurityScheme(name = "bearer", type = SecuritySchemeType.HTTP, scheme = "bearer", bearerFormat = "JWT") -public class OpenApiConfig { -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app34/SpringDocApp34Test.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app34/SpringDocApp34Test.java deleted file mode 100644 index fe1cf4e07..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app34/SpringDocApp34Test.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * - * * - * * * - * * * * Copyright 2019-2020 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.app34; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -public class SpringDocApp34Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp {} -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app34/SpringRestConfiguration.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app34/SpringRestConfiguration.java deleted file mode 100644 index 70808c53f..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app34/SpringRestConfiguration.java +++ /dev/null @@ -1,15 +0,0 @@ -package test.org.springdoc.api.app34; - - -import org.springframework.context.annotation.Configuration; -import org.springframework.data.rest.core.config.RepositoryRestConfiguration; -import org.springframework.data.rest.webmvc.config.RepositoryRestConfigurer; -import org.springframework.web.servlet.config.annotation.CorsRegistry; - -@Configuration -public class SpringRestConfiguration implements RepositoryRestConfigurer { - @Override - public void configureRepositoryRestConfiguration(RepositoryRestConfiguration config, CorsRegistry cors) { - config.exposeIdsFor(Account.class, Customer.class); - } -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app35/ChildProperty.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app35/ChildProperty.java deleted file mode 100644 index 74b313bc8..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app35/ChildProperty.java +++ /dev/null @@ -1,35 +0,0 @@ -package test.org.springdoc.api.app35; - - -import jakarta.persistence.Entity; -import jakarta.persistence.GeneratedValue; -import jakarta.persistence.GenerationType; -import jakarta.persistence.Id; -import lombok.Data; - -@Entity -public @Data -class ChildProperty { - - @Id - @GeneratedValue(strategy = GenerationType.AUTO) - private long id; - - private String name; - - public long getId() { - return id; - } - - public void setId(long id) { - this.id = id; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app35/ChildPropertyRepository.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app35/ChildPropertyRepository.java deleted file mode 100644 index 8a1f3e0f7..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app35/ChildPropertyRepository.java +++ /dev/null @@ -1,9 +0,0 @@ -package test.org.springdoc.api.app35; - -import io.swagger.v3.oas.annotations.Hidden; - -import org.springframework.data.repository.PagingAndSortingRepository; - -@Hidden -public interface ChildPropertyRepository extends PagingAndSortingRepository { -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app35/Property.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app35/Property.java deleted file mode 100644 index 7afeb9cfb..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app35/Property.java +++ /dev/null @@ -1,49 +0,0 @@ -package test.org.springdoc.api.app35; - - -import jakarta.persistence.Entity; -import jakarta.persistence.GeneratedValue; -import jakarta.persistence.GenerationType; -import jakarta.persistence.Id; -import jakarta.persistence.JoinColumn; -import jakarta.persistence.ManyToOne; -import lombok.Data; - -@Entity -public @Data -class Property { - - @Id - @GeneratedValue(strategy = GenerationType.AUTO) - private long id; - - private String name; - - @ManyToOne - @JoinColumn(name = "child_property_id") - private ChildProperty myChildPropertyName; - - public long getId() { - return id; - } - - public void setId(long id) { - this.id = id; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public ChildProperty getMyChildPropertyName() { - return myChildPropertyName; - } - - public void setMyChildPropertyName(ChildProperty myChildPropertyName) { - this.myChildPropertyName = myChildPropertyName; - } -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app35/PropertyRepository.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app35/PropertyRepository.java deleted file mode 100644 index 39d5e3017..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app35/PropertyRepository.java +++ /dev/null @@ -1,9 +0,0 @@ -package test.org.springdoc.api.app35; - -import io.swagger.v3.oas.annotations.Hidden; - -import org.springframework.data.repository.PagingAndSortingRepository; - -@Hidden -public interface PropertyRepository extends PagingAndSortingRepository { -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app35/SpringDocApp35Test.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app35/SpringDocApp35Test.java deleted file mode 100644 index 00723376b..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app35/SpringDocApp35Test.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * - * * - * * * - * * * * Copyright 2019-2020 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.app35; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -public class SpringDocApp35Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp {} -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app36/EnumFieldHolder.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app36/EnumFieldHolder.java deleted file mode 100644 index bd506b1f5..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app36/EnumFieldHolder.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * - * * 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.app36; - -import jakarta.persistence.Entity; -import jakarta.persistence.GeneratedValue; -import jakarta.persistence.Id; - -@Entity -public class EnumFieldHolder { - - public enum EnumField { - - FOO, BAR; - - } - - @Id - @GeneratedValue - private Long id; - - private EnumField enumField; - - public Long getId() { - return id; - } - - public EnumField getEnumField() { - return enumField; - } - - public void setEnumField(EnumField enumField) { - this.enumField = enumField; - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app36/EnumFieldHolderRepository.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app36/EnumFieldHolderRepository.java deleted file mode 100644 index 2bde495dd..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app36/EnumFieldHolderRepository.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * - * * 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.app36; - -import java.util.List; - -import org.springframework.data.repository.Repository; -import org.springframework.data.repository.query.Param; -import org.springframework.data.rest.core.annotation.RepositoryRestResource; -import org.springframework.data.util.Streamable; - -@RepositoryRestResource -public interface EnumFieldHolderRepository extends Repository { - - Streamable findAllByEnumField(@Param("enumField") EnumFieldHolder.EnumField enumField); - - Streamable findAllByEnumFieldIn(@Param("enumFields") List enumFields); - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app36/SpringDocApp36Test.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app36/SpringDocApp36Test.java deleted file mode 100644 index 74850c071..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app36/SpringDocApp36Test.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * - * * 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.app36; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -public class SpringDocApp36Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp { - - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app37/BaseEntity.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app37/BaseEntity.java deleted file mode 100644 index 514bc4292..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app37/BaseEntity.java +++ /dev/null @@ -1,44 +0,0 @@ -package test.org.springdoc.api.app37; - -import java.io.Serializable; - -import jakarta.persistence.Column; -import jakarta.persistence.GeneratedValue; -import jakarta.persistence.GenerationType; -import jakarta.persistence.Id; -import jakarta.persistence.MappedSuperclass; -import lombok.Data; -import lombok.NoArgsConstructor; -import lombok.experimental.SuperBuilder; -import org.hibernate.annotations.DynamicInsert; -import org.hibernate.annotations.DynamicUpdate; - -/** - * @author bnasslahsen - */ - -@Data -@MappedSuperclass -@DynamicInsert(true) -@DynamicUpdate(true) -@SuperBuilder(toBuilder = true) -@NoArgsConstructor -public abstract class BaseEntity implements Serializable { - - /** SVUDI */ - private static final long serialVersionUID = 1L; - - /** 数据库中的ID */ - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - @Column(name = "ID", unique = true, nullable = false, insertable = false, updatable = false) - private Long id; - - - /** - * 数据是否合法 - * - * @return 是否合法 - */ - public abstract boolean isValid(); -} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app37/ProductEntity.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app37/ProductEntity.java deleted file mode 100644 index 8d39d89b7..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app37/ProductEntity.java +++ /dev/null @@ -1,60 +0,0 @@ -package test.org.springdoc.api.app37; - -import java.math.BigDecimal; -import java.time.LocalDate; - -import jakarta.persistence.Column; -import jakarta.persistence.Entity; -import jakarta.persistence.Table; -import jakarta.validation.constraints.NotNull; -import lombok.EqualsAndHashCode; -import lombok.Getter; -import lombok.NoArgsConstructor; -import lombok.Setter; -import lombok.ToString; -import lombok.experimental.SuperBuilder; - -/** - * @author bnasslahsen - */ - -@Getter -@Setter -@ToString(callSuper = true) -@EqualsAndHashCode(callSuper = false) -@Entity -@Table(name = "PRODUCT_ENTITY") -@SuperBuilder(toBuilder = true) -@NoArgsConstructor -public class ProductEntity extends BaseEntity implements Comparable { - - /** SVUDI */ - private static final long serialVersionUID = 1L; - - /** 名字. */ - @NotNull - @Column(nullable = false) - private String name; - - /** 单价. */ - @NotNull - @Column(nullable = false) - private BigDecimal price; - - /** 日期. */ - @NotNull - @Column(nullable = false) - private LocalDate date; - - @Override - public boolean isValid() { - return name != null && price != null && date != null; - } - - /** 根据日期排序 */ - @Override - public int compareTo(ProductEntity oProduct) { - return this.getDate().compareTo(oProduct.getDate()); - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app37/ProductRepository.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app37/ProductRepository.java deleted file mode 100644 index 99f7cc57e..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app37/ProductRepository.java +++ /dev/null @@ -1,89 +0,0 @@ -package test.org.springdoc.api.app37; - -/** - * @author bnasslahsen - */ - -import java.math.BigDecimal; -import java.time.LocalDate; -import java.util.List; - -import ch.qos.logback.core.rolling.helper.DateTokenConverter; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.enums.ParameterIn; - -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.data.repository.query.Param; -import org.springframework.data.rest.core.annotation.RepositoryRestResource; -import org.springframework.format.annotation.DateTimeFormat; - -/** - * 商品信息 - * - * @author zctmdc - */ -@RepositoryRestResource(path = "product") -public interface ProductRepository extends JpaRepository { - - List findByPrice( @Parameter( - name = "price", - description = "test desc", - in = ParameterIn.QUERY, - required = true - ) - @Param("price") BigDecimal price); - /** - * 根据商品名称查询商品信息 - * - * @param name 商品名称 - * @return 商品信息列表 - */ - List findByName(@Parameter(name = "name2", required = true) String name); - - /** - * 根据商品名称查询最新的商品信息 - * - * @param name 商品名称 - * @return 商品信息 - */ - ProductEntity findTopByNameOrderByDateDesc(@Parameter(name = "name2", required = true) String name); - - /** - * 根据商品名称模糊查询商品信息并按时间降序排序 - * - * @param name 商品名称 - * @return 商品信息列表 - */ - List findByNameContainingIgnoreCaseOrderByDateDesc( - @Parameter(name = "name2", required = true) String name); - - /** - * 根据商品名称模糊查询商品信息并按时间降序排序 - * - * @param name 商品名称 - * @return 商品信息列表 - */ - List findByNameContainingIgnoreCase( - @Parameter(name = "name2", required = true) String name); - - /** - * 根据商品名称模糊查询指定日期前的商品信息 - * - * @param end 指定日期结束 - * @return 商品信息列表 - */ - List findByDateBefore( - @Parameter(name = "end2", required = true) @DateTimeFormat(pattern = DateTokenConverter.DEFAULT_DATE_PATTERN) @Param("end") LocalDate end); - - /** - * 根据商品名称模糊查询指定日期前的商品信息 - * - * @param name 商品名称 - * @param end 指定日期结束 - * @return 商品信息列表 - */ - List findByNameContainingIgnoreCaseAndDateBefore( - @Parameter(name = "name2", required = true) String name, - @Parameter(name = "end2", required = true) @DateTimeFormat(pattern = DateTokenConverter.DEFAULT_DATE_PATTERN) @Param("end") LocalDate end); - -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app37/SpringDocApp37Test.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app37/SpringDocApp37Test.java deleted file mode 100644 index 705fb5984..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app37/SpringDocApp37Test.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * - * * 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.app37; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -public class SpringDocApp37Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp { - - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app38/DefaultFlatParamObjectController.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app38/DefaultFlatParamObjectController.java deleted file mode 100644 index 7823db61c..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app38/DefaultFlatParamObjectController.java +++ /dev/null @@ -1,14 +0,0 @@ -package test.org.springdoc.api.app38; - -import org.springframework.data.domain.Sort; -import org.springframework.data.web.SortDefault; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -@RestController -public class DefaultFlatParamObjectController { - @GetMapping("/test1") - public String test1(@SortDefault("name") Sort sort) { - return null; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app38/SpringDocApp38Test.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app38/SpringDocApp38Test.java deleted file mode 100644 index bb67e61fb..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app38/SpringDocApp38Test.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * - * * Copyright 2019-2023 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.app38; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.test.context.TestPropertySource; - -@TestPropertySource(properties = { "springdoc.default-flat-param-object=true" }) -public class SpringDocApp38Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp { - - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app4/DatabaseLoader.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app4/DatabaseLoader.java deleted file mode 100644 index 2c15ce5b5..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app4/DatabaseLoader.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app4; - -import org.springframework.boot.CommandLineRunner; -import org.springframework.context.annotation.Bean; -import org.springframework.stereotype.Component; - -/** - * Pre-load some data using a Spring Boot {@link CommandLineRunner}. - * - * @author Greg Turnquist - */ -@Component -class DatabaseLoader { - - /** - * Use Spring to inject a {@link EmployeeRepository} that can then load data. Since this will run only after the app - * is operational, the database will be up. - * - * @param repository - */ - @Bean - CommandLineRunner init(EmployeeRepository repository) { - - return args -> { - repository.save(new Employee("Frodo", "Baggins", "ring bearer")); - repository.save(new Employee("Bilbo", "Baggins", "burglar")); - }; - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app4/Employee.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app4/Employee.java deleted file mode 100644 index ba2ba9e72..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app4/Employee.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app4; - -import jakarta.persistence.Entity; -import jakarta.persistence.GeneratedValue; -import jakarta.persistence.Id; -import lombok.AccessLevel; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -/** - * Domain object representing a company employee. Project Lombok keeps actual code at a minimum. {@code @Data} - - * Generates getters, setters, toString, hash, and equals functions {@code @Entity} - JPA annotation to flag this class - * for DB persistence {@code @NoArgsConstructor} - Create a constructor with no args to support JPA - * {@code @AllArgsConstructor} - Create a constructor with all args to support testing - * {@code @JsonIgnoreProperties(ignoreUnknow=true)} When converting JSON to Java, ignore any unrecognized attributes. - * This is critical for REST because it encourages adding new fields in later versions that won't break. It also allows - * things like _links to be ignore as well, meaning HAL documents can be fetched and later posted to the server without - * adjustment. - * - * @author Greg Turnquist - */ -@Data -@Entity -@NoArgsConstructor(access = AccessLevel.PRIVATE) -@AllArgsConstructor -class Employee { - - @Id - @GeneratedValue - private Long id; - - private String firstName; - - private String lastName; - - private String role; - - /** - * Useful constructor when id is not yet known. - * - * @param firstName - * @param lastName - * @param role - */ - Employee(String firstName, String lastName, String role) { - - this.firstName = firstName; - this.lastName = lastName; - this.role = role; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app4/EmployeeController.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app4/EmployeeController.java deleted file mode 100644 index 98d115732..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app4/EmployeeController.java +++ /dev/null @@ -1,127 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app4; - -import java.net.URI; -import java.net.URISyntaxException; -import java.util.List; -import java.util.stream.StreamSupport; - -import org.springframework.hateoas.CollectionModel; -import org.springframework.hateoas.EntityModel; -import org.springframework.hateoas.IanaLinkRelations; -import org.springframework.hateoas.Link; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RestController; - -import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.linkTo; -import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.methodOn; - -/** - * Spring Web {@link RestController} used to generate a REST API. - * - * @author Greg Turnquist - */ -@RestController -class EmployeeController { - - private final EmployeeRepository repository; - - EmployeeController(EmployeeRepository repository) { - this.repository = repository; - } - - /** - * Look up all employees, and transform them into a REST collection resource. Then return them through Spring Web's - * {@link ResponseEntity} fluent API. - */ - @GetMapping("/employees") - ResponseEntity>> findAll() { - - List> employees = StreamSupport.stream(repository.findAll().spliterator(), false) - .map(employee -> EntityModel.of(employee, // - linkTo(methodOn(EmployeeController.class).findOne(employee.getId())).withSelfRel(), // - linkTo(methodOn(EmployeeController.class).findAll()).withRel("employees"))) // - .toList(); - - return ResponseEntity.ok( // - CollectionModel.of(employees, // - linkTo(methodOn(EmployeeController.class).findAll()).withSelfRel())); - } - - @PostMapping("/employees") - ResponseEntity> newEmployee(@RequestBody Employee employee) { - - try { - Employee savedEmployee = repository.save(employee); - - EntityModel employeeResource = EntityModel.of(savedEmployee, // - linkTo(methodOn(EmployeeController.class).findOne(savedEmployee.getId())).withSelfRel()); - - return ResponseEntity // - .created(new URI(employeeResource.getRequiredLink(IanaLinkRelations.SELF).getHref())) // - .body(employeeResource); - } - catch (URISyntaxException e) { - return ResponseEntity.badRequest().body(null); - } - } - - /** - * Look up a single {@link Employee} and transform it into a REST resource. Then return it through Spring Web's - * {@link ResponseEntity} fluent API. - * - * @param id - */ - @GetMapping("/employees/{id}") - ResponseEntity> findOne(@PathVariable long id) { - - return repository.findById(id) // - .map(employee -> EntityModel.of(employee, // - linkTo(methodOn(EmployeeController.class).findOne(employee.getId())).withSelfRel(), // - linkTo(methodOn(EmployeeController.class).findAll()).withRel("employees"))) // - .map(ResponseEntity::ok) // - .orElse(ResponseEntity.notFound().build()); - } - - /** - * Update existing employee then return a Location header. - * - * @param employee - * @param id - * @return - */ - @PutMapping("/employees/{id}") - ResponseEntity updateEmployee(@RequestBody Employee employee, @PathVariable long id) throws URISyntaxException { - - Employee employeeToUpdate = employee; - employeeToUpdate.setId(id); - repository.save(employeeToUpdate); - - Link newlyCreatedLink = linkTo(methodOn(EmployeeController.class).findOne(id)).withSelfRel(); - - return ResponseEntity.noContent().location(new URI(newlyCreatedLink.getHref())).build(); - - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app4/EmployeeRepository.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app4/EmployeeRepository.java deleted file mode 100644 index a13dbc3c5..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app4/EmployeeRepository.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app4; - -import org.springframework.data.repository.CrudRepository; - -/** - * A simple Spring Data {@link CrudRepository} for storing {@link Employee}s. - * - * @author Greg Turnquist - */ -interface EmployeeRepository extends CrudRepository { -} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app4/SpringDocApp4Test.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app4/SpringDocApp4Test.java deleted file mode 100644 index faa270b76..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app4/SpringDocApp4Test.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app4; - -import test.org.springdoc.api.AbstractSpringDocTest; - -public class SpringDocApp4Test extends AbstractSpringDocTest { - - -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app4/SpringDocTestApp.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app4/SpringDocTestApp.java deleted file mode 100644 index a833bd8d8..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app4/SpringDocTestApp.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app4; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.Bean; -import org.springframework.hateoas.server.core.EvoInflectorLinkRelationProvider; - -@SpringBootApplication -public class SpringDocTestApp { - - public static void main(String[] args) { - SpringApplication.run(SpringDocTestApp.class, args); - } - - @Bean - EvoInflectorLinkRelationProvider relProvider() { - return new EvoInflectorLinkRelationProvider(); - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app5/Country.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app5/Country.java deleted file mode 100644 index 784b38324..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app5/Country.java +++ /dev/null @@ -1,94 +0,0 @@ -package test.org.springdoc.api.app5; - -import jakarta.persistence.Basic; -import jakarta.persistence.Column; -import jakarta.persistence.Entity; -import jakarta.persistence.EnumType; -import jakarta.persistence.Enumerated; -import jakarta.persistence.GeneratedValue; -import jakarta.persistence.Id; - -/** - * @author gibah - */ - -@Entity -public class Country { - - @Id - @GeneratedValue - private Long id; - - @Basic - @Column(nullable = false) - private String name; - - @Basic - private String shortName; - - @Basic - private String dialingCode; - - @Basic - @Column(unique = true, nullable = false) - private String codeISO3166; - - @Basic - @Column(nullable = false) - @Enumerated(EnumType.STRING) - private Status status; - - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getShortName() { - return shortName; - } - - public void setShortName(String shortName) { - this.shortName = shortName; - } - - public String getDialingCode() { - return dialingCode; - } - - public void setDialingCode(String dialingCode) { - this.dialingCode = dialingCode; - } - - public String getCodeISO3166() { - return codeISO3166; - } - - public void setCodeISO3166(String codeISO3166) { - this.codeISO3166 = codeISO3166; - } - - public Status getStatus() { - return status; - } - - public Country setStatus(Status status) { - this.status = status; - return this; - } - - public enum Status { - ACTIVE, INACTIVE - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app5/CountryPredicate.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app5/CountryPredicate.java deleted file mode 100644 index 4730ed454..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app5/CountryPredicate.java +++ /dev/null @@ -1,13 +0,0 @@ -package test.org.springdoc.api.app5; - -import org.springframework.data.querydsl.binding.QuerydslBinderCustomizer; -import org.springframework.data.querydsl.binding.QuerydslBindings; - -public class CountryPredicate implements QuerydslBinderCustomizer { - - @Override - public void customize(QuerydslBindings querydslBindings, QCountry qCountry) { - querydslBindings.bind(qCountry.codeISO3166).as("code").first((path, value) -> path.containsIgnoreCase(value)); - querydslBindings.bind(qCountry.dialingCode).as("postCode").first((path, value) -> path.containsIgnoreCase(value)); - } -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app5/GreetingController.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app5/GreetingController.java deleted file mode 100644 index 2c7cacdcc..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app5/GreetingController.java +++ /dev/null @@ -1,22 +0,0 @@ -package test.org.springdoc.api.app5; - -import java.util.List; - -import com.querydsl.core.types.Predicate; -import test.org.springdoc.api.app5.Country.Status; - -import org.springframework.data.querydsl.binding.QuerydslPredicate; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -@RestController -public class GreetingController { - - @GetMapping("/test") - public ResponseEntity sayHello2(@QuerydslPredicate(bindings = CountryPredicate.class, root = Country.class) Predicate predicate, - @RequestParam List statuses) { - return ResponseEntity.ok().build(); - } -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app5/QCountry.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app5/QCountry.java deleted file mode 100644 index 201667040..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app5/QCountry.java +++ /dev/null @@ -1,50 +0,0 @@ -package test.org.springdoc.api.app5; - -import com.querydsl.core.types.Path; -import com.querydsl.core.types.PathMetadata; -import com.querydsl.core.types.dsl.EntityPathBase; -import com.querydsl.core.types.dsl.EnumPath; -import com.querydsl.core.types.dsl.NumberPath; -import com.querydsl.core.types.dsl.StringPath; -import jakarta.annotation.Generated; -import test.org.springdoc.api.app5.Country.Status; - -import static com.querydsl.core.types.PathMetadataFactory.forVariable; - - -/** - * QCountry is a Querydsl query type for Country - */ -@Generated("com.querydsl.codegen.EntitySerializer") -public class QCountry extends EntityPathBase { - - public static final QCountry country = new QCountry("country"); - - private static final long serialVersionUID = -1184258693L; - - public final StringPath codeISO3166 = createString("codeISO3166"); - - public final StringPath dialingCode = createString("dialingCode"); - - public final NumberPath id = createNumber("id", Long.class); - - public final StringPath name = createString("name"); - - public final StringPath shortName = createString("shortName"); - - public final EnumPath status = createEnum("status", Status.class); - - public QCountry(String variable) { - super(Country.class, forVariable(variable)); - } - - public QCountry(Path path) { - super(path.getType(), path.getMetadata()); - } - - public QCountry(PathMetadata metadata) { - super(Country.class, metadata); - } - -} - diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app5/SpringDocApp5Test.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app5/SpringDocApp5Test.java deleted file mode 100644 index e5ff03a64..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app5/SpringDocApp5Test.java +++ /dev/null @@ -1,18 +0,0 @@ -package test.org.springdoc.api.app5; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * @author Gibah Joseph - * Email: gibahjoe@gmail.com - * Mar, 2020 - **/ - -public class SpringDocApp5Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp {} - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app6/DatabaseLoader.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app6/DatabaseLoader.java deleted file mode 100644 index 3058d3a0c..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app6/DatabaseLoader.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app6; - -import org.springframework.boot.CommandLineRunner; -import org.springframework.context.annotation.Bean; -import org.springframework.stereotype.Component; - -/** - * Pre-load some data using a Spring Boot {@link CommandLineRunner}. - * - * @author Greg Turnquist - */ -@Component -class DatabaseLoader { - - /** - * Use Spring to inject a {@link EmployeeRepository} that can then load data. Since this will run only after the app - * is operational, the database will be up. - * - * @param repository - */ - @Bean - CommandLineRunner init(EmployeeRepository repository) { - - return args -> { - repository.save(new Employee("Frodo", "Baggins", "ring bearer")); - repository.save(new Employee("Bilbo", "Baggins", "burglar")); - }; - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app6/Employee.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app6/Employee.java deleted file mode 100644 index 81762d147..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app6/Employee.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app6; - -import jakarta.persistence.Entity; -import jakarta.persistence.GeneratedValue; -import jakarta.persistence.Id; -import lombok.AccessLevel; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -/** - * Domain object representing a company employee. Project Lombok keeps actual code at a minimum. {@code @Data} - - * Generates getters, setters, toString, hash, and equals functions {@code @Entity} - JPA annotation to flag this class - * for DB persistence {@code @NoArgsConstructor} - Create a constructor with no args to support JPA - * {@code @AllArgsConstructor} - Create a constructor with all args to support testing - * {@code @JsonIgnoreProperties(ignoreUnknow=true)} When converting JSON to Java, ignore any unrecognized attributes. - * This is critical for REST because it encourages adding new fields in later versions that won't break. It also allows - * things like _links to be ignore as well, meaning HAL documents can be fetched and later posted to the server without - * adjustment. - * - * @author Greg Turnquist - */ -@Data -@Entity -@NoArgsConstructor(access = AccessLevel.PRIVATE) -@AllArgsConstructor -class Employee { - - @Id - @GeneratedValue - private Long id; - - private String firstName; - - private String lastName; - - private String role; - - /** - * Useful constructor when id is not yet known. - * - * @param firstName - * @param lastName - * @param role - */ - Employee(String firstName, String lastName, String role) { - - this.firstName = firstName; - this.lastName = lastName; - this.role = role; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app6/EmployeeController.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app6/EmployeeController.java deleted file mode 100644 index 0cefc1580..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app6/EmployeeController.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app6; - -import org.springframework.hateoas.EntityModel; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RestController; - -/** - * Spring Web {@link RestController} used to generate a REST API. - * - * @author Greg Turnquist - */ -@RestController -class EmployeeController { - - /** - * Look up a single {@link Employee} and transform it into a REST resource. Then return it through Spring Web's - * {@link ResponseEntity} fluent API. - * - * @param id - */ - @GetMapping("/employees/{id}") - EntityModel findOne(@PathVariable long id) { - - return null; - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app6/EmployeeRepository.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app6/EmployeeRepository.java deleted file mode 100644 index dd5dafaae..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app6/EmployeeRepository.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app6; - -import org.springframework.data.repository.CrudRepository; - -/** - * A simple Spring Data {@link CrudRepository} for storing {@link Employee}s. - * - * @author Greg Turnquist - */ -interface EmployeeRepository extends CrudRepository { -} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app6/SpringDocApp6Test.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app6/SpringDocApp6Test.java deleted file mode 100644 index d2db28e94..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app6/SpringDocApp6Test.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app6; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.test.context.TestPropertySource; - -@TestPropertySource(properties = "springdoc.remove-broken-reference-definitions=false") -public class SpringDocApp6Test extends AbstractSpringDocTest { - - -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app6/SpringDocTestApp.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app6/SpringDocTestApp.java deleted file mode 100644 index bb74043f5..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app6/SpringDocTestApp.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app6; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.Bean; -import org.springframework.hateoas.server.core.EvoInflectorLinkRelationProvider; - -@SpringBootApplication -public class SpringDocTestApp { - - public static void main(String[] args) { - SpringApplication.run(SpringDocTestApp.class, args); - } - - @Bean - EvoInflectorLinkRelationProvider relProvider() { - return new EvoInflectorLinkRelationProvider(); - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app7/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app7/HelloController.java deleted file mode 100644 index 6c99e3a02..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app7/HelloController.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app7; - -import java.util.List; - -import jakarta.validation.constraints.NotNull; -import org.springdoc.core.annotations.ParameterObject; - -import org.springframework.data.domain.Pageable; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -@RestController -public class HelloController { - - @GetMapping(value = "/search", produces = { "application/xml", "application/json" }) - public ResponseEntity> getAllPets(@NotNull @ParameterObject Pageable pageable) { - return null; - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app7/PersonDTO.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app7/PersonDTO.java deleted file mode 100644 index e7d21b4de..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app7/PersonDTO.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app7; - -import io.swagger.v3.oas.annotations.media.Schema; - -@Schema -public class PersonDTO { - private String email; - - private String firstName; - - private String lastName; - - public PersonDTO() { - } - - public PersonDTO(final String email, final String firstName, final String lastName) { - this.email = email; - this.firstName = firstName; - this.lastName = lastName; - } - - public String getEmail() { - return email; - } - - public void setEmail(final String email) { - this.email = email; - } - - public String getFirstName() { - return firstName; - } - - public void setFirstName(final String firstName) { - this.firstName = firstName; - } - - public String getLastName() { - return lastName; - } - - public void setLastName(final String lastName) { - this.lastName = lastName; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app7/SpringDocApp7Test.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app7/SpringDocApp7Test.java deleted file mode 100644 index 5f180a504..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app7/SpringDocApp7Test.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app7; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -public class SpringDocApp7Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp {} - -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app8/Album.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app8/Album.java deleted file mode 100644 index de60a7a48..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app8/Album.java +++ /dev/null @@ -1,29 +0,0 @@ -package test.org.springdoc.api.app8; - -public class Album { - - private String title; - - private String description; - - private String releaseDate; - - public Album(String title, String description, String releaseDate) { - this.title = title; - this.description = description; - this.releaseDate = releaseDate; - } - - public String getTitle() { - return title; - } - - public String getDescription() { - return description; - } - - public String getReleaseDate() { - return releaseDate; - } - -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app8/AlbumController.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app8/AlbumController.java deleted file mode 100644 index 537fa646f..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app8/AlbumController.java +++ /dev/null @@ -1,32 +0,0 @@ -package test.org.springdoc.api.app8; - -import java.util.Arrays; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.domain.Page; -import org.springframework.data.domain.PageImpl; -import org.springframework.data.web.PagedResourcesAssembler; -import org.springframework.hateoas.PagedModel; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -@RestController -@SuppressWarnings("unchecked") -public class AlbumController { - - @Autowired - private AlbumModelAssembler albumModelAssembler; - - @Autowired - private PagedResourcesAssembler pagedResourcesAssembler; - - @GetMapping("/api/albums") - public PagedModel getAllAlbums() { - Album album1 = new Album("album-title-1", "album-description-1", "album-release-date-1"); - Album album2 = new Album("album-title-2", "album-description-2", "album-release-date-2"); - Page albumPage = new PageImpl<>(Arrays.asList(album1, album2)); - - return pagedResourcesAssembler.toModel(albumPage, albumModelAssembler); - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app8/AlbumModelAssembler.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app8/AlbumModelAssembler.java deleted file mode 100644 index a8e68dda3..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app8/AlbumModelAssembler.java +++ /dev/null @@ -1,20 +0,0 @@ -package test.org.springdoc.api.app8; - -import java.util.ArrayList; -import java.util.List; - -import org.springframework.hateoas.EntityModel; -import org.springframework.hateoas.Link; -import org.springframework.hateoas.server.RepresentationModelAssembler; -import org.springframework.stereotype.Component; - -@Component -public class AlbumModelAssembler implements RepresentationModelAssembler> { - - @Override - public EntityModel toModel(Album entity) { - List links = new ArrayList<>(); - return EntityModel.of(entity, links); - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app8/SpringDocApp8Test.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app8/SpringDocApp8Test.java deleted file mode 100644 index 89f5cfdc4..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app8/SpringDocApp8Test.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app8; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -public class SpringDocApp8Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp {} - -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app9/SpringDocApp9Test.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app9/SpringDocApp9Test.java deleted file mode 100644 index f17f38fe2..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app9/SpringDocApp9Test.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * - * * - * * * - * * * * - * * * * * 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.app9; - -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; - -import com.fasterxml.jackson.databind.introspect.SimpleMixInResolver; -import com.fasterxml.jackson.databind.type.ClassKey; -import org.apache.commons.lang3.reflect.FieldUtils; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeEach; -import org.springdoc.core.providers.ObjectMapperProvider; -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.test.context.TestPropertySource; - -@TestPropertySource(properties = "spring.hateoas.use-hal-as-default-json-media-type= false") -@SuppressWarnings({ "deprecation", "unchecked" }) -public class SpringDocApp9Test extends AbstractSpringDocTest { - - private final Map> springMixins = new HashMap<>(); - - @Autowired - ObjectMapperProvider objectMapperProvider; - - @BeforeEach - void init() throws IllegalAccessException { - SimpleMixInResolver _mixIns = (SimpleMixInResolver) FieldUtils.readDeclaredField(objectMapperProvider.jsonMapper(), "_mixIns", true); - Map> _localMixIns = (Map>) FieldUtils.readDeclaredField(_mixIns, "_localMixIns", true); - Iterator>> it = _localMixIns.entrySet().iterator(); - while (it.hasNext()) { - Map.Entry> entry = it.next(); - if (entry.getKey().toString().startsWith("org.springframework")) { - springMixins.put(entry.getKey(), entry.getValue()); - it.remove(); - } - } - - } - - @AfterEach - void clean() throws IllegalAccessException { - SimpleMixInResolver _mixIns = (SimpleMixInResolver) FieldUtils.readDeclaredField(objectMapperProvider.jsonMapper(), "_mixIns", true); - Map> _localMixIns = (Map>) FieldUtils.readDeclaredField(_mixIns, "_localMixIns", true); - _localMixIns.putAll(springMixins); - } - - @SpringBootApplication - static class SpringDocTestApp {} - -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app9/component/controller/ComponentsController.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app9/component/controller/ComponentsController.java deleted file mode 100644 index 0011c0bb6..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app9/component/controller/ComponentsController.java +++ /dev/null @@ -1,78 +0,0 @@ -package test.org.springdoc.api.app9.component.controller; - - -import java.util.Optional; - -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.media.Content; -import io.swagger.v3.oas.annotations.media.Schema; -import io.swagger.v3.oas.annotations.responses.ApiResponse; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springdoc.core.converters.models.PageableAsQueryParam; -import test.org.springdoc.api.app9.component.controller.hateoas.ComponentDtoModelAssembler; -import test.org.springdoc.api.app9.component.dto.DemoComponentDto; -import test.org.springdoc.api.app9.component.dto.converter.DemoComponentConverter; -import test.org.springdoc.api.app9.component.model.DemoComponent; -import test.org.springdoc.api.app9.component.service.ComponentsService; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.domain.Page; -import org.springframework.data.domain.Pageable; -import org.springframework.data.web.PagedResourcesAssembler; -import org.springframework.hateoas.EntityModel; -import org.springframework.hateoas.PagedModel; -import org.springframework.hateoas.RepresentationModel; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.linkTo; -import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.methodOn; - -@RestController -@RequestMapping(path = "/components", produces = "application/json") -@Tag(name = "components", description = "Everything about components") -public class ComponentsController { - - @Autowired - private ComponentsService componentsService; - - @Autowired - private DemoComponentConverter toDtoConverter; - - @Autowired - private ComponentDtoModelAssembler componentDtoModelAssembler; - - @Autowired - private PagedResourcesAssembler pagedResourcesAssembler; - - @Operation(summary = "List the components") - @PageableAsQueryParam - @GetMapping - public ResponseEntity>>> findAll(@Parameter(hidden = true) Pageable pageable) { - Page results = componentsService.findAll(pageable); - - return ResponseEntity.ok(pagedResourcesAssembler.toModel(results, componentDtoModelAssembler)); - } - - @Operation(summary = "Get one component by its ID", description = "Returns a single component", // - responses = { // - @ApiResponse(responseCode = "200", description = "Component found"), // - @ApiResponse(responseCode = "404", description = "Component not found", content = { @Content(schema = @Schema(implementation = Void.class)) }) // - }) - @GetMapping("/{componentId}") - public ResponseEntity> findById(@PathVariable String componentId) { - Optional foundComponent = componentsService.findById(componentId); - - if (foundComponent.isPresent()) { - return ResponseEntity.ok(EntityModel.of(toDtoConverter.convert(foundComponent.get()), // - linkTo(methodOn(ComponentsController.class).findAll(null)).withRel("components"))); - } - - return ResponseEntity.notFound().location(linkTo(methodOn(ComponentsController.class).findAll(null)).toUri()).build(); - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app9/component/controller/hateoas/ComponentDtoModelAssembler.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app9/component/controller/hateoas/ComponentDtoModelAssembler.java deleted file mode 100644 index 761628f0c..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app9/component/controller/hateoas/ComponentDtoModelAssembler.java +++ /dev/null @@ -1,26 +0,0 @@ -package test.org.springdoc.api.app9.component.controller.hateoas; - - -import test.org.springdoc.api.app9.component.dto.DemoComponentDto; -import test.org.springdoc.api.app9.component.dto.converter.DemoComponentConverter; -import test.org.springdoc.api.app9.component.model.DemoComponent; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.hateoas.EntityModel; -import org.springframework.hateoas.RepresentationModel; -import org.springframework.hateoas.server.RepresentationModelAssembler; -import org.springframework.stereotype.Component; - -@Component -@SuppressWarnings({ "deprecation", "unchecked" }) -public class ComponentDtoModelAssembler implements RepresentationModelAssembler>> { - - @Autowired - private DemoComponentConverter toDtoConverter; - - @Override - public RepresentationModel> toModel(DemoComponent entity) { - return EntityModel.of(toDtoConverter.convert(entity)); - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app9/component/controller/hateoas/DemoComponentDtoModelProcessor.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app9/component/controller/hateoas/DemoComponentDtoModelProcessor.java deleted file mode 100644 index b3b35ba8d..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app9/component/controller/hateoas/DemoComponentDtoModelProcessor.java +++ /dev/null @@ -1,26 +0,0 @@ -package test.org.springdoc.api.app9.component.controller.hateoas; - - -import test.org.springdoc.api.app9.component.controller.ComponentsController; -import test.org.springdoc.api.app9.component.dto.DemoComponentDto; - -import org.springframework.hateoas.EntityModel; -import org.springframework.hateoas.server.RepresentationModelProcessor; -import org.springframework.stereotype.Component; - -import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.linkTo; -import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.methodOn; - -@Component -public class DemoComponentDtoModelProcessor implements RepresentationModelProcessor> { - - @Override - public EntityModel process(EntityModel model) { - final String id = model.getContent().getId(); - - model.add(linkTo(methodOn(ComponentsController.class).findById(id)).withSelfRel()); - - return model; - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app9/component/dto/DemoComponentDto.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app9/component/dto/DemoComponentDto.java deleted file mode 100644 index 270d7c919..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app9/component/dto/DemoComponentDto.java +++ /dev/null @@ -1,25 +0,0 @@ -package test.org.springdoc.api.app9.component.dto; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; - -import org.springframework.hateoas.server.core.Relation; - -@Data -@Builder -@NoArgsConstructor -@AllArgsConstructor -@Relation(collectionRelation = "components") -@Schema(description = "A demo component to illustrate Springdoc Issue #401") -public final class DemoComponentDto { - - @Schema(description = "Some ID", example = "1") - private String id; - - @Schema(description = "Some dummy payload", example = "Hello World") - private String payload; - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app9/component/dto/converter/DemoComponentConverter.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app9/component/dto/converter/DemoComponentConverter.java deleted file mode 100644 index aef3520ce..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app9/component/dto/converter/DemoComponentConverter.java +++ /dev/null @@ -1,25 +0,0 @@ -package test.org.springdoc.api.app9.component.dto.converter; - - -import test.org.springdoc.api.app9.component.dto.DemoComponentDto; -import test.org.springdoc.api.app9.component.model.DemoComponent; -import test.org.springdoc.api.app9.utils.Converter; - -import org.springframework.stereotype.Component; - -@Component -public class DemoComponentConverter implements Converter { - - @Override - public DemoComponentDto convert(DemoComponent source) { - if (source == null) { - return null; - } - - return DemoComponentDto.builder() // - .id(source.getId()) // - .payload(source.getPayload()) // - .build(); - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app9/component/model/DemoComponent.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app9/component/model/DemoComponent.java deleted file mode 100644 index 679d8eadf..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app9/component/model/DemoComponent.java +++ /dev/null @@ -1,21 +0,0 @@ -package test.org.springdoc.api.app9.component.model; - -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.EqualsAndHashCode; - -import org.springframework.data.annotation.Id; - -@Data -@Builder -@AllArgsConstructor -@EqualsAndHashCode -public class DemoComponent { - - @Id - private String id; - - private String payload; - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app9/component/service/ComponentsService.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app9/component/service/ComponentsService.java deleted file mode 100644 index eab7b3f2a..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app9/component/service/ComponentsService.java +++ /dev/null @@ -1,28 +0,0 @@ -package test.org.springdoc.api.app9.component.service; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.Map; -import java.util.Optional; - -import test.org.springdoc.api.app9.component.model.DemoComponent; - -import org.springframework.data.domain.Page; -import org.springframework.data.domain.PageImpl; -import org.springframework.data.domain.Pageable; -import org.springframework.stereotype.Service; - -@Service -public class ComponentsService { - - private static final Map repo = Collections.singletonMap("1", DemoComponent.builder().id("1").payload("Hello World !").build()); - - public Optional findById(String componentId) { - return Optional.ofNullable(repo.get(componentId)); - } - - public Page findAll(Pageable pageable) { - return new PageImpl(new ArrayList<>(repo.values()), pageable, repo.size()); - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app9/core/config/OpenAPIConfiguration.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app9/core/config/OpenAPIConfiguration.java deleted file mode 100644 index d927be634..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app9/core/config/OpenAPIConfiguration.java +++ /dev/null @@ -1,18 +0,0 @@ -package test.org.springdoc.api.app9.core.config; - -import io.swagger.v3.oas.annotations.OpenAPIDefinition; -import io.swagger.v3.oas.annotations.info.Info; - -import org.springframework.stereotype.Component; - -@Component -@OpenAPIDefinition( // - info = @Info( // - title = "Demo Springdoc Issue #401", // - version = "0.0.1-SNAPSHOT", // - description = "A demo API to illustrate Springdoc Issue #401." // - ) // -) -public class OpenAPIConfiguration { - // NO-OP -} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app9/core/config/SpringRestConfiguration.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app9/core/config/SpringRestConfiguration.java deleted file mode 100644 index 3ed047190..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app9/core/config/SpringRestConfiguration.java +++ /dev/null @@ -1,16 +0,0 @@ -package test.org.springdoc.api.app9.core.config; - -import org.springframework.context.annotation.Configuration; -import org.springframework.data.rest.core.config.RepositoryRestConfiguration; -import org.springframework.data.rest.webmvc.config.RepositoryRestConfigurer; -import org.springframework.http.MediaType; -import org.springframework.web.servlet.config.annotation.CorsRegistry; - -@Configuration -public class SpringRestConfiguration implements RepositoryRestConfigurer { - @Override - public void configureRepositoryRestConfiguration(RepositoryRestConfiguration config, CorsRegistry cors) { - config.setDefaultMediaType(MediaType.APPLICATION_JSON); - config.useHalAsDefaultJsonMediaType(false); - } -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app9/core/config/WebMvcConfiguration.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app9/core/config/WebMvcConfiguration.java deleted file mode 100644 index 497a9eb71..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app9/core/config/WebMvcConfiguration.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * - * * - * * * Copyright 2019-2020 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.app9.core.config; - -import org.springframework.boot.convert.ApplicationConversionService; -import org.springframework.context.annotation.Configuration; -import org.springframework.format.FormatterRegistry; -import org.springframework.web.servlet.config.annotation.CorsRegistry; -import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; - -import static org.springdoc.core.utils.Constants.ALL_PATTERN; - -@Configuration -public class WebMvcConfiguration implements WebMvcConfigurer { - - private final long MAX_AGE_SECS = 3600; - - @Override - public void addCorsMappings(CorsRegistry registry) { - registry.addMapping(ALL_PATTERN) // - .allowedOrigins("http://localhost") // - .allowedMethods("GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS") // - .allowedHeaders("*") // - .allowCredentials(true) // - .maxAge(MAX_AGE_SECS); - } - - @Override - public void addFormatters(FormatterRegistry registry) { - ApplicationConversionService.configure(registry); - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app9/core/exception/BadArgumentException.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app9/core/exception/BadArgumentException.java deleted file mode 100644 index 1f4623a2f..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app9/core/exception/BadArgumentException.java +++ /dev/null @@ -1,15 +0,0 @@ -package test.org.springdoc.api.app9.core.exception; - -import org.springframework.http.HttpStatus; -import org.springframework.web.bind.annotation.ResponseStatus; - -@ResponseStatus(value = HttpStatus.BAD_REQUEST) -public class BadArgumentException extends Exception { - - private static final long serialVersionUID = -4975801683971908022L; - - public BadArgumentException(String message) { - super(message); - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app9/core/exception/BusinessException.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app9/core/exception/BusinessException.java deleted file mode 100644 index 589b543b8..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app9/core/exception/BusinessException.java +++ /dev/null @@ -1,11 +0,0 @@ -package test.org.springdoc.api.app9.core.exception; - -public class BusinessException extends Exception { - - private static final long serialVersionUID = -5454643285401132760L; - - public BusinessException(String message) { - super(message); - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app9/core/model/ExceptionDto.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app9/core/model/ExceptionDto.java deleted file mode 100644 index 42b56200f..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app9/core/model/ExceptionDto.java +++ /dev/null @@ -1,26 +0,0 @@ -package test.org.springdoc.api.app9.core.model; - -import java.time.Instant; - -import io.swagger.v3.oas.annotations.media.Schema; -import jakarta.validation.constraints.NotEmpty; -import jakarta.validation.constraints.NotNull; -import lombok.Data; -import lombok.NonNull; - -@Data -public class ExceptionDto { - - @NonNull - @NotNull - @NotEmpty - @Schema(description = "The date and time the problem occured", example = "2020-02-04T13:21:08.098+0000", type = "string", format = "date-time") - private Instant timestamp; - - @Schema(description = "The exception class", example = "com.it4it.it4data.newdata.dataplatform.portal.api.core.exception.BadArgumentException") - private String exception; - - @Schema(description = "The exception message", example = "Trying to update a non existing component !") - private String message; - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app9/utils/Converter.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app9/utils/Converter.java deleted file mode 100644 index f1ad8f278..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/app9/utils/Converter.java +++ /dev/null @@ -1,7 +0,0 @@ -package test.org.springdoc.api.app9.utils; - -public interface Converter { - - T convert(S source); - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/AbstractSpringDocTest.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/AbstractSpringDocTest.java new file mode 100644 index 000000000..53b6057d9 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/AbstractSpringDocTest.java @@ -0,0 +1,85 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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; + +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; + +import org.junit.jupiter.api.Test; +import org.springdoc.core.utils.Constants; + +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.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; + +@ActiveProfiles("test") +@SpringBootTest +@AutoConfigureMockMvc +@TestPropertySource(properties = "springdoc.api-docs.version=openapi_3_0" ) +public abstract class AbstractSpringDocTest { + + public static String className; + + @Autowired + protected MockMvc mockMvc; + + public static String getContent(String fileName) { + try { + Path path = Paths.get(AbstractSpringDocTest.class.getClassLoader().getResource(fileName).toURI()); + byte[] fileBytes = Files.readAllBytes(path); + return new String(fileBytes, StandardCharsets.UTF_8); + } + catch (Exception e) { + throw new RuntimeException("Failed to read file: " + fileName, e); + } + } + + @Test + void testApp() throws Exception { + className = getClass().getSimpleName(); + String testNumber = className.replaceAll("[^0-9]", ""); + MvcResult mockMvcResult = mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL)).andExpect(status().isOk()) + .andExpect(jsonPath("$.openapi", is("3.0.1"))).andReturn(); + String result = mockMvcResult.getResponse().getContentAsString(); + Path path = Paths.get(getClass().getClassLoader().getResource("results/3.0.1/app" + testNumber + ".json").toURI()); + byte[] fileBytes = Files.readAllBytes(path); + String expected = new String(fileBytes); + assertEquals(expected, result, true); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app10/Account.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app10/Account.java new file mode 100644 index 000000000..c45a4ac37 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app10/Account.java @@ -0,0 +1,63 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app10; + +import java.util.Date; + +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.Temporal; +import jakarta.persistence.TemporalType; + +@Entity +public class Account { + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private Long id; + + @ManyToOne + private Customer customer; + + @Temporal(TemporalType.DATE) + private Date expiryDate; + + public Long getId() { + return id; + } + + public Customer getCustomer() { + return customer; + } + + public Date getExpiryDate() { + return expiryDate; + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app10/AccountRepository.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app10/AccountRepository.java new file mode 100644 index 000000000..62c75c379 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app10/AccountRepository.java @@ -0,0 +1,50 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app10; + + +import java.util.List; + +import org.springframework.data.repository.CrudRepository; +import org.springframework.data.repository.query.Param; +import org.springframework.data.rest.core.annotation.RepositoryRestResource; + +/** + * Repository to manage {@link Account} instances. + * + */ +@RepositoryRestResource +public interface AccountRepository extends CrudRepository { + + /** + * Returns all accounts belonging to the given {@link Customer}. + * + * @param customer + * @return + */ + List findByCustomer(@Param("customer") Customer customer); +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app10/Customer.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app10/Customer.java new file mode 100644 index 000000000..df93bf4f9 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app10/Customer.java @@ -0,0 +1,60 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app10; + + +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; + +/** + * @author Oliver Gierke + */ +@Entity +public class Customer { + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private Long id; + + private String firstname; + + private String lastname; + + public Long getId() { + return id; + } + + public String getFirstname() { + return firstname; + } + + public String getLastname() { + return lastname; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app10/CustomerRepository.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app10/CustomerRepository.java new file mode 100644 index 000000000..fb0da38ec --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app10/CustomerRepository.java @@ -0,0 +1,76 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app10; + +import java.util.List; +import java.util.Optional; + +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.data.jpa.repository.JpaSpecificationExecutor; +import org.springframework.data.repository.CrudRepository; +import org.springframework.data.repository.query.Param; +import org.springframework.data.rest.core.annotation.RepositoryRestResource; +import org.springframework.data.rest.core.annotation.RestResource; + +/** + * Repository to manage {@link Customer} instances. + * + * @author Oliver Gierke + */ +@RepositoryRestResource +public interface CustomerRepository extends CrudRepository, JpaSpecificationExecutor { + + /** + * Returns a page of {@link Customer}s with the given lastname. + * + * @param lastname + * @param pageable + * @return + */ + Page findByLastname(@Param("lastname") String lastname, Pageable pageable); + + @Override + @RestResource(exported = false) + void deleteById(Long id); + + @Override + @RestResource(exported = false) + void delete(Customer entity); + + @Override + @RestResource + List findAll(); + + @Override + @RestResource(exported = false) + Optional findById(Long aLong); + + @Override + @RestResource(exported = false) + S save(S entity); +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app10/SpringDocApp10Test.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app10/SpringDocApp10Test.java new file mode 100644 index 000000000..8c5fcfe37 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app10/SpringDocApp10Test.java @@ -0,0 +1,37 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app10; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp10Test extends AbstractSpringDocTest { + + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app11/Person.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app11/Person.java new file mode 100644 index 000000000..b57168bb8 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app11/Person.java @@ -0,0 +1,60 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app11; + +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; + +@Entity +public class Person { + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private long id; + + private String firstName; + + private String lastName; + + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app11/PersonRepository.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app11/PersonRepository.java new file mode 100644 index 000000000..78c0abc04 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app11/PersonRepository.java @@ -0,0 +1,40 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app11; + +import java.util.List; + +import org.springframework.data.repository.PagingAndSortingRepository; +import org.springframework.data.repository.query.Param; +import org.springframework.data.rest.core.annotation.RepositoryRestResource; + +@RepositoryRestResource(collectionResourceRel = "people", path = "peopleme") +public interface PersonRepository extends PagingAndSortingRepository { + + List findByLastName(@Param("name") String name); + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app11/SpringDocApp11Test.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app11/SpringDocApp11Test.java new file mode 100644 index 000000000..65bb4c97c --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app11/SpringDocApp11Test.java @@ -0,0 +1,37 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app11; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp11Test extends AbstractSpringDocTest { + + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app12/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app12/HelloController.java new file mode 100644 index 000000000..87be5b190 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app12/HelloController.java @@ -0,0 +1,85 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app12; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; + +import org.springframework.hateoas.EntityModel; +import org.springframework.hateoas.MediaTypes; +import org.springframework.hateoas.server.mvc.WebMvcLinkBuilder; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + + +@RequestMapping("/demo") +@RestController +public class HelloController { + + @Operation(summary = "GetMyData", operationId = "gettt", + responses = @ApiResponse(responseCode = "204", + content = @Content(mediaType = "application/vnd.something"))) + @GetMapping(produces = "application/vnd.something") + public ResponseEntity getSomethingElse() { + return ResponseEntity.noContent().build(); + } + + @GetMapping(produces = MediaType.TEXT_PLAIN_VALUE) + public String get() { + return "some text"; + } + + @GetMapping(produces = MediaTypes.HAL_JSON_VALUE) + public EntityModel getHal() { + return EntityModel.of(new JsonResponse(), + WebMvcLinkBuilder.linkTo(HelloController.class).slash("somelink").withSelfRel() + ); + } + + @GetMapping(produces = MediaType.APPLICATION_JSON_VALUE) + public JsonResponse getJson() { + return new JsonResponse(); + } + + @GetMapping(produces = MediaType.APPLICATION_XML_VALUE) + @ApiResponse(responseCode = "202", + content = @Content(mediaType = MediaType.APPLICATION_XML_VALUE, schema = @Schema(implementation = JsonResponse.class))) + public JsonResponse getXML() { + return new JsonResponse(); + } + + public class JsonResponse { + @JsonProperty + private String field; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app12/SpringDocApp12Test.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app12/SpringDocApp12Test.java new file mode 100644 index 000000000..5132651a4 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app12/SpringDocApp12Test.java @@ -0,0 +1,51 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app12; + +import io.swagger.v3.oas.models.Operation; +import org.springdoc.core.customizers.OperationCustomizer; +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; +import org.springframework.web.method.HandlerMethod; + +public class SpringDocApp12Test extends AbstractSpringDocTest { + + @SpringBootApplication + static class SpringDocTestApp { + @Bean + OperationCustomizer operationCustomizer() { + return (Operation operation, HandlerMethod handlerMethod) -> { + if (operation.getOperationId().startsWith("gettt")) + operation.setOperationId("gettt"); + return operation; + }; + } + } + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app13/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app13/HelloController.java new file mode 100644 index 000000000..c094b330d --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app13/HelloController.java @@ -0,0 +1,84 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app13; + +import java.util.List; + +import org.springdoc.core.annotations.ParameterObject; + +import org.springframework.data.domain.Pageable; +import org.springframework.data.domain.Sort.Direction; +import org.springframework.data.web.PageableDefault; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class HelloController { + + @GetMapping(value = "/search", produces = { "application/xml", "application/json" }) + public ResponseEntity> getAllPets(@PageableDefault(size = 5, sort = "name") @ParameterObject Pageable pageable) { + return null; + } + + + @GetMapping("/test1") + public String getPatientList1(@PageableDefault(size = 100, sort = { "someField", "someoTHER" }, + direction = Direction.DESC) + @ParameterObject Pageable pageable) { + return "bla"; + } + + @GetMapping("/test2") + public String getPatientList2(@PageableDefault(size = 100, sort = "someField", + direction = Direction.DESC) + @ParameterObject Pageable pageable) { + return "bla"; + } + + @GetMapping("/test3") + public String getPatientList3(@PageableDefault(size = 100) + @ParameterObject Pageable pageable) { + return "bla"; + } + + @GetMapping("/test4") + public String getPatientList4(@PageableDefault(100) + @ParameterObject Pageable pageable) { + return "bla"; + } + + @GetMapping("/test5") + public void read( + @PageableDefault(sort = { + "some,desc", + "other,asc", + "another.that,desc" + }) + @ParameterObject final Pageable pageable) { + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app13/PersonDTO.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app13/PersonDTO.java new file mode 100644 index 000000000..5a417e784 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app13/PersonDTO.java @@ -0,0 +1,71 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app13; + +import io.swagger.v3.oas.annotations.media.Schema; + +@Schema +public class PersonDTO { + private String email; + + private String firstName; + + private String lastName; + + public PersonDTO() { + } + + public PersonDTO(final String email, final String firstName, final String lastName) { + this.email = email; + this.firstName = firstName; + this.lastName = lastName; + } + + public String getEmail() { + return email; + } + + public void setEmail(final String email) { + this.email = email; + } + + public String getFirstName() { + return firstName; + } + + public void setFirstName(final String firstName) { + this.firstName = firstName; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(final String lastName) { + this.lastName = lastName; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app13/SpringDocApp13Test.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app13/SpringDocApp13Test.java new file mode 100644 index 000000000..31e790770 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app13/SpringDocApp13Test.java @@ -0,0 +1,38 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app13; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp13Test extends AbstractSpringDocTest { + + @SpringBootApplication + static class SpringDocTestApp {} + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app14/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app14/HelloController.java new file mode 100644 index 000000000..6252302f6 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app14/HelloController.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.app14; + +import java.util.List; + +import org.springdoc.core.annotations.ParameterObject; + +import org.springframework.data.domain.Pageable; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class HelloController { + + @GetMapping(value = "/search", produces = { "application/xml", "application/json" }) + public ResponseEntity> getAllPets(@ParameterObject Pageable pageable) { + return null; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app14/PersonDTO.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app14/PersonDTO.java new file mode 100644 index 000000000..e7633340a --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app14/PersonDTO.java @@ -0,0 +1,71 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app14; + +import io.swagger.v3.oas.annotations.media.Schema; + +@Schema +public class PersonDTO { + private String email; + + private String firstName; + + private String lastName; + + public PersonDTO() { + } + + public PersonDTO(final String email, final String firstName, final String lastName) { + this.email = email; + this.firstName = firstName; + this.lastName = lastName; + } + + public String getEmail() { + return email; + } + + public void setEmail(final String email) { + this.email = email; + } + + public String getFirstName() { + return firstName; + } + + public void setFirstName(final String firstName) { + this.firstName = firstName; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(final String lastName) { + this.lastName = lastName; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app14/SpringDocApp14Test.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app14/SpringDocApp14Test.java new file mode 100644 index 000000000..d3fa04045 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app14/SpringDocApp14Test.java @@ -0,0 +1,67 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app14; + +import java.util.Optional; + +import org.springdoc.core.configuration.SpringDocDataRestConfiguration; +import org.springdoc.core.customizers.DataRestDelegatingMethodParameterCustomizer; +import org.springdoc.core.providers.RepositoryRestConfigurationProvider; +import org.springdoc.core.providers.SpringDataWebPropertiesProvider; +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.data.rest.RepositoryRestMvcAutoConfiguration; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Lazy; +import org.springframework.test.context.TestPropertySource; + +@TestPropertySource(properties = { "spring.data.web.pageable.default-page-size=25", + "spring.data.web.pageable.page-parameter=pages", + "spring.data.web.pageable.size-parameter=sizes", + "spring.data.web.pageable.one-indexed-parameters=true", + "spring.data.web.pageable.prefix=prefix_", + "spring.data.web.sort.sort-parameter=sorts" }) +@EnableAutoConfiguration(exclude = { + RepositoryRestMvcAutoConfiguration.class, SpringDocDataRestConfiguration.class +}) +public class SpringDocApp14Test extends AbstractSpringDocTest { + + @SpringBootApplication + static class SpringDocTestApp { + // We only need to test spring-web with Pageable, without the use of spring-data-rest-starter + @Bean + @ConditionalOnMissingBean + @Lazy(false) + DataRestDelegatingMethodParameterCustomizer dataRestDelegatingMethodParameterCustomizer(Optional optionalSpringDataWebPropertiesProvider, Optional optionalRepositoryRestConfiguration) { + return new DataRestDelegatingMethodParameterCustomizer(optionalSpringDataWebPropertiesProvider, optionalRepositoryRestConfiguration); + } + } + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app15/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app15/HelloController.java new file mode 100644 index 000000000..f487167be --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app15/HelloController.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.app15; + +import java.util.List; + +import org.springdoc.core.annotations.ParameterObject; + +import org.springframework.data.domain.Pageable; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class HelloController { + + @GetMapping(value = "/search", produces = { "application/xml", "application/json" }) + public ResponseEntity> getAllPets(@ParameterObject Pageable pageable) { + return null; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app15/PersonDTO.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app15/PersonDTO.java new file mode 100644 index 000000000..3b80ef331 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app15/PersonDTO.java @@ -0,0 +1,71 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app15; + +import io.swagger.v3.oas.annotations.media.Schema; + +@Schema +public class PersonDTO { + private String email; + + private String firstName; + + private String lastName; + + public PersonDTO() { + } + + public PersonDTO(final String email, final String firstName, final String lastName) { + this.email = email; + this.firstName = firstName; + this.lastName = lastName; + } + + public String getEmail() { + return email; + } + + public void setEmail(final String email) { + this.email = email; + } + + public String getFirstName() { + return firstName; + } + + public void setFirstName(final String firstName) { + this.firstName = firstName; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(final String lastName) { + this.lastName = lastName; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app15/SpringDocApp15Test.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app15/SpringDocApp15Test.java new file mode 100644 index 000000000..5d267a330 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app15/SpringDocApp15Test.java @@ -0,0 +1,40 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app15; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.test.context.TestPropertySource; + +@TestPropertySource(properties = "spring.data.rest.default-page-size=50") +public class SpringDocApp15Test extends AbstractSpringDocTest { + + @SpringBootApplication + static class SpringDocTestApp {} + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app16/Account.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app16/Account.java new file mode 100644 index 000000000..201cc5439 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app16/Account.java @@ -0,0 +1,63 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app16; + +import java.util.Date; + +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.Temporal; +import jakarta.persistence.TemporalType; + +@Entity +public class Account { + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private Long id; + + @ManyToOne + private Customer customer; + + @Temporal(TemporalType.DATE) + private Date expiryDate; + + public Long getId() { + return id; + } + + public Customer getCustomer() { + return customer; + } + + public Date getExpiryDate() { + return expiryDate; + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app16/AccountRepository.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app16/AccountRepository.java new file mode 100644 index 000000000..1d5397ed1 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app16/AccountRepository.java @@ -0,0 +1,55 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app16; + + +import java.util.List; + +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.tags.Tag; + +import org.springframework.data.repository.CrudRepository; +import org.springframework.data.repository.query.Param; +import org.springframework.data.rest.core.annotation.RepositoryRestResource; + +/** + * Repository to manage {@link Account} instances. + * + */ +@RepositoryRestResource +@Tag(name = "The account Repository") +@SecurityRequirement(name = "bearer") +public interface AccountRepository extends CrudRepository { + + /** + * Returns all accounts belonging to the given {@link Customer}. + * + * @param customer + * @return + */ + List findByCustomer(@Param("customer") Customer customer); +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app16/Customer.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app16/Customer.java new file mode 100644 index 000000000..434784ed8 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app16/Customer.java @@ -0,0 +1,60 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app16; + + +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; + +/** + * @author Oliver Gierke + */ +@Entity +public class Customer { + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private Long id; + + private String firstname; + + private String lastname; + + public Long getId() { + return id; + } + + public String getFirstname() { + return firstname; + } + + public String getLastname() { + return lastname; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app16/CustomerRepository.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app16/CustomerRepository.java new file mode 100644 index 000000000..17fcc6020 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app16/CustomerRepository.java @@ -0,0 +1,66 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app16; + +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.tags.Tag; + +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.data.jpa.repository.JpaSpecificationExecutor; +import org.springframework.data.repository.CrudRepository; +import org.springframework.data.repository.query.Param; +import org.springframework.data.rest.core.annotation.RepositoryRestResource; +import org.springframework.data.rest.core.annotation.RestResource; + +/** + * Repository to manage {@link Customer} instances. + * + * @author Oliver Gierke + */ +@RepositoryRestResource +@Tag(name = "The customer Repository") +public interface CustomerRepository extends CrudRepository, JpaSpecificationExecutor { + + /** + * Returns a page of {@link Customer}s with the given lastname. + * + * @param lastname + * @param pageable + * @return + */ + @SecurityRequirement(name = "bearer") + Page findByLastname(@Param("lastname") String lastname, Pageable pageable); + + @Override + @RestResource(exported = false) + void deleteById(Long id); + + @Override + @RestResource(exported = false) + void delete(Customer entity); +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app16/OpenApiConfig.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app16/OpenApiConfig.java new file mode 100644 index 000000000..d17b975a4 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app16/OpenApiConfig.java @@ -0,0 +1,38 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app16; + +import io.swagger.v3.oas.annotations.OpenAPIDefinition; +import io.swagger.v3.oas.annotations.enums.SecuritySchemeType; +import io.swagger.v3.oas.annotations.info.Info; +import io.swagger.v3.oas.annotations.info.License; +import io.swagger.v3.oas.annotations.security.SecurityScheme; + +@OpenAPIDefinition(info = @Info(title = "My App", description = "Some long and useful description", version = "v1", license = @License(name = "Apache 2.0", url = "https://www.apache.org/licenses/LICENSE-2.0"))) +@SecurityScheme(name = "bearer", type = SecuritySchemeType.HTTP, scheme = "bearer", bearerFormat = "JWT") +public class OpenApiConfig { +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app16/SpringDocApp16Test.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app16/SpringDocApp16Test.java new file mode 100644 index 000000000..17526d688 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app16/SpringDocApp16Test.java @@ -0,0 +1,49 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app16; + +import io.swagger.v3.oas.models.Operation; +import org.springdoc.core.customizers.DataRestRouterOperationCustomizer; +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; + +public class SpringDocApp16Test extends AbstractSpringDocTest { + + @SpringBootApplication + static class SpringDocTestApp { + @Bean + public DataRestRouterOperationCustomizer addRouterOperationCustomizer() { + return (routerOperation) -> { + Operation operation = routerOperation.getOperationModel(); + operation.setSummary(operation.getOperationId()); + return routerOperation; + }; + } + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app17/ChildProperty.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app17/ChildProperty.java new file mode 100644 index 000000000..0a2e9911a --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app17/ChildProperty.java @@ -0,0 +1,60 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app17; + +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import lombok.Data; + +@Entity +public @Data +class ChildProperty { + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private long id; + + private String name; + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app17/ChildPropertyRepository.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app17/ChildPropertyRepository.java new file mode 100644 index 000000000..fdcfb3183 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app17/ChildPropertyRepository.java @@ -0,0 +1,32 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app17; + +import org.springframework.data.repository.PagingAndSortingRepository; + +public interface ChildPropertyRepository extends PagingAndSortingRepository { +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app17/Property.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app17/Property.java new file mode 100644 index 000000000..af3c3d6d1 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app17/Property.java @@ -0,0 +1,74 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app17; + +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; +import lombok.Data; + +@Entity +public @Data +class Property { + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private long id; + + private String name; + + @ManyToOne + @JoinColumn(name = "child_property_id") + private ChildProperty myChildPropertyName; + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public ChildProperty getMyChildPropertyName() { + return myChildPropertyName; + } + + public void setMyChildPropertyName(ChildProperty myChildPropertyName) { + this.myChildPropertyName = myChildPropertyName; + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app17/PropertyRepository.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app17/PropertyRepository.java new file mode 100644 index 000000000..cc44d08a1 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app17/PropertyRepository.java @@ -0,0 +1,32 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app17; + +import org.springframework.data.repository.PagingAndSortingRepository; + +public interface PropertyRepository extends PagingAndSortingRepository { +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app17/SpringDocApp17Test.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app17/SpringDocApp17Test.java new file mode 100644 index 000000000..a59e54168 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app17/SpringDocApp17Test.java @@ -0,0 +1,37 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app17; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp17Test extends AbstractSpringDocTest { + + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app18/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app18/HelloController.java new file mode 100644 index 000000000..9b02113f5 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app18/HelloController.java @@ -0,0 +1,53 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app18; + +import io.swagger.v3.oas.annotations.Operation; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.validation.Valid; +import org.springdoc.core.annotations.ParameterObject; + +import org.springframework.http.MediaType; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@Validated +@RestController +@RequestMapping(value = { HelloController.VERSION + "/helloWorld", "latest/helloWorld" }, produces = MediaType.APPLICATION_JSON_VALUE) +public class HelloController { + + public static final String VERSION = "v1"; + + @Operation(summary = "Example endpoint") + @GetMapping("/helloWorld") + public HelloWorldModel helloWorld(@Valid @ParameterObject HelloWorldModel helloWorldModel, HttpServletRequest request) { + return new HelloWorldModel(); + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app18/HelloWorldModel.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app18/HelloWorldModel.java new file mode 100644 index 000000000..c1071d5e9 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app18/HelloWorldModel.java @@ -0,0 +1,63 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app18; + +import java.time.LocalDate; + +import io.swagger.v3.oas.annotations.Parameter; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; + +import org.springframework.format.annotation.DateTimeFormat; + +public class HelloWorldModel { + + @Parameter(description = "Description for abc", example = "def") + @NotBlank + private String abc; + + @Parameter(description = "Description of this date", example = "2020-10-25") + @NotNull + @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) + private LocalDate thisDate; + + public String getAbc() { + return abc; + } + + public void setAbc(String abc) { + this.abc = abc; + } + + public LocalDate getThisDate() { + return thisDate; + } + + public void setThisDate(LocalDate thisDate) { + this.thisDate = thisDate; + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app18/SpringDocApp18Test.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app18/SpringDocApp18Test.java new file mode 100644 index 000000000..e1145bc6a --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app18/SpringDocApp18Test.java @@ -0,0 +1,37 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app18; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp18Test extends AbstractSpringDocTest { + + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app19/Application.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app19/Application.java new file mode 100644 index 000000000..a353b9266 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app19/Application.java @@ -0,0 +1,106 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app19; + +import java.io.Serializable; +import java.time.LocalDateTime; + +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.EntityListeners; +import jakarta.persistence.EnumType; +import jakarta.persistence.Enumerated; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.Id; +import jakarta.persistence.Table; +import lombok.Data; + +import org.springframework.data.annotation.CreatedDate; +import org.springframework.data.jpa.domain.support.AuditingEntityListener; + +@Data +@Entity +@Table(schema = "application", name = "application") +@Schema(description = "app") +@EntityListeners(AuditingEntityListener.class) +public class Application implements Serializable { + private static final long serialVersionUID = 6582562282311194139L; + + @Id + @Column(length = 64) + @GeneratedValue + @Schema(description = "id") + private String id; + + @Column(nullable = false, length = 64) + @Schema(description = "name") + private String name; + + @Column(length = 1024) + @Schema(description = "description") + private String description; + + @Column(length = 32) + @Schema(description = "app type") + @Enumerated(EnumType.STRING) + private AppType type = AppType.EXTERNAL; + + @Column + @Schema(description = "icon") + private String icon; + + @Column(nullable = false) + @CreatedDate + @Schema(description = "createTime") + private LocalDateTime createTime; + + @Column(length = 1024) + @Schema(description = "rsa-publicKey") + private String publicKey; + + @Column(length = 16, nullable = false) + @Enumerated(EnumType.STRING) + @Schema(description = "status") + private AuditStatus auditStatus = AuditStatus.UN_SUBMITTED; + + @Column + @Schema(description = "auditTime") + private LocalDateTime auditTime; + + public enum AuditStatus { + UN_SUBMITTED, + PENDING, + APPROVED, + FAILED + } + + public enum AppType { + INNER, + EXTERNAL + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app19/ApplicationPredicate.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app19/ApplicationPredicate.java new file mode 100644 index 000000000..a8b5332ff --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app19/ApplicationPredicate.java @@ -0,0 +1,44 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app19; + +import com.querydsl.core.types.dsl.StringExpression; + +import org.springframework.data.querydsl.binding.QuerydslBinderCustomizer; +import org.springframework.data.querydsl.binding.QuerydslBindings; + +public class ApplicationPredicate implements QuerydslBinderCustomizer { + + @Override + public void customize(QuerydslBindings bindings, QApplication root) { + bindings.excludeUnlistedProperties(true); + bindings.bind(root.name).first(StringExpression::containsIgnoreCase); + bindings.including(root.icon); + bindings.including(root.name); + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app19/GreetingController.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app19/GreetingController.java new file mode 100644 index 000000000..63e3a4d20 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app19/GreetingController.java @@ -0,0 +1,45 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app19; + +import com.querydsl.core.types.Predicate; + +import org.springframework.data.querydsl.binding.QuerydslPredicate; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class GreetingController { + + @GetMapping("/test2") + public ResponseEntity sayHello2(@QuerydslPredicate(root = Application.class, bindings = ApplicationPredicate.class) Predicate predicate, + @RequestParam String test) { + return ResponseEntity.ok().build(); + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app19/QApplication.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app19/QApplication.java new file mode 100644 index 000000000..627cbf229 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app19/QApplication.java @@ -0,0 +1,81 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app19; + +import com.querydsl.core.types.Path; +import com.querydsl.core.types.PathMetadata; +import com.querydsl.core.types.dsl.DateTimePath; +import com.querydsl.core.types.dsl.EntityPathBase; +import com.querydsl.core.types.dsl.EnumPath; +import com.querydsl.core.types.dsl.StringPath; +import jakarta.annotation.Generated; + +import static com.querydsl.core.types.PathMetadataFactory.forVariable; + + +/** + * QApplication is a Querydsl query type for Application + */ +@Generated("com.querydsl.codegen.EntitySerializer") +public class QApplication extends EntityPathBase { + + public static final QApplication application = new QApplication("application"); + + private static final long serialVersionUID = 2120388982L; + + public final EnumPath auditStatus = createEnum("auditStatus", Application.AuditStatus.class); + + public final DateTimePath auditTime = createDateTime("auditTime", java.time.LocalDateTime.class); + + public final DateTimePath createTime = createDateTime("createTime", java.time.LocalDateTime.class); + + public final StringPath description = createString("description"); + + public final StringPath icon = createString("icon"); + + public final StringPath id = createString("id"); + + public final StringPath name = createString("name"); + + public final StringPath publicKey = createString("publicKey"); + + public final EnumPath type = createEnum("type", Application.AppType.class); + + public QApplication(String variable) { + super(Application.class, forVariable(variable)); + } + + public QApplication(Path path) { + super(path.getType(), path.getMetadata()); + } + + public QApplication(PathMetadata metadata) { + super(Application.class, metadata); + } + +} + diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app19/SpringDocApp19Test.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app19/SpringDocApp19Test.java new file mode 100644 index 000000000..5e64cbbe3 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app19/SpringDocApp19Test.java @@ -0,0 +1,37 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app19; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp19Test extends AbstractSpringDocTest { + + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app2/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app2/HelloController.java new file mode 100644 index 000000000..d44c34b07 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app2/HelloController.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.app2; + +import java.util.List; + +import jakarta.validation.constraints.NotNull; + +import org.springframework.data.domain.Pageable; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class HelloController { + + @GetMapping(value = "/search", produces = { "application/xml", "application/json" }) + public ResponseEntity> getAllPets(@NotNull Pageable pageable) { + return null; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app2/PersonDTO.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app2/PersonDTO.java new file mode 100644 index 000000000..407f38b21 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app2/PersonDTO.java @@ -0,0 +1,71 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app2; + +import io.swagger.v3.oas.annotations.media.Schema; + +@Schema +public class PersonDTO { + private String email; + + private String firstName; + + private String lastName; + + public PersonDTO() { + } + + public PersonDTO(final String email, final String firstName, final String lastName) { + this.email = email; + this.firstName = firstName; + this.lastName = lastName; + } + + public String getEmail() { + return email; + } + + public void setEmail(final String email) { + this.email = email; + } + + public String getFirstName() { + return firstName; + } + + public void setFirstName(final String firstName) { + this.firstName = firstName; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(final String lastName) { + this.lastName = lastName; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app2/SpringDocApp2Test.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app2/SpringDocApp2Test.java new file mode 100644 index 000000000..e6eeb44a1 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app2/SpringDocApp2Test.java @@ -0,0 +1,38 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app2; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp2Test extends AbstractSpringDocTest { + + @SpringBootApplication + static class SpringDocTestApp {} + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app20/Bank.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app20/Bank.java new file mode 100644 index 000000000..9a7ad78b7 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app20/Bank.java @@ -0,0 +1,107 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app20; + +import java.util.Objects; + +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.SequenceGenerator; +import jakarta.persistence.Table; +import org.hibernate.annotations.NaturalId; + +@Entity +@Table(name = "bank") +public class Bank implements EntityDefinition { + + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "bnk_seq") + @SequenceGenerator(name = "bnk_seq", sequenceName = "bnk_seq", allocationSize = 1) + private Long id; + + @Column(unique = true) + @NaturalId + private String code; + + @Column(unique = true, nullable = false) + private String name; + + public Long getId() { + return this.id; + } + + public String getCode() { + return this.code; + } + + public String getName() { + return this.name; + } + + public void setName(String name) { + this.name = name; + } + + @Override + public int hashCode() { + return Objects.hash(getCode()); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (!(o instanceof Bank)) { + return false; + } + Bank bank = (Bank) o; + return Objects.equals(getCode(), bank.getCode()); + } + + @Override + public String toString() { + return "Bank{" + + "id=" + id + + ", code='" + code + '\'' + + ", name='" + name + '\'' + + '}'; + } + + @Override + public String getKey() { + return code; + } + + @Override + public String getDescription() { + return name; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app20/BankRepository.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app20/BankRepository.java new file mode 100644 index 000000000..223623480 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app20/BankRepository.java @@ -0,0 +1,36 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app20; + +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.rest.core.annotation.RepositoryRestResource; +import org.springframework.stereotype.Repository; + +@Repository +@RepositoryRestResource(path = "banks") +public interface BankRepository extends JpaRepository, CodeLookupRepository { +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app20/CodeLookupRepository.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app20/CodeLookupRepository.java new file mode 100644 index 000000000..d25471fca --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app20/CodeLookupRepository.java @@ -0,0 +1,38 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app20; + +import org.springframework.data.repository.NoRepositoryBean; +import org.springframework.data.repository.query.Param; + +@NoRepositoryBean +public interface CodeLookupRepository { + EntityT findOneByCode(@Param("code") KeyT code); + + Long countByCode(KeyT code); +} + diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app20/DemoApplication.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app20/DemoApplication.java new file mode 100644 index 000000000..2cc632c6c --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app20/DemoApplication.java @@ -0,0 +1,47 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app20; + +import io.swagger.v3.oas.annotations.OpenAPIDefinition; +import io.swagger.v3.oas.annotations.info.Info; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +@OpenAPIDefinition( + info = @Info( + title = "Core API" + ) +) +public class DemoApplication { + + public static void main(String[] args) { + SpringApplication.run(DemoApplication.class, args); + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app20/EntityDefinition.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app20/EntityDefinition.java new file mode 100644 index 000000000..458a0813a --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app20/EntityDefinition.java @@ -0,0 +1,38 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app20; + +import com.fasterxml.jackson.annotation.JsonIgnore; + +public interface EntityDefinition { + + @JsonIgnore + String getKey(); + + @JsonIgnore + String getDescription(); +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app20/SpringDocApp20Test.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app20/SpringDocApp20Test.java new file mode 100644 index 000000000..de6c59de5 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app20/SpringDocApp20Test.java @@ -0,0 +1,37 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app20; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp20Test extends AbstractSpringDocTest { + + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app21/Person.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app21/Person.java new file mode 100644 index 000000000..d1312f8db --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app21/Person.java @@ -0,0 +1,60 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app21; + +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; + +@Entity +public class Person { + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private long id; + + private String firstName; + + private String lastName; + + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app21/PersonRepository.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app21/PersonRepository.java new file mode 100644 index 000000000..95d1dc9c9 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app21/PersonRepository.java @@ -0,0 +1,59 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app21; + +import java.util.List; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; + +import org.springframework.data.repository.PagingAndSortingRepository; +import org.springframework.data.repository.query.Param; +import org.springframework.data.rest.core.annotation.RepositoryRestResource; + +@RepositoryRestResource(collectionResourceRel = "people", path = "peopleme") +public interface PersonRepository extends PagingAndSortingRepository { + + @Operation(description = "this is my test") + @ApiResponses( + value = { + @ApiResponse(responseCode = "200", description = "successful operation"), + @ApiResponse(responseCode = "400", description = "Invalid ID supplied"), + @ApiResponse(responseCode = "404", description = "Contact not found"), + @ApiResponse(responseCode = "405", description = "Validation exception") } + ) + List findByLastName(@Param("lastName") String name); + + @Operation(description = "this is another test", responses = { + @ApiResponse(responseCode = "200", description = "another successful operation"), + @ApiResponse(responseCode = "404", description = "another Contact not found") } + ) + List findByFirstName(@Param("firstName") @Parameter(description = "this is for first Name") String name); + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app21/SpringDocApp21Test.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app21/SpringDocApp21Test.java new file mode 100644 index 000000000..090988903 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app21/SpringDocApp21Test.java @@ -0,0 +1,37 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app21; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp21Test extends AbstractSpringDocTest { + + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app22/Person.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app22/Person.java new file mode 100644 index 000000000..952b6b375 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app22/Person.java @@ -0,0 +1,60 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app22; + +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; + +@Entity +public class Person { + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private long id; + + private String firstName; + + private String lastName; + + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app22/PersonApi.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app22/PersonApi.java new file mode 100644 index 000000000..949483d9f --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app22/PersonApi.java @@ -0,0 +1,40 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app22; + +import org.springframework.data.rest.webmvc.RepositoryRestController; +import org.springframework.web.bind.annotation.GetMapping; + +@RepositoryRestController +public class PersonApi { + + @GetMapping("/people/test") + public Person test() { + return new Person(); + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app22/PersonRepository.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app22/PersonRepository.java new file mode 100644 index 000000000..aea57b358 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app22/PersonRepository.java @@ -0,0 +1,35 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app22; + +import org.springframework.data.repository.PagingAndSortingRepository; +import org.springframework.data.rest.core.annotation.RepositoryRestResource; + +@RepositoryRestResource(path = "people", collectionResourceRel = "people") +public interface PersonRepository extends PagingAndSortingRepository { + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app22/SpringDocApp22Test.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app22/SpringDocApp22Test.java new file mode 100644 index 000000000..40b3741e9 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app22/SpringDocApp22Test.java @@ -0,0 +1,38 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app22; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp22Test extends AbstractSpringDocTest { + + @SpringBootApplication + static class SpringDocTestApp {} + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app23/Clinic.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app23/Clinic.java new file mode 100644 index 000000000..b9879fe5c --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app23/Clinic.java @@ -0,0 +1,57 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app23; + +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; + +@Data +@Entity +@NoArgsConstructor +@AllArgsConstructor +@EqualsAndHashCode(callSuper = false) +@Builder +public class Clinic { + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private Long id; + + @NotNull + @NotBlank + private String name; + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app23/ClinicRepo.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app23/ClinicRepo.java new file mode 100644 index 000000000..84e92aa31 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app23/ClinicRepo.java @@ -0,0 +1,34 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app23; + +import org.springframework.data.repository.CrudRepository; +import org.springframework.web.bind.annotation.CrossOrigin; + +@CrossOrigin +public interface ClinicRepo extends CrudRepository { +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app23/Doctor.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app23/Doctor.java new file mode 100644 index 000000000..ec3465d9f --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app23/Doctor.java @@ -0,0 +1,66 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app23; + +import java.util.Set; + +import io.swagger.v3.oas.annotations.media.ArraySchema; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.media.Schema.AccessMode; +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.ManyToMany; +import jakarta.validation.constraints.Size; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; + +@Data +@Entity +@NoArgsConstructor +@AllArgsConstructor +@EqualsAndHashCode(callSuper = false) +@Builder +public class Doctor { + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private Long id; + + @ManyToMany + @Size(min = 1) + @ArraySchema( + schema = @Schema( + implementation = String.class, + accessMode = AccessMode.WRITE_ONLY + )) + private Set clinics; +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app23/DoctorRepo.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app23/DoctorRepo.java new file mode 100644 index 000000000..b041e5894 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app23/DoctorRepo.java @@ -0,0 +1,34 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app23; + +import org.springframework.data.repository.CrudRepository; +import org.springframework.web.bind.annotation.CrossOrigin; + +@CrossOrigin +public interface DoctorRepo extends CrudRepository { +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app23/SpringDocApp23Test.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app23/SpringDocApp23Test.java new file mode 100644 index 000000000..7a17c9f5b --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app23/SpringDocApp23Test.java @@ -0,0 +1,38 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app23; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp23Test extends AbstractSpringDocTest { + + @SpringBootApplication + static class SpringDocTestApp {} + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app24/QUser.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app24/QUser.java new file mode 100644 index 000000000..0af0989e2 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app24/QUser.java @@ -0,0 +1,70 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app24; + +import com.querydsl.core.types.Path; +import com.querydsl.core.types.PathMetadata; +import com.querydsl.core.types.dsl.EntityPathBase; +import com.querydsl.core.types.dsl.NumberPath; +import com.querydsl.core.types.dsl.StringPath; +import jakarta.annotation.Generated; + +import static com.querydsl.core.types.PathMetadataFactory.forVariable; + + +/** + * QUser is a Querydsl query type for User + */ +@Generated("com.querydsl.codegen.EntitySerializer") +public class QUser extends EntityPathBase { + + public static final QUser user = new QUser("user"); + + private static final long serialVersionUID = 222331676L; + + public final StringPath email = createString("email"); + + public final StringPath firstName = createString("firstName"); + + public final NumberPath id = createNumber("id", Long.class); + + public final StringPath lastName = createString("lastName"); + + public QUser(String variable) { + super(User.class, forVariable(variable)); + } + + public QUser(Path path) { + super(path.getType(), path.getMetadata()); + } + + public QUser(PathMetadata metadata) { + super(User.class, metadata); + } + +} + diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app24/SpringDocApp24Test.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app24/SpringDocApp24Test.java new file mode 100644 index 000000000..c9db43749 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app24/SpringDocApp24Test.java @@ -0,0 +1,38 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app24; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp24Test extends AbstractSpringDocTest { + + @SpringBootApplication + static class SpringDocTestApp {} + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app24/TesteResource.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app24/TesteResource.java new file mode 100644 index 000000000..34417ce12 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app24/TesteResource.java @@ -0,0 +1,47 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app24; + +import com.querydsl.core.types.Predicate; +import lombok.AllArgsConstructor; + +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.data.querydsl.binding.QuerydslPredicate; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + + +@RestController +@AllArgsConstructor +public class TesteResource { + + @GetMapping("/") + public Page testeQueryDslAndSpringDoc(@QuerydslPredicate(root = User.class, bindings = UserPredicate.class) Predicate predicate, Pageable pageable) { + return null; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app24/User.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app24/User.java new file mode 100644 index 000000000..f0402de53 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app24/User.java @@ -0,0 +1,50 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app24; + +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import lombok.Getter; +import lombok.Setter; + +@Entity +@Getter +@Setter +public class User { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + private String firstName; + + private String lastName; + + private String email; +} + diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app24/UserPredicate.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app24/UserPredicate.java new file mode 100644 index 000000000..bfca2ed00 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app24/UserPredicate.java @@ -0,0 +1,41 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app24; + +import org.springframework.data.querydsl.binding.QuerydslBinderCustomizer; +import org.springframework.data.querydsl.binding.QuerydslBindings; + +public class UserPredicate implements QuerydslBinderCustomizer { + + + @Override + public void customize(QuerydslBindings bindings, QUser user) { + bindings.excludeUnlistedProperties(true); + bindings.including(user.email); + bindings.bind(user.firstName).as("name").withDefaultBinding(); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app25/SpringDocApp25Test.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app25/SpringDocApp25Test.java new file mode 100644 index 000000000..7cbac719a --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app25/SpringDocApp25Test.java @@ -0,0 +1,38 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app25; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp25Test extends AbstractSpringDocTest { + + @SpringBootApplication + static class SpringDocTestApp {} + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app25/model/Address.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app25/model/Address.java new file mode 100644 index 000000000..1edaa1bbb --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app25/model/Address.java @@ -0,0 +1,54 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app25.model; + +import jakarta.persistence.Embeddable; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Embeddable +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class Address { + + private String name; + + private String street; + + private String number; + + private String zipcode; + + private String city; + + private String country; + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app25/model/BaseEntity.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app25/model/BaseEntity.java new file mode 100644 index 000000000..e9ab93ee2 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app25/model/BaseEntity.java @@ -0,0 +1,56 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app25.model; + +import java.util.UUID; + +import jakarta.persistence.Id; +import jakarta.persistence.MappedSuperclass; +import jakarta.persistence.PrePersist; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import org.hibernate.annotations.JdbcTypeCode; +import org.hibernate.type.SqlTypes; + +@Getter +@Setter +@NoArgsConstructor +@MappedSuperclass +public abstract class BaseEntity { + + @Id + @JdbcTypeCode(SqlTypes.CHAR) + private UUID id; + + @PrePersist + private void generateId() { + if (id == null) + id = UUID.randomUUID(); + } + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app25/model/Cat.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app25/model/Cat.java new file mode 100644 index 000000000..a863cdb3c --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app25/model/Cat.java @@ -0,0 +1,59 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app25.model; + +import jakarta.persistence.Entity; +import jakarta.persistence.EnumType; +import jakarta.persistence.Enumerated; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; + +@Entity +@Data +@EqualsAndHashCode(callSuper = false) +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class Cat extends Pet { + + @Enumerated(EnumType.STRING) + private CoatType coat; + + @Builder + public Cat(String name, Owner owner, CoatType coat) { + super(name, owner); + this.coat = coat; + } + + public static enum CoatType { + TABBY, TOROISE, COLORPOINT, BICOLOR, TRICOLOR, SOLID + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app25/model/Clinic.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app25/model/Clinic.java new file mode 100644 index 000000000..4bd47fdbf --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app25/model/Clinic.java @@ -0,0 +1,56 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app25.model; + +import java.util.Set; + +import jakarta.persistence.ElementCollection; +import jakarta.persistence.Entity; +import jakarta.validation.constraints.NotNull; +import jakarta.validation.constraints.Size; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; + +@Entity +@Data +@EqualsAndHashCode(callSuper = false) +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class Clinic extends BaseEntity { + + @NotNull + private String name; + + @Size(min = 1) + @ElementCollection + private Set
addresses; + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app25/model/Doctor.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app25/model/Doctor.java new file mode 100644 index 000000000..406528d9a --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app25/model/Doctor.java @@ -0,0 +1,64 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app25.model; + +import java.util.Set; + +import jakarta.persistence.Entity; +import jakarta.persistence.EnumType; +import jakarta.persistence.Enumerated; +import jakarta.persistence.ManyToMany; +import jakarta.validation.constraints.NotNull; +import jakarta.validation.constraints.Size; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; + +@Entity +@Data +@EqualsAndHashCode(callSuper = false) +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class Doctor extends BaseEntity { + + @NotNull + private String firstname; + + @NotNull + private String lastname; + + @Enumerated(EnumType.STRING) + private Specialty specialty; + + @Size(min = 1) + @ManyToMany + private Set clinics; + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app25/model/Dog.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app25/model/Dog.java new file mode 100644 index 000000000..337537a75 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app25/model/Dog.java @@ -0,0 +1,58 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app25.model; + +import jakarta.persistence.Entity; +import jakarta.persistence.EnumType; +import jakarta.persistence.Enumerated; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; + +@Entity +@Data +@EqualsAndHashCode(callSuper = false) +@AllArgsConstructor +@NoArgsConstructor +public class Dog extends Pet { + + @Enumerated(EnumType.STRING) + private CoatType coat; + + @Builder + public Dog(String name, Owner owner, CoatType coat) { + super(name, owner); + this.coat = coat; + } + + public static enum CoatType { + SMOOTH, SHORT, COMBINATION, DOUBLE, HEAVY, SILKY, LONG, CURLY, WIRE, HAIRLESS + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app25/model/Owner.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app25/model/Owner.java new file mode 100644 index 000000000..a8d12436f --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app25/model/Owner.java @@ -0,0 +1,63 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app25.model; + +import java.util.Set; + +import jakarta.persistence.CascadeType; +import jakarta.persistence.Embedded; +import jakarta.persistence.Entity; +import jakarta.persistence.OneToMany; +import jakarta.validation.constraints.NotNull; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; + +@Entity +@Data +@EqualsAndHashCode(callSuper = false) +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class Owner extends BaseEntity { + + private String firstname; + + @NotNull + private String lastname; + + @NotNull + @Embedded + private Address addresses; + + @EqualsAndHashCode.Exclude + @OneToMany(mappedBy = "owner", cascade = { CascadeType.ALL }) + private Set pets; + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app25/model/Pet.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app25/model/Pet.java new file mode 100644 index 000000000..77a59719c --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app25/model/Pet.java @@ -0,0 +1,70 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app25.model; + +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonSubTypes.Type; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import jakarta.persistence.Entity; +import jakarta.persistence.Inheritance; +import jakarta.persistence.InheritanceType; +import jakarta.persistence.ManyToOne; +import jakarta.validation.constraints.NotNull; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import lombok.NonNull; +import lombok.RequiredArgsConstructor; + +@Entity + +@EqualsAndHashCode(callSuper = false) +@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS) + +@Data +@NoArgsConstructor +@RequiredArgsConstructor + +@JsonTypeInfo( + use = JsonTypeInfo.Id.NAME, + include = JsonTypeInfo.As.PROPERTY, + property = "_type") +@JsonSubTypes({ + @Type(value = Dog.class, name = "dog"), + @Type(value = Cat.class, name = "cat") +}) +public class Pet extends BaseEntity { + + @NonNull + @NotNull + private String name; + + @NonNull + @ManyToOne + private Owner owner; + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app25/model/Specialty.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app25/model/Specialty.java new file mode 100644 index 000000000..56428ba4a --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app25/model/Specialty.java @@ -0,0 +1,105 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app25.model; + +public enum Specialty { + + ALLERGY_AND_IMMUNOLOGY, + ADOLESCENT_MEDICINE, + ANESTHESIOLOGY, + AEROSPACE_MEDICINE, + BARIATRICS, + CARDIOLOGY, + CARDIOTHORACIC_SURGERY, + CHILD_AND_ADOLESCENT_PSYCHIATRY, + CLINICAL_NEUROPHYSIOLOGY, + COLORECTAL_SURGERY, + DERMATOLOGY, + DEVELOPMENTAL_PEDIATRICS, + EMERGENCY_MEDICINE, + ENDOCRINOLOGY, + FAMILY_MEDICINE, + FORENSIC_PATHOLOGY, + FORENSIC_PSYCHIATRY, + GASTROENTEROLOGY, + GENERAL_SURGERY, + GENERAL_SURGICAL_ONCOLOGY, + GERIATRICS, + GERIATRIC_PSYCHIATRY, + GYNECOLOGIC_ONCOLOGY, + HEMATOLOGY, + HEMATOLOGIC_PATHOLOGY, + INFECTIOUS_DISEASE, + INTERNAL_MEDICINE, + INTERVENTIONAL_RADIOLOGY, + INTENSIVE_CARE_MEDICINE, + MATERNAL_FETAL_MEDICINE, + MEDICAL_BIOCHEMISTRY, + MEDICAL_GENETICS, + MEDICAL_ONCOLOGY, + NEONATOLOGY, + NEPHROLOGY, + NEUROLOGY, + NEUROPATHOLOGY, + NEUROSURGERY, + NUCLEAR_MEDICINE, + OBSTETRICS_AND_GYNECOLOGY, + OCCUPATIONAL_MEDICINE, + OPHTHALMOLOGY, + ORTHOPEDIC_SURGERY, + ORAL_AND_MAXILLOFACIAL_SURGERY, + OTORHINOLARYNGOLOGY, + PALLIATIVE_CARE, + PATHOLOGY, + PEDIATRICS, + PEDIATRIC_ALLERGY_AND_IMMUNOLOGY, + PEDIATRIC_CARDIOLOGY, + PEDIATRIC_EMERGENCY_MEDICINE, + PEDIATRIC_ENDOCRINOLOGY, + PEDIATRIC_GASTROENTEROLOGY, + PEDIATRIC_HEMATOLOGY_AND_ONCOLOGY, + PEDIATRIC_INFECTIOUS_DISEASE, + PEDIATRIC_NEPHROLOGY, + PEDIATRIC_RESPIRATORY_MEDICINE, + PEDIATRIC_RHEUMATOLOGY, + PEDIATRIC_SURGERY, + PHYSICAL_MEDICINE_AND_REHABILITATION, + PLASTIC_RECONSTRUCTIVE_AND_AESTHETIC_SURGERY, + PSYCHIATRY, + PUBLIC_HEALTH, + RADIATION_ONCOLOGY, + RADIOLOGY, + REPRODUCTIVE_ENDOCRINOLOGY_AND_INFERTILITY, + RESPIRATORY_MEDICINE, + RHEUMATOLOGY, + SPORTS_MEDICINE, + THORACIC_SURGERY, + NEURORADIOLOGY, + UROLOGY, + VASCULAR_SURGERY; + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app25/repo/ClinicRepo.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app25/repo/ClinicRepo.java new file mode 100644 index 000000000..b7a65d114 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app25/repo/ClinicRepo.java @@ -0,0 +1,39 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app25.repo; + +import java.util.UUID; + +import test.org.springdoc.api.v30.app25.model.Clinic; + +import org.springframework.data.repository.CrudRepository; +import org.springframework.web.bind.annotation.CrossOrigin; + +@CrossOrigin +public interface ClinicRepo extends CrudRepository { + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app25/repo/DoctorRepo.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app25/repo/DoctorRepo.java new file mode 100644 index 000000000..f4155fb8c --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app25/repo/DoctorRepo.java @@ -0,0 +1,42 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app25.repo; + +import java.util.UUID; + +import test.org.springdoc.api.v30.app25.model.Clinic; +import test.org.springdoc.api.v30.app25.model.Doctor; + +import org.springframework.data.repository.CrudRepository; +import org.springframework.web.bind.annotation.CrossOrigin; + +@CrossOrigin +public interface DoctorRepo extends CrudRepository { + + Iterable findByClinicsContains(Clinic clinic); + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app25/repo/OwnerRepo.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app25/repo/OwnerRepo.java new file mode 100644 index 000000000..5c864c484 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app25/repo/OwnerRepo.java @@ -0,0 +1,39 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app25.repo; + +import java.util.UUID; + +import test.org.springdoc.api.v30.app25.model.Owner; + +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.web.bind.annotation.CrossOrigin; + +@CrossOrigin +public interface OwnerRepo extends JpaRepository { + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app25/repo/PetRepo.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app25/repo/PetRepo.java new file mode 100644 index 000000000..0a924fae1 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app25/repo/PetRepo.java @@ -0,0 +1,39 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app25.repo; + +import java.util.UUID; + +import test.org.springdoc.api.v30.app25.model.Pet; + +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.web.bind.annotation.CrossOrigin; + +@CrossOrigin +public interface PetRepo extends JpaRepository { + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app26/Person.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app26/Person.java new file mode 100644 index 000000000..617ceabd2 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app26/Person.java @@ -0,0 +1,68 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app26; + +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; + +@Entity +public class Person { + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private long id; + + private String firstName; + + private String lastName; + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app26/PersonRepository.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app26/PersonRepository.java new file mode 100644 index 000000000..8e5c48f15 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app26/PersonRepository.java @@ -0,0 +1,44 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app26; + +import java.util.List; + +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.PagingAndSortingRepository; +import org.springframework.data.repository.query.Param; +import org.springframework.data.rest.core.annotation.RepositoryRestResource; + +@RepositoryRestResource(collectionResourceRel = "people", path = "peopleme") +public interface PersonRepository extends PagingAndSortingRepository { + + List findByLastName(@Param("name") String name); + + @Query(value = "select 1 from dual", nativeQuery = true) + void testQuery(); + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app26/SpringDocApp26Test.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app26/SpringDocApp26Test.java new file mode 100644 index 000000000..f0381cb6c --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app26/SpringDocApp26Test.java @@ -0,0 +1,39 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app26; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp26Test extends AbstractSpringDocTest { + + @SpringBootApplication + static class SpringDocTestApp { + } + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app26/SpringRestConfiguration.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app26/SpringRestConfiguration.java new file mode 100644 index 000000000..a4a40475f --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app26/SpringRestConfiguration.java @@ -0,0 +1,40 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app26; + +import org.springframework.context.annotation.Configuration; +import org.springframework.data.rest.core.config.RepositoryRestConfiguration; +import org.springframework.data.rest.webmvc.config.RepositoryRestConfigurer; +import org.springframework.web.servlet.config.annotation.CorsRegistry; + +@Configuration +public class SpringRestConfiguration implements RepositoryRestConfigurer { + @Override + public void configureRepositoryRestConfiguration(RepositoryRestConfiguration config, CorsRegistry cors) { + config.exposeIdsFor(Person.class); + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app27/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app27/HelloController.java new file mode 100644 index 000000000..58f687835 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app27/HelloController.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.app27; + +import java.util.List; + +import jakarta.validation.constraints.NotNull; + +import org.springframework.data.domain.Pageable; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class HelloController { + + @GetMapping(value = "/search", produces = { "application/xml", "application/json" }) + public ResponseEntity> getAllPets(@NotNull Pageable pageable) { + return null; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app27/PersonDTO.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app27/PersonDTO.java new file mode 100644 index 000000000..9cc882f67 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app27/PersonDTO.java @@ -0,0 +1,71 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app27; + +import io.swagger.v3.oas.annotations.media.Schema; + +@Schema +public class PersonDTO { + private String email; + + private String firstName; + + private String lastName; + + public PersonDTO() { + } + + public PersonDTO(final String email, final String firstName, final String lastName) { + this.email = email; + this.firstName = firstName; + this.lastName = lastName; + } + + public String getEmail() { + return email; + } + + public void setEmail(final String email) { + this.email = email; + } + + public String getFirstName() { + return firstName; + } + + public void setFirstName(final String firstName) { + this.firstName = firstName; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(final String lastName) { + this.lastName = lastName; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app27/SpringDocApp27Test.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app27/SpringDocApp27Test.java new file mode 100644 index 000000000..3278e2960 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app27/SpringDocApp27Test.java @@ -0,0 +1,51 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app27; + +import java.util.Optional; + +import io.swagger.v3.core.converter.ModelConverter; +import io.swagger.v3.core.converter.ModelConverters; +import org.springdoc.core.converters.PageableOpenAPIConverter; +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.test.context.TestPropertySource; + +@TestPropertySource(properties = "springdoc.model-converters.pageable-converter.enabled=false") +public class SpringDocApp27Test extends AbstractSpringDocTest { + + static { + Optional pageabeConverter = + ModelConverters.getInstance().getConverters() + .stream().filter(modelConverter -> modelConverter instanceof PageableOpenAPIConverter).findAny(); + pageabeConverter.ifPresent(ModelConverters.getInstance()::removeConverter); + } + + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app28/ExamplePageable.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app28/ExamplePageable.java new file mode 100644 index 000000000..2de642529 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app28/ExamplePageable.java @@ -0,0 +1,85 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app28; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.v3.oas.annotations.Parameter; + +import org.springframework.data.domain.Pageable; +import org.springframework.data.domain.Sort; + +public class ExamplePageable implements Pageable { + + @Parameter(description = "Anything") + @JsonProperty + private int something; + + @Override + public int getPageNumber() { + return 0; + } + + @Override + public int getPageSize() { + return 0; + } + + @Override + public long getOffset() { + return 0; + } + + @Override + public Sort getSort() { + return null; + } + + @Override + public Pageable next() { + return null; + } + + @Override + public Pageable previousOrFirst() { + return null; + } + + @Override + public Pageable first() { + return null; + } + + @Override + public Pageable withPage(int pageNumber) { + return null; + } + + @Override + public boolean hasPrevious() { + return false; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app28/ExamplePageableReplacement.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app28/ExamplePageableReplacement.java new file mode 100644 index 000000000..9e8b38341 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app28/ExamplePageableReplacement.java @@ -0,0 +1,56 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app28; + +import java.util.List; + +import io.swagger.v3.oas.annotations.Parameter; +import org.springdoc.core.converters.models.Pageable; + +public class ExamplePageableReplacement extends Pageable { + + @Parameter(description = "Anything") + private int something; + + /** + * Instantiates a new Pageable. + * @param page the page + * @param size the size + * @param sort the sort + */ + public ExamplePageableReplacement(int page, int size, List sort) { + super(page, size, sort); + } + + public int getSomething() { + return something; + } + + public void setSomething(int something) { + this.something = something; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app28/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app28/HelloController.java new file mode 100644 index 000000000..93e341856 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app28/HelloController.java @@ -0,0 +1,47 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app28; + +import org.springdoc.core.annotations.ParameterObject; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * @author bnasslahsen + */ +@RestController +@RequestMapping("/api") +public class HelloController { + + + @GetMapping("/items/nested") + public void showNestedItem(@ParameterObject ExamplePageable examplePageable) { + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app28/SpringDocApp28Test.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app28/SpringDocApp28Test.java new file mode 100644 index 000000000..72b8d027f --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app28/SpringDocApp28Test.java @@ -0,0 +1,42 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app28; + +import org.springdoc.core.utils.SpringDocUtils; +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp28Test extends AbstractSpringDocTest { + + static { + SpringDocUtils.getConfig().replaceParameterObjectWithClass(ExamplePageable.class, ExamplePageableReplacement.class); + } + + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app29/Person.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app29/Person.java new file mode 100644 index 000000000..c824d6dc1 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app29/Person.java @@ -0,0 +1,60 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app29; + +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; + +@Entity +public class Person { + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private long id; + + private String firstName; + + private String lastName; + + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app29/PersonApi.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app29/PersonApi.java new file mode 100644 index 000000000..04f46a79a --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app29/PersonApi.java @@ -0,0 +1,40 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app29; + +import org.springframework.data.rest.webmvc.BasePathAwareController; +import org.springframework.web.bind.annotation.GetMapping; + +@BasePathAwareController +public class PersonApi { + + @GetMapping("/people/test") + public Person test() { + return new Person(); + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app29/PersonRepository.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app29/PersonRepository.java new file mode 100644 index 000000000..b1dbd3b8f --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app29/PersonRepository.java @@ -0,0 +1,35 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app29; + +import org.springframework.data.repository.PagingAndSortingRepository; +import org.springframework.data.rest.core.annotation.RepositoryRestResource; + +@RepositoryRestResource(path = "people", collectionResourceRel = "people") +public interface PersonRepository extends PagingAndSortingRepository { + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app29/SpringDocApp29Test.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app29/SpringDocApp29Test.java new file mode 100644 index 000000000..77f9d091b --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app29/SpringDocApp29Test.java @@ -0,0 +1,38 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app29; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp29Test extends AbstractSpringDocTest { + + @SpringBootApplication + static class SpringDocTestApp {} + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app3/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app3/HelloController.java new file mode 100644 index 000000000..106024df3 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app3/HelloController.java @@ -0,0 +1,54 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app3; + +import org.springdoc.core.converters.models.PageableAsQueryParam; +import org.springdoc.core.converters.models.SortAsQueryParam; + +import org.springframework.http.MediaType; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequestMapping(path = "/demo", + produces = MediaType.TEXT_PLAIN_VALUE) +public class HelloController { + + @GetMapping("operation4") + @PageableAsQueryParam + public String operation4() { + return "operation4"; + } + + @GetMapping("operation5") + @SortAsQueryParam + public String operation5() { + return "operation5"; + } + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app3/SpringDocApp3Test.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app3/SpringDocApp3Test.java new file mode 100644 index 000000000..a2df76273 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app3/SpringDocApp3Test.java @@ -0,0 +1,38 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app3; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp3Test extends AbstractSpringDocTest { + + @SpringBootApplication + static class SpringDocTestApp {} + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app30/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app30/HelloController.java new file mode 100644 index 000000000..b729ce0b6 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app30/HelloController.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app30; + +import com.querydsl.core.types.Predicate; + +import org.springframework.data.querydsl.binding.QuerydslPredicate; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + + +@RestController +public class HelloController { + + @GetMapping("/") + public User testQueryDslAndSpringDoc(@QuerydslPredicate(root = User.class, bindings = UserPredicate.class) Predicate predicate) { + return null; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app30/QUser.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app30/QUser.java new file mode 100644 index 000000000..f80b57bc5 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app30/QUser.java @@ -0,0 +1,68 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app30; + + +import com.querydsl.core.types.Path; +import com.querydsl.core.types.PathMetadata; +import com.querydsl.core.types.dsl.EntityPathBase; +import com.querydsl.core.types.dsl.NumberPath; +import com.querydsl.core.types.dsl.StringPath; + +import static com.querydsl.core.types.PathMetadataFactory.forVariable; + + +/** + * QUser is a Querydsl query type for User + */ +public class QUser extends EntityPathBase { + + public static final QUser user = new QUser("user"); + + private static final long serialVersionUID = 222331676L; + + public final StringPath email = createString("email"); + + public final StringPath firstName = createString("firstName"); + + public final NumberPath id = createNumber("id", Long.class); + + public final StringPath lastName = createString("lastName"); + + public QUser(String variable) { + super(User.class, forVariable(variable)); + } + + public QUser(Path path) { + super(path.getType(), path.getMetadata()); + } + + public QUser(PathMetadata metadata) { + super(User.class, metadata); + } + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app30/SpringDocApp30Test.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app30/SpringDocApp30Test.java new file mode 100644 index 000000000..1620b2c1b --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app30/SpringDocApp30Test.java @@ -0,0 +1,38 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app30; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp30Test extends AbstractSpringDocTest { + + @SpringBootApplication + static class SpringDocTestApp {} + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app30/User.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app30/User.java new file mode 100644 index 000000000..a6f2f5f10 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app30/User.java @@ -0,0 +1,50 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app30; + + +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import lombok.Getter; +import lombok.Setter; + +@Entity +@Getter +@Setter +public class User { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + private String firstName; + + private String lastName; + + private String email; +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app30/UserPredicate.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app30/UserPredicate.java new file mode 100644 index 000000000..6b5531387 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app30/UserPredicate.java @@ -0,0 +1,42 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app30; + + +import org.springframework.data.querydsl.binding.QuerydslBinderCustomizer; +import org.springframework.data.querydsl.binding.QuerydslBindings; + +public class UserPredicate implements QuerydslBinderCustomizer { + + + @Override + public void customize(QuerydslBindings bindings, QUser user) { + bindings.excludeUnlistedProperties(true); + bindings.including(user.email); + bindings.bind(user.firstName).as("name").withDefaultBinding(); + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app301/Person.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app301/Person.java new file mode 100644 index 000000000..c41696aae --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app301/Person.java @@ -0,0 +1,60 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app301; + +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; + +@Entity +public class Person { + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private long id; + + private String firstName; + + private String lastName; + + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app301/PersonApi.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app301/PersonApi.java new file mode 100644 index 000000000..42ea14b32 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app301/PersonApi.java @@ -0,0 +1,40 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app301; + +import org.springframework.data.rest.webmvc.BasePathAwareController; +import org.springframework.web.bind.annotation.GetMapping; + +@BasePathAwareController +public class PersonApi { + + @GetMapping("/people/test") + public Person test() { + return new Person(); + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app301/PersonRepository.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app301/PersonRepository.java new file mode 100644 index 000000000..e1ceb492f --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app301/PersonRepository.java @@ -0,0 +1,35 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app301; + +import org.springframework.data.repository.PagingAndSortingRepository; +import org.springframework.data.rest.core.annotation.RepositoryRestResource; + +@RepositoryRestResource(path = "people", collectionResourceRel = "people") +public interface PersonRepository extends PagingAndSortingRepository { + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app301/SpringDocApp301Test.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app301/SpringDocApp301Test.java new file mode 100644 index 000000000..183533b06 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app301/SpringDocApp301Test.java @@ -0,0 +1,78 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app301; + +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; +import java.util.Map.Entry; + +import com.fasterxml.jackson.databind.introspect.SimpleMixInResolver; +import com.fasterxml.jackson.databind.type.ClassKey; +import org.apache.commons.lang3.reflect.FieldUtils; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.springdoc.core.providers.ObjectMapperProvider; +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.test.context.TestPropertySource; + +@TestPropertySource(properties = "springdoc.enable-data-rest=false") +public class SpringDocApp301Test extends AbstractSpringDocTest { + + private final Map> springMixins = new HashMap<>(); + + @Autowired + ObjectMapperProvider objectMapperProvider; + + @BeforeEach + void init() throws IllegalAccessException { + SimpleMixInResolver _mixIns = (SimpleMixInResolver) FieldUtils.readDeclaredField(objectMapperProvider.jsonMapper(), "_mixIns", true); + Map> _localMixIns = (Map>) FieldUtils.readDeclaredField(_mixIns, "_localMixIns", true); + Iterator>> it = _localMixIns.entrySet().iterator(); + while (it.hasNext()) { + Map.Entry> entry = it.next(); + if (entry.getKey().toString().startsWith("org.springframework")) { + springMixins.put(entry.getKey(), entry.getValue()); + it.remove(); + } + } + + } + + @AfterEach + void clean() throws IllegalAccessException { + SimpleMixInResolver _mixIns = (SimpleMixInResolver) FieldUtils.readDeclaredField(objectMapperProvider.jsonMapper(), "_mixIns", true); + Map> _localMixIns = (Map>) FieldUtils.readDeclaredField(_mixIns, "_localMixIns", true); + _localMixIns.putAll(springMixins); + } + + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app31/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app31/HelloController.java new file mode 100644 index 000000000..dc7df05e6 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app31/HelloController.java @@ -0,0 +1,77 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app31; + +import java.util.List; + +import org.springdoc.core.annotations.ParameterObject; + +import org.springframework.data.domain.Pageable; +import org.springframework.data.domain.Sort; +import org.springframework.data.domain.Sort.Direction; +import org.springframework.data.web.SortDefault; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class HelloController { + + @GetMapping(value = "/search", produces = { "application/xml", "application/json" }) + public ResponseEntity> getAllPets(@SortDefault("name") @ParameterObject Sort sort) { + return null; + } + + + @GetMapping("/test1") + public String getPatientList1(@SortDefault(sort = { "someField", "someoTHER" }, + direction = Direction.DESC) + @ParameterObject Sort sort) { + return "bla"; + } + + @GetMapping("/test2") + public String getPatientList2(@SortDefault(sort = "someField", + direction = Direction.DESC) + @ParameterObject Sort sort) { + return "bla"; + } + + @GetMapping("/test3") + public String getPatientList3(@SortDefault(sort = { "someField", "someoTHER" }, + direction = Direction.DESC) + @ParameterObject Pageable pageable) { + return "bla"; + } + + @GetMapping("/test4") + public String getPatientList4(@SortDefault(sort = "someField", + direction = Direction.DESC) + @ParameterObject Pageable pageable) { + return "bla"; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app31/PersonDTO.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app31/PersonDTO.java new file mode 100644 index 000000000..a995fd804 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app31/PersonDTO.java @@ -0,0 +1,71 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app31; + +import io.swagger.v3.oas.annotations.media.Schema; + +@Schema +public class PersonDTO { + private String email; + + private String firstName; + + private String lastName; + + public PersonDTO() { + } + + public PersonDTO(final String email, final String firstName, final String lastName) { + this.email = email; + this.firstName = firstName; + this.lastName = lastName; + } + + public String getEmail() { + return email; + } + + public void setEmail(final String email) { + this.email = email; + } + + public String getFirstName() { + return firstName; + } + + public void setFirstName(final String firstName) { + this.firstName = firstName; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(final String lastName) { + this.lastName = lastName; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app31/SpringDocApp31Test.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app31/SpringDocApp31Test.java new file mode 100644 index 000000000..10b68f470 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app31/SpringDocApp31Test.java @@ -0,0 +1,38 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app31; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp31Test extends AbstractSpringDocTest { + + @SpringBootApplication + static class SpringDocTestApp {} + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app32/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app32/HelloController.java new file mode 100644 index 000000000..c3f80c35b --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app32/HelloController.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.app32; + +import java.util.List; + +import org.springdoc.core.annotations.ParameterObject; + +import org.springframework.data.domain.Sort; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class HelloController { + + @GetMapping(value = "/search", produces = { "application/xml", "application/json" }) + public ResponseEntity> getAllPets(@ParameterObject Sort sort) { + return null; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app32/PersonDTO.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app32/PersonDTO.java new file mode 100644 index 000000000..0919022b3 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app32/PersonDTO.java @@ -0,0 +1,71 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app32; + +import io.swagger.v3.oas.annotations.media.Schema; + +@Schema +public class PersonDTO { + private String email; + + private String firstName; + + private String lastName; + + public PersonDTO() { + } + + public PersonDTO(final String email, final String firstName, final String lastName) { + this.email = email; + this.firstName = firstName; + this.lastName = lastName; + } + + public String getEmail() { + return email; + } + + public void setEmail(final String email) { + this.email = email; + } + + public String getFirstName() { + return firstName; + } + + public void setFirstName(final String firstName) { + this.firstName = firstName; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(final String lastName) { + this.lastName = lastName; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app32/SpringDocApp32Test.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app32/SpringDocApp32Test.java new file mode 100644 index 000000000..6b4113423 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app32/SpringDocApp32Test.java @@ -0,0 +1,62 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app32; + +import java.util.Optional; + +import org.springdoc.core.configuration.SpringDocDataRestConfiguration; +import org.springdoc.core.customizers.DataRestDelegatingMethodParameterCustomizer; +import org.springdoc.core.providers.RepositoryRestConfigurationProvider; +import org.springdoc.core.providers.SpringDataWebPropertiesProvider; +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.data.rest.RepositoryRestMvcAutoConfiguration; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Lazy; +import org.springframework.test.context.TestPropertySource; + +@TestPropertySource(properties = "spring.data.web.sort.sort-parameter=sorts") +@EnableAutoConfiguration(exclude = { + RepositoryRestMvcAutoConfiguration.class, SpringDocDataRestConfiguration.class +}) +public class SpringDocApp32Test extends AbstractSpringDocTest { + + @SpringBootApplication + static class SpringDocTestApp { + // We only need to test spring-web with Sort, without the use of spring-data-rest-starter + @Bean + @ConditionalOnMissingBean + @Lazy(false) + DataRestDelegatingMethodParameterCustomizer dataRestDelegatingMethodParameterCustomizer(Optional optionalSpringDataWebPropertiesProvider, Optional optionalRepositoryRestConfiguration) { + return new DataRestDelegatingMethodParameterCustomizer(optionalSpringDataWebPropertiesProvider, optionalRepositoryRestConfiguration); + } + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app33/ExampleSort.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app33/ExampleSort.java new file mode 100644 index 000000000..59e928a3e --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app33/ExampleSort.java @@ -0,0 +1,45 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app33; + +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.v3.oas.annotations.Parameter; + +import org.springframework.data.domain.Sort; + +public class ExampleSort extends Sort { + + @Parameter(description = "Anything") + @JsonProperty + private int something; + + protected ExampleSort(List orders) { + super(orders); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app33/ExampleSortReplacement.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app33/ExampleSortReplacement.java new file mode 100644 index 000000000..6c48b9b2b --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app33/ExampleSortReplacement.java @@ -0,0 +1,54 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app33; + +import java.util.List; + +import io.swagger.v3.oas.annotations.Parameter; +import org.springdoc.core.converters.models.Sort; + +public class ExampleSortReplacement extends Sort { + + @Parameter(description = "Anything") + private int something; + + /** + * Instantiates a new Sort. + * @param sort the sort + */ + public ExampleSortReplacement(List sort) { + super(sort); + } + + public int getSomething() { + return something; + } + + public void setSomething(int something) { + this.something = something; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app33/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app33/HelloController.java new file mode 100644 index 000000000..1b495fe92 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app33/HelloController.java @@ -0,0 +1,44 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app33; + +import org.springdoc.core.annotations.ParameterObject; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequestMapping("/api") +public class HelloController { + + + @GetMapping("/items/nested") + public void showNestedItem(@ParameterObject ExampleSort exampleSort) { + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app33/SpringDocApp33Test.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app33/SpringDocApp33Test.java new file mode 100644 index 000000000..4eddf485d --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app33/SpringDocApp33Test.java @@ -0,0 +1,42 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app33; + +import org.springdoc.core.utils.SpringDocUtils; +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp33Test extends AbstractSpringDocTest { + + static { + SpringDocUtils.getConfig().replaceParameterObjectWithClass(ExampleSort.class, ExampleSortReplacement.class); + } + + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app34/Account.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app34/Account.java new file mode 100644 index 000000000..79ed96068 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app34/Account.java @@ -0,0 +1,64 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app34; + +import java.util.Date; + +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.Temporal; +import jakarta.persistence.TemporalType; + + +@Entity +public class Account { + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private Long id; + + @ManyToOne + private Customer customer; + + @Temporal(TemporalType.DATE) + private Date expiryDate; + + public Long getId() { + return id; + } + + public Customer getCustomer() { + return customer; + } + + public Date getExpiryDate() { + return expiryDate; + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app34/AccountRepository.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app34/AccountRepository.java new file mode 100644 index 000000000..320f1a7fa --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app34/AccountRepository.java @@ -0,0 +1,55 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app34; + + +import java.util.List; + +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.tags.Tag; + +import org.springframework.data.repository.CrudRepository; +import org.springframework.data.repository.query.Param; +import org.springframework.data.rest.core.annotation.RepositoryRestResource; + +/** + * Repository to manage {@link Account} instances. + * + */ +@RepositoryRestResource +@Tag(name = "The account Repository") +@SecurityRequirement(name = "bearer") +public interface AccountRepository extends CrudRepository { + + /** + * Returns all accounts belonging to the given {@link Customer}. + * + * @param customer + * @return + */ + List findByCustomer(@Param("customer") Customer customer); +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app34/Customer.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app34/Customer.java new file mode 100644 index 000000000..e11557c67 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app34/Customer.java @@ -0,0 +1,75 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app34; + + +import java.util.Collection; + +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.OneToMany; + + +/** + * @author Oliver Gierke + */ +@Entity +public class Customer { + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private Long id; + + private String firstname; + + private String lastname; + + @OneToMany(mappedBy = "customer") + private Collection accounts; + + public Long getId() { + return id; + } + + public String getFirstname() { + return firstname; + } + + public String getLastname() { + return lastname; + } + + public Collection getAccounts() { + return accounts; + } + + public void setAccounts(Collection accounts) { + this.accounts = accounts; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app34/CustomerRepository.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app34/CustomerRepository.java new file mode 100644 index 000000000..1c09702dd --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app34/CustomerRepository.java @@ -0,0 +1,66 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app34; + +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.tags.Tag; + +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.data.jpa.repository.JpaSpecificationExecutor; +import org.springframework.data.repository.CrudRepository; +import org.springframework.data.repository.query.Param; +import org.springframework.data.rest.core.annotation.RepositoryRestResource; +import org.springframework.data.rest.core.annotation.RestResource; + +/** + * Repository to manage {@link Customer} instances. + * + * @author Oliver Gierke + */ +@RepositoryRestResource +@Tag(name = "The customer Repository") +public interface CustomerRepository extends CrudRepository, JpaSpecificationExecutor { + + /** + * Returns a page of {@link Customer}s with the given lastname. + * + * @param lastname + * @param pageable + * @return + */ + @SecurityRequirement(name = "bearer") + Page findByLastname(@Param("lastname") String lastname, Pageable pageable); + + @Override + @RestResource(exported = false) + void deleteById(Long id); + + @Override + @RestResource(exported = false) + void delete(Customer entity); +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app34/OpenApiConfig.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app34/OpenApiConfig.java new file mode 100644 index 000000000..e1b2b1b10 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app34/OpenApiConfig.java @@ -0,0 +1,38 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app34; + +import io.swagger.v3.oas.annotations.OpenAPIDefinition; +import io.swagger.v3.oas.annotations.enums.SecuritySchemeType; +import io.swagger.v3.oas.annotations.info.Info; +import io.swagger.v3.oas.annotations.info.License; +import io.swagger.v3.oas.annotations.security.SecurityScheme; + +@OpenAPIDefinition(info = @Info(title = "My App", description = "Some long and useful description", version = "v1", license = @License(name = "Apache 2.0", url = "https://www.apache.org/licenses/LICENSE-2.0"))) +@SecurityScheme(name = "bearer", type = SecuritySchemeType.HTTP, scheme = "bearer", bearerFormat = "JWT") +public class OpenApiConfig { +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app34/SpringDocApp34Test.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app34/SpringDocApp34Test.java new file mode 100644 index 000000000..a853bd3d4 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app34/SpringDocApp34Test.java @@ -0,0 +1,37 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app34; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp34Test extends AbstractSpringDocTest { + + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app34/SpringRestConfiguration.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app34/SpringRestConfiguration.java new file mode 100644 index 000000000..4fcc3a20d --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app34/SpringRestConfiguration.java @@ -0,0 +1,41 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app34; + + +import org.springframework.context.annotation.Configuration; +import org.springframework.data.rest.core.config.RepositoryRestConfiguration; +import org.springframework.data.rest.webmvc.config.RepositoryRestConfigurer; +import org.springframework.web.servlet.config.annotation.CorsRegistry; + +@Configuration +public class SpringRestConfiguration implements RepositoryRestConfigurer { + @Override + public void configureRepositoryRestConfiguration(RepositoryRestConfiguration config, CorsRegistry cors) { + config.exposeIdsFor(Account.class, Customer.class); + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app35/ChildProperty.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app35/ChildProperty.java new file mode 100644 index 000000000..4e1f5f2c4 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app35/ChildProperty.java @@ -0,0 +1,61 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app35; + + +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import lombok.Data; + +@Entity +public @Data +class ChildProperty { + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private long id; + + private String name; + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app35/ChildPropertyRepository.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app35/ChildPropertyRepository.java new file mode 100644 index 000000000..81bbfebe1 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app35/ChildPropertyRepository.java @@ -0,0 +1,35 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app35; + +import io.swagger.v3.oas.annotations.Hidden; + +import org.springframework.data.repository.PagingAndSortingRepository; + +@Hidden +public interface ChildPropertyRepository extends PagingAndSortingRepository { +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app35/Property.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app35/Property.java new file mode 100644 index 000000000..4eeb7aae3 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app35/Property.java @@ -0,0 +1,75 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app35; + + +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; +import lombok.Data; + +@Entity +public @Data +class Property { + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private long id; + + private String name; + + @ManyToOne + @JoinColumn(name = "child_property_id") + private ChildProperty myChildPropertyName; + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public ChildProperty getMyChildPropertyName() { + return myChildPropertyName; + } + + public void setMyChildPropertyName(ChildProperty myChildPropertyName) { + this.myChildPropertyName = myChildPropertyName; + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app35/PropertyRepository.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app35/PropertyRepository.java new file mode 100644 index 000000000..ab06524bd --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app35/PropertyRepository.java @@ -0,0 +1,35 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app35; + +import io.swagger.v3.oas.annotations.Hidden; + +import org.springframework.data.repository.PagingAndSortingRepository; + +@Hidden +public interface PropertyRepository extends PagingAndSortingRepository { +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app35/SpringDocApp35Test.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app35/SpringDocApp35Test.java new file mode 100644 index 000000000..8c045f8b8 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app35/SpringDocApp35Test.java @@ -0,0 +1,37 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app35; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp35Test extends AbstractSpringDocTest { + + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app36/EnumFieldHolder.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app36/EnumFieldHolder.java new file mode 100644 index 000000000..13d50ffde --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app36/EnumFieldHolder.java @@ -0,0 +1,60 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app36; + +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.Id; + +@Entity +public class EnumFieldHolder { + + public enum EnumField { + + FOO, BAR; + + } + + @Id + @GeneratedValue + private Long id; + + private EnumField enumField; + + public Long getId() { + return id; + } + + public EnumField getEnumField() { + return enumField; + } + + public void setEnumField(EnumField enumField) { + this.enumField = enumField; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app36/EnumFieldHolderRepository.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app36/EnumFieldHolderRepository.java new file mode 100644 index 000000000..9de06794b --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app36/EnumFieldHolderRepository.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app36; + +import java.util.List; + +import org.springframework.data.repository.Repository; +import org.springframework.data.repository.query.Param; +import org.springframework.data.rest.core.annotation.RepositoryRestResource; +import org.springframework.data.util.Streamable; + +@RepositoryRestResource +public interface EnumFieldHolderRepository extends Repository { + + Streamable findAllByEnumField(@Param("enumField") EnumFieldHolder.EnumField enumField); + + Streamable findAllByEnumFieldIn(@Param("enumFields") List enumFields); + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app36/SpringDocApp36Test.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app36/SpringDocApp36Test.java new file mode 100644 index 000000000..c112fed6d --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app36/SpringDocApp36Test.java @@ -0,0 +1,40 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app36; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp36Test extends AbstractSpringDocTest { + + @SpringBootApplication + static class SpringDocTestApp { + + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app37/BaseEntity.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app37/BaseEntity.java new file mode 100644 index 000000000..29236f1b9 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app37/BaseEntity.java @@ -0,0 +1,70 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app37; + +import java.io.Serializable; + +import jakarta.persistence.Column; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.MappedSuperclass; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.SuperBuilder; +import org.hibernate.annotations.DynamicInsert; +import org.hibernate.annotations.DynamicUpdate; + +/** + * @author bnasslahsen + */ + +@Data +@MappedSuperclass +@DynamicInsert(true) +@DynamicUpdate(true) +@SuperBuilder(toBuilder = true) +@NoArgsConstructor +public abstract class BaseEntity implements Serializable { + + /** SVUDI */ + private static final long serialVersionUID = 1L; + + /** 数据库中的ID */ + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "ID", unique = true, nullable = false, insertable = false, updatable = false) + private Long id; + + + /** + * 数据是否合法 + * + * @return 是否合法 + */ + public abstract boolean isValid(); +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app37/ProductEntity.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app37/ProductEntity.java new file mode 100644 index 000000000..c95da374c --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app37/ProductEntity.java @@ -0,0 +1,86 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app37; + +import java.math.BigDecimal; +import java.time.LocalDate; + +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.Table; +import jakarta.validation.constraints.NotNull; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; +import lombok.experimental.SuperBuilder; + +/** + * @author bnasslahsen + */ + +@Getter +@Setter +@ToString(callSuper = true) +@EqualsAndHashCode(callSuper = false) +@Entity +@Table(name = "PRODUCT_ENTITY") +@SuperBuilder(toBuilder = true) +@NoArgsConstructor +public class ProductEntity extends BaseEntity implements Comparable { + + /** SVUDI */ + private static final long serialVersionUID = 1L; + + /** 名字. */ + @NotNull + @Column(nullable = false) + private String name; + + /** 单价. */ + @NotNull + @Column(nullable = false) + private BigDecimal price; + + /** 日期. */ + @NotNull + @Column(nullable = false) + private LocalDate date; + + @Override + public boolean isValid() { + return name != null && price != null && date != null; + } + + /** 根据日期排序 */ + @Override + public int compareTo(ProductEntity oProduct) { + return this.getDate().compareTo(oProduct.getDate()); + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app37/ProductRepository.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app37/ProductRepository.java new file mode 100644 index 000000000..93dd0ecb3 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app37/ProductRepository.java @@ -0,0 +1,115 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app37; + +/** + * @author bnasslahsen + */ + +import java.math.BigDecimal; +import java.time.LocalDate; +import java.util.List; + +import ch.qos.logback.core.rolling.helper.DateTokenConverter; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.enums.ParameterIn; + +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.repository.query.Param; +import org.springframework.data.rest.core.annotation.RepositoryRestResource; +import org.springframework.format.annotation.DateTimeFormat; + +/** + * 商品信息 + * + * @author zctmdc + */ +@RepositoryRestResource(path = "product") +public interface ProductRepository extends JpaRepository { + + List findByPrice( @Parameter( + name = "price", + description = "test desc", + in = ParameterIn.QUERY, + required = true + ) + @Param("price") BigDecimal price); + /** + * 根据商品名称查询商品信息 + * + * @param name 商品名称 + * @return 商品信息列表 + */ + List findByName(@Parameter(name = "name2", required = true) String name); + + /** + * 根据商品名称查询最新的商品信息 + * + * @param name 商品名称 + * @return 商品信息 + */ + ProductEntity findTopByNameOrderByDateDesc(@Parameter(name = "name2", required = true) String name); + + /** + * 根据商品名称模糊查询商品信息并按时间降序排序 + * + * @param name 商品名称 + * @return 商品信息列表 + */ + List findByNameContainingIgnoreCaseOrderByDateDesc( + @Parameter(name = "name2", required = true) String name); + + /** + * 根据商品名称模糊查询商品信息并按时间降序排序 + * + * @param name 商品名称 + * @return 商品信息列表 + */ + List findByNameContainingIgnoreCase( + @Parameter(name = "name2", required = true) String name); + + /** + * 根据商品名称模糊查询指定日期前的商品信息 + * + * @param end 指定日期结束 + * @return 商品信息列表 + */ + List findByDateBefore( + @Parameter(name = "end2", required = true) @DateTimeFormat(pattern = DateTokenConverter.DEFAULT_DATE_PATTERN) @Param("end") LocalDate end); + + /** + * 根据商品名称模糊查询指定日期前的商品信息 + * + * @param name 商品名称 + * @param end 指定日期结束 + * @return 商品信息列表 + */ + List findByNameContainingIgnoreCaseAndDateBefore( + @Parameter(name = "name2", required = true) String name, + @Parameter(name = "end2", required = true) @DateTimeFormat(pattern = DateTokenConverter.DEFAULT_DATE_PATTERN) @Param("end") LocalDate end); + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app37/SpringDocApp37Test.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app37/SpringDocApp37Test.java new file mode 100644 index 000000000..f7cc2471a --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app37/SpringDocApp37Test.java @@ -0,0 +1,40 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app37; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp37Test extends AbstractSpringDocTest { + + @SpringBootApplication + static class SpringDocTestApp { + + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app38/DefaultFlatParamObjectController.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app38/DefaultFlatParamObjectController.java new file mode 100644 index 000000000..f96bff150 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app38/DefaultFlatParamObjectController.java @@ -0,0 +1,40 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app38; + +import org.springframework.data.domain.Sort; +import org.springframework.data.web.SortDefault; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class DefaultFlatParamObjectController { + @GetMapping("/test1") + public String test1(@SortDefault("name") Sort sort) { + return null; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app38/SpringDocApp38Test.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app38/SpringDocApp38Test.java new file mode 100644 index 000000000..6c3cff547 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app38/SpringDocApp38Test.java @@ -0,0 +1,42 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app38; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.test.context.TestPropertySource; + +@TestPropertySource(properties = { "springdoc.default-flat-param-object=true" }) +public class SpringDocApp38Test extends AbstractSpringDocTest { + + @SpringBootApplication + static class SpringDocTestApp { + + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app4/DatabaseLoader.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app4/DatabaseLoader.java new file mode 100644 index 000000000..a0bfd766e --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app4/DatabaseLoader.java @@ -0,0 +1,55 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app4; + +import org.springframework.boot.CommandLineRunner; +import org.springframework.context.annotation.Bean; +import org.springframework.stereotype.Component; + +/** + * Pre-load some data using a Spring Boot {@link CommandLineRunner}. + * + * @author Greg Turnquist + */ +@Component +class DatabaseLoader { + + /** + * Use Spring to inject a {@link EmployeeRepository} that can then load data. Since this will run only after the app + * is operational, the database will be up. + * + * @param repository + */ + @Bean + CommandLineRunner init(EmployeeRepository repository) { + + return args -> { + repository.save(new Employee("Frodo", "Baggins", "ring bearer")); + repository.save(new Employee("Bilbo", "Baggins", "burglar")); + }; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app4/Employee.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app4/Employee.java new file mode 100644 index 000000000..41a7bbb80 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app4/Employee.java @@ -0,0 +1,77 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app4; + +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.Id; +import lombok.AccessLevel; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * Domain object representing a company employee. Project Lombok keeps actual code at a minimum. {@code @Data} - + * Generates getters, setters, toString, hash, and equals functions {@code @Entity} - JPA annotation to flag this class + * for DB persistence {@code @NoArgsConstructor} - Create a constructor with no args to support JPA + * {@code @AllArgsConstructor} - Create a constructor with all args to support testing + * {@code @JsonIgnoreProperties(ignoreUnknow=true)} When converting JSON to Java, ignore any unrecognized attributes. + * This is critical for REST because it encourages adding new fields in later versions that won't break. It also allows + * things like _links to be ignore as well, meaning HAL documents can be fetched and later posted to the server without + * adjustment. + * + * @author Greg Turnquist + */ +@Data +@Entity +@NoArgsConstructor(access = AccessLevel.PRIVATE) +@AllArgsConstructor +class Employee { + + @Id + @GeneratedValue + private Long id; + + private String firstName; + + private String lastName; + + private String role; + + /** + * Useful constructor when id is not yet known. + * + * @param firstName + * @param lastName + * @param role + */ + Employee(String firstName, String lastName, String role) { + + this.firstName = firstName; + this.lastName = lastName; + this.role = role; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app4/EmployeeController.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app4/EmployeeController.java new file mode 100644 index 000000000..09f44adb8 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app4/EmployeeController.java @@ -0,0 +1,135 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app4; + +import java.net.URI; +import java.net.URISyntaxException; +import java.util.List; +import java.util.stream.StreamSupport; + +import org.springframework.hateoas.CollectionModel; +import org.springframework.hateoas.EntityModel; +import org.springframework.hateoas.IanaLinkRelations; +import org.springframework.hateoas.Link; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RestController; + +import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.linkTo; +import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.methodOn; + +/** + * Spring Web {@link RestController} used to generate a REST API. + * + * @author Greg Turnquist + */ +@RestController +class EmployeeController { + + private final EmployeeRepository repository; + + EmployeeController(EmployeeRepository repository) { + this.repository = repository; + } + + /** + * Look up all employees, and transform them into a REST collection resource. Then return them through Spring Web's + * {@link ResponseEntity} fluent API. + */ + @GetMapping("/employees") + ResponseEntity>> findAll() { + + List> employees = StreamSupport.stream(repository.findAll().spliterator(), false) + .map(employee -> EntityModel.of(employee, // + linkTo(methodOn(EmployeeController.class).findOne(employee.getId())).withSelfRel(), // + linkTo(methodOn(EmployeeController.class).findAll()).withRel("employees"))) // + .toList(); + + return ResponseEntity.ok( // + CollectionModel.of(employees, // + linkTo(methodOn(EmployeeController.class).findAll()).withSelfRel())); + } + + @PostMapping("/employees") + ResponseEntity> newEmployee(@RequestBody Employee employee) { + + try { + Employee savedEmployee = repository.save(employee); + + EntityModel employeeResource = EntityModel.of(savedEmployee, // + linkTo(methodOn(EmployeeController.class).findOne(savedEmployee.getId())).withSelfRel()); + + return ResponseEntity // + .created(new URI(employeeResource.getRequiredLink(IanaLinkRelations.SELF).getHref())) // + .body(employeeResource); + } + catch (URISyntaxException e) { + return ResponseEntity.badRequest().body(null); + } + } + + /** + * Look up a single {@link Employee} and transform it into a REST resource. Then return it through Spring Web's + * {@link ResponseEntity} fluent API. + * + * @param id + */ + @GetMapping("/employees/{id}") + ResponseEntity> findOne(@PathVariable long id) { + + return repository.findById(id) // + .map(employee -> EntityModel.of(employee, // + linkTo(methodOn(EmployeeController.class).findOne(employee.getId())).withSelfRel(), // + linkTo(methodOn(EmployeeController.class).findAll()).withRel("employees"))) // + .map(ResponseEntity::ok) // + .orElse(ResponseEntity.notFound().build()); + } + + /** + * Update existing employee then return a Location header. + * + * @param employee + * @param id + * @return + */ + @PutMapping("/employees/{id}") + ResponseEntity updateEmployee(@RequestBody Employee employee, @PathVariable long id) throws URISyntaxException { + + Employee employeeToUpdate = employee; + employeeToUpdate.setId(id); + repository.save(employeeToUpdate); + + Link newlyCreatedLink = linkTo(methodOn(EmployeeController.class).findOne(id)).withSelfRel(); + + return ResponseEntity.noContent().location(new URI(newlyCreatedLink.getHref())).build(); + + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app4/EmployeeRepository.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app4/EmployeeRepository.java new file mode 100644 index 000000000..78295fc7a --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app4/EmployeeRepository.java @@ -0,0 +1,36 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app4; + +import org.springframework.data.repository.CrudRepository; + +/** + * A simple Spring Data {@link CrudRepository} for storing {@link Employee}s. + * + * @author Greg Turnquist + */ +interface EmployeeRepository extends CrudRepository { +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app4/SpringDocApp4Test.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app4/SpringDocApp4Test.java new file mode 100644 index 000000000..b21bbadc1 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app4/SpringDocApp4Test.java @@ -0,0 +1,34 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app4; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +public class SpringDocApp4Test extends AbstractSpringDocTest { + + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app4/SpringDocTestApp.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app4/SpringDocTestApp.java new file mode 100644 index 000000000..c62943422 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app4/SpringDocTestApp.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.app4; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; +import org.springframework.hateoas.server.core.EvoInflectorLinkRelationProvider; + +@SpringBootApplication +public class SpringDocTestApp { + + public static void main(String[] args) { + SpringApplication.run(SpringDocTestApp.class, args); + } + + @Bean + EvoInflectorLinkRelationProvider relProvider() { + return new EvoInflectorLinkRelationProvider(); + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app5/Country.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app5/Country.java new file mode 100644 index 000000000..3bc1533a3 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app5/Country.java @@ -0,0 +1,120 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app5; + +import jakarta.persistence.Basic; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.EnumType; +import jakarta.persistence.Enumerated; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.Id; + +/** + * @author gibah + */ + +@Entity +public class Country { + + @Id + @GeneratedValue + private Long id; + + @Basic + @Column(nullable = false) + private String name; + + @Basic + private String shortName; + + @Basic + private String dialingCode; + + @Basic + @Column(unique = true, nullable = false) + private String codeISO3166; + + @Basic + @Column(nullable = false) + @Enumerated(EnumType.STRING) + private Status status; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getShortName() { + return shortName; + } + + public void setShortName(String shortName) { + this.shortName = shortName; + } + + public String getDialingCode() { + return dialingCode; + } + + public void setDialingCode(String dialingCode) { + this.dialingCode = dialingCode; + } + + public String getCodeISO3166() { + return codeISO3166; + } + + public void setCodeISO3166(String codeISO3166) { + this.codeISO3166 = codeISO3166; + } + + public Status getStatus() { + return status; + } + + public Country setStatus(Status status) { + this.status = status; + return this; + } + + public enum Status { + ACTIVE, INACTIVE + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app5/CountryPredicate.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app5/CountryPredicate.java new file mode 100644 index 000000000..0a934a1b1 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app5/CountryPredicate.java @@ -0,0 +1,39 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app5; + +import org.springframework.data.querydsl.binding.QuerydslBinderCustomizer; +import org.springframework.data.querydsl.binding.QuerydslBindings; + +public class CountryPredicate implements QuerydslBinderCustomizer { + + @Override + public void customize(QuerydslBindings querydslBindings, QCountry qCountry) { + querydslBindings.bind(qCountry.codeISO3166).as("code").first((path, value) -> path.containsIgnoreCase(value)); + querydslBindings.bind(qCountry.dialingCode).as("postCode").first((path, value) -> path.containsIgnoreCase(value)); + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app5/GreetingController.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app5/GreetingController.java new file mode 100644 index 000000000..2739a4143 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app5/GreetingController.java @@ -0,0 +1,48 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app5; + +import java.util.List; + +import com.querydsl.core.types.Predicate; +import test.org.springdoc.api.v30.app5.Country.Status; + +import org.springframework.data.querydsl.binding.QuerydslPredicate; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class GreetingController { + + @GetMapping("/test") + public ResponseEntity sayHello2(@QuerydslPredicate(bindings = CountryPredicate.class, root = Country.class) Predicate predicate, + @RequestParam List statuses) { + return ResponseEntity.ok().build(); + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app5/QCountry.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app5/QCountry.java new file mode 100644 index 000000000..d6294b7b2 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app5/QCountry.java @@ -0,0 +1,76 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app5; + +import com.querydsl.core.types.Path; +import com.querydsl.core.types.PathMetadata; +import com.querydsl.core.types.dsl.EntityPathBase; +import com.querydsl.core.types.dsl.EnumPath; +import com.querydsl.core.types.dsl.NumberPath; +import com.querydsl.core.types.dsl.StringPath; +import jakarta.annotation.Generated; +import test.org.springdoc.api.v30.app5.Country.Status; + +import static com.querydsl.core.types.PathMetadataFactory.forVariable; + + +/** + * QCountry is a Querydsl query type for Country + */ +@Generated("com.querydsl.codegen.EntitySerializer") +public class QCountry extends EntityPathBase { + + public static final QCountry country = new QCountry("country"); + + private static final long serialVersionUID = -1184258693L; + + public final StringPath codeISO3166 = createString("codeISO3166"); + + public final StringPath dialingCode = createString("dialingCode"); + + public final NumberPath id = createNumber("id", Long.class); + + public final StringPath name = createString("name"); + + public final StringPath shortName = createString("shortName"); + + public final EnumPath status = createEnum("status", Status.class); + + public QCountry(String variable) { + super(Country.class, forVariable(variable)); + } + + public QCountry(Path path) { + super(path.getType(), path.getMetadata()); + } + + public QCountry(PathMetadata metadata) { + super(Country.class, metadata); + } + +} + diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app5/SpringDocApp5Test.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app5/SpringDocApp5Test.java new file mode 100644 index 000000000..efa971f2c --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app5/SpringDocApp5Test.java @@ -0,0 +1,44 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app5; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * @author Gibah Joseph + * Email: gibahjoe@gmail.com + * Mar, 2020 + **/ + +public class SpringDocApp5Test extends AbstractSpringDocTest { + + @SpringBootApplication + static class SpringDocTestApp {} + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app6/DatabaseLoader.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app6/DatabaseLoader.java new file mode 100644 index 000000000..94c9b630c --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app6/DatabaseLoader.java @@ -0,0 +1,55 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app6; + +import org.springframework.boot.CommandLineRunner; +import org.springframework.context.annotation.Bean; +import org.springframework.stereotype.Component; + +/** + * Pre-load some data using a Spring Boot {@link CommandLineRunner}. + * + * @author Greg Turnquist + */ +@Component +class DatabaseLoader { + + /** + * Use Spring to inject a {@link EmployeeRepository} that can then load data. Since this will run only after the app + * is operational, the database will be up. + * + * @param repository + */ + @Bean + CommandLineRunner init(EmployeeRepository repository) { + + return args -> { + repository.save(new Employee("Frodo", "Baggins", "ring bearer")); + repository.save(new Employee("Bilbo", "Baggins", "burglar")); + }; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app6/Employee.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app6/Employee.java new file mode 100644 index 000000000..f3e76b2bd --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app6/Employee.java @@ -0,0 +1,77 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app6; + +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.Id; +import lombok.AccessLevel; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * Domain object representing a company employee. Project Lombok keeps actual code at a minimum. {@code @Data} - + * Generates getters, setters, toString, hash, and equals functions {@code @Entity} - JPA annotation to flag this class + * for DB persistence {@code @NoArgsConstructor} - Create a constructor with no args to support JPA + * {@code @AllArgsConstructor} - Create a constructor with all args to support testing + * {@code @JsonIgnoreProperties(ignoreUnknow=true)} When converting JSON to Java, ignore any unrecognized attributes. + * This is critical for REST because it encourages adding new fields in later versions that won't break. It also allows + * things like _links to be ignore as well, meaning HAL documents can be fetched and later posted to the server without + * adjustment. + * + * @author Greg Turnquist + */ +@Data +@Entity +@NoArgsConstructor(access = AccessLevel.PRIVATE) +@AllArgsConstructor +class Employee { + + @Id + @GeneratedValue + private Long id; + + private String firstName; + + private String lastName; + + private String role; + + /** + * Useful constructor when id is not yet known. + * + * @param firstName + * @param lastName + * @param role + */ + Employee(String firstName, String lastName, String role) { + + this.firstName = firstName; + this.lastName = lastName; + this.role = role; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app6/EmployeeController.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app6/EmployeeController.java new file mode 100644 index 000000000..1be9db363 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app6/EmployeeController.java @@ -0,0 +1,54 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app6; + +import org.springframework.hateoas.EntityModel; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RestController; + +/** + * Spring Web {@link RestController} used to generate a REST API. + * + * @author Greg Turnquist + */ +@RestController +class EmployeeController { + + /** + * Look up a single {@link Employee} and transform it into a REST resource. Then return it through Spring Web's + * {@link ResponseEntity} fluent API. + * + * @param id + */ + @GetMapping("/employees/{id}") + EntityModel findOne(@PathVariable long id) { + + return null; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app6/EmployeeRepository.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app6/EmployeeRepository.java new file mode 100644 index 000000000..d850232ef --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app6/EmployeeRepository.java @@ -0,0 +1,36 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app6; + +import org.springframework.data.repository.CrudRepository; + +/** + * A simple Spring Data {@link CrudRepository} for storing {@link Employee}s. + * + * @author Greg Turnquist + */ +interface EmployeeRepository extends CrudRepository { +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app6/SpringDocApp6Test.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app6/SpringDocApp6Test.java new file mode 100644 index 000000000..886f9105d --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app6/SpringDocApp6Test.java @@ -0,0 +1,37 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app6; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.test.context.TestPropertySource; + +@TestPropertySource(properties = "springdoc.remove-broken-reference-definitions=false") +public class SpringDocApp6Test extends AbstractSpringDocTest { + + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app6/SpringDocTestApp.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app6/SpringDocTestApp.java new file mode 100644 index 000000000..1ec73e3c4 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app6/SpringDocTestApp.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.app6; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; +import org.springframework.hateoas.server.core.EvoInflectorLinkRelationProvider; + +@SpringBootApplication +public class SpringDocTestApp { + + public static void main(String[] args) { + SpringApplication.run(SpringDocTestApp.class, args); + } + + @Bean + EvoInflectorLinkRelationProvider relProvider() { + return new EvoInflectorLinkRelationProvider(); + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app7/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app7/HelloController.java new file mode 100644 index 000000000..cae453e79 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app7/HelloController.java @@ -0,0 +1,47 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app7; + +import java.util.List; + +import jakarta.validation.constraints.NotNull; +import org.springdoc.core.annotations.ParameterObject; + +import org.springframework.data.domain.Pageable; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class HelloController { + + @GetMapping(value = "/search", produces = { "application/xml", "application/json" }) + public ResponseEntity> getAllPets(@NotNull @ParameterObject Pageable pageable) { + return null; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app7/PersonDTO.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app7/PersonDTO.java new file mode 100644 index 000000000..7e66b26a6 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app7/PersonDTO.java @@ -0,0 +1,71 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app7; + +import io.swagger.v3.oas.annotations.media.Schema; + +@Schema +public class PersonDTO { + private String email; + + private String firstName; + + private String lastName; + + public PersonDTO() { + } + + public PersonDTO(final String email, final String firstName, final String lastName) { + this.email = email; + this.firstName = firstName; + this.lastName = lastName; + } + + public String getEmail() { + return email; + } + + public void setEmail(final String email) { + this.email = email; + } + + public String getFirstName() { + return firstName; + } + + public void setFirstName(final String firstName) { + this.firstName = firstName; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(final String lastName) { + this.lastName = lastName; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app7/SpringDocApp7Test.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app7/SpringDocApp7Test.java new file mode 100644 index 000000000..06ee8c982 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app7/SpringDocApp7Test.java @@ -0,0 +1,38 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app7; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp7Test extends AbstractSpringDocTest { + + @SpringBootApplication + static class SpringDocTestApp {} + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app8/Album.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app8/Album.java new file mode 100644 index 000000000..3a3bea5e2 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app8/Album.java @@ -0,0 +1,55 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app8; + +public class Album { + + private String title; + + private String description; + + private String releaseDate; + + public Album(String title, String description, String releaseDate) { + this.title = title; + this.description = description; + this.releaseDate = releaseDate; + } + + public String getTitle() { + return title; + } + + public String getDescription() { + return description; + } + + public String getReleaseDate() { + return releaseDate; + } + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app8/AlbumController.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app8/AlbumController.java new file mode 100644 index 000000000..21a5f0cd1 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app8/AlbumController.java @@ -0,0 +1,58 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app8; + +import java.util.Arrays; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageImpl; +import org.springframework.data.web.PagedResourcesAssembler; +import org.springframework.hateoas.PagedModel; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@SuppressWarnings("unchecked") +public class AlbumController { + + @Autowired + private AlbumModelAssembler albumModelAssembler; + + @Autowired + private PagedResourcesAssembler pagedResourcesAssembler; + + @GetMapping("/api/albums") + public PagedModel getAllAlbums() { + Album album1 = new Album("album-title-1", "album-description-1", "album-release-date-1"); + Album album2 = new Album("album-title-2", "album-description-2", "album-release-date-2"); + Page albumPage = new PageImpl<>(Arrays.asList(album1, album2)); + + return pagedResourcesAssembler.toModel(albumPage, albumModelAssembler); + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app8/AlbumModelAssembler.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app8/AlbumModelAssembler.java new file mode 100644 index 000000000..a68002442 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app8/AlbumModelAssembler.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.app8; + +import java.util.ArrayList; +import java.util.List; + +import org.springframework.hateoas.EntityModel; +import org.springframework.hateoas.Link; +import org.springframework.hateoas.server.RepresentationModelAssembler; +import org.springframework.stereotype.Component; + +@Component +public class AlbumModelAssembler implements RepresentationModelAssembler> { + + @Override + public EntityModel toModel(Album entity) { + List links = new ArrayList<>(); + return EntityModel.of(entity, links); + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app8/SpringDocApp8Test.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app8/SpringDocApp8Test.java new file mode 100644 index 000000000..1b6a8682e --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app8/SpringDocApp8Test.java @@ -0,0 +1,38 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app8; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp8Test extends AbstractSpringDocTest { + + @SpringBootApplication + static class SpringDocTestApp {} + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app9/SpringDocApp9Test.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app9/SpringDocApp9Test.java new file mode 100644 index 000000000..96b79a9a6 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app9/SpringDocApp9Test.java @@ -0,0 +1,79 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app9; + +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; + +import com.fasterxml.jackson.databind.introspect.SimpleMixInResolver; +import com.fasterxml.jackson.databind.type.ClassKey; +import org.apache.commons.lang3.reflect.FieldUtils; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.springdoc.core.providers.ObjectMapperProvider; +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.test.context.TestPropertySource; + +@TestPropertySource(properties = "spring.hateoas.use-hal-as-default-json-media-type= false") +@SuppressWarnings({ "deprecation", "unchecked" }) +public class SpringDocApp9Test extends AbstractSpringDocTest { + + private final Map> springMixins = new HashMap<>(); + + @Autowired + ObjectMapperProvider objectMapperProvider; + + @BeforeEach + void init() throws IllegalAccessException { + SimpleMixInResolver _mixIns = (SimpleMixInResolver) FieldUtils.readDeclaredField(objectMapperProvider.jsonMapper(), "_mixIns", true); + Map> _localMixIns = (Map>) FieldUtils.readDeclaredField(_mixIns, "_localMixIns", true); + Iterator>> it = _localMixIns.entrySet().iterator(); + while (it.hasNext()) { + Map.Entry> entry = it.next(); + if (entry.getKey().toString().startsWith("org.springframework")) { + springMixins.put(entry.getKey(), entry.getValue()); + it.remove(); + } + } + + } + + @AfterEach + void clean() throws IllegalAccessException { + SimpleMixInResolver _mixIns = (SimpleMixInResolver) FieldUtils.readDeclaredField(objectMapperProvider.jsonMapper(), "_mixIns", true); + Map> _localMixIns = (Map>) FieldUtils.readDeclaredField(_mixIns, "_localMixIns", true); + _localMixIns.putAll(springMixins); + } + + @SpringBootApplication + static class SpringDocTestApp {} + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app9/component/controller/ComponentsController.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app9/component/controller/ComponentsController.java new file mode 100644 index 000000000..878c31b11 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app9/component/controller/ComponentsController.java @@ -0,0 +1,104 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app9.component.controller; + + +import java.util.Optional; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springdoc.core.converters.models.PageableAsQueryParam; +import test.org.springdoc.api.v30.app9.component.controller.hateoas.ComponentDtoModelAssembler; +import test.org.springdoc.api.v30.app9.component.dto.DemoComponentDto; +import test.org.springdoc.api.v30.app9.component.dto.converter.DemoComponentConverter; +import test.org.springdoc.api.v30.app9.component.model.DemoComponent; +import test.org.springdoc.api.v30.app9.component.service.ComponentsService; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.data.web.PagedResourcesAssembler; +import org.springframework.hateoas.EntityModel; +import org.springframework.hateoas.PagedModel; +import org.springframework.hateoas.RepresentationModel; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.linkTo; +import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.methodOn; + +@RestController +@RequestMapping(path = "/components", produces = "application/json") +@Tag(name = "components", description = "Everything about components") +public class ComponentsController { + + @Autowired + private ComponentsService componentsService; + + @Autowired + private DemoComponentConverter toDtoConverter; + + @Autowired + private ComponentDtoModelAssembler componentDtoModelAssembler; + + @Autowired + private PagedResourcesAssembler pagedResourcesAssembler; + + @Operation(summary = "List the components") + @PageableAsQueryParam + @GetMapping + public ResponseEntity>>> findAll(@Parameter(hidden = true) Pageable pageable) { + Page results = componentsService.findAll(pageable); + + return ResponseEntity.ok(pagedResourcesAssembler.toModel(results, componentDtoModelAssembler)); + } + + @Operation(summary = "Get one component by its ID", description = "Returns a single component", // + responses = { // + @ApiResponse(responseCode = "200", description = "Component found"), // + @ApiResponse(responseCode = "404", description = "Component not found", content = { @Content(schema = @Schema(implementation = Void.class)) }) // + }) + @GetMapping("/{componentId}") + public ResponseEntity> findById(@PathVariable String componentId) { + Optional foundComponent = componentsService.findById(componentId); + + if (foundComponent.isPresent()) { + return ResponseEntity.ok(EntityModel.of(toDtoConverter.convert(foundComponent.get()), // + linkTo(methodOn(ComponentsController.class).findAll(null)).withRel("components"))); + } + + return ResponseEntity.notFound().location(linkTo(methodOn(ComponentsController.class).findAll(null)).toUri()).build(); + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app9/component/controller/hateoas/ComponentDtoModelAssembler.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app9/component/controller/hateoas/ComponentDtoModelAssembler.java new file mode 100644 index 000000000..f9b2b5497 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app9/component/controller/hateoas/ComponentDtoModelAssembler.java @@ -0,0 +1,52 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app9.component.controller.hateoas; + + +import test.org.springdoc.api.v30.app9.component.dto.DemoComponentDto; +import test.org.springdoc.api.v30.app9.component.dto.converter.DemoComponentConverter; +import test.org.springdoc.api.v30.app9.component.model.DemoComponent; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.hateoas.EntityModel; +import org.springframework.hateoas.RepresentationModel; +import org.springframework.hateoas.server.RepresentationModelAssembler; +import org.springframework.stereotype.Component; + +@Component +@SuppressWarnings({ "deprecation", "unchecked" }) +public class ComponentDtoModelAssembler implements RepresentationModelAssembler>> { + + @Autowired + private DemoComponentConverter toDtoConverter; + + @Override + public RepresentationModel> toModel(DemoComponent entity) { + return EntityModel.of(toDtoConverter.convert(entity)); + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app9/component/controller/hateoas/DemoComponentDtoModelProcessor.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app9/component/controller/hateoas/DemoComponentDtoModelProcessor.java new file mode 100644 index 000000000..b555eb898 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app9/component/controller/hateoas/DemoComponentDtoModelProcessor.java @@ -0,0 +1,52 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app9.component.controller.hateoas; + + +import test.org.springdoc.api.v30.app9.component.controller.ComponentsController; +import test.org.springdoc.api.v30.app9.component.dto.DemoComponentDto; + +import org.springframework.hateoas.EntityModel; +import org.springframework.hateoas.server.RepresentationModelProcessor; +import org.springframework.stereotype.Component; + +import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.linkTo; +import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.methodOn; + +@Component +public class DemoComponentDtoModelProcessor implements RepresentationModelProcessor> { + + @Override + public EntityModel process(EntityModel model) { + final String id = model.getContent().getId(); + + model.add(linkTo(methodOn(ComponentsController.class).findById(id)).withSelfRel()); + + return model; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app9/component/dto/DemoComponentDto.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app9/component/dto/DemoComponentDto.java new file mode 100644 index 000000000..a4ba03883 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app9/component/dto/DemoComponentDto.java @@ -0,0 +1,51 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app9.component.dto; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import org.springframework.hateoas.server.core.Relation; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@Relation(collectionRelation = "components") +@Schema(description = "A demo component to illustrate Springdoc Issue #401") +public final class DemoComponentDto { + + @Schema(description = "Some ID", example = "1") + private String id; + + @Schema(description = "Some dummy payload", example = "Hello World") + private String payload; + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app9/component/dto/converter/DemoComponentConverter.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app9/component/dto/converter/DemoComponentConverter.java new file mode 100644 index 000000000..046747a19 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app9/component/dto/converter/DemoComponentConverter.java @@ -0,0 +1,51 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app9.component.dto.converter; + + +import test.org.springdoc.api.v30.app9.component.dto.DemoComponentDto; +import test.org.springdoc.api.v30.app9.component.model.DemoComponent; +import test.org.springdoc.api.v30.app9.utils.Converter; + +import org.springframework.stereotype.Component; + +@Component +public class DemoComponentConverter implements Converter { + + @Override + public DemoComponentDto convert(DemoComponent source) { + if (source == null) { + return null; + } + + return DemoComponentDto.builder() // + .id(source.getId()) // + .payload(source.getPayload()) // + .build(); + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app9/component/model/DemoComponent.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app9/component/model/DemoComponent.java new file mode 100644 index 000000000..900153f3c --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app9/component/model/DemoComponent.java @@ -0,0 +1,47 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app9.component.model; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import org.springframework.data.annotation.Id; + +@Data +@Builder +@AllArgsConstructor +@EqualsAndHashCode +public class DemoComponent { + + @Id + private String id; + + private String payload; + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app9/component/service/ComponentsService.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app9/component/service/ComponentsService.java new file mode 100644 index 000000000..b162699d0 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app9/component/service/ComponentsService.java @@ -0,0 +1,54 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app9.component.service; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.Map; +import java.util.Optional; + +import test.org.springdoc.api.v30.app9.component.model.DemoComponent; + +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageImpl; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Service; + +@Service +public class ComponentsService { + + private static final Map repo = Collections.singletonMap("1", DemoComponent.builder().id("1").payload("Hello World !").build()); + + public Optional findById(String componentId) { + return Optional.ofNullable(repo.get(componentId)); + } + + public Page findAll(Pageable pageable) { + return new PageImpl(new ArrayList<>(repo.values()), pageable, repo.size()); + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app9/core/config/OpenAPIConfiguration.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app9/core/config/OpenAPIConfiguration.java new file mode 100644 index 000000000..946a7e170 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app9/core/config/OpenAPIConfiguration.java @@ -0,0 +1,44 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app9.core.config; + +import io.swagger.v3.oas.annotations.OpenAPIDefinition; +import io.swagger.v3.oas.annotations.info.Info; + +import org.springframework.stereotype.Component; + +@Component +@OpenAPIDefinition( // + info = @Info( // + title = "Demo Springdoc Issue #401", // + version = "0.0.1-SNAPSHOT", // + description = "A demo API to illustrate Springdoc Issue #401." // + ) // +) +public class OpenAPIConfiguration { + // NO-OP +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app9/core/config/SpringRestConfiguration.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app9/core/config/SpringRestConfiguration.java new file mode 100644 index 000000000..d0a1f9751 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app9/core/config/SpringRestConfiguration.java @@ -0,0 +1,42 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app9.core.config; + +import org.springframework.context.annotation.Configuration; +import org.springframework.data.rest.core.config.RepositoryRestConfiguration; +import org.springframework.data.rest.webmvc.config.RepositoryRestConfigurer; +import org.springframework.http.MediaType; +import org.springframework.web.servlet.config.annotation.CorsRegistry; + +@Configuration +public class SpringRestConfiguration implements RepositoryRestConfigurer { + @Override + public void configureRepositoryRestConfiguration(RepositoryRestConfiguration config, CorsRegistry cors) { + config.setDefaultMediaType(MediaType.APPLICATION_JSON); + config.useHalAsDefaultJsonMediaType(false); + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app9/core/config/WebMvcConfiguration.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app9/core/config/WebMvcConfiguration.java new file mode 100644 index 000000000..d04900fec --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app9/core/config/WebMvcConfiguration.java @@ -0,0 +1,57 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app9.core.config; + +import org.springframework.boot.convert.ApplicationConversionService; +import org.springframework.context.annotation.Configuration; +import org.springframework.format.FormatterRegistry; +import org.springframework.web.servlet.config.annotation.CorsRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; + +import static org.springdoc.core.utils.Constants.ALL_PATTERN; + +@Configuration +public class WebMvcConfiguration implements WebMvcConfigurer { + + private final long MAX_AGE_SECS = 3600; + + @Override + public void addCorsMappings(CorsRegistry registry) { + registry.addMapping(ALL_PATTERN) // + .allowedOrigins("http://localhost") // + .allowedMethods("GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS") // + .allowedHeaders("*") // + .allowCredentials(true) // + .maxAge(MAX_AGE_SECS); + } + + @Override + public void addFormatters(FormatterRegistry registry) { + ApplicationConversionService.configure(registry); + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app9/core/exception/BadArgumentException.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app9/core/exception/BadArgumentException.java new file mode 100644 index 000000000..16e450418 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app9/core/exception/BadArgumentException.java @@ -0,0 +1,41 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app9.core.exception; + +import org.springframework.http.HttpStatus; +import org.springframework.web.bind.annotation.ResponseStatus; + +@ResponseStatus(value = HttpStatus.BAD_REQUEST) +public class BadArgumentException extends Exception { + + private static final long serialVersionUID = -4975801683971908022L; + + public BadArgumentException(String message) { + super(message); + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app9/core/exception/BusinessException.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app9/core/exception/BusinessException.java new file mode 100644 index 000000000..b71019f31 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app9/core/exception/BusinessException.java @@ -0,0 +1,37 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app9.core.exception; + +public class BusinessException extends Exception { + + private static final long serialVersionUID = -5454643285401132760L; + + public BusinessException(String message) { + super(message); + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app9/core/model/ExceptionDto.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app9/core/model/ExceptionDto.java new file mode 100644 index 000000000..1b66c28ba --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app9/core/model/ExceptionDto.java @@ -0,0 +1,52 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app9.core.model; + +import java.time.Instant; + +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotEmpty; +import jakarta.validation.constraints.NotNull; +import lombok.Data; +import lombok.NonNull; + +@Data +public class ExceptionDto { + + @NonNull + @NotNull + @NotEmpty + @Schema(description = "The date and time the problem occured", example = "2020-02-04T13:21:08.098+0000", type = "string", format = "date-time") + private Instant timestamp; + + @Schema(description = "The exception class", example = "com.it4it.it4data.newdata.dataplatform.portal.api.core.exception.BadArgumentException") + private String exception; + + @Schema(description = "The exception message", example = "Trying to update a non existing component !") + private String message; + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app9/utils/Converter.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app9/utils/Converter.java new file mode 100644 index 000000000..9ab47120c --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v30/app9/utils/Converter.java @@ -0,0 +1,33 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app9.utils; + +public interface Converter { + + T convert(S source); + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/AbstractSpringDocTest.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/AbstractSpringDocTest.java new file mode 100644 index 000000000..a88d3265e --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/AbstractSpringDocTest.java @@ -0,0 +1,83 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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; + +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; + +import org.junit.jupiter.api.Test; +import org.springdoc.core.utils.Constants; + +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.web.servlet.MockMvc; +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; + +@ActiveProfiles("test") +@SpringBootTest +@AutoConfigureMockMvc +public abstract class AbstractSpringDocTest { + + public static String className; + + @Autowired + protected MockMvc mockMvc; + + public static String getContent(String fileName) { + try { + Path path = Paths.get(AbstractSpringDocTest.class.getClassLoader().getResource(fileName).toURI()); + byte[] fileBytes = Files.readAllBytes(path); + return new String(fileBytes, StandardCharsets.UTF_8); + } + catch (Exception e) { + throw new RuntimeException("Failed to read file: " + fileName, e); + } + } + + @Test + void testApp() throws Exception { + className = getClass().getSimpleName(); + String testNumber = className.replaceAll("[^0-9]", ""); + MvcResult mockMvcResult = mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL)).andExpect(status().isOk()) + .andExpect(jsonPath("$.openapi", is("3.1.0"))).andReturn(); + String result = mockMvcResult.getResponse().getContentAsString(); + Path path = Paths.get(getClass().getClassLoader().getResource("results/3.1.0/app" + testNumber + ".json").toURI()); + byte[] fileBytes = Files.readAllBytes(path); + String expected = new String(fileBytes); + assertEquals(expected, result, true); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app10/Account.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app10/Account.java new file mode 100644 index 000000000..fe913cdcc --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app10/Account.java @@ -0,0 +1,63 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app10; + +import java.util.Date; + +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.Temporal; +import jakarta.persistence.TemporalType; + +@Entity +public class Account { + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private Long id; + + @ManyToOne + private Customer customer; + + @Temporal(TemporalType.DATE) + private Date expiryDate; + + public Long getId() { + return id; + } + + public Customer getCustomer() { + return customer; + } + + public Date getExpiryDate() { + return expiryDate; + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app10/AccountRepository.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app10/AccountRepository.java new file mode 100644 index 000000000..2ad726fb0 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app10/AccountRepository.java @@ -0,0 +1,50 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app10; + + +import java.util.List; + +import org.springframework.data.repository.CrudRepository; +import org.springframework.data.repository.query.Param; +import org.springframework.data.rest.core.annotation.RepositoryRestResource; + +/** + * Repository to manage {@link Account} instances. + * + */ +@RepositoryRestResource +public interface AccountRepository extends CrudRepository { + + /** + * Returns all accounts belonging to the given {@link Customer}. + * + * @param customer + * @return + */ + List findByCustomer(@Param("customer") Customer customer); +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app10/Customer.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app10/Customer.java new file mode 100644 index 000000000..f0263d37d --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app10/Customer.java @@ -0,0 +1,60 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app10; + + +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; + +/** + * @author Oliver Gierke + */ +@Entity +public class Customer { + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private Long id; + + private String firstname; + + private String lastname; + + public Long getId() { + return id; + } + + public String getFirstname() { + return firstname; + } + + public String getLastname() { + return lastname; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app10/CustomerRepository.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app10/CustomerRepository.java new file mode 100644 index 000000000..9b6f89670 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app10/CustomerRepository.java @@ -0,0 +1,76 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app10; + +import java.util.List; +import java.util.Optional; + +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.data.jpa.repository.JpaSpecificationExecutor; +import org.springframework.data.repository.CrudRepository; +import org.springframework.data.repository.query.Param; +import org.springframework.data.rest.core.annotation.RepositoryRestResource; +import org.springframework.data.rest.core.annotation.RestResource; + +/** + * Repository to manage {@link Customer} instances. + * + * @author Oliver Gierke + */ +@RepositoryRestResource +public interface CustomerRepository extends CrudRepository, JpaSpecificationExecutor { + + /** + * Returns a page of {@link Customer}s with the given lastname. + * + * @param lastname + * @param pageable + * @return + */ + Page findByLastname(@Param("lastname") String lastname, Pageable pageable); + + @Override + @RestResource(exported = false) + void deleteById(Long id); + + @Override + @RestResource(exported = false) + void delete(Customer entity); + + @Override + @RestResource + List findAll(); + + @Override + @RestResource(exported = false) + Optional findById(Long aLong); + + @Override + @RestResource(exported = false) + S save(S entity); +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app10/SpringDocApp10Test.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app10/SpringDocApp10Test.java new file mode 100644 index 000000000..f2b91c7a5 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app10/SpringDocApp10Test.java @@ -0,0 +1,37 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app10; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp10Test extends AbstractSpringDocTest { + + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app11/Person.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app11/Person.java new file mode 100644 index 000000000..92905ae73 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app11/Person.java @@ -0,0 +1,60 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app11; + +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; + +@Entity +public class Person { + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private long id; + + private String firstName; + + private String lastName; + + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app11/PersonRepository.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app11/PersonRepository.java new file mode 100644 index 000000000..f1aed0151 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app11/PersonRepository.java @@ -0,0 +1,40 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app11; + +import java.util.List; + +import org.springframework.data.repository.PagingAndSortingRepository; +import org.springframework.data.repository.query.Param; +import org.springframework.data.rest.core.annotation.RepositoryRestResource; + +@RepositoryRestResource(collectionResourceRel = "people", path = "peopleme") +public interface PersonRepository extends PagingAndSortingRepository { + + List findByLastName(@Param("name") String name); + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app11/SpringDocApp11Test.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app11/SpringDocApp11Test.java new file mode 100644 index 000000000..4411b7abd --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app11/SpringDocApp11Test.java @@ -0,0 +1,37 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app11; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp11Test extends AbstractSpringDocTest { + + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app12/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app12/HelloController.java new file mode 100644 index 000000000..f8169da98 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app12/HelloController.java @@ -0,0 +1,85 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app12; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; + +import org.springframework.hateoas.EntityModel; +import org.springframework.hateoas.MediaTypes; +import org.springframework.hateoas.server.mvc.WebMvcLinkBuilder; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + + +@RequestMapping("/demo") +@RestController +public class HelloController { + + @Operation(summary = "GetMyData", operationId = "gettt", + responses = @ApiResponse(responseCode = "204", + content = @Content(mediaType = "application/vnd.something"))) + @GetMapping(produces = "application/vnd.something") + public ResponseEntity getSomethingElse() { + return ResponseEntity.noContent().build(); + } + + @GetMapping(produces = MediaType.TEXT_PLAIN_VALUE) + public String get() { + return "some text"; + } + + @GetMapping(produces = MediaTypes.HAL_JSON_VALUE) + public EntityModel getHal() { + return EntityModel.of(new JsonResponse(), + WebMvcLinkBuilder.linkTo(HelloController.class).slash("somelink").withSelfRel() + ); + } + + @GetMapping(produces = MediaType.APPLICATION_JSON_VALUE) + public JsonResponse getJson() { + return new JsonResponse(); + } + + @GetMapping(produces = MediaType.APPLICATION_XML_VALUE) + @ApiResponse(responseCode = "202", + content = @Content(mediaType = MediaType.APPLICATION_XML_VALUE, schema = @Schema(implementation = JsonResponse.class))) + public JsonResponse getXML() { + return new JsonResponse(); + } + + public class JsonResponse { + @JsonProperty + private String field; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app12/SpringDocApp12Test.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app12/SpringDocApp12Test.java new file mode 100644 index 000000000..0cd6ffdb2 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app12/SpringDocApp12Test.java @@ -0,0 +1,51 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app12; + +import io.swagger.v3.oas.models.Operation; +import org.springdoc.core.customizers.OperationCustomizer; +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; +import org.springframework.web.method.HandlerMethod; + +public class SpringDocApp12Test extends AbstractSpringDocTest { + + @SpringBootApplication + static class SpringDocTestApp { + @Bean + OperationCustomizer operationCustomizer() { + return (Operation operation, HandlerMethod handlerMethod) -> { + if (operation.getOperationId().startsWith("gettt")) + operation.setOperationId("gettt"); + return operation; + }; + } + } + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app13/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app13/HelloController.java new file mode 100644 index 000000000..fe7d3a85b --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app13/HelloController.java @@ -0,0 +1,84 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app13; + +import java.util.List; + +import org.springdoc.core.annotations.ParameterObject; + +import org.springframework.data.domain.Pageable; +import org.springframework.data.domain.Sort.Direction; +import org.springframework.data.web.PageableDefault; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class HelloController { + + @GetMapping(value = "/search", produces = { "application/xml", "application/json" }) + public ResponseEntity> getAllPets(@PageableDefault(size = 5, sort = "name") @ParameterObject Pageable pageable) { + return null; + } + + + @GetMapping("/test1") + public String getPatientList1(@PageableDefault(size = 100, sort = { "someField", "someoTHER" }, + direction = Direction.DESC) + @ParameterObject Pageable pageable) { + return "bla"; + } + + @GetMapping("/test2") + public String getPatientList2(@PageableDefault(size = 100, sort = "someField", + direction = Direction.DESC) + @ParameterObject Pageable pageable) { + return "bla"; + } + + @GetMapping("/test3") + public String getPatientList3(@PageableDefault(size = 100) + @ParameterObject Pageable pageable) { + return "bla"; + } + + @GetMapping("/test4") + public String getPatientList4(@PageableDefault(100) + @ParameterObject Pageable pageable) { + return "bla"; + } + + @GetMapping("/test5") + public void read( + @PageableDefault(sort = { + "some,desc", + "other,asc", + "another.that,desc" + }) + @ParameterObject final Pageable pageable) { + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app13/PersonDTO.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app13/PersonDTO.java new file mode 100644 index 000000000..6ec5d1458 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app13/PersonDTO.java @@ -0,0 +1,71 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app13; + +import io.swagger.v3.oas.annotations.media.Schema; + +@Schema +public class PersonDTO { + private String email; + + private String firstName; + + private String lastName; + + public PersonDTO() { + } + + public PersonDTO(final String email, final String firstName, final String lastName) { + this.email = email; + this.firstName = firstName; + this.lastName = lastName; + } + + public String getEmail() { + return email; + } + + public void setEmail(final String email) { + this.email = email; + } + + public String getFirstName() { + return firstName; + } + + public void setFirstName(final String firstName) { + this.firstName = firstName; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(final String lastName) { + this.lastName = lastName; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app13/SpringDocApp13Test.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app13/SpringDocApp13Test.java new file mode 100644 index 000000000..9b149c949 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app13/SpringDocApp13Test.java @@ -0,0 +1,38 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app13; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp13Test extends AbstractSpringDocTest { + + @SpringBootApplication + static class SpringDocTestApp {} + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app14/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app14/HelloController.java new file mode 100644 index 000000000..743ad62f6 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app14/HelloController.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.app14; + +import java.util.List; + +import org.springdoc.core.annotations.ParameterObject; + +import org.springframework.data.domain.Pageable; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class HelloController { + + @GetMapping(value = "/search", produces = { "application/xml", "application/json" }) + public ResponseEntity> getAllPets(@ParameterObject Pageable pageable) { + return null; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app14/PersonDTO.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app14/PersonDTO.java new file mode 100644 index 000000000..2cbe843e9 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app14/PersonDTO.java @@ -0,0 +1,71 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app14; + +import io.swagger.v3.oas.annotations.media.Schema; + +@Schema +public class PersonDTO { + private String email; + + private String firstName; + + private String lastName; + + public PersonDTO() { + } + + public PersonDTO(final String email, final String firstName, final String lastName) { + this.email = email; + this.firstName = firstName; + this.lastName = lastName; + } + + public String getEmail() { + return email; + } + + public void setEmail(final String email) { + this.email = email; + } + + public String getFirstName() { + return firstName; + } + + public void setFirstName(final String firstName) { + this.firstName = firstName; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(final String lastName) { + this.lastName = lastName; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app14/SpringDocApp14Test.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app14/SpringDocApp14Test.java new file mode 100644 index 000000000..8a0f23df3 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app14/SpringDocApp14Test.java @@ -0,0 +1,67 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app14; + +import java.util.Optional; + +import org.springdoc.core.configuration.SpringDocDataRestConfiguration; +import org.springdoc.core.customizers.DataRestDelegatingMethodParameterCustomizer; +import org.springdoc.core.providers.RepositoryRestConfigurationProvider; +import org.springdoc.core.providers.SpringDataWebPropertiesProvider; +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.data.rest.RepositoryRestMvcAutoConfiguration; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Lazy; +import org.springframework.test.context.TestPropertySource; + +@TestPropertySource(properties = { "spring.data.web.pageable.default-page-size=25", + "spring.data.web.pageable.page-parameter=pages", + "spring.data.web.pageable.size-parameter=sizes", + "spring.data.web.pageable.one-indexed-parameters=true", + "spring.data.web.pageable.prefix=prefix_", + "spring.data.web.sort.sort-parameter=sorts" }) +@EnableAutoConfiguration(exclude = { + RepositoryRestMvcAutoConfiguration.class, SpringDocDataRestConfiguration.class +}) +public class SpringDocApp14Test extends AbstractSpringDocTest { + + @SpringBootApplication + static class SpringDocTestApp { + // We only need to test spring-web with Pageable, without the use of spring-data-rest-starter + @Bean + @ConditionalOnMissingBean + @Lazy(false) + DataRestDelegatingMethodParameterCustomizer dataRestDelegatingMethodParameterCustomizer(Optional optionalSpringDataWebPropertiesProvider, Optional optionalRepositoryRestConfiguration) { + return new DataRestDelegatingMethodParameterCustomizer(optionalSpringDataWebPropertiesProvider, optionalRepositoryRestConfiguration); + } + } + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app15/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app15/HelloController.java new file mode 100644 index 000000000..4a877d43c --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app15/HelloController.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.app15; + +import java.util.List; + +import org.springdoc.core.annotations.ParameterObject; + +import org.springframework.data.domain.Pageable; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class HelloController { + + @GetMapping(value = "/search", produces = { "application/xml", "application/json" }) + public ResponseEntity> getAllPets(@ParameterObject Pageable pageable) { + return null; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app15/PersonDTO.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app15/PersonDTO.java new file mode 100644 index 000000000..076f6332d --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app15/PersonDTO.java @@ -0,0 +1,71 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app15; + +import io.swagger.v3.oas.annotations.media.Schema; + +@Schema +public class PersonDTO { + private String email; + + private String firstName; + + private String lastName; + + public PersonDTO() { + } + + public PersonDTO(final String email, final String firstName, final String lastName) { + this.email = email; + this.firstName = firstName; + this.lastName = lastName; + } + + public String getEmail() { + return email; + } + + public void setEmail(final String email) { + this.email = email; + } + + public String getFirstName() { + return firstName; + } + + public void setFirstName(final String firstName) { + this.firstName = firstName; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(final String lastName) { + this.lastName = lastName; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app15/SpringDocApp15Test.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app15/SpringDocApp15Test.java new file mode 100644 index 000000000..38df23261 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app15/SpringDocApp15Test.java @@ -0,0 +1,40 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app15; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.test.context.TestPropertySource; + +@TestPropertySource(properties = "spring.data.rest.default-page-size=50") +public class SpringDocApp15Test extends AbstractSpringDocTest { + + @SpringBootApplication + static class SpringDocTestApp {} + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app16/Account.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app16/Account.java new file mode 100644 index 000000000..1eaf072a7 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app16/Account.java @@ -0,0 +1,63 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app16; + +import java.util.Date; + +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.Temporal; +import jakarta.persistence.TemporalType; + +@Entity +public class Account { + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private Long id; + + @ManyToOne + private Customer customer; + + @Temporal(TemporalType.DATE) + private Date expiryDate; + + public Long getId() { + return id; + } + + public Customer getCustomer() { + return customer; + } + + public Date getExpiryDate() { + return expiryDate; + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app16/AccountRepository.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app16/AccountRepository.java new file mode 100644 index 000000000..84d138196 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app16/AccountRepository.java @@ -0,0 +1,55 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app16; + + +import java.util.List; + +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.tags.Tag; + +import org.springframework.data.repository.CrudRepository; +import org.springframework.data.repository.query.Param; +import org.springframework.data.rest.core.annotation.RepositoryRestResource; + +/** + * Repository to manage {@link Account} instances. + * + */ +@RepositoryRestResource +@Tag(name = "The account Repository") +@SecurityRequirement(name = "bearer") +public interface AccountRepository extends CrudRepository { + + /** + * Returns all accounts belonging to the given {@link Customer}. + * + * @param customer + * @return + */ + List findByCustomer(@Param("customer") Customer customer); +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app16/Customer.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app16/Customer.java new file mode 100644 index 000000000..2c674c95a --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app16/Customer.java @@ -0,0 +1,60 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app16; + + +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; + +/** + * @author Oliver Gierke + */ +@Entity +public class Customer { + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private Long id; + + private String firstname; + + private String lastname; + + public Long getId() { + return id; + } + + public String getFirstname() { + return firstname; + } + + public String getLastname() { + return lastname; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app16/CustomerRepository.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app16/CustomerRepository.java new file mode 100644 index 000000000..5ce219160 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app16/CustomerRepository.java @@ -0,0 +1,66 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app16; + +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.tags.Tag; + +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.data.jpa.repository.JpaSpecificationExecutor; +import org.springframework.data.repository.CrudRepository; +import org.springframework.data.repository.query.Param; +import org.springframework.data.rest.core.annotation.RepositoryRestResource; +import org.springframework.data.rest.core.annotation.RestResource; + +/** + * Repository to manage {@link Customer} instances. + * + * @author Oliver Gierke + */ +@RepositoryRestResource +@Tag(name = "The customer Repository") +public interface CustomerRepository extends CrudRepository, JpaSpecificationExecutor { + + /** + * Returns a page of {@link Customer}s with the given lastname. + * + * @param lastname + * @param pageable + * @return + */ + @SecurityRequirement(name = "bearer") + Page findByLastname(@Param("lastname") String lastname, Pageable pageable); + + @Override + @RestResource(exported = false) + void deleteById(Long id); + + @Override + @RestResource(exported = false) + void delete(Customer entity); +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app16/OpenApiConfig.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app16/OpenApiConfig.java new file mode 100644 index 000000000..2b8d31e10 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app16/OpenApiConfig.java @@ -0,0 +1,38 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app16; + +import io.swagger.v3.oas.annotations.OpenAPIDefinition; +import io.swagger.v3.oas.annotations.enums.SecuritySchemeType; +import io.swagger.v3.oas.annotations.info.Info; +import io.swagger.v3.oas.annotations.info.License; +import io.swagger.v3.oas.annotations.security.SecurityScheme; + +@OpenAPIDefinition(info = @Info(title = "My App", description = "Some long and useful description", version = "v1", license = @License(name = "Apache 2.0", url = "https://www.apache.org/licenses/LICENSE-2.0"))) +@SecurityScheme(name = "bearer", type = SecuritySchemeType.HTTP, scheme = "bearer", bearerFormat = "JWT") +public class OpenApiConfig { +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app16/SpringDocApp16Test.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app16/SpringDocApp16Test.java new file mode 100644 index 000000000..ac798f879 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app16/SpringDocApp16Test.java @@ -0,0 +1,49 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app16; + +import io.swagger.v3.oas.models.Operation; +import org.springdoc.core.customizers.DataRestRouterOperationCustomizer; +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; + +public class SpringDocApp16Test extends AbstractSpringDocTest { + + @SpringBootApplication + static class SpringDocTestApp { + @Bean + public DataRestRouterOperationCustomizer addRouterOperationCustomizer() { + return (routerOperation) -> { + Operation operation = routerOperation.getOperationModel(); + operation.setSummary(operation.getOperationId()); + return routerOperation; + }; + } + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app17/ChildProperty.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app17/ChildProperty.java new file mode 100644 index 000000000..6863c34a4 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app17/ChildProperty.java @@ -0,0 +1,60 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app17; + +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import lombok.Data; + +@Entity +public @Data +class ChildProperty { + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private long id; + + private String name; + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app17/ChildPropertyRepository.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app17/ChildPropertyRepository.java new file mode 100644 index 000000000..7c5918285 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app17/ChildPropertyRepository.java @@ -0,0 +1,32 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app17; + +import org.springframework.data.repository.PagingAndSortingRepository; + +public interface ChildPropertyRepository extends PagingAndSortingRepository { +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app17/Property.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app17/Property.java new file mode 100644 index 000000000..d45816636 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app17/Property.java @@ -0,0 +1,74 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app17; + +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; +import lombok.Data; + +@Entity +public @Data +class Property { + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private long id; + + private String name; + + @ManyToOne + @JoinColumn(name = "child_property_id") + private ChildProperty myChildPropertyName; + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public ChildProperty getMyChildPropertyName() { + return myChildPropertyName; + } + + public void setMyChildPropertyName(ChildProperty myChildPropertyName) { + this.myChildPropertyName = myChildPropertyName; + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app17/PropertyRepository.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app17/PropertyRepository.java new file mode 100644 index 000000000..a7311f867 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app17/PropertyRepository.java @@ -0,0 +1,32 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app17; + +import org.springframework.data.repository.PagingAndSortingRepository; + +public interface PropertyRepository extends PagingAndSortingRepository { +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app17/SpringDocApp17Test.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app17/SpringDocApp17Test.java new file mode 100644 index 000000000..3af44ad26 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app17/SpringDocApp17Test.java @@ -0,0 +1,37 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app17; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp17Test extends AbstractSpringDocTest { + + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app18/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app18/HelloController.java new file mode 100644 index 000000000..e002a40ae --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app18/HelloController.java @@ -0,0 +1,53 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app18; + +import io.swagger.v3.oas.annotations.Operation; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.validation.Valid; +import org.springdoc.core.annotations.ParameterObject; + +import org.springframework.http.MediaType; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@Validated +@RestController +@RequestMapping(value = { HelloController.VERSION + "/helloWorld", "latest/helloWorld" }, produces = MediaType.APPLICATION_JSON_VALUE) +public class HelloController { + + public static final String VERSION = "v1"; + + @Operation(summary = "Example endpoint") + @GetMapping("/helloWorld") + public HelloWorldModel helloWorld(@Valid @ParameterObject HelloWorldModel helloWorldModel, HttpServletRequest request) { + return new HelloWorldModel(); + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app18/HelloWorldModel.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app18/HelloWorldModel.java new file mode 100644 index 000000000..05f3826f2 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app18/HelloWorldModel.java @@ -0,0 +1,63 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app18; + +import java.time.LocalDate; + +import io.swagger.v3.oas.annotations.Parameter; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; + +import org.springframework.format.annotation.DateTimeFormat; + +public class HelloWorldModel { + + @Parameter(description = "Description for abc", example = "def") + @NotBlank + private String abc; + + @Parameter(description = "Description of this date", example = "2020-10-25") + @NotNull + @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) + private LocalDate thisDate; + + public String getAbc() { + return abc; + } + + public void setAbc(String abc) { + this.abc = abc; + } + + public LocalDate getThisDate() { + return thisDate; + } + + public void setThisDate(LocalDate thisDate) { + this.thisDate = thisDate; + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app18/SpringDocApp18Test.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app18/SpringDocApp18Test.java new file mode 100644 index 000000000..650852c30 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app18/SpringDocApp18Test.java @@ -0,0 +1,37 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app18; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp18Test extends AbstractSpringDocTest { + + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app19/Application.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app19/Application.java new file mode 100644 index 000000000..001818afe --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app19/Application.java @@ -0,0 +1,106 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app19; + +import java.io.Serializable; +import java.time.LocalDateTime; + +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.EntityListeners; +import jakarta.persistence.EnumType; +import jakarta.persistence.Enumerated; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.Id; +import jakarta.persistence.Table; +import lombok.Data; + +import org.springframework.data.annotation.CreatedDate; +import org.springframework.data.jpa.domain.support.AuditingEntityListener; + +@Data +@Entity +@Table(schema = "application", name = "application") +@Schema(description = "app") +@EntityListeners(AuditingEntityListener.class) +public class Application implements Serializable { + private static final long serialVersionUID = 6582562282311194139L; + + @Id + @Column(length = 64) + @GeneratedValue + @Schema(description = "id") + private String id; + + @Column(nullable = false, length = 64) + @Schema(description = "name") + private String name; + + @Column(length = 1024) + @Schema(description = "description") + private String description; + + @Column(length = 32) + @Schema(description = "app type") + @Enumerated(EnumType.STRING) + private AppType type = AppType.EXTERNAL; + + @Column + @Schema(description = "icon") + private String icon; + + @Column(nullable = false) + @CreatedDate + @Schema(description = "createTime") + private LocalDateTime createTime; + + @Column(length = 1024) + @Schema(description = "rsa-publicKey") + private String publicKey; + + @Column(length = 16, nullable = false) + @Enumerated(EnumType.STRING) + @Schema(description = "status") + private AuditStatus auditStatus = AuditStatus.UN_SUBMITTED; + + @Column + @Schema(description = "auditTime") + private LocalDateTime auditTime; + + public enum AuditStatus { + UN_SUBMITTED, + PENDING, + APPROVED, + FAILED + } + + public enum AppType { + INNER, + EXTERNAL + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app19/ApplicationPredicate.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app19/ApplicationPredicate.java new file mode 100644 index 000000000..4ddae77e0 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app19/ApplicationPredicate.java @@ -0,0 +1,44 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app19; + +import com.querydsl.core.types.dsl.StringExpression; + +import org.springframework.data.querydsl.binding.QuerydslBinderCustomizer; +import org.springframework.data.querydsl.binding.QuerydslBindings; + +public class ApplicationPredicate implements QuerydslBinderCustomizer { + + @Override + public void customize(QuerydslBindings bindings, QApplication root) { + bindings.excludeUnlistedProperties(true); + bindings.bind(root.name).first(StringExpression::containsIgnoreCase); + bindings.including(root.icon); + bindings.including(root.name); + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app19/GreetingController.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app19/GreetingController.java new file mode 100644 index 000000000..df13412e1 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app19/GreetingController.java @@ -0,0 +1,45 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app19; + +import com.querydsl.core.types.Predicate; + +import org.springframework.data.querydsl.binding.QuerydslPredicate; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class GreetingController { + + @GetMapping("/test2") + public ResponseEntity sayHello2(@QuerydslPredicate(root = Application.class, bindings = ApplicationPredicate.class) Predicate predicate, + @RequestParam String test) { + return ResponseEntity.ok().build(); + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app19/QApplication.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app19/QApplication.java new file mode 100644 index 000000000..b4894fa2b --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app19/QApplication.java @@ -0,0 +1,81 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app19; + +import com.querydsl.core.types.Path; +import com.querydsl.core.types.PathMetadata; +import com.querydsl.core.types.dsl.DateTimePath; +import com.querydsl.core.types.dsl.EntityPathBase; +import com.querydsl.core.types.dsl.EnumPath; +import com.querydsl.core.types.dsl.StringPath; +import jakarta.annotation.Generated; + +import static com.querydsl.core.types.PathMetadataFactory.forVariable; + + +/** + * QApplication is a Querydsl query type for Application + */ +@Generated("com.querydsl.codegen.EntitySerializer") +public class QApplication extends EntityPathBase { + + public static final QApplication application = new QApplication("application"); + + private static final long serialVersionUID = 2120388982L; + + public final EnumPath auditStatus = createEnum("auditStatus", Application.AuditStatus.class); + + public final DateTimePath auditTime = createDateTime("auditTime", java.time.LocalDateTime.class); + + public final DateTimePath createTime = createDateTime("createTime", java.time.LocalDateTime.class); + + public final StringPath description = createString("description"); + + public final StringPath icon = createString("icon"); + + public final StringPath id = createString("id"); + + public final StringPath name = createString("name"); + + public final StringPath publicKey = createString("publicKey"); + + public final EnumPath type = createEnum("type", Application.AppType.class); + + public QApplication(String variable) { + super(Application.class, forVariable(variable)); + } + + public QApplication(Path path) { + super(path.getType(), path.getMetadata()); + } + + public QApplication(PathMetadata metadata) { + super(Application.class, metadata); + } + +} + diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app19/SpringDocApp19Test.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app19/SpringDocApp19Test.java new file mode 100644 index 000000000..1885539f0 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app19/SpringDocApp19Test.java @@ -0,0 +1,37 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app19; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp19Test extends AbstractSpringDocTest { + + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app2/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app2/HelloController.java new file mode 100644 index 000000000..ef37cd93b --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app2/HelloController.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.app2; + +import java.util.List; + +import jakarta.validation.constraints.NotNull; + +import org.springframework.data.domain.Pageable; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class HelloController { + + @GetMapping(value = "/search", produces = { "application/xml", "application/json" }) + public ResponseEntity> getAllPets(@NotNull Pageable pageable) { + return null; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app2/PersonDTO.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app2/PersonDTO.java new file mode 100644 index 000000000..ba048cb66 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app2/PersonDTO.java @@ -0,0 +1,71 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app2; + +import io.swagger.v3.oas.annotations.media.Schema; + +@Schema +public class PersonDTO { + private String email; + + private String firstName; + + private String lastName; + + public PersonDTO() { + } + + public PersonDTO(final String email, final String firstName, final String lastName) { + this.email = email; + this.firstName = firstName; + this.lastName = lastName; + } + + public String getEmail() { + return email; + } + + public void setEmail(final String email) { + this.email = email; + } + + public String getFirstName() { + return firstName; + } + + public void setFirstName(final String firstName) { + this.firstName = firstName; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(final String lastName) { + this.lastName = lastName; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app2/SpringDocApp2Test.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app2/SpringDocApp2Test.java new file mode 100644 index 000000000..3fef40c5a --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app2/SpringDocApp2Test.java @@ -0,0 +1,38 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app2; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp2Test extends AbstractSpringDocTest { + + @SpringBootApplication + static class SpringDocTestApp {} + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app20/Bank.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app20/Bank.java new file mode 100644 index 000000000..f802ce0f3 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app20/Bank.java @@ -0,0 +1,107 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app20; + +import java.util.Objects; + +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.SequenceGenerator; +import jakarta.persistence.Table; +import org.hibernate.annotations.NaturalId; + +@Entity +@Table(name = "bank") +public class Bank implements EntityDefinition { + + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "bnk_seq") + @SequenceGenerator(name = "bnk_seq", sequenceName = "bnk_seq", allocationSize = 1) + private Long id; + + @Column(unique = true) + @NaturalId + private String code; + + @Column(unique = true, nullable = false) + private String name; + + public Long getId() { + return this.id; + } + + public String getCode() { + return this.code; + } + + public String getName() { + return this.name; + } + + public void setName(String name) { + this.name = name; + } + + @Override + public int hashCode() { + return Objects.hash(getCode()); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (!(o instanceof Bank)) { + return false; + } + Bank bank = (Bank) o; + return Objects.equals(getCode(), bank.getCode()); + } + + @Override + public String toString() { + return "Bank{" + + "id=" + id + + ", code='" + code + '\'' + + ", name='" + name + '\'' + + '}'; + } + + @Override + public String getKey() { + return code; + } + + @Override + public String getDescription() { + return name; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app20/BankRepository.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app20/BankRepository.java new file mode 100644 index 000000000..48ab7f656 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app20/BankRepository.java @@ -0,0 +1,36 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app20; + +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.rest.core.annotation.RepositoryRestResource; +import org.springframework.stereotype.Repository; + +@Repository +@RepositoryRestResource(path = "banks") +public interface BankRepository extends JpaRepository, CodeLookupRepository { +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app20/CodeLookupRepository.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app20/CodeLookupRepository.java new file mode 100644 index 000000000..f484ab661 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app20/CodeLookupRepository.java @@ -0,0 +1,38 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app20; + +import org.springframework.data.repository.NoRepositoryBean; +import org.springframework.data.repository.query.Param; + +@NoRepositoryBean +public interface CodeLookupRepository { + EntityT findOneByCode(@Param("code") KeyT code); + + Long countByCode(KeyT code); +} + diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app20/DemoApplication.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app20/DemoApplication.java new file mode 100644 index 000000000..fa34360f1 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app20/DemoApplication.java @@ -0,0 +1,47 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app20; + +import io.swagger.v3.oas.annotations.OpenAPIDefinition; +import io.swagger.v3.oas.annotations.info.Info; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +@OpenAPIDefinition( + info = @Info( + title = "Core API" + ) +) +public class DemoApplication { + + public static void main(String[] args) { + SpringApplication.run(DemoApplication.class, args); + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app20/EntityDefinition.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app20/EntityDefinition.java new file mode 100644 index 000000000..9e6a71094 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app20/EntityDefinition.java @@ -0,0 +1,38 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app20; + +import com.fasterxml.jackson.annotation.JsonIgnore; + +public interface EntityDefinition { + + @JsonIgnore + String getKey(); + + @JsonIgnore + String getDescription(); +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app20/SpringDocApp20Test.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app20/SpringDocApp20Test.java new file mode 100644 index 000000000..33e4c1026 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app20/SpringDocApp20Test.java @@ -0,0 +1,37 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app20; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp20Test extends AbstractSpringDocTest { + + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app21/Person.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app21/Person.java new file mode 100644 index 000000000..caec567a4 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app21/Person.java @@ -0,0 +1,60 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app21; + +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; + +@Entity +public class Person { + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private long id; + + private String firstName; + + private String lastName; + + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app21/PersonRepository.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app21/PersonRepository.java new file mode 100644 index 000000000..b3c492389 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app21/PersonRepository.java @@ -0,0 +1,59 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app21; + +import java.util.List; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; + +import org.springframework.data.repository.PagingAndSortingRepository; +import org.springframework.data.repository.query.Param; +import org.springframework.data.rest.core.annotation.RepositoryRestResource; + +@RepositoryRestResource(collectionResourceRel = "people", path = "peopleme") +public interface PersonRepository extends PagingAndSortingRepository { + + @Operation(description = "this is my test") + @ApiResponses( + value = { + @ApiResponse(responseCode = "200", description = "successful operation"), + @ApiResponse(responseCode = "400", description = "Invalid ID supplied"), + @ApiResponse(responseCode = "404", description = "Contact not found"), + @ApiResponse(responseCode = "405", description = "Validation exception") } + ) + List findByLastName(@Param("lastName") String name); + + @Operation(description = "this is another test", responses = { + @ApiResponse(responseCode = "200", description = "another successful operation"), + @ApiResponse(responseCode = "404", description = "another Contact not found") } + ) + List findByFirstName(@Param("firstName") @Parameter(description = "this is for first Name") String name); + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app21/SpringDocApp21Test.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app21/SpringDocApp21Test.java new file mode 100644 index 000000000..e57bb1ed1 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app21/SpringDocApp21Test.java @@ -0,0 +1,37 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app21; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp21Test extends AbstractSpringDocTest { + + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app22/Person.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app22/Person.java new file mode 100644 index 000000000..47458862f --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app22/Person.java @@ -0,0 +1,60 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app22; + +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; + +@Entity +public class Person { + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private long id; + + private String firstName; + + private String lastName; + + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app22/PersonApi.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app22/PersonApi.java new file mode 100644 index 000000000..e5417c885 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app22/PersonApi.java @@ -0,0 +1,40 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app22; + +import org.springframework.data.rest.webmvc.RepositoryRestController; +import org.springframework.web.bind.annotation.GetMapping; + +@RepositoryRestController +public class PersonApi { + + @GetMapping("/people/test") + public Person test() { + return new Person(); + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app22/PersonRepository.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app22/PersonRepository.java new file mode 100644 index 000000000..77d72c0c0 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app22/PersonRepository.java @@ -0,0 +1,35 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app22; + +import org.springframework.data.repository.PagingAndSortingRepository; +import org.springframework.data.rest.core.annotation.RepositoryRestResource; + +@RepositoryRestResource(path = "people", collectionResourceRel = "people") +public interface PersonRepository extends PagingAndSortingRepository { + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app22/SpringDocApp22Test.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app22/SpringDocApp22Test.java new file mode 100644 index 000000000..80861859d --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app22/SpringDocApp22Test.java @@ -0,0 +1,38 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app22; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp22Test extends AbstractSpringDocTest { + + @SpringBootApplication + static class SpringDocTestApp {} + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app23/Clinic.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app23/Clinic.java new file mode 100644 index 000000000..e2156d75a --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app23/Clinic.java @@ -0,0 +1,57 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app23; + +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; + +@Data +@Entity +@NoArgsConstructor +@AllArgsConstructor +@EqualsAndHashCode(callSuper = false) +@Builder +public class Clinic { + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private Long id; + + @NotNull + @NotBlank + private String name; + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app23/ClinicRepo.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app23/ClinicRepo.java new file mode 100644 index 000000000..6dfd42399 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app23/ClinicRepo.java @@ -0,0 +1,34 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app23; + +import org.springframework.data.repository.CrudRepository; +import org.springframework.web.bind.annotation.CrossOrigin; + +@CrossOrigin +public interface ClinicRepo extends CrudRepository { +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app23/Doctor.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app23/Doctor.java new file mode 100644 index 000000000..5a6902465 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app23/Doctor.java @@ -0,0 +1,66 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app23; + +import java.util.Set; + +import io.swagger.v3.oas.annotations.media.ArraySchema; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.media.Schema.AccessMode; +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.ManyToMany; +import jakarta.validation.constraints.Size; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; + +@Data +@Entity +@NoArgsConstructor +@AllArgsConstructor +@EqualsAndHashCode(callSuper = false) +@Builder +public class Doctor { + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private Long id; + + @ManyToMany + @Size(min = 1) + @ArraySchema( + schema = @Schema( + implementation = String.class, + accessMode = AccessMode.WRITE_ONLY + )) + private Set clinics; +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app23/DoctorRepo.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app23/DoctorRepo.java new file mode 100644 index 000000000..308b73cfa --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app23/DoctorRepo.java @@ -0,0 +1,34 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app23; + +import org.springframework.data.repository.CrudRepository; +import org.springframework.web.bind.annotation.CrossOrigin; + +@CrossOrigin +public interface DoctorRepo extends CrudRepository { +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app23/SpringDocApp23Test.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app23/SpringDocApp23Test.java new file mode 100644 index 000000000..4c33f4ac2 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app23/SpringDocApp23Test.java @@ -0,0 +1,38 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app23; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp23Test extends AbstractSpringDocTest { + + @SpringBootApplication + static class SpringDocTestApp {} + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app24/QUser.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app24/QUser.java new file mode 100644 index 000000000..1db52884e --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app24/QUser.java @@ -0,0 +1,70 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app24; + +import com.querydsl.core.types.Path; +import com.querydsl.core.types.PathMetadata; +import com.querydsl.core.types.dsl.EntityPathBase; +import com.querydsl.core.types.dsl.NumberPath; +import com.querydsl.core.types.dsl.StringPath; +import jakarta.annotation.Generated; + +import static com.querydsl.core.types.PathMetadataFactory.forVariable; + + +/** + * QUser is a Querydsl query type for User + */ +@Generated("com.querydsl.codegen.EntitySerializer") +public class QUser extends EntityPathBase { + + public static final QUser user = new QUser("user"); + + private static final long serialVersionUID = 222331676L; + + public final StringPath email = createString("email"); + + public final StringPath firstName = createString("firstName"); + + public final NumberPath id = createNumber("id", Long.class); + + public final StringPath lastName = createString("lastName"); + + public QUser(String variable) { + super(User.class, forVariable(variable)); + } + + public QUser(Path path) { + super(path.getType(), path.getMetadata()); + } + + public QUser(PathMetadata metadata) { + super(User.class, metadata); + } + +} + diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app24/SpringDocApp24Test.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app24/SpringDocApp24Test.java new file mode 100644 index 000000000..6fdbbc1de --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app24/SpringDocApp24Test.java @@ -0,0 +1,38 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app24; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp24Test extends AbstractSpringDocTest { + + @SpringBootApplication + static class SpringDocTestApp {} + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app24/TesteResource.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app24/TesteResource.java new file mode 100644 index 000000000..c63417b7c --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app24/TesteResource.java @@ -0,0 +1,47 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app24; + +import com.querydsl.core.types.Predicate; +import lombok.AllArgsConstructor; + +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.data.querydsl.binding.QuerydslPredicate; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + + +@RestController +@AllArgsConstructor +public class TesteResource { + + @GetMapping("/") + public Page testeQueryDslAndSpringDoc(@QuerydslPredicate(root = User.class, bindings = UserPredicate.class) Predicate predicate, Pageable pageable) { + return null; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app24/User.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app24/User.java new file mode 100644 index 000000000..79741b964 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app24/User.java @@ -0,0 +1,50 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app24; + +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import lombok.Getter; +import lombok.Setter; + +@Entity +@Getter +@Setter +public class User { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + private String firstName; + + private String lastName; + + private String email; +} + diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app24/UserPredicate.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app24/UserPredicate.java new file mode 100644 index 000000000..2a76b9557 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app24/UserPredicate.java @@ -0,0 +1,41 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app24; + +import org.springframework.data.querydsl.binding.QuerydslBinderCustomizer; +import org.springframework.data.querydsl.binding.QuerydslBindings; + +public class UserPredicate implements QuerydslBinderCustomizer { + + + @Override + public void customize(QuerydslBindings bindings, QUser user) { + bindings.excludeUnlistedProperties(true); + bindings.including(user.email); + bindings.bind(user.firstName).as("name").withDefaultBinding(); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app25/SpringDocApp25Test.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app25/SpringDocApp25Test.java new file mode 100644 index 000000000..be50c24c0 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app25/SpringDocApp25Test.java @@ -0,0 +1,38 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app25; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp25Test extends AbstractSpringDocTest { + + @SpringBootApplication + static class SpringDocTestApp {} + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app25/model/Address.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app25/model/Address.java new file mode 100644 index 000000000..bf41b6c05 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app25/model/Address.java @@ -0,0 +1,54 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app25.model; + +import jakarta.persistence.Embeddable; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Embeddable +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class Address { + + private String name; + + private String street; + + private String number; + + private String zipcode; + + private String city; + + private String country; + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app25/model/BaseEntity.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app25/model/BaseEntity.java new file mode 100644 index 000000000..a7f6d757a --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app25/model/BaseEntity.java @@ -0,0 +1,56 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app25.model; + +import java.util.UUID; + +import jakarta.persistence.Id; +import jakarta.persistence.MappedSuperclass; +import jakarta.persistence.PrePersist; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import org.hibernate.annotations.JdbcTypeCode; +import org.hibernate.type.SqlTypes; + +@Getter +@Setter +@NoArgsConstructor +@MappedSuperclass +public abstract class BaseEntity { + + @Id + @JdbcTypeCode(SqlTypes.CHAR) + private UUID id; + + @PrePersist + private void generateId() { + if (id == null) + id = UUID.randomUUID(); + } + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app25/model/Cat.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app25/model/Cat.java new file mode 100644 index 000000000..0e6c58840 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app25/model/Cat.java @@ -0,0 +1,59 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app25.model; + +import jakarta.persistence.Entity; +import jakarta.persistence.EnumType; +import jakarta.persistence.Enumerated; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; + +@Entity +@Data +@EqualsAndHashCode(callSuper = false) +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class Cat extends Pet { + + @Enumerated(EnumType.STRING) + private CoatType coat; + + @Builder + public Cat(String name, Owner owner, CoatType coat) { + super(name, owner); + this.coat = coat; + } + + public static enum CoatType { + TABBY, TOROISE, COLORPOINT, BICOLOR, TRICOLOR, SOLID + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app25/model/Clinic.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app25/model/Clinic.java new file mode 100644 index 000000000..7e7cb72e3 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app25/model/Clinic.java @@ -0,0 +1,56 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app25.model; + +import java.util.Set; + +import jakarta.persistence.ElementCollection; +import jakarta.persistence.Entity; +import jakarta.validation.constraints.NotNull; +import jakarta.validation.constraints.Size; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; + +@Entity +@Data +@EqualsAndHashCode(callSuper = false) +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class Clinic extends BaseEntity { + + @NotNull + private String name; + + @Size(min = 1) + @ElementCollection + private Set
addresses; + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app25/model/Doctor.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app25/model/Doctor.java new file mode 100644 index 000000000..aa6935387 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app25/model/Doctor.java @@ -0,0 +1,64 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app25.model; + +import java.util.Set; + +import jakarta.persistence.Entity; +import jakarta.persistence.EnumType; +import jakarta.persistence.Enumerated; +import jakarta.persistence.ManyToMany; +import jakarta.validation.constraints.NotNull; +import jakarta.validation.constraints.Size; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; + +@Entity +@Data +@EqualsAndHashCode(callSuper = false) +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class Doctor extends BaseEntity { + + @NotNull + private String firstname; + + @NotNull + private String lastname; + + @Enumerated(EnumType.STRING) + private Specialty specialty; + + @Size(min = 1) + @ManyToMany + private Set clinics; + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app25/model/Dog.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app25/model/Dog.java new file mode 100644 index 000000000..d3a2bfdc8 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app25/model/Dog.java @@ -0,0 +1,58 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app25.model; + +import jakarta.persistence.Entity; +import jakarta.persistence.EnumType; +import jakarta.persistence.Enumerated; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; + +@Entity +@Data +@EqualsAndHashCode(callSuper = false) +@AllArgsConstructor +@NoArgsConstructor +public class Dog extends Pet { + + @Enumerated(EnumType.STRING) + private CoatType coat; + + @Builder + public Dog(String name, Owner owner, CoatType coat) { + super(name, owner); + this.coat = coat; + } + + public static enum CoatType { + SMOOTH, SHORT, COMBINATION, DOUBLE, HEAVY, SILKY, LONG, CURLY, WIRE, HAIRLESS + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app25/model/Owner.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app25/model/Owner.java new file mode 100644 index 000000000..970a27b3d --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app25/model/Owner.java @@ -0,0 +1,63 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app25.model; + +import java.util.Set; + +import jakarta.persistence.CascadeType; +import jakarta.persistence.Embedded; +import jakarta.persistence.Entity; +import jakarta.persistence.OneToMany; +import jakarta.validation.constraints.NotNull; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; + +@Entity +@Data +@EqualsAndHashCode(callSuper = false) +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class Owner extends BaseEntity { + + private String firstname; + + @NotNull + private String lastname; + + @NotNull + @Embedded + private Address addresses; + + @EqualsAndHashCode.Exclude + @OneToMany(mappedBy = "owner", cascade = { CascadeType.ALL }) + private Set pets; + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app25/model/Pet.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app25/model/Pet.java new file mode 100644 index 000000000..95f2c2817 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app25/model/Pet.java @@ -0,0 +1,70 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app25.model; + +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonSubTypes.Type; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import jakarta.persistence.Entity; +import jakarta.persistence.Inheritance; +import jakarta.persistence.InheritanceType; +import jakarta.persistence.ManyToOne; +import jakarta.validation.constraints.NotNull; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import lombok.NonNull; +import lombok.RequiredArgsConstructor; + +@Entity + +@EqualsAndHashCode(callSuper = false) +@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS) + +@Data +@NoArgsConstructor +@RequiredArgsConstructor + +@JsonTypeInfo( + use = JsonTypeInfo.Id.NAME, + include = JsonTypeInfo.As.PROPERTY, + property = "_type") +@JsonSubTypes({ + @Type(value = Dog.class, name = "dog"), + @Type(value = Cat.class, name = "cat") +}) +public class Pet extends BaseEntity { + + @NonNull + @NotNull + private String name; + + @NonNull + @ManyToOne + private Owner owner; + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app25/model/Specialty.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app25/model/Specialty.java new file mode 100644 index 000000000..01b2e195f --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app25/model/Specialty.java @@ -0,0 +1,105 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app25.model; + +public enum Specialty { + + ALLERGY_AND_IMMUNOLOGY, + ADOLESCENT_MEDICINE, + ANESTHESIOLOGY, + AEROSPACE_MEDICINE, + BARIATRICS, + CARDIOLOGY, + CARDIOTHORACIC_SURGERY, + CHILD_AND_ADOLESCENT_PSYCHIATRY, + CLINICAL_NEUROPHYSIOLOGY, + COLORECTAL_SURGERY, + DERMATOLOGY, + DEVELOPMENTAL_PEDIATRICS, + EMERGENCY_MEDICINE, + ENDOCRINOLOGY, + FAMILY_MEDICINE, + FORENSIC_PATHOLOGY, + FORENSIC_PSYCHIATRY, + GASTROENTEROLOGY, + GENERAL_SURGERY, + GENERAL_SURGICAL_ONCOLOGY, + GERIATRICS, + GERIATRIC_PSYCHIATRY, + GYNECOLOGIC_ONCOLOGY, + HEMATOLOGY, + HEMATOLOGIC_PATHOLOGY, + INFECTIOUS_DISEASE, + INTERNAL_MEDICINE, + INTERVENTIONAL_RADIOLOGY, + INTENSIVE_CARE_MEDICINE, + MATERNAL_FETAL_MEDICINE, + MEDICAL_BIOCHEMISTRY, + MEDICAL_GENETICS, + MEDICAL_ONCOLOGY, + NEONATOLOGY, + NEPHROLOGY, + NEUROLOGY, + NEUROPATHOLOGY, + NEUROSURGERY, + NUCLEAR_MEDICINE, + OBSTETRICS_AND_GYNECOLOGY, + OCCUPATIONAL_MEDICINE, + OPHTHALMOLOGY, + ORTHOPEDIC_SURGERY, + ORAL_AND_MAXILLOFACIAL_SURGERY, + OTORHINOLARYNGOLOGY, + PALLIATIVE_CARE, + PATHOLOGY, + PEDIATRICS, + PEDIATRIC_ALLERGY_AND_IMMUNOLOGY, + PEDIATRIC_CARDIOLOGY, + PEDIATRIC_EMERGENCY_MEDICINE, + PEDIATRIC_ENDOCRINOLOGY, + PEDIATRIC_GASTROENTEROLOGY, + PEDIATRIC_HEMATOLOGY_AND_ONCOLOGY, + PEDIATRIC_INFECTIOUS_DISEASE, + PEDIATRIC_NEPHROLOGY, + PEDIATRIC_RESPIRATORY_MEDICINE, + PEDIATRIC_RHEUMATOLOGY, + PEDIATRIC_SURGERY, + PHYSICAL_MEDICINE_AND_REHABILITATION, + PLASTIC_RECONSTRUCTIVE_AND_AESTHETIC_SURGERY, + PSYCHIATRY, + PUBLIC_HEALTH, + RADIATION_ONCOLOGY, + RADIOLOGY, + REPRODUCTIVE_ENDOCRINOLOGY_AND_INFERTILITY, + RESPIRATORY_MEDICINE, + RHEUMATOLOGY, + SPORTS_MEDICINE, + THORACIC_SURGERY, + NEURORADIOLOGY, + UROLOGY, + VASCULAR_SURGERY; + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app25/repo/ClinicRepo.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app25/repo/ClinicRepo.java new file mode 100644 index 000000000..4e2afd69d --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app25/repo/ClinicRepo.java @@ -0,0 +1,39 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app25.repo; + +import java.util.UUID; + +import test.org.springdoc.api.v31.app25.model.Clinic; + +import org.springframework.data.repository.CrudRepository; +import org.springframework.web.bind.annotation.CrossOrigin; + +@CrossOrigin +public interface ClinicRepo extends CrudRepository { + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app25/repo/DoctorRepo.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app25/repo/DoctorRepo.java new file mode 100644 index 000000000..3b7b90aca --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app25/repo/DoctorRepo.java @@ -0,0 +1,42 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app25.repo; + +import java.util.UUID; + +import test.org.springdoc.api.v31.app25.model.Clinic; +import test.org.springdoc.api.v31.app25.model.Doctor; + +import org.springframework.data.repository.CrudRepository; +import org.springframework.web.bind.annotation.CrossOrigin; + +@CrossOrigin +public interface DoctorRepo extends CrudRepository { + + Iterable findByClinicsContains(Clinic clinic); + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app25/repo/OwnerRepo.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app25/repo/OwnerRepo.java new file mode 100644 index 000000000..eaa5a18b9 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app25/repo/OwnerRepo.java @@ -0,0 +1,39 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app25.repo; + +import java.util.UUID; + +import test.org.springdoc.api.v31.app25.model.Owner; + +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.web.bind.annotation.CrossOrigin; + +@CrossOrigin +public interface OwnerRepo extends JpaRepository { + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app25/repo/PetRepo.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app25/repo/PetRepo.java new file mode 100644 index 000000000..a4223bd3f --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app25/repo/PetRepo.java @@ -0,0 +1,39 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app25.repo; + +import java.util.UUID; + +import test.org.springdoc.api.v31.app25.model.Pet; + +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.web.bind.annotation.CrossOrigin; + +@CrossOrigin +public interface PetRepo extends JpaRepository { + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app26/Person.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app26/Person.java new file mode 100644 index 000000000..7876d4520 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app26/Person.java @@ -0,0 +1,68 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app26; + +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; + +@Entity +public class Person { + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private long id; + + private String firstName; + + private String lastName; + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app26/PersonRepository.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app26/PersonRepository.java new file mode 100644 index 000000000..1813497d6 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app26/PersonRepository.java @@ -0,0 +1,44 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app26; + +import java.util.List; + +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.PagingAndSortingRepository; +import org.springframework.data.repository.query.Param; +import org.springframework.data.rest.core.annotation.RepositoryRestResource; + +@RepositoryRestResource(collectionResourceRel = "people", path = "peopleme") +public interface PersonRepository extends PagingAndSortingRepository { + + List findByLastName(@Param("name") String name); + + @Query(value = "select 1 from dual", nativeQuery = true) + void testQuery(); + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app26/SpringDocApp26Test.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app26/SpringDocApp26Test.java new file mode 100644 index 000000000..04ae935b7 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app26/SpringDocApp26Test.java @@ -0,0 +1,39 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app26; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp26Test extends AbstractSpringDocTest { + + @SpringBootApplication + static class SpringDocTestApp { + } + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app26/SpringRestConfiguration.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app26/SpringRestConfiguration.java new file mode 100644 index 000000000..1006d3d04 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app26/SpringRestConfiguration.java @@ -0,0 +1,40 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app26; + +import org.springframework.context.annotation.Configuration; +import org.springframework.data.rest.core.config.RepositoryRestConfiguration; +import org.springframework.data.rest.webmvc.config.RepositoryRestConfigurer; +import org.springframework.web.servlet.config.annotation.CorsRegistry; + +@Configuration +public class SpringRestConfiguration implements RepositoryRestConfigurer { + @Override + public void configureRepositoryRestConfiguration(RepositoryRestConfiguration config, CorsRegistry cors) { + config.exposeIdsFor(Person.class); + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app27/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app27/HelloController.java new file mode 100644 index 000000000..0fdf5865c --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app27/HelloController.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.app27; + +import java.util.List; + +import jakarta.validation.constraints.NotNull; + +import org.springframework.data.domain.Pageable; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class HelloController { + + @GetMapping(value = "/search", produces = { "application/xml", "application/json" }) + public ResponseEntity> getAllPets(@NotNull Pageable pageable) { + return null; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app27/PersonDTO.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app27/PersonDTO.java new file mode 100644 index 000000000..1b2b72898 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app27/PersonDTO.java @@ -0,0 +1,71 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app27; + +import io.swagger.v3.oas.annotations.media.Schema; + +@Schema +public class PersonDTO { + private String email; + + private String firstName; + + private String lastName; + + public PersonDTO() { + } + + public PersonDTO(final String email, final String firstName, final String lastName) { + this.email = email; + this.firstName = firstName; + this.lastName = lastName; + } + + public String getEmail() { + return email; + } + + public void setEmail(final String email) { + this.email = email; + } + + public String getFirstName() { + return firstName; + } + + public void setFirstName(final String firstName) { + this.firstName = firstName; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(final String lastName) { + this.lastName = lastName; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app27/SpringDocApp27Test.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app27/SpringDocApp27Test.java new file mode 100644 index 000000000..5306c9e4b --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app27/SpringDocApp27Test.java @@ -0,0 +1,51 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app27; + +import java.util.Optional; + +import io.swagger.v3.core.converter.ModelConverter; +import io.swagger.v3.core.converter.ModelConverters; +import org.springdoc.core.converters.PageableOpenAPIConverter; +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.test.context.TestPropertySource; + +@TestPropertySource(properties = "springdoc.model-converters.pageable-converter.enabled=false") +public class SpringDocApp27Test extends AbstractSpringDocTest { + + static { + Optional pageabeConverter = + ModelConverters.getInstance(true).getConverters() + .stream().filter(modelConverter -> modelConverter instanceof PageableOpenAPIConverter).findAny(); + pageabeConverter.ifPresent(ModelConverters.getInstance(true)::removeConverter); + } + + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app28/ExamplePageable.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app28/ExamplePageable.java new file mode 100644 index 000000000..aa22fd81e --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app28/ExamplePageable.java @@ -0,0 +1,85 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app28; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.v3.oas.annotations.Parameter; + +import org.springframework.data.domain.Pageable; +import org.springframework.data.domain.Sort; + +public class ExamplePageable implements Pageable { + + @Parameter(description = "Anything") + @JsonProperty + private int something; + + @Override + public int getPageNumber() { + return 0; + } + + @Override + public int getPageSize() { + return 0; + } + + @Override + public long getOffset() { + return 0; + } + + @Override + public Sort getSort() { + return null; + } + + @Override + public Pageable next() { + return null; + } + + @Override + public Pageable previousOrFirst() { + return null; + } + + @Override + public Pageable first() { + return null; + } + + @Override + public Pageable withPage(int pageNumber) { + return null; + } + + @Override + public boolean hasPrevious() { + return false; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app28/ExamplePageableReplacement.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app28/ExamplePageableReplacement.java new file mode 100644 index 000000000..cfe5fa80e --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app28/ExamplePageableReplacement.java @@ -0,0 +1,56 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app28; + +import java.util.List; + +import io.swagger.v3.oas.annotations.Parameter; +import org.springdoc.core.converters.models.Pageable; + +public class ExamplePageableReplacement extends Pageable { + + @Parameter(description = "Anything") + private int something; + + /** + * Instantiates a new Pageable. + * @param page the page + * @param size the size + * @param sort the sort + */ + public ExamplePageableReplacement(int page, int size, List sort) { + super(page, size, sort); + } + + public int getSomething() { + return something; + } + + public void setSomething(int something) { + this.something = something; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app28/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app28/HelloController.java new file mode 100644 index 000000000..f841501f5 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app28/HelloController.java @@ -0,0 +1,47 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app28; + +import org.springdoc.core.annotations.ParameterObject; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * @author bnasslahsen + */ +@RestController +@RequestMapping("/api") +public class HelloController { + + + @GetMapping("/items/nested") + public void showNestedItem(@ParameterObject ExamplePageable examplePageable) { + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app28/SpringDocApp28Test.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app28/SpringDocApp28Test.java new file mode 100644 index 000000000..49a4a0ead --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app28/SpringDocApp28Test.java @@ -0,0 +1,42 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app28; + +import org.springdoc.core.utils.SpringDocUtils; +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp28Test extends AbstractSpringDocTest { + + static { + SpringDocUtils.getConfig().replaceParameterObjectWithClass(ExamplePageable.class, ExamplePageableReplacement.class); + } + + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app29/Person.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app29/Person.java new file mode 100644 index 000000000..589b0fb3e --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app29/Person.java @@ -0,0 +1,60 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app29; + +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; + +@Entity +public class Person { + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private long id; + + private String firstName; + + private String lastName; + + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app29/PersonApi.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app29/PersonApi.java new file mode 100644 index 000000000..bbf716e56 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app29/PersonApi.java @@ -0,0 +1,40 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app29; + +import org.springframework.data.rest.webmvc.BasePathAwareController; +import org.springframework.web.bind.annotation.GetMapping; + +@BasePathAwareController +public class PersonApi { + + @GetMapping("/people/test") + public Person test() { + return new Person(); + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app29/PersonRepository.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app29/PersonRepository.java new file mode 100644 index 000000000..0dd92e452 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app29/PersonRepository.java @@ -0,0 +1,35 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app29; + +import org.springframework.data.repository.PagingAndSortingRepository; +import org.springframework.data.rest.core.annotation.RepositoryRestResource; + +@RepositoryRestResource(path = "people", collectionResourceRel = "people") +public interface PersonRepository extends PagingAndSortingRepository { + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app29/SpringDocApp29Test.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app29/SpringDocApp29Test.java new file mode 100644 index 000000000..136f530be --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app29/SpringDocApp29Test.java @@ -0,0 +1,38 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app29; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp29Test extends AbstractSpringDocTest { + + @SpringBootApplication + static class SpringDocTestApp {} + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app3/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app3/HelloController.java new file mode 100644 index 000000000..b8386c2ee --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app3/HelloController.java @@ -0,0 +1,54 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app3; + +import org.springdoc.core.converters.models.PageableAsQueryParam; +import org.springdoc.core.converters.models.SortAsQueryParam; + +import org.springframework.http.MediaType; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequestMapping(path = "/demo", + produces = MediaType.TEXT_PLAIN_VALUE) +public class HelloController { + + @GetMapping("operation4") + @PageableAsQueryParam + public String operation4() { + return "operation4"; + } + + @GetMapping("operation5") + @SortAsQueryParam + public String operation5() { + return "operation5"; + } + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app3/SpringDocApp3Test.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app3/SpringDocApp3Test.java new file mode 100644 index 000000000..a5377b94f --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app3/SpringDocApp3Test.java @@ -0,0 +1,38 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app3; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp3Test extends AbstractSpringDocTest { + + @SpringBootApplication + static class SpringDocTestApp {} + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app30/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app30/HelloController.java new file mode 100644 index 000000000..e68880518 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app30/HelloController.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app30; + +import com.querydsl.core.types.Predicate; + +import org.springframework.data.querydsl.binding.QuerydslPredicate; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + + +@RestController +public class HelloController { + + @GetMapping("/") + public User testQueryDslAndSpringDoc(@QuerydslPredicate(root = User.class, bindings = UserPredicate.class) Predicate predicate) { + return null; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app30/QUser.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app30/QUser.java new file mode 100644 index 000000000..aaa8eb9de --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app30/QUser.java @@ -0,0 +1,68 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app30; + + +import com.querydsl.core.types.Path; +import com.querydsl.core.types.PathMetadata; +import com.querydsl.core.types.dsl.EntityPathBase; +import com.querydsl.core.types.dsl.NumberPath; +import com.querydsl.core.types.dsl.StringPath; + +import static com.querydsl.core.types.PathMetadataFactory.forVariable; + + +/** + * QUser is a Querydsl query type for User + */ +public class QUser extends EntityPathBase { + + public static final QUser user = new QUser("user"); + + private static final long serialVersionUID = 222331676L; + + public final StringPath email = createString("email"); + + public final StringPath firstName = createString("firstName"); + + public final NumberPath id = createNumber("id", Long.class); + + public final StringPath lastName = createString("lastName"); + + public QUser(String variable) { + super(User.class, forVariable(variable)); + } + + public QUser(Path path) { + super(path.getType(), path.getMetadata()); + } + + public QUser(PathMetadata metadata) { + super(User.class, metadata); + } + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app30/SpringDocApp30Test.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app30/SpringDocApp30Test.java new file mode 100644 index 000000000..c9e0bb870 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app30/SpringDocApp30Test.java @@ -0,0 +1,38 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app30; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp30Test extends AbstractSpringDocTest { + + @SpringBootApplication + static class SpringDocTestApp {} + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app30/User.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app30/User.java new file mode 100644 index 000000000..d13a9f693 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app30/User.java @@ -0,0 +1,50 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app30; + + +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import lombok.Getter; +import lombok.Setter; + +@Entity +@Getter +@Setter +public class User { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + private String firstName; + + private String lastName; + + private String email; +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app30/UserPredicate.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app30/UserPredicate.java new file mode 100644 index 000000000..f11de7712 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app30/UserPredicate.java @@ -0,0 +1,42 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app30; + + +import org.springframework.data.querydsl.binding.QuerydslBinderCustomizer; +import org.springframework.data.querydsl.binding.QuerydslBindings; + +public class UserPredicate implements QuerydslBinderCustomizer { + + + @Override + public void customize(QuerydslBindings bindings, QUser user) { + bindings.excludeUnlistedProperties(true); + bindings.including(user.email); + bindings.bind(user.firstName).as("name").withDefaultBinding(); + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app301/Person.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app301/Person.java new file mode 100644 index 000000000..eb78bf1f8 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app301/Person.java @@ -0,0 +1,60 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app301; + +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; + +@Entity +public class Person { + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private long id; + + private String firstName; + + private String lastName; + + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app301/PersonApi.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app301/PersonApi.java new file mode 100644 index 000000000..d4527fc25 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app301/PersonApi.java @@ -0,0 +1,40 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app301; + +import org.springframework.data.rest.webmvc.BasePathAwareController; +import org.springframework.web.bind.annotation.GetMapping; + +@BasePathAwareController +public class PersonApi { + + @GetMapping("/people/test") + public Person test() { + return new Person(); + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app301/PersonRepository.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app301/PersonRepository.java new file mode 100644 index 000000000..3f360b1f6 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app301/PersonRepository.java @@ -0,0 +1,35 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app301; + +import org.springframework.data.repository.PagingAndSortingRepository; +import org.springframework.data.rest.core.annotation.RepositoryRestResource; + +@RepositoryRestResource(path = "people", collectionResourceRel = "people") +public interface PersonRepository extends PagingAndSortingRepository { + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app301/SpringDocApp301Test.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app301/SpringDocApp301Test.java new file mode 100644 index 000000000..2f7366421 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app301/SpringDocApp301Test.java @@ -0,0 +1,78 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app301; + +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; +import java.util.Map.Entry; + +import com.fasterxml.jackson.databind.introspect.SimpleMixInResolver; +import com.fasterxml.jackson.databind.type.ClassKey; +import org.apache.commons.lang3.reflect.FieldUtils; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.springdoc.core.providers.ObjectMapperProvider; +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.test.context.TestPropertySource; + +@TestPropertySource(properties = "springdoc.enable-data-rest=false") +public class SpringDocApp301Test extends AbstractSpringDocTest { + + private final Map> springMixins = new HashMap<>(); + + @Autowired + ObjectMapperProvider objectMapperProvider; + + @BeforeEach + void init() throws IllegalAccessException { + SimpleMixInResolver _mixIns = (SimpleMixInResolver) FieldUtils.readDeclaredField(objectMapperProvider.jsonMapper(), "_mixIns", true); + Map> _localMixIns = (Map>) FieldUtils.readDeclaredField(_mixIns, "_localMixIns", true); + Iterator>> it = _localMixIns.entrySet().iterator(); + while (it.hasNext()) { + Entry> entry = it.next(); + if (entry.getKey().toString().startsWith("org.springframework")) { + springMixins.put(entry.getKey(), entry.getValue()); + it.remove(); + } + } + + } + + @AfterEach + void clean() throws IllegalAccessException { + SimpleMixInResolver _mixIns = (SimpleMixInResolver) FieldUtils.readDeclaredField(objectMapperProvider.jsonMapper(), "_mixIns", true); + Map> _localMixIns = (Map>) FieldUtils.readDeclaredField(_mixIns, "_localMixIns", true); + _localMixIns.putAll(springMixins); + } + + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app31/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app31/HelloController.java new file mode 100644 index 000000000..fa4b30b91 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app31/HelloController.java @@ -0,0 +1,77 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app31; + +import java.util.List; + +import org.springdoc.core.annotations.ParameterObject; + +import org.springframework.data.domain.Pageable; +import org.springframework.data.domain.Sort; +import org.springframework.data.domain.Sort.Direction; +import org.springframework.data.web.SortDefault; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class HelloController { + + @GetMapping(value = "/search", produces = { "application/xml", "application/json" }) + public ResponseEntity> getAllPets(@SortDefault("name") @ParameterObject Sort sort) { + return null; + } + + + @GetMapping("/test1") + public String getPatientList1(@SortDefault(sort = { "someField", "someoTHER" }, + direction = Direction.DESC) + @ParameterObject Sort sort) { + return "bla"; + } + + @GetMapping("/test2") + public String getPatientList2(@SortDefault(sort = "someField", + direction = Direction.DESC) + @ParameterObject Sort sort) { + return "bla"; + } + + @GetMapping("/test3") + public String getPatientList3(@SortDefault(sort = { "someField", "someoTHER" }, + direction = Direction.DESC) + @ParameterObject Pageable pageable) { + return "bla"; + } + + @GetMapping("/test4") + public String getPatientList4(@SortDefault(sort = "someField", + direction = Direction.DESC) + @ParameterObject Pageable pageable) { + return "bla"; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app31/PersonDTO.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app31/PersonDTO.java new file mode 100644 index 000000000..69a162dc7 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app31/PersonDTO.java @@ -0,0 +1,71 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app31; + +import io.swagger.v3.oas.annotations.media.Schema; + +@Schema +public class PersonDTO { + private String email; + + private String firstName; + + private String lastName; + + public PersonDTO() { + } + + public PersonDTO(final String email, final String firstName, final String lastName) { + this.email = email; + this.firstName = firstName; + this.lastName = lastName; + } + + public String getEmail() { + return email; + } + + public void setEmail(final String email) { + this.email = email; + } + + public String getFirstName() { + return firstName; + } + + public void setFirstName(final String firstName) { + this.firstName = firstName; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(final String lastName) { + this.lastName = lastName; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app31/SpringDocApp31Test.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app31/SpringDocApp31Test.java new file mode 100644 index 000000000..b92ad6523 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app31/SpringDocApp31Test.java @@ -0,0 +1,38 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app31; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp31Test extends AbstractSpringDocTest { + + @SpringBootApplication + static class SpringDocTestApp {} + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app32/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app32/HelloController.java new file mode 100644 index 000000000..4a2a6f369 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app32/HelloController.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.app32; + +import java.util.List; + +import org.springdoc.core.annotations.ParameterObject; + +import org.springframework.data.domain.Sort; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class HelloController { + + @GetMapping(value = "/search", produces = { "application/xml", "application/json" }) + public ResponseEntity> getAllPets(@ParameterObject Sort sort) { + return null; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app32/PersonDTO.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app32/PersonDTO.java new file mode 100644 index 000000000..f7b4e19a8 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app32/PersonDTO.java @@ -0,0 +1,71 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app32; + +import io.swagger.v3.oas.annotations.media.Schema; + +@Schema +public class PersonDTO { + private String email; + + private String firstName; + + private String lastName; + + public PersonDTO() { + } + + public PersonDTO(final String email, final String firstName, final String lastName) { + this.email = email; + this.firstName = firstName; + this.lastName = lastName; + } + + public String getEmail() { + return email; + } + + public void setEmail(final String email) { + this.email = email; + } + + public String getFirstName() { + return firstName; + } + + public void setFirstName(final String firstName) { + this.firstName = firstName; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(final String lastName) { + this.lastName = lastName; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app32/SpringDocApp32Test.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app32/SpringDocApp32Test.java new file mode 100644 index 000000000..6c8aa36dd --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app32/SpringDocApp32Test.java @@ -0,0 +1,62 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app32; + +import java.util.Optional; + +import org.springdoc.core.configuration.SpringDocDataRestConfiguration; +import org.springdoc.core.customizers.DataRestDelegatingMethodParameterCustomizer; +import org.springdoc.core.providers.RepositoryRestConfigurationProvider; +import org.springdoc.core.providers.SpringDataWebPropertiesProvider; +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.data.rest.RepositoryRestMvcAutoConfiguration; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Lazy; +import org.springframework.test.context.TestPropertySource; + +@TestPropertySource(properties = "spring.data.web.sort.sort-parameter=sorts") +@EnableAutoConfiguration(exclude = { + RepositoryRestMvcAutoConfiguration.class, SpringDocDataRestConfiguration.class +}) +public class SpringDocApp32Test extends AbstractSpringDocTest { + + @SpringBootApplication + static class SpringDocTestApp { + // We only need to test spring-web with Sort, without the use of spring-data-rest-starter + @Bean + @ConditionalOnMissingBean + @Lazy(false) + DataRestDelegatingMethodParameterCustomizer dataRestDelegatingMethodParameterCustomizer(Optional optionalSpringDataWebPropertiesProvider, Optional optionalRepositoryRestConfiguration) { + return new DataRestDelegatingMethodParameterCustomizer(optionalSpringDataWebPropertiesProvider, optionalRepositoryRestConfiguration); + } + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app33/ExampleSort.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app33/ExampleSort.java new file mode 100644 index 000000000..23bf9ecf0 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app33/ExampleSort.java @@ -0,0 +1,45 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app33; + +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.v3.oas.annotations.Parameter; + +import org.springframework.data.domain.Sort; + +public class ExampleSort extends Sort { + + @Parameter(description = "Anything") + @JsonProperty + private int something; + + protected ExampleSort(List orders) { + super(orders); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app33/ExampleSortReplacement.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app33/ExampleSortReplacement.java new file mode 100644 index 000000000..65e3f8765 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app33/ExampleSortReplacement.java @@ -0,0 +1,54 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app33; + +import java.util.List; + +import io.swagger.v3.oas.annotations.Parameter; +import org.springdoc.core.converters.models.Sort; + +public class ExampleSortReplacement extends Sort { + + @Parameter(description = "Anything") + private int something; + + /** + * Instantiates a new Sort. + * @param sort the sort + */ + public ExampleSortReplacement(List sort) { + super(sort); + } + + public int getSomething() { + return something; + } + + public void setSomething(int something) { + this.something = something; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app33/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app33/HelloController.java new file mode 100644 index 000000000..1a9a293e1 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app33/HelloController.java @@ -0,0 +1,44 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app33; + +import org.springdoc.core.annotations.ParameterObject; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequestMapping("/api") +public class HelloController { + + + @GetMapping("/items/nested") + public void showNestedItem(@ParameterObject ExampleSort exampleSort) { + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app33/SpringDocApp33Test.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app33/SpringDocApp33Test.java new file mode 100644 index 000000000..5273fbf0d --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app33/SpringDocApp33Test.java @@ -0,0 +1,42 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app33; + +import org.springdoc.core.utils.SpringDocUtils; +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp33Test extends AbstractSpringDocTest { + + static { + SpringDocUtils.getConfig().replaceParameterObjectWithClass(ExampleSort.class, ExampleSortReplacement.class); + } + + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app34/Account.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app34/Account.java new file mode 100644 index 000000000..2795be4dc --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app34/Account.java @@ -0,0 +1,64 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app34; + +import java.util.Date; + +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.Temporal; +import jakarta.persistence.TemporalType; + + +@Entity +public class Account { + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private Long id; + + @ManyToOne + private Customer customer; + + @Temporal(TemporalType.DATE) + private Date expiryDate; + + public Long getId() { + return id; + } + + public Customer getCustomer() { + return customer; + } + + public Date getExpiryDate() { + return expiryDate; + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app34/AccountRepository.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app34/AccountRepository.java new file mode 100644 index 000000000..b6a80d186 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app34/AccountRepository.java @@ -0,0 +1,55 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app34; + + +import java.util.List; + +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.tags.Tag; + +import org.springframework.data.repository.CrudRepository; +import org.springframework.data.repository.query.Param; +import org.springframework.data.rest.core.annotation.RepositoryRestResource; + +/** + * Repository to manage {@link Account} instances. + * + */ +@RepositoryRestResource +@Tag(name = "The account Repository") +@SecurityRequirement(name = "bearer") +public interface AccountRepository extends CrudRepository { + + /** + * Returns all accounts belonging to the given {@link Customer}. + * + * @param customer + * @return + */ + List findByCustomer(@Param("customer") Customer customer); +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app34/Customer.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app34/Customer.java new file mode 100644 index 000000000..0d803fd6a --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app34/Customer.java @@ -0,0 +1,75 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app34; + + +import java.util.Collection; + +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.OneToMany; + + +/** + * @author Oliver Gierke + */ +@Entity +public class Customer { + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private Long id; + + private String firstname; + + private String lastname; + + @OneToMany(mappedBy = "customer") + private Collection accounts; + + public Long getId() { + return id; + } + + public String getFirstname() { + return firstname; + } + + public String getLastname() { + return lastname; + } + + public Collection getAccounts() { + return accounts; + } + + public void setAccounts(Collection accounts) { + this.accounts = accounts; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app34/CustomerRepository.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app34/CustomerRepository.java new file mode 100644 index 000000000..ee799f9f4 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app34/CustomerRepository.java @@ -0,0 +1,66 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app34; + +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.tags.Tag; + +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.data.jpa.repository.JpaSpecificationExecutor; +import org.springframework.data.repository.CrudRepository; +import org.springframework.data.repository.query.Param; +import org.springframework.data.rest.core.annotation.RepositoryRestResource; +import org.springframework.data.rest.core.annotation.RestResource; + +/** + * Repository to manage {@link Customer} instances. + * + * @author Oliver Gierke + */ +@RepositoryRestResource +@Tag(name = "The customer Repository") +public interface CustomerRepository extends CrudRepository, JpaSpecificationExecutor { + + /** + * Returns a page of {@link Customer}s with the given lastname. + * + * @param lastname + * @param pageable + * @return + */ + @SecurityRequirement(name = "bearer") + Page findByLastname(@Param("lastname") String lastname, Pageable pageable); + + @Override + @RestResource(exported = false) + void deleteById(Long id); + + @Override + @RestResource(exported = false) + void delete(Customer entity); +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app34/OpenApiConfig.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app34/OpenApiConfig.java new file mode 100644 index 000000000..f456244de --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app34/OpenApiConfig.java @@ -0,0 +1,38 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app34; + +import io.swagger.v3.oas.annotations.OpenAPIDefinition; +import io.swagger.v3.oas.annotations.enums.SecuritySchemeType; +import io.swagger.v3.oas.annotations.info.Info; +import io.swagger.v3.oas.annotations.info.License; +import io.swagger.v3.oas.annotations.security.SecurityScheme; + +@OpenAPIDefinition(info = @Info(title = "My App", description = "Some long and useful description", version = "v1", license = @License(name = "Apache 2.0", url = "https://www.apache.org/licenses/LICENSE-2.0"))) +@SecurityScheme(name = "bearer", type = SecuritySchemeType.HTTP, scheme = "bearer", bearerFormat = "JWT") +public class OpenApiConfig { +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app34/SpringDocApp34Test.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app34/SpringDocApp34Test.java new file mode 100644 index 000000000..1063a917e --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app34/SpringDocApp34Test.java @@ -0,0 +1,37 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app34; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp34Test extends AbstractSpringDocTest { + + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app34/SpringRestConfiguration.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app34/SpringRestConfiguration.java new file mode 100644 index 000000000..c25b9a964 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app34/SpringRestConfiguration.java @@ -0,0 +1,41 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app34; + + +import org.springframework.context.annotation.Configuration; +import org.springframework.data.rest.core.config.RepositoryRestConfiguration; +import org.springframework.data.rest.webmvc.config.RepositoryRestConfigurer; +import org.springframework.web.servlet.config.annotation.CorsRegistry; + +@Configuration +public class SpringRestConfiguration implements RepositoryRestConfigurer { + @Override + public void configureRepositoryRestConfiguration(RepositoryRestConfiguration config, CorsRegistry cors) { + config.exposeIdsFor(Account.class, Customer.class); + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app35/ChildProperty.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app35/ChildProperty.java new file mode 100644 index 000000000..24e096224 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app35/ChildProperty.java @@ -0,0 +1,61 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app35; + + +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import lombok.Data; + +@Entity +public @Data +class ChildProperty { + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private long id; + + private String name; + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app35/ChildPropertyRepository.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app35/ChildPropertyRepository.java new file mode 100644 index 000000000..1bc444c51 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app35/ChildPropertyRepository.java @@ -0,0 +1,35 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app35; + +import io.swagger.v3.oas.annotations.Hidden; + +import org.springframework.data.repository.PagingAndSortingRepository; + +@Hidden +public interface ChildPropertyRepository extends PagingAndSortingRepository { +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app35/Property.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app35/Property.java new file mode 100644 index 000000000..c3d33f0de --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app35/Property.java @@ -0,0 +1,75 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app35; + + +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; +import lombok.Data; + +@Entity +public @Data +class Property { + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private long id; + + private String name; + + @ManyToOne + @JoinColumn(name = "child_property_id") + private ChildProperty myChildPropertyName; + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public ChildProperty getMyChildPropertyName() { + return myChildPropertyName; + } + + public void setMyChildPropertyName(ChildProperty myChildPropertyName) { + this.myChildPropertyName = myChildPropertyName; + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app35/PropertyRepository.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app35/PropertyRepository.java new file mode 100644 index 000000000..14eff26bf --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app35/PropertyRepository.java @@ -0,0 +1,35 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app35; + +import io.swagger.v3.oas.annotations.Hidden; + +import org.springframework.data.repository.PagingAndSortingRepository; + +@Hidden +public interface PropertyRepository extends PagingAndSortingRepository { +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app35/SpringDocApp35Test.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app35/SpringDocApp35Test.java new file mode 100644 index 000000000..8078d891d --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app35/SpringDocApp35Test.java @@ -0,0 +1,37 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app35; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp35Test extends AbstractSpringDocTest { + + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app36/EnumFieldHolder.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app36/EnumFieldHolder.java new file mode 100644 index 000000000..87fd8389f --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app36/EnumFieldHolder.java @@ -0,0 +1,60 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app36; + +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.Id; + +@Entity +public class EnumFieldHolder { + + public enum EnumField { + + FOO, BAR; + + } + + @Id + @GeneratedValue + private Long id; + + private EnumField enumField; + + public Long getId() { + return id; + } + + public EnumField getEnumField() { + return enumField; + } + + public void setEnumField(EnumField enumField) { + this.enumField = enumField; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app36/EnumFieldHolderRepository.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app36/EnumFieldHolderRepository.java new file mode 100644 index 000000000..13996b095 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app36/EnumFieldHolderRepository.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app36; + +import java.util.List; + +import org.springframework.data.repository.Repository; +import org.springframework.data.repository.query.Param; +import org.springframework.data.rest.core.annotation.RepositoryRestResource; +import org.springframework.data.util.Streamable; + +@RepositoryRestResource +public interface EnumFieldHolderRepository extends Repository { + + Streamable findAllByEnumField(@Param("enumField") EnumFieldHolder.EnumField enumField); + + Streamable findAllByEnumFieldIn(@Param("enumFields") List enumFields); + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app36/SpringDocApp36Test.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app36/SpringDocApp36Test.java new file mode 100644 index 000000000..d633ac324 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app36/SpringDocApp36Test.java @@ -0,0 +1,40 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app36; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp36Test extends AbstractSpringDocTest { + + @SpringBootApplication + static class SpringDocTestApp { + + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app37/BaseEntity.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app37/BaseEntity.java new file mode 100644 index 000000000..63a93d153 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app37/BaseEntity.java @@ -0,0 +1,70 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app37; + +import java.io.Serializable; + +import jakarta.persistence.Column; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.MappedSuperclass; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.SuperBuilder; +import org.hibernate.annotations.DynamicInsert; +import org.hibernate.annotations.DynamicUpdate; + +/** + * @author bnasslahsen + */ + +@Data +@MappedSuperclass +@DynamicInsert(true) +@DynamicUpdate(true) +@SuperBuilder(toBuilder = true) +@NoArgsConstructor +public abstract class BaseEntity implements Serializable { + + /** SVUDI */ + private static final long serialVersionUID = 1L; + + /** 数据库中的ID */ + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "ID", unique = true, nullable = false, insertable = false, updatable = false) + private Long id; + + + /** + * 数据是否合法 + * + * @return 是否合法 + */ + public abstract boolean isValid(); +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app37/ProductEntity.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app37/ProductEntity.java new file mode 100644 index 000000000..afaf6b513 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app37/ProductEntity.java @@ -0,0 +1,86 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app37; + +import java.math.BigDecimal; +import java.time.LocalDate; + +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.Table; +import jakarta.validation.constraints.NotNull; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; +import lombok.experimental.SuperBuilder; + +/** + * @author bnasslahsen + */ + +@Getter +@Setter +@ToString(callSuper = true) +@EqualsAndHashCode(callSuper = false) +@Entity +@Table(name = "PRODUCT_ENTITY") +@SuperBuilder(toBuilder = true) +@NoArgsConstructor +public class ProductEntity extends BaseEntity implements Comparable { + + /** SVUDI */ + private static final long serialVersionUID = 1L; + + /** 名字. */ + @NotNull + @Column(nullable = false) + private String name; + + /** 单价. */ + @NotNull + @Column(nullable = false) + private BigDecimal price; + + /** 日期. */ + @NotNull + @Column(nullable = false) + private LocalDate date; + + @Override + public boolean isValid() { + return name != null && price != null && date != null; + } + + /** 根据日期排序 */ + @Override + public int compareTo(ProductEntity oProduct) { + return this.getDate().compareTo(oProduct.getDate()); + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app37/ProductRepository.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app37/ProductRepository.java new file mode 100644 index 000000000..999fdf505 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app37/ProductRepository.java @@ -0,0 +1,115 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app37; + +/** + * @author bnasslahsen + */ + +import java.math.BigDecimal; +import java.time.LocalDate; +import java.util.List; + +import ch.qos.logback.core.rolling.helper.DateTokenConverter; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.enums.ParameterIn; + +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.repository.query.Param; +import org.springframework.data.rest.core.annotation.RepositoryRestResource; +import org.springframework.format.annotation.DateTimeFormat; + +/** + * 商品信息 + * + * @author zctmdc + */ +@RepositoryRestResource(path = "product") +public interface ProductRepository extends JpaRepository { + + List findByPrice( @Parameter( + name = "price", + description = "test desc", + in = ParameterIn.QUERY, + required = true + ) + @Param("price") BigDecimal price); + /** + * 根据商品名称查询商品信息 + * + * @param name 商品名称 + * @return 商品信息列表 + */ + List findByName(@Parameter(name = "name2", required = true) String name); + + /** + * 根据商品名称查询最新的商品信息 + * + * @param name 商品名称 + * @return 商品信息 + */ + ProductEntity findTopByNameOrderByDateDesc(@Parameter(name = "name2", required = true) String name); + + /** + * 根据商品名称模糊查询商品信息并按时间降序排序 + * + * @param name 商品名称 + * @return 商品信息列表 + */ + List findByNameContainingIgnoreCaseOrderByDateDesc( + @Parameter(name = "name2", required = true) String name); + + /** + * 根据商品名称模糊查询商品信息并按时间降序排序 + * + * @param name 商品名称 + * @return 商品信息列表 + */ + List findByNameContainingIgnoreCase( + @Parameter(name = "name2", required = true) String name); + + /** + * 根据商品名称模糊查询指定日期前的商品信息 + * + * @param end 指定日期结束 + * @return 商品信息列表 + */ + List findByDateBefore( + @Parameter(name = "end2", required = true) @DateTimeFormat(pattern = DateTokenConverter.DEFAULT_DATE_PATTERN) @Param("end") LocalDate end); + + /** + * 根据商品名称模糊查询指定日期前的商品信息 + * + * @param name 商品名称 + * @param end 指定日期结束 + * @return 商品信息列表 + */ + List findByNameContainingIgnoreCaseAndDateBefore( + @Parameter(name = "name2", required = true) String name, + @Parameter(name = "end2", required = true) @DateTimeFormat(pattern = DateTokenConverter.DEFAULT_DATE_PATTERN) @Param("end") LocalDate end); + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app37/SpringDocApp37Test.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app37/SpringDocApp37Test.java new file mode 100644 index 000000000..35e25b485 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app37/SpringDocApp37Test.java @@ -0,0 +1,40 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app37; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp37Test extends AbstractSpringDocTest { + + @SpringBootApplication + static class SpringDocTestApp { + + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app38/DefaultFlatParamObjectController.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app38/DefaultFlatParamObjectController.java new file mode 100644 index 000000000..a38090ad9 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app38/DefaultFlatParamObjectController.java @@ -0,0 +1,40 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app38; + +import org.springframework.data.domain.Sort; +import org.springframework.data.web.SortDefault; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class DefaultFlatParamObjectController { + @GetMapping("/test1") + public String test1(@SortDefault("name") Sort sort) { + return null; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app38/SpringDocApp38Test.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app38/SpringDocApp38Test.java new file mode 100644 index 000000000..53cb5da8f --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app38/SpringDocApp38Test.java @@ -0,0 +1,42 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app38; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.test.context.TestPropertySource; + +@TestPropertySource(properties = { "springdoc.default-flat-param-object=true" }) +public class SpringDocApp38Test extends AbstractSpringDocTest { + + @SpringBootApplication + static class SpringDocTestApp { + + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app4/DatabaseLoader.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app4/DatabaseLoader.java new file mode 100644 index 000000000..30dde550b --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app4/DatabaseLoader.java @@ -0,0 +1,55 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app4; + +import org.springframework.boot.CommandLineRunner; +import org.springframework.context.annotation.Bean; +import org.springframework.stereotype.Component; + +/** + * Pre-load some data using a Spring Boot {@link CommandLineRunner}. + * + * @author Greg Turnquist + */ +@Component +class DatabaseLoader { + + /** + * Use Spring to inject a {@link EmployeeRepository} that can then load data. Since this will run only after the app + * is operational, the database will be up. + * + * @param repository + */ + @Bean + CommandLineRunner init(EmployeeRepository repository) { + + return args -> { + repository.save(new Employee("Frodo", "Baggins", "ring bearer")); + repository.save(new Employee("Bilbo", "Baggins", "burglar")); + }; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app4/Employee.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app4/Employee.java new file mode 100644 index 000000000..bad2b6f36 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app4/Employee.java @@ -0,0 +1,77 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app4; + +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.Id; +import lombok.AccessLevel; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * Domain object representing a company employee. Project Lombok keeps actual code at a minimum. {@code @Data} - + * Generates getters, setters, toString, hash, and equals functions {@code @Entity} - JPA annotation to flag this class + * for DB persistence {@code @NoArgsConstructor} - Create a constructor with no args to support JPA + * {@code @AllArgsConstructor} - Create a constructor with all args to support testing + * {@code @JsonIgnoreProperties(ignoreUnknow=true)} When converting JSON to Java, ignore any unrecognized attributes. + * This is critical for REST because it encourages adding new fields in later versions that won't break. It also allows + * things like _links to be ignore as well, meaning HAL documents can be fetched and later posted to the server without + * adjustment. + * + * @author Greg Turnquist + */ +@Data +@Entity +@NoArgsConstructor(access = AccessLevel.PRIVATE) +@AllArgsConstructor +class Employee { + + @Id + @GeneratedValue + private Long id; + + private String firstName; + + private String lastName; + + private String role; + + /** + * Useful constructor when id is not yet known. + * + * @param firstName + * @param lastName + * @param role + */ + Employee(String firstName, String lastName, String role) { + + this.firstName = firstName; + this.lastName = lastName; + this.role = role; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app4/EmployeeController.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app4/EmployeeController.java new file mode 100644 index 000000000..f09b013d3 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app4/EmployeeController.java @@ -0,0 +1,135 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app4; + +import java.net.URI; +import java.net.URISyntaxException; +import java.util.List; +import java.util.stream.StreamSupport; + +import org.springframework.hateoas.CollectionModel; +import org.springframework.hateoas.EntityModel; +import org.springframework.hateoas.IanaLinkRelations; +import org.springframework.hateoas.Link; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RestController; + +import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.linkTo; +import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.methodOn; + +/** + * Spring Web {@link RestController} used to generate a REST API. + * + * @author Greg Turnquist + */ +@RestController +class EmployeeController { + + private final EmployeeRepository repository; + + EmployeeController(EmployeeRepository repository) { + this.repository = repository; + } + + /** + * Look up all employees, and transform them into a REST collection resource. Then return them through Spring Web's + * {@link ResponseEntity} fluent API. + */ + @GetMapping("/employees") + ResponseEntity>> findAll() { + + List> employees = StreamSupport.stream(repository.findAll().spliterator(), false) + .map(employee -> EntityModel.of(employee, // + linkTo(methodOn(EmployeeController.class).findOne(employee.getId())).withSelfRel(), // + linkTo(methodOn(EmployeeController.class).findAll()).withRel("employees"))) // + .toList(); + + return ResponseEntity.ok( // + CollectionModel.of(employees, // + linkTo(methodOn(EmployeeController.class).findAll()).withSelfRel())); + } + + @PostMapping("/employees") + ResponseEntity> newEmployee(@RequestBody Employee employee) { + + try { + Employee savedEmployee = repository.save(employee); + + EntityModel employeeResource = EntityModel.of(savedEmployee, // + linkTo(methodOn(EmployeeController.class).findOne(savedEmployee.getId())).withSelfRel()); + + return ResponseEntity // + .created(new URI(employeeResource.getRequiredLink(IanaLinkRelations.SELF).getHref())) // + .body(employeeResource); + } + catch (URISyntaxException e) { + return ResponseEntity.badRequest().body(null); + } + } + + /** + * Look up a single {@link Employee} and transform it into a REST resource. Then return it through Spring Web's + * {@link ResponseEntity} fluent API. + * + * @param id + */ + @GetMapping("/employees/{id}") + ResponseEntity> findOne(@PathVariable long id) { + + return repository.findById(id) // + .map(employee -> EntityModel.of(employee, // + linkTo(methodOn(EmployeeController.class).findOne(employee.getId())).withSelfRel(), // + linkTo(methodOn(EmployeeController.class).findAll()).withRel("employees"))) // + .map(ResponseEntity::ok) // + .orElse(ResponseEntity.notFound().build()); + } + + /** + * Update existing employee then return a Location header. + * + * @param employee + * @param id + * @return + */ + @PutMapping("/employees/{id}") + ResponseEntity updateEmployee(@RequestBody Employee employee, @PathVariable long id) throws URISyntaxException { + + Employee employeeToUpdate = employee; + employeeToUpdate.setId(id); + repository.save(employeeToUpdate); + + Link newlyCreatedLink = linkTo(methodOn(EmployeeController.class).findOne(id)).withSelfRel(); + + return ResponseEntity.noContent().location(new URI(newlyCreatedLink.getHref())).build(); + + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app4/EmployeeRepository.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app4/EmployeeRepository.java new file mode 100644 index 000000000..14a5d162d --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app4/EmployeeRepository.java @@ -0,0 +1,36 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app4; + +import org.springframework.data.repository.CrudRepository; + +/** + * A simple Spring Data {@link CrudRepository} for storing {@link Employee}s. + * + * @author Greg Turnquist + */ +interface EmployeeRepository extends CrudRepository { +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app4/SpringDocApp4Test.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app4/SpringDocApp4Test.java new file mode 100644 index 000000000..5d60fc494 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app4/SpringDocApp4Test.java @@ -0,0 +1,34 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app4; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +public class SpringDocApp4Test extends AbstractSpringDocTest { + + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app4/SpringDocTestApp.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app4/SpringDocTestApp.java new file mode 100644 index 000000000..7da86449d --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app4/SpringDocTestApp.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.app4; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; +import org.springframework.hateoas.server.core.EvoInflectorLinkRelationProvider; + +@SpringBootApplication +public class SpringDocTestApp { + + public static void main(String[] args) { + SpringApplication.run(SpringDocTestApp.class, args); + } + + @Bean + EvoInflectorLinkRelationProvider relProvider() { + return new EvoInflectorLinkRelationProvider(); + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app5/Country.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app5/Country.java new file mode 100644 index 000000000..becea25bf --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app5/Country.java @@ -0,0 +1,120 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app5; + +import jakarta.persistence.Basic; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.EnumType; +import jakarta.persistence.Enumerated; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.Id; + +/** + * @author gibah + */ + +@Entity +public class Country { + + @Id + @GeneratedValue + private Long id; + + @Basic + @Column(nullable = false) + private String name; + + @Basic + private String shortName; + + @Basic + private String dialingCode; + + @Basic + @Column(unique = true, nullable = false) + private String codeISO3166; + + @Basic + @Column(nullable = false) + @Enumerated(EnumType.STRING) + private Status status; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getShortName() { + return shortName; + } + + public void setShortName(String shortName) { + this.shortName = shortName; + } + + public String getDialingCode() { + return dialingCode; + } + + public void setDialingCode(String dialingCode) { + this.dialingCode = dialingCode; + } + + public String getCodeISO3166() { + return codeISO3166; + } + + public void setCodeISO3166(String codeISO3166) { + this.codeISO3166 = codeISO3166; + } + + public Status getStatus() { + return status; + } + + public Country setStatus(Status status) { + this.status = status; + return this; + } + + public enum Status { + ACTIVE, INACTIVE + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app5/CountryPredicate.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app5/CountryPredicate.java new file mode 100644 index 000000000..fef275fc0 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app5/CountryPredicate.java @@ -0,0 +1,39 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app5; + +import org.springframework.data.querydsl.binding.QuerydslBinderCustomizer; +import org.springframework.data.querydsl.binding.QuerydslBindings; + +public class CountryPredicate implements QuerydslBinderCustomizer { + + @Override + public void customize(QuerydslBindings querydslBindings, QCountry qCountry) { + querydslBindings.bind(qCountry.codeISO3166).as("code").first((path, value) -> path.containsIgnoreCase(value)); + querydslBindings.bind(qCountry.dialingCode).as("postCode").first((path, value) -> path.containsIgnoreCase(value)); + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app5/GreetingController.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app5/GreetingController.java new file mode 100644 index 000000000..3efbb32af --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app5/GreetingController.java @@ -0,0 +1,48 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app5; + +import java.util.List; + +import com.querydsl.core.types.Predicate; +import test.org.springdoc.api.v30.app5.Country.Status; + +import org.springframework.data.querydsl.binding.QuerydslPredicate; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class GreetingController { + + @GetMapping("/test") + public ResponseEntity sayHello2(@QuerydslPredicate(bindings = CountryPredicate.class, root = Country.class) Predicate predicate, + @RequestParam List statuses) { + return ResponseEntity.ok().build(); + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app5/QCountry.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app5/QCountry.java new file mode 100644 index 000000000..00c9aa679 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app5/QCountry.java @@ -0,0 +1,76 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app5; + +import com.querydsl.core.types.Path; +import com.querydsl.core.types.PathMetadata; +import com.querydsl.core.types.dsl.EntityPathBase; +import com.querydsl.core.types.dsl.EnumPath; +import com.querydsl.core.types.dsl.NumberPath; +import com.querydsl.core.types.dsl.StringPath; +import jakarta.annotation.Generated; +import test.org.springdoc.api.v30.app5.Country.Status; + +import static com.querydsl.core.types.PathMetadataFactory.forVariable; + + +/** + * QCountry is a Querydsl query type for Country + */ +@Generated("com.querydsl.codegen.EntitySerializer") +public class QCountry extends EntityPathBase { + + public static final QCountry country = new QCountry("country"); + + private static final long serialVersionUID = -1184258693L; + + public final StringPath codeISO3166 = createString("codeISO3166"); + + public final StringPath dialingCode = createString("dialingCode"); + + public final NumberPath id = createNumber("id", Long.class); + + public final StringPath name = createString("name"); + + public final StringPath shortName = createString("shortName"); + + public final EnumPath status = createEnum("status", Status.class); + + public QCountry(String variable) { + super(Country.class, forVariable(variable)); + } + + public QCountry(Path path) { + super(path.getType(), path.getMetadata()); + } + + public QCountry(PathMetadata metadata) { + super(Country.class, metadata); + } + +} + diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app5/SpringDocApp5Test.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app5/SpringDocApp5Test.java new file mode 100644 index 000000000..c4f996968 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app5/SpringDocApp5Test.java @@ -0,0 +1,44 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app5; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * @author Gibah Joseph + * Email: gibahjoe@gmail.com + * Mar, 2020 + **/ + +public class SpringDocApp5Test extends AbstractSpringDocTest { + + @SpringBootApplication + static class SpringDocTestApp {} + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app6/DatabaseLoader.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app6/DatabaseLoader.java new file mode 100644 index 000000000..5001a631e --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app6/DatabaseLoader.java @@ -0,0 +1,55 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app6; + +import org.springframework.boot.CommandLineRunner; +import org.springframework.context.annotation.Bean; +import org.springframework.stereotype.Component; + +/** + * Pre-load some data using a Spring Boot {@link CommandLineRunner}. + * + * @author Greg Turnquist + */ +@Component +class DatabaseLoader { + + /** + * Use Spring to inject a {@link EmployeeRepository} that can then load data. Since this will run only after the app + * is operational, the database will be up. + * + * @param repository + */ + @Bean + CommandLineRunner init(EmployeeRepository repository) { + + return args -> { + repository.save(new Employee("Frodo", "Baggins", "ring bearer")); + repository.save(new Employee("Bilbo", "Baggins", "burglar")); + }; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app6/Employee.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app6/Employee.java new file mode 100644 index 000000000..50b2fbee8 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app6/Employee.java @@ -0,0 +1,77 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app6; + +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.Id; +import lombok.AccessLevel; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * Domain object representing a company employee. Project Lombok keeps actual code at a minimum. {@code @Data} - + * Generates getters, setters, toString, hash, and equals functions {@code @Entity} - JPA annotation to flag this class + * for DB persistence {@code @NoArgsConstructor} - Create a constructor with no args to support JPA + * {@code @AllArgsConstructor} - Create a constructor with all args to support testing + * {@code @JsonIgnoreProperties(ignoreUnknow=true)} When converting JSON to Java, ignore any unrecognized attributes. + * This is critical for REST because it encourages adding new fields in later versions that won't break. It also allows + * things like _links to be ignore as well, meaning HAL documents can be fetched and later posted to the server without + * adjustment. + * + * @author Greg Turnquist + */ +@Data +@Entity +@NoArgsConstructor(access = AccessLevel.PRIVATE) +@AllArgsConstructor +class Employee { + + @Id + @GeneratedValue + private Long id; + + private String firstName; + + private String lastName; + + private String role; + + /** + * Useful constructor when id is not yet known. + * + * @param firstName + * @param lastName + * @param role + */ + Employee(String firstName, String lastName, String role) { + + this.firstName = firstName; + this.lastName = lastName; + this.role = role; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app6/EmployeeController.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app6/EmployeeController.java new file mode 100644 index 000000000..ec36b2a11 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app6/EmployeeController.java @@ -0,0 +1,54 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app6; + +import org.springframework.hateoas.EntityModel; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RestController; + +/** + * Spring Web {@link RestController} used to generate a REST API. + * + * @author Greg Turnquist + */ +@RestController +class EmployeeController { + + /** + * Look up a single {@link Employee} and transform it into a REST resource. Then return it through Spring Web's + * {@link ResponseEntity} fluent API. + * + * @param id + */ + @GetMapping("/employees/{id}") + EntityModel findOne(@PathVariable long id) { + + return null; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app6/EmployeeRepository.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app6/EmployeeRepository.java new file mode 100644 index 000000000..61c4aa887 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app6/EmployeeRepository.java @@ -0,0 +1,36 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app6; + +import org.springframework.data.repository.CrudRepository; + +/** + * A simple Spring Data {@link CrudRepository} for storing {@link Employee}s. + * + * @author Greg Turnquist + */ +interface EmployeeRepository extends CrudRepository { +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app6/SpringDocApp6Test.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app6/SpringDocApp6Test.java new file mode 100644 index 000000000..1933073e2 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app6/SpringDocApp6Test.java @@ -0,0 +1,37 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app6; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.test.context.TestPropertySource; + +@TestPropertySource(properties = "springdoc.remove-broken-reference-definitions=false") +public class SpringDocApp6Test extends AbstractSpringDocTest { + + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app6/SpringDocTestApp.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app6/SpringDocTestApp.java new file mode 100644 index 000000000..053730202 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app6/SpringDocTestApp.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.app6; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; +import org.springframework.hateoas.server.core.EvoInflectorLinkRelationProvider; + +@SpringBootApplication +public class SpringDocTestApp { + + public static void main(String[] args) { + SpringApplication.run(SpringDocTestApp.class, args); + } + + @Bean + EvoInflectorLinkRelationProvider relProvider() { + return new EvoInflectorLinkRelationProvider(); + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app7/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app7/HelloController.java new file mode 100644 index 000000000..528071409 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app7/HelloController.java @@ -0,0 +1,47 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app7; + +import java.util.List; + +import jakarta.validation.constraints.NotNull; +import org.springdoc.core.annotations.ParameterObject; + +import org.springframework.data.domain.Pageable; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class HelloController { + + @GetMapping(value = "/search", produces = { "application/xml", "application/json" }) + public ResponseEntity> getAllPets(@NotNull @ParameterObject Pageable pageable) { + return null; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app7/PersonDTO.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app7/PersonDTO.java new file mode 100644 index 000000000..d601029e2 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app7/PersonDTO.java @@ -0,0 +1,71 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app7; + +import io.swagger.v3.oas.annotations.media.Schema; + +@Schema +public class PersonDTO { + private String email; + + private String firstName; + + private String lastName; + + public PersonDTO() { + } + + public PersonDTO(final String email, final String firstName, final String lastName) { + this.email = email; + this.firstName = firstName; + this.lastName = lastName; + } + + public String getEmail() { + return email; + } + + public void setEmail(final String email) { + this.email = email; + } + + public String getFirstName() { + return firstName; + } + + public void setFirstName(final String firstName) { + this.firstName = firstName; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(final String lastName) { + this.lastName = lastName; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app7/SpringDocApp7Test.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app7/SpringDocApp7Test.java new file mode 100644 index 000000000..f18601f70 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app7/SpringDocApp7Test.java @@ -0,0 +1,38 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app7; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp7Test extends AbstractSpringDocTest { + + @SpringBootApplication + static class SpringDocTestApp {} + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app8/Album.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app8/Album.java new file mode 100644 index 000000000..8f024d3cd --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app8/Album.java @@ -0,0 +1,55 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app8; + +public class Album { + + private String title; + + private String description; + + private String releaseDate; + + public Album(String title, String description, String releaseDate) { + this.title = title; + this.description = description; + this.releaseDate = releaseDate; + } + + public String getTitle() { + return title; + } + + public String getDescription() { + return description; + } + + public String getReleaseDate() { + return releaseDate; + } + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app8/AlbumController.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app8/AlbumController.java new file mode 100644 index 000000000..8412ab28b --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app8/AlbumController.java @@ -0,0 +1,58 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app8; + +import java.util.Arrays; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageImpl; +import org.springframework.data.web.PagedResourcesAssembler; +import org.springframework.hateoas.PagedModel; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@SuppressWarnings("unchecked") +public class AlbumController { + + @Autowired + private AlbumModelAssembler albumModelAssembler; + + @Autowired + private PagedResourcesAssembler pagedResourcesAssembler; + + @GetMapping("/api/albums") + public PagedModel getAllAlbums() { + Album album1 = new Album("album-title-1", "album-description-1", "album-release-date-1"); + Album album2 = new Album("album-title-2", "album-description-2", "album-release-date-2"); + Page albumPage = new PageImpl<>(Arrays.asList(album1, album2)); + + return pagedResourcesAssembler.toModel(albumPage, albumModelAssembler); + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app8/AlbumModelAssembler.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app8/AlbumModelAssembler.java new file mode 100644 index 000000000..4ac085987 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app8/AlbumModelAssembler.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.app8; + +import java.util.ArrayList; +import java.util.List; + +import org.springframework.hateoas.EntityModel; +import org.springframework.hateoas.Link; +import org.springframework.hateoas.server.RepresentationModelAssembler; +import org.springframework.stereotype.Component; + +@Component +public class AlbumModelAssembler implements RepresentationModelAssembler> { + + @Override + public EntityModel toModel(Album entity) { + List links = new ArrayList<>(); + return EntityModel.of(entity, links); + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app8/SpringDocApp8Test.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app8/SpringDocApp8Test.java new file mode 100644 index 000000000..7954f61e9 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app8/SpringDocApp8Test.java @@ -0,0 +1,38 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app8; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp8Test extends AbstractSpringDocTest { + + @SpringBootApplication + static class SpringDocTestApp {} + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app9/SpringDocApp9Test.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app9/SpringDocApp9Test.java new file mode 100644 index 000000000..0f813a91a --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app9/SpringDocApp9Test.java @@ -0,0 +1,79 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app9; + +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; + +import com.fasterxml.jackson.databind.introspect.SimpleMixInResolver; +import com.fasterxml.jackson.databind.type.ClassKey; +import org.apache.commons.lang3.reflect.FieldUtils; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.springdoc.core.providers.ObjectMapperProvider; +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.test.context.TestPropertySource; + +@TestPropertySource(properties = "spring.hateoas.use-hal-as-default-json-media-type= false") +@SuppressWarnings({ "deprecation", "unchecked" }) +public class SpringDocApp9Test extends AbstractSpringDocTest { + + private final Map> springMixins = new HashMap<>(); + + @Autowired + ObjectMapperProvider objectMapperProvider; + + @BeforeEach + void init() throws IllegalAccessException { + SimpleMixInResolver _mixIns = (SimpleMixInResolver) FieldUtils.readDeclaredField(objectMapperProvider.jsonMapper(), "_mixIns", true); + Map> _localMixIns = (Map>) FieldUtils.readDeclaredField(_mixIns, "_localMixIns", true); + Iterator>> it = _localMixIns.entrySet().iterator(); + while (it.hasNext()) { + Map.Entry> entry = it.next(); + if (entry.getKey().toString().startsWith("org.springframework")) { + springMixins.put(entry.getKey(), entry.getValue()); + it.remove(); + } + } + + } + + @AfterEach + void clean() throws IllegalAccessException { + SimpleMixInResolver _mixIns = (SimpleMixInResolver) FieldUtils.readDeclaredField(objectMapperProvider.jsonMapper(), "_mixIns", true); + Map> _localMixIns = (Map>) FieldUtils.readDeclaredField(_mixIns, "_localMixIns", true); + _localMixIns.putAll(springMixins); + } + + @SpringBootApplication + static class SpringDocTestApp {} + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app9/component/controller/ComponentsController.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app9/component/controller/ComponentsController.java new file mode 100644 index 000000000..c49d0d590 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app9/component/controller/ComponentsController.java @@ -0,0 +1,104 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app9.component.controller; + + +import java.util.Optional; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springdoc.core.converters.models.PageableAsQueryParam; +import test.org.springdoc.api.v31.app9.component.controller.hateoas.ComponentDtoModelAssembler; +import test.org.springdoc.api.v31.app9.component.dto.DemoComponentDto; +import test.org.springdoc.api.v31.app9.component.dto.converter.DemoComponentConverter; +import test.org.springdoc.api.v31.app9.component.model.DemoComponent; +import test.org.springdoc.api.v31.app9.component.service.ComponentsService; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.data.web.PagedResourcesAssembler; +import org.springframework.hateoas.EntityModel; +import org.springframework.hateoas.PagedModel; +import org.springframework.hateoas.RepresentationModel; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.linkTo; +import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.methodOn; + +@RestController +@RequestMapping(path = "/components", produces = "application/json") +@Tag(name = "components", description = "Everything about components") +public class ComponentsController { + + @Autowired + private ComponentsService componentsService; + + @Autowired + private DemoComponentConverter toDtoConverter; + + @Autowired + private ComponentDtoModelAssembler componentDtoModelAssembler; + + @Autowired + private PagedResourcesAssembler pagedResourcesAssembler; + + @Operation(summary = "List the components") + @PageableAsQueryParam + @GetMapping + public ResponseEntity>>> findAll(@Parameter(hidden = true) Pageable pageable) { + Page results = componentsService.findAll(pageable); + + return ResponseEntity.ok(pagedResourcesAssembler.toModel(results, componentDtoModelAssembler)); + } + + @Operation(summary = "Get one component by its ID", description = "Returns a single component", // + responses = { // + @ApiResponse(responseCode = "200", description = "Component found"), // + @ApiResponse(responseCode = "404", description = "Component not found", content = { @Content(schema = @Schema(implementation = Void.class)) }) // + }) + @GetMapping("/{componentId}") + public ResponseEntity> findById(@PathVariable String componentId) { + Optional foundComponent = componentsService.findById(componentId); + + if (foundComponent.isPresent()) { + return ResponseEntity.ok(EntityModel.of(toDtoConverter.convert(foundComponent.get()), // + linkTo(methodOn(ComponentsController.class).findAll(null)).withRel("components"))); + } + + return ResponseEntity.notFound().location(linkTo(methodOn(ComponentsController.class).findAll(null)).toUri()).build(); + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app9/component/controller/hateoas/ComponentDtoModelAssembler.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app9/component/controller/hateoas/ComponentDtoModelAssembler.java new file mode 100644 index 000000000..087885889 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app9/component/controller/hateoas/ComponentDtoModelAssembler.java @@ -0,0 +1,52 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app9.component.controller.hateoas; + + +import test.org.springdoc.api.v31.app9.component.dto.DemoComponentDto; +import test.org.springdoc.api.v31.app9.component.dto.converter.DemoComponentConverter; +import test.org.springdoc.api.v31.app9.component.model.DemoComponent; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.hateoas.EntityModel; +import org.springframework.hateoas.RepresentationModel; +import org.springframework.hateoas.server.RepresentationModelAssembler; +import org.springframework.stereotype.Component; + +@Component +@SuppressWarnings({ "deprecation", "unchecked" }) +public class ComponentDtoModelAssembler implements RepresentationModelAssembler>> { + + @Autowired + private DemoComponentConverter toDtoConverter; + + @Override + public RepresentationModel> toModel(DemoComponent entity) { + return EntityModel.of(toDtoConverter.convert(entity)); + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app9/component/controller/hateoas/DemoComponentDtoModelProcessor.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app9/component/controller/hateoas/DemoComponentDtoModelProcessor.java new file mode 100644 index 000000000..5fa37eca4 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app9/component/controller/hateoas/DemoComponentDtoModelProcessor.java @@ -0,0 +1,52 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app9.component.controller.hateoas; + + +import test.org.springdoc.api.v31.app9.component.controller.ComponentsController; +import test.org.springdoc.api.v31.app9.component.dto.DemoComponentDto; + +import org.springframework.hateoas.EntityModel; +import org.springframework.hateoas.server.RepresentationModelProcessor; +import org.springframework.stereotype.Component; + +import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.linkTo; +import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.methodOn; + +@Component +public class DemoComponentDtoModelProcessor implements RepresentationModelProcessor> { + + @Override + public EntityModel process(EntityModel model) { + final String id = model.getContent().getId(); + + model.add(linkTo(methodOn(ComponentsController.class).findById(id)).withSelfRel()); + + return model; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app9/component/dto/DemoComponentDto.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app9/component/dto/DemoComponentDto.java new file mode 100644 index 000000000..a38ac49da --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app9/component/dto/DemoComponentDto.java @@ -0,0 +1,51 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app9.component.dto; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import org.springframework.hateoas.server.core.Relation; + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@Relation(collectionRelation = "components") +@Schema(description = "A demo component to illustrate Springdoc Issue #401") +public final class DemoComponentDto { + + @Schema(description = "Some ID", example = "1") + private String id; + + @Schema(description = "Some dummy payload", example = "Hello World") + private String payload; + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app9/component/dto/converter/DemoComponentConverter.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app9/component/dto/converter/DemoComponentConverter.java new file mode 100644 index 000000000..cd42b81f6 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app9/component/dto/converter/DemoComponentConverter.java @@ -0,0 +1,51 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app9.component.dto.converter; + + +import test.org.springdoc.api.v31.app9.component.dto.DemoComponentDto; +import test.org.springdoc.api.v31.app9.component.model.DemoComponent; +import test.org.springdoc.api.v31.app9.utils.Converter; + +import org.springframework.stereotype.Component; + +@Component +public class DemoComponentConverter implements Converter { + + @Override + public DemoComponentDto convert(DemoComponent source) { + if (source == null) { + return null; + } + + return DemoComponentDto.builder() // + .id(source.getId()) // + .payload(source.getPayload()) // + .build(); + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app9/component/model/DemoComponent.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app9/component/model/DemoComponent.java new file mode 100644 index 000000000..75a9ea4e6 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app9/component/model/DemoComponent.java @@ -0,0 +1,47 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app9.component.model; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import org.springframework.data.annotation.Id; + +@Data +@Builder +@AllArgsConstructor +@EqualsAndHashCode +public class DemoComponent { + + @Id + private String id; + + private String payload; + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app9/component/service/ComponentsService.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app9/component/service/ComponentsService.java new file mode 100644 index 000000000..8429cf32a --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app9/component/service/ComponentsService.java @@ -0,0 +1,54 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app9.component.service; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.Map; +import java.util.Optional; + +import test.org.springdoc.api.v31.app9.component.model.DemoComponent; + +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageImpl; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Service; + +@Service +public class ComponentsService { + + private static final Map repo = Collections.singletonMap("1", DemoComponent.builder().id("1").payload("Hello World !").build()); + + public Optional findById(String componentId) { + return Optional.ofNullable(repo.get(componentId)); + } + + public Page findAll(Pageable pageable) { + return new PageImpl(new ArrayList<>(repo.values()), pageable, repo.size()); + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app9/core/config/OpenAPIConfiguration.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app9/core/config/OpenAPIConfiguration.java new file mode 100644 index 000000000..34cc20b32 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app9/core/config/OpenAPIConfiguration.java @@ -0,0 +1,44 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app9.core.config; + +import io.swagger.v3.oas.annotations.OpenAPIDefinition; +import io.swagger.v3.oas.annotations.info.Info; + +import org.springframework.stereotype.Component; + +@Component +@OpenAPIDefinition( // + info = @Info( // + title = "Demo Springdoc Issue #401", // + version = "0.0.1-SNAPSHOT", // + description = "A demo API to illustrate Springdoc Issue #401." // + ) // +) +public class OpenAPIConfiguration { + // NO-OP +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app9/core/config/SpringRestConfiguration.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app9/core/config/SpringRestConfiguration.java new file mode 100644 index 000000000..d831a89b1 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app9/core/config/SpringRestConfiguration.java @@ -0,0 +1,42 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app9.core.config; + +import org.springframework.context.annotation.Configuration; +import org.springframework.data.rest.core.config.RepositoryRestConfiguration; +import org.springframework.data.rest.webmvc.config.RepositoryRestConfigurer; +import org.springframework.http.MediaType; +import org.springframework.web.servlet.config.annotation.CorsRegistry; + +@Configuration +public class SpringRestConfiguration implements RepositoryRestConfigurer { + @Override + public void configureRepositoryRestConfiguration(RepositoryRestConfiguration config, CorsRegistry cors) { + config.setDefaultMediaType(MediaType.APPLICATION_JSON); + config.useHalAsDefaultJsonMediaType(false); + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app9/core/config/WebMvcConfiguration.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app9/core/config/WebMvcConfiguration.java new file mode 100644 index 000000000..787ea1200 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app9/core/config/WebMvcConfiguration.java @@ -0,0 +1,57 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app9.core.config; + +import org.springframework.boot.convert.ApplicationConversionService; +import org.springframework.context.annotation.Configuration; +import org.springframework.format.FormatterRegistry; +import org.springframework.web.servlet.config.annotation.CorsRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; + +import static org.springdoc.core.utils.Constants.ALL_PATTERN; + +@Configuration +public class WebMvcConfiguration implements WebMvcConfigurer { + + private final long MAX_AGE_SECS = 3600; + + @Override + public void addCorsMappings(CorsRegistry registry) { + registry.addMapping(ALL_PATTERN) // + .allowedOrigins("http://localhost") // + .allowedMethods("GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS") // + .allowedHeaders("*") // + .allowCredentials(true) // + .maxAge(MAX_AGE_SECS); + } + + @Override + public void addFormatters(FormatterRegistry registry) { + ApplicationConversionService.configure(registry); + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app9/core/exception/BadArgumentException.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app9/core/exception/BadArgumentException.java new file mode 100644 index 000000000..22f91c4a5 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app9/core/exception/BadArgumentException.java @@ -0,0 +1,41 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app9.core.exception; + +import org.springframework.http.HttpStatus; +import org.springframework.web.bind.annotation.ResponseStatus; + +@ResponseStatus(value = HttpStatus.BAD_REQUEST) +public class BadArgumentException extends Exception { + + private static final long serialVersionUID = -4975801683971908022L; + + public BadArgumentException(String message) { + super(message); + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app9/core/exception/BusinessException.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app9/core/exception/BusinessException.java new file mode 100644 index 000000000..c5861511a --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app9/core/exception/BusinessException.java @@ -0,0 +1,37 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app9.core.exception; + +public class BusinessException extends Exception { + + private static final long serialVersionUID = -5454643285401132760L; + + public BusinessException(String message) { + super(message); + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app9/core/model/ExceptionDto.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app9/core/model/ExceptionDto.java new file mode 100644 index 000000000..7b188439c --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app9/core/model/ExceptionDto.java @@ -0,0 +1,52 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app9.core.model; + +import java.time.Instant; + +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotEmpty; +import jakarta.validation.constraints.NotNull; +import lombok.Data; +import lombok.NonNull; + +@Data +public class ExceptionDto { + + @NonNull + @NotNull + @NotEmpty + @Schema(description = "The date and time the problem occured", example = "2020-02-04T13:21:08.098+0000", type = "string", format = "date-time") + private Instant timestamp; + + @Schema(description = "The exception class", example = "com.it4it.it4data.newdata.dataplatform.portal.api.core.exception.BadArgumentException") + private String exception; + + @Schema(description = "The exception message", example = "Trying to update a non existing component !") + private String message; + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app9/utils/Converter.java b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app9/utils/Converter.java new file mode 100644 index 000000000..5e5ee17ba --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/java/test/org/springdoc/api/v31/app9/utils/Converter.java @@ -0,0 +1,33 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app9.utils; + +public interface Converter { + + T convert(S source); + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/app10.json b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.0.1/app10.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/app10.json rename to springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.0.1/app10.json diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/app11.json b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.0.1/app11.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/app11.json rename to springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.0.1/app11.json diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/app12.json b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.0.1/app12.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/app12.json rename to springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.0.1/app12.json diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/app13.json b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.0.1/app13.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/app13.json rename to springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.0.1/app13.json diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/app14.json b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.0.1/app14.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/app14.json rename to springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.0.1/app14.json diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/app15.json b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.0.1/app15.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/app15.json rename to springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.0.1/app15.json diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/app16.json b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.0.1/app16.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/app16.json rename to springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.0.1/app16.json diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/app17.json b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.0.1/app17.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/app17.json rename to springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.0.1/app17.json diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/app18.json b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.0.1/app18.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/app18.json rename to springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.0.1/app18.json diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/app19.json b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.0.1/app19.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/app19.json rename to springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.0.1/app19.json diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/app2.json b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.0.1/app2.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/app2.json rename to springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.0.1/app2.json diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/app20.json b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.0.1/app20.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/app20.json rename to springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.0.1/app20.json diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/app21.json b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.0.1/app21.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/app21.json rename to springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.0.1/app21.json diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/app22.json b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.0.1/app22.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/app22.json rename to springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.0.1/app22.json diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/app23.json b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.0.1/app23.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/app23.json rename to springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.0.1/app23.json diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/app24.json b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.0.1/app24.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/app24.json rename to springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.0.1/app24.json diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/app25.json b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.0.1/app25.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/app25.json rename to springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.0.1/app25.json diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/app26.json b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.0.1/app26.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/app26.json rename to springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.0.1/app26.json diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/app27.json b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.0.1/app27.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/app27.json rename to springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.0.1/app27.json diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/app28.json b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.0.1/app28.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/app28.json rename to springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.0.1/app28.json diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/app29.json b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.0.1/app29.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/app29.json rename to springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.0.1/app29.json diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/app3.json b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.0.1/app3.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/app3.json rename to springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.0.1/app3.json diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/app30.json b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.0.1/app30.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/app30.json rename to springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.0.1/app30.json diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/app301.json b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.0.1/app301.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/app301.json rename to springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.0.1/app301.json diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/app31.json b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.0.1/app31.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/app31.json rename to springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.0.1/app31.json diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/app32.json b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.0.1/app32.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/app32.json rename to springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.0.1/app32.json diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/app33.json b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.0.1/app33.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/app33.json rename to springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.0.1/app33.json diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/app34.json b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.0.1/app34.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/app34.json rename to springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.0.1/app34.json diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/app35.json b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.0.1/app35.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/app35.json rename to springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.0.1/app35.json diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/app36.json b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.0.1/app36.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/app36.json rename to springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.0.1/app36.json diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/app37.json b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.0.1/app37.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/app37.json rename to springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.0.1/app37.json diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/app38.json b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.0.1/app38.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/app38.json rename to springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.0.1/app38.json diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/app4.json b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.0.1/app4.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/app4.json rename to springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.0.1/app4.json diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/app5.json b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.0.1/app5.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/app5.json rename to springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.0.1/app5.json diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/app6.json b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.0.1/app6.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/app6.json rename to springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.0.1/app6.json diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/app7.json b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.0.1/app7.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/app7.json rename to springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.0.1/app7.json diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/app8.json b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.0.1/app8.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/app8.json rename to springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.0.1/app8.json diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/app9.json b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.0.1/app9.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/app9.json rename to springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.0.1/app9.json diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.1.0/app10.json b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.1.0/app10.json new file mode 100644 index 000000000..dacf06142 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.1.0/app10.json @@ -0,0 +1,960 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/accounts": { + "get": { + "tags": [ + "account-entity-controller" + ], + "description": "get-account", + "operationId": "getCollectionResource-account-get", + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/CollectionModelEntityModelAccount" + } + }, + "application/x-spring-data-compact+json": { + "schema": { + "$ref": "#/components/schemas/CollectionModelEntityModelAccount" + } + }, + "text/uri-list": { + "schema": { + "type": "string" + } + } + } + } + } + }, + "post": { + "tags": [ + "account-entity-controller" + ], + "description": "create-account", + "operationId": "postCollectionResource-account-post", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/AccountRequestBody" + } + } + }, + "required": true + }, + "responses": { + "201": { + "description": "Created", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/EntityModelAccount" + } + } + } + } + } + } + }, + "/accounts/search/findByCustomer": { + "get": { + "tags": [ + "account-search-controller" + ], + "operationId": "executeSearch-account-get", + "parameters": [ + { + "name": "customer", + "in": "query", + "schema": { + "$ref": "#/components/schemas/Customer" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/CollectionModelEntityModelAccount" + } + } + } + }, + "404": { + "description": "Not Found" + } + } + } + }, + "/accounts/{id}": { + "get": { + "tags": [ + "account-entity-controller" + ], + "description": "get-account", + "operationId": "getItemResource-account-get", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/EntityModelAccount" + } + } + } + }, + "404": { + "description": "Not Found" + } + } + }, + "put": { + "tags": [ + "account-entity-controller" + ], + "description": "update-account", + "operationId": "putItemResource-account-put", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/AccountRequestBody" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/EntityModelAccount" + } + } + } + }, + "201": { + "description": "Created", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/EntityModelAccount" + } + } + } + }, + "204": { + "description": "No Content" + } + } + }, + "delete": { + "tags": [ + "account-entity-controller" + ], + "description": "delete-account", + "operationId": "deleteItemResource-account-delete", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "204": { + "description": "No Content" + }, + "404": { + "description": "Not Found" + } + } + }, + "patch": { + "tags": [ + "account-entity-controller" + ], + "description": "patch-account", + "operationId": "patchItemResource-account-patch", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/AccountRequestBody" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/EntityModelAccount" + } + } + } + }, + "204": { + "description": "No Content" + } + } + } + }, + "/accounts/{id}/customer": { + "get": { + "tags": [ + "account-property-reference-controller" + ], + "description": "get-customer-by-account-Id", + "operationId": "followPropertyReference-account-get", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/EntityModelCustomer" + } + }, + "text/uri-list": { + "schema": { + "type": "string" + } + } + } + }, + "404": { + "description": "Not Found" + } + } + }, + "put": { + "tags": [ + "account-property-reference-controller" + ], + "description": "update-customer-by-account-Id", + "operationId": "createPropertyReference-account-put", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CollectionModelObject" + } + }, + "application/x-spring-data-compact+json": { + "schema": { + "$ref": "#/components/schemas/CollectionModelObject" + } + }, + "text/uri-list": { + "schema": { + "type": "string" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/EntityModelCustomer" + } + } + } + }, + "201": { + "description": "Created", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/EntityModelCustomer" + } + } + } + }, + "204": { + "description": "No Content" + } + } + }, + "delete": { + "tags": [ + "account-property-reference-controller" + ], + "description": "delete-customer-by-account-Id", + "operationId": "deletePropertyReference-account-delete", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "204": { + "description": "No Content" + }, + "404": { + "description": "Not Found" + } + } + }, + "patch": { + "tags": [ + "account-property-reference-controller" + ], + "description": "patch-customer-by-account-Id", + "operationId": "createPropertyReference-account-patch", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CollectionModelObject" + } + }, + "application/x-spring-data-compact+json": { + "schema": { + "$ref": "#/components/schemas/CollectionModelObject" + } + }, + "text/uri-list": { + "schema": { + "type": "string" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/EntityModelCustomer" + } + } + } + }, + "204": { + "description": "No Content" + } + } + } + }, + "/accounts/{id}/customer/{propertyId}": { + "get": { + "tags": [ + "account-property-reference-controller" + ], + "description": "get-customer-by-account-Id", + "operationId": "followPropertyReference-account-get_1", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "propertyId", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/EntityModelCustomer" + } + } + } + }, + "404": { + "description": "Not Found" + } + } + }, + "delete": { + "tags": [ + "account-property-reference-controller" + ], + "description": "delete-customer-by-account-Id", + "operationId": "deletePropertyReferenceId-account-delete", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "propertyId", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "204": { + "description": "No Content" + }, + "404": { + "description": "Not Found" + } + } + } + }, + "/customers": { + "get": { + "tags": [ + "customer-entity-controller" + ], + "description": "get-customer", + "operationId": "getCollectionResource-customer-get", + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/CollectionModelEntityModelCustomer" + } + }, + "application/x-spring-data-compact+json": { + "schema": { + "$ref": "#/components/schemas/CollectionModelEntityModelCustomer" + } + }, + "text/uri-list": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/customers/search/findByLastname": { + "get": { + "tags": [ + "customer-search-controller" + ], + "operationId": "executeSearch-customer-get", + "parameters": [ + { + "name": "lastname", + "in": "query", + "schema": { + "type": "string" + } + }, + { + "name": "page", + "in": "query", + "description": "Zero-based page index (0..N)", + "required": false, + "schema": { + "minimum": 0, + "type": "integer", + "default": 0 + } + }, + { + "name": "size", + "in": "query", + "description": "The size of the page to be returned", + "required": false, + "schema": { + "minimum": 1, + "type": "integer", + "default": 20 + } + }, + { + "name": "sort", + "in": "query", + "description": "Sorting criteria in the format: property,(asc|desc). Default sort order is ascending. Multiple sort criteria are supported.", + "required": false, + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/PagedModelEntityModelCustomer" + } + } + } + }, + "404": { + "description": "Not Found" + } + } + } + }, + "/profile": { + "get": { + "tags": [ + "profile-controller" + ], + "operationId": "listAllFormsOfMetadata", + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/RepresentationModelObject" + } + } + } + } + } + } + }, + "/profile/accounts": { + "get": { + "tags": [ + "profile-controller" + ], + "operationId": "descriptor", + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "string" + } + }, + "application/alps+json": { + "schema": { + "type": "string" + } + }, + "application/schema+json": { + "schema": { + "$ref": "#/components/schemas/JsonSchema" + } + } + } + } + } + } + }, + "/profile/customers": { + "get": { + "tags": [ + "profile-controller" + ], + "operationId": "descriptor_1", + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "string" + } + }, + "application/alps+json": { + "schema": { + "type": "string" + } + }, + "application/schema+json": { + "schema": { + "$ref": "#/components/schemas/JsonSchema" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "AbstractJsonSchemaPropertyObject": { + "type": "object", + "properties": { + "title": { + "type": "string" + }, + "readOnly": { + "type": "boolean" + } + } + }, + "Item": { + "type": "object", + "properties": { + "type": { + "type": "string" + }, + "properties": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/AbstractJsonSchemaPropertyObject" + } + }, + "requiredProperties": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "JsonSchema": { + "type": "object", + "properties": { + "title": { + "type": "string" + }, + "description": { + "type": "string" + }, + "properties": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/AbstractJsonSchemaPropertyObject" + } + }, + "requiredProperties": { + "type": "array", + "items": { + "type": "string" + } + }, + "definitions": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/Item" + } + }, + "type": { + "type": "string" + }, + "$schema": { + "type": "string" + } + } + }, + "Links": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/Link" + } + }, + "RepresentationModelObject": { + "type": "object", + "properties": { + "_links": { + "$ref": "#/components/schemas/Links" + } + } + }, + "CollectionModelEntityModelCustomer": { + "type": "object", + "properties": { + "_embedded": { + "type": "object", + "properties": { + "customers": { + "type": "array", + "items": { + "$ref": "#/components/schemas/EntityModelCustomer" + } + } + } + }, + "_links": { + "$ref": "#/components/schemas/Links" + } + } + }, + "Customer": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "firstname": { + "type": "string" + }, + "lastname": { + "type": "string" + } + } + }, + "EntityModelCustomer": { + "type": "object", + "properties": { + "firstname": { + "type": "string" + }, + "lastname": { + "type": "string" + }, + "_links": { + "$ref": "#/components/schemas/Links" + } + } + }, + "PageMetadata": { + "type": "object", + "properties": { + "size": { + "type": "integer", + "format": "int64" + }, + "totalElements": { + "type": "integer", + "format": "int64" + }, + "totalPages": { + "type": "integer", + "format": "int64" + }, + "number": { + "type": "integer", + "format": "int64" + } + } + }, + "PagedModelEntityModelCustomer": { + "type": "object", + "properties": { + "_embedded": { + "type": "object", + "properties": { + "customers": { + "type": "array", + "items": { + "$ref": "#/components/schemas/EntityModelCustomer" + } + } + } + }, + "_links": { + "$ref": "#/components/schemas/Links" + }, + "page": { + "$ref": "#/components/schemas/PageMetadata" + } + } + }, + "EntityModelAccount": { + "type": "object", + "properties": { + "expiryDate": { + "type": "string", + "format": "date-time" + }, + "_links": { + "$ref": "#/components/schemas/Links" + } + } + }, + "CollectionModelEntityModelAccount": { + "type": "object", + "properties": { + "_embedded": { + "type": "object", + "properties": { + "accounts": { + "type": "array", + "items": { + "$ref": "#/components/schemas/EntityModelAccount" + } + } + } + }, + "_links": { + "$ref": "#/components/schemas/Links" + } + } + }, + "CollectionModelObject": { + "type": "object", + "properties": { + "_embedded": { + "type": "object", + "properties": { + "objects": { + "type": "array", + "items": { + "type": "object" + } + } + } + }, + "_links": { + "$ref": "#/components/schemas/Links" + } + } + }, + "AccountRequestBody": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "customer": { + "type": "string" + }, + "expiryDate": { + "type": "string", + "format": "date-time" + } + } + }, + "Link": { + "type": "object", + "properties": { + "href": { + "type": "string" + }, + "hreflang": { + "type": "string" + }, + "title": { + "type": "string" + }, + "type": { + "type": "string" + }, + "deprecation": { + "type": "string" + }, + "profile": { + "type": "string" + }, + "name": { + "type": "string" + }, + "templated": { + "type": "boolean" + } + } + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.1.0/app11.json b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.1.0/app11.json new file mode 100644 index 000000000..3e9d8a418 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.1.0/app11.json @@ -0,0 +1,353 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/peopleme": { + "get": { + "tags": [ + "person-entity-controller" + ], + "description": "get-person", + "operationId": "getCollectionResource-person-get", + "parameters": [ + { + "name": "page", + "in": "query", + "description": "Zero-based page index (0..N)", + "required": false, + "schema": { + "minimum": 0, + "type": "integer", + "default": 0 + } + }, + { + "name": "size", + "in": "query", + "description": "The size of the page to be returned", + "required": false, + "schema": { + "minimum": 1, + "type": "integer", + "default": 20 + } + }, + { + "name": "sort", + "in": "query", + "description": "Sorting criteria in the format: property,(asc|desc). Default sort order is ascending. Multiple sort criteria are supported.", + "required": false, + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/PagedModelEntityModelPerson" + } + }, + "application/x-spring-data-compact+json": { + "schema": { + "$ref": "#/components/schemas/PagedModelEntityModelPerson" + } + }, + "text/uri-list": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/peopleme/search/findByLastName": { + "get": { + "tags": [ + "person-search-controller" + ], + "operationId": "executeSearch-person-get", + "parameters": [ + { + "name": "name", + "in": "query", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/CollectionModelEntityModelPerson" + } + } + } + }, + "404": { + "description": "Not Found" + } + } + } + }, + "/profile": { + "get": { + "tags": [ + "profile-controller" + ], + "operationId": "listAllFormsOfMetadata", + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/RepresentationModelObject" + } + } + } + } + } + } + }, + "/profile/peopleme": { + "get": { + "tags": [ + "profile-controller" + ], + "operationId": "descriptor", + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "string" + } + }, + "application/alps+json": { + "schema": { + "type": "string" + } + }, + "application/schema+json": { + "schema": { + "$ref": "#/components/schemas/JsonSchema" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "AbstractJsonSchemaPropertyObject": { + "type": "object", + "properties": { + "title": { + "type": "string" + }, + "readOnly": { + "type": "boolean" + } + } + }, + "Item": { + "type": "object", + "properties": { + "type": { + "type": "string" + }, + "properties": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/AbstractJsonSchemaPropertyObject" + } + }, + "requiredProperties": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "JsonSchema": { + "type": "object", + "properties": { + "title": { + "type": "string" + }, + "description": { + "type": "string" + }, + "properties": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/AbstractJsonSchemaPropertyObject" + } + }, + "requiredProperties": { + "type": "array", + "items": { + "type": "string" + } + }, + "definitions": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/Item" + } + }, + "type": { + "type": "string" + }, + "$schema": { + "type": "string" + } + } + }, + "Links": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/Link" + } + }, + "RepresentationModelObject": { + "type": "object", + "properties": { + "_links": { + "$ref": "#/components/schemas/Links" + } + } + }, + "EntityModelPerson": { + "type": "object", + "properties": { + "firstName": { + "type": "string" + }, + "lastName": { + "type": "string" + }, + "_links": { + "$ref": "#/components/schemas/Links" + } + } + }, + "PageMetadata": { + "type": "object", + "properties": { + "size": { + "type": "integer", + "format": "int64" + }, + "totalElements": { + "type": "integer", + "format": "int64" + }, + "totalPages": { + "type": "integer", + "format": "int64" + }, + "number": { + "type": "integer", + "format": "int64" + } + } + }, + "PagedModelEntityModelPerson": { + "type": "object", + "properties": { + "_embedded": { + "type": "object", + "properties": { + "people": { + "type": "array", + "items": { + "$ref": "#/components/schemas/EntityModelPerson" + } + } + } + }, + "_links": { + "$ref": "#/components/schemas/Links" + }, + "page": { + "$ref": "#/components/schemas/PageMetadata" + } + } + }, + "CollectionModelEntityModelPerson": { + "type": "object", + "properties": { + "_embedded": { + "type": "object", + "properties": { + "people": { + "type": "array", + "items": { + "$ref": "#/components/schemas/EntityModelPerson" + } + } + } + }, + "_links": { + "$ref": "#/components/schemas/Links" + } + } + }, + "Link": { + "type": "object", + "properties": { + "href": { + "type": "string" + }, + "hreflang": { + "type": "string" + }, + "title": { + "type": "string" + }, + "type": { + "type": "string" + }, + "deprecation": { + "type": "string" + }, + "profile": { + "type": "string" + }, + "name": { + "type": "string" + }, + "templated": { + "type": "boolean" + } + } + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.1.0/app12.json b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.1.0/app12.json new file mode 100644 index 000000000..b5d3256c8 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.1.0/app12.json @@ -0,0 +1,120 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/demo": { + "get": { + "tags": [ + "hello-controller" + ], + "summary": "GetMyData", + "operationId": "gettt", + "responses": { + "200": { + "description": "OK", + "content": { + "text/plain": { + "schema": { + "type": "string" + } + }, + "application/json": { + "schema": { + "$ref": "#/components/schemas/JsonResponse" + } + }, + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/EntityModelJsonResponse" + } + } + } + }, + "204": { + "description": "No Content", + "content": { + "application/vnd.something": {} + } + }, + "202": { + "description": "Accepted", + "content": { + "application/xml": { + "schema": { + "$ref": "#/components/schemas/JsonResponse" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "JsonResponse": { + "type": "object", + "properties": { + "field": { + "type": "string" + } + } + }, + "EntityModelJsonResponse": { + "type": "object", + "properties": { + "field": { + "type": "string" + }, + "_links": { + "$ref": "#/components/schemas/Links" + } + } + }, + "Links": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/Link" + } + }, + "Link": { + "type": "object", + "properties": { + "href": { + "type": "string" + }, + "hreflang": { + "type": "string" + }, + "title": { + "type": "string" + }, + "type": { + "type": "string" + }, + "deprecation": { + "type": "string" + }, + "profile": { + "type": "string" + }, + "name": { + "type": "string" + }, + "templated": { + "type": "boolean" + } + } + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.1.0/app13.json b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.1.0/app13.json new file mode 100644 index 000000000..7d6b13b15 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.1.0/app13.json @@ -0,0 +1,388 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/test5": { + "get": { + "tags": [ + "hello-controller" + ], + "operationId": "read", + "parameters": [ + { + "name": "page", + "in": "query", + "description": "Zero-based page index (0..N)", + "required": false, + "schema": { + "minimum": 0, + "type": "integer", + "default": 0 + } + }, + { + "name": "size", + "in": "query", + "description": "The size of the page to be returned", + "required": false, + "schema": { + "minimum": 1, + "type": "integer", + "default": 10 + } + }, + { + "name": "sort", + "in": "query", + "description": "Sorting criteria in the format: property,(asc|desc). Default sort order is ascending. Multiple sort criteria are supported.", + "required": false, + "schema": { + "type": "array", + "items": { + "type": "string" + }, + "default": [ + "some,desc", + "other,asc", + "another.that,desc" + ] + } + } + ], + "responses": { + "200": { + "description": "OK" + } + } + } + }, + "/test4": { + "get": { + "tags": [ + "hello-controller" + ], + "operationId": "getPatientList4", + "parameters": [ + { + "name": "page", + "in": "query", + "description": "Zero-based page index (0..N)", + "required": false, + "schema": { + "minimum": 0, + "type": "integer", + "default": 0 + } + }, + { + "name": "size", + "in": "query", + "description": "The size of the page to be returned", + "required": false, + "schema": { + "minimum": 1, + "type": "integer", + "default": 100 + } + }, + { + "name": "sort", + "in": "query", + "description": "Sorting criteria in the format: property,(asc|desc). Default sort order is ascending. Multiple sort criteria are supported.", + "required": false, + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/test3": { + "get": { + "tags": [ + "hello-controller" + ], + "operationId": "getPatientList3", + "parameters": [ + { + "name": "page", + "in": "query", + "description": "Zero-based page index (0..N)", + "required": false, + "schema": { + "minimum": 0, + "type": "integer", + "default": 0 + } + }, + { + "name": "size", + "in": "query", + "description": "The size of the page to be returned", + "required": false, + "schema": { + "minimum": 1, + "type": "integer", + "default": 100 + } + }, + { + "name": "sort", + "in": "query", + "description": "Sorting criteria in the format: property,(asc|desc). Default sort order is ascending. Multiple sort criteria are supported.", + "required": false, + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/test2": { + "get": { + "tags": [ + "hello-controller" + ], + "operationId": "getPatientList2", + "parameters": [ + { + "name": "page", + "in": "query", + "description": "Zero-based page index (0..N)", + "required": false, + "schema": { + "minimum": 0, + "type": "integer", + "default": 0 + } + }, + { + "name": "size", + "in": "query", + "description": "The size of the page to be returned", + "required": false, + "schema": { + "minimum": 1, + "type": "integer", + "default": 100 + } + }, + { + "name": "sort", + "in": "query", + "description": "Sorting criteria in the format: property,(asc|desc). Default sort order is ascending. Multiple sort criteria are supported.", + "required": false, + "schema": { + "type": "array", + "items": { + "type": "string" + }, + "default": [ + "someField,DESC" + ] + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/test1": { + "get": { + "tags": [ + "hello-controller" + ], + "operationId": "getPatientList1", + "parameters": [ + { + "name": "page", + "in": "query", + "description": "Zero-based page index (0..N)", + "required": false, + "schema": { + "minimum": 0, + "type": "integer", + "default": 0 + } + }, + { + "name": "size", + "in": "query", + "description": "The size of the page to be returned", + "required": false, + "schema": { + "minimum": 1, + "type": "integer", + "default": 100 + } + }, + { + "name": "sort", + "in": "query", + "description": "Sorting criteria in the format: property,(asc|desc). Default sort order is ascending. Multiple sort criteria are supported.", + "required": false, + "schema": { + "type": "array", + "items": { + "type": "string" + }, + "default": [ + "someField,DESC", + "someoTHER,DESC" + ] + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/search": { + "get": { + "tags": [ + "hello-controller" + ], + "operationId": "getAllPets", + "parameters": [ + { + "name": "page", + "in": "query", + "description": "Zero-based page index (0..N)", + "required": false, + "schema": { + "minimum": 0, + "type": "integer", + "default": 0 + } + }, + { + "name": "size", + "in": "query", + "description": "The size of the page to be returned", + "required": false, + "schema": { + "minimum": 1, + "type": "integer", + "default": 5 + } + }, + { + "name": "sort", + "in": "query", + "description": "Sorting criteria in the format: property,(asc|desc). Default sort order is ascending. Multiple sort criteria are supported.", + "required": false, + "schema": { + "type": "array", + "items": { + "type": "string" + }, + "default": [ + "name,ASC" + ] + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/xml": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/PersonDTO" + } + } + }, + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/PersonDTO" + } + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "PersonDTO": { + "type": "object", + "properties": { + "email": { + "type": "string" + }, + "firstName": { + "type": "string" + }, + "lastName": { + "type": "string" + } + } + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.1.0/app14.json b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.1.0/app14.json new file mode 100644 index 000000000..a2e119230 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.1.0/app14.json @@ -0,0 +1,100 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/search": { + "get": { + "tags": [ + "hello-controller" + ], + "operationId": "getAllPets", + "parameters": [ + { + "name": "prefix_pages", + "in": "query", + "description": "One-based page index (1..N)", + "required": false, + "schema": { + "type": "integer", + "default": 1, + "minimum": 0 + } + }, + { + "name": "prefix_sizes", + "in": "query", + "description": "The size of the page to be returned", + "required": false, + "schema": { + "type": "integer", + "default": 25, + "minimum": 1 + } + }, + { + "name": "sorts", + "in": "query", + "description": "Sorting criteria in the format: property,(asc|desc). Default sort order is ascending. Multiple sort criteria are supported.", + "required": false, + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/xml": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/PersonDTO" + } + } + }, + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/PersonDTO" + } + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "PersonDTO": { + "type": "object", + "properties": { + "email": { + "type": "string" + }, + "firstName": { + "type": "string" + }, + "lastName": { + "type": "string" + } + } + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.1.0/app15.json b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.1.0/app15.json new file mode 100644 index 000000000..afaff436f --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.1.0/app15.json @@ -0,0 +1,100 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/search": { + "get": { + "tags": [ + "hello-controller" + ], + "operationId": "getAllPets", + "parameters": [ + { + "name": "page", + "in": "query", + "description": "Zero-based page index (0..N)", + "required": false, + "schema": { + "type": "integer", + "default": 0, + "minimum": 0 + } + }, + { + "name": "size", + "in": "query", + "description": "The size of the page to be returned", + "required": false, + "schema": { + "type": "integer", + "default": 50, + "minimum": 1 + } + }, + { + "name": "sort", + "in": "query", + "description": "Sorting criteria in the format: property,(asc|desc). Default sort order is ascending. Multiple sort criteria are supported.", + "required": false, + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/xml": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/PersonDTO" + } + } + }, + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/PersonDTO" + } + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "PersonDTO": { + "type": "object", + "properties": { + "email": { + "type": "string" + }, + "firstName": { + "type": "string" + }, + "lastName": { + "type": "string" + } + } + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.1.0/app16.json b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.1.0/app16.json new file mode 100644 index 000000000..d7ab06682 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.1.0/app16.json @@ -0,0 +1,1236 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "My App", + "description": "Some long and useful description", + "license": { + "name": "Apache 2.0", + "url": "https://www.apache.org/licenses/LICENSE-2.0" + }, + "version": "v1" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/accounts": { + "get": { + "tags": [ + "The account Repository" + ], + "summary": "getCollectionResource-account-get", + "description": "get-account", + "operationId": "getCollectionResource-account-get", + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/CollectionModelEntityModelAccount" + } + }, + "application/x-spring-data-compact+json": { + "schema": { + "$ref": "#/components/schemas/CollectionModelEntityModelAccount" + } + }, + "text/uri-list": { + "schema": { + "type": "string" + } + } + } + } + }, + "security": [ + { + "bearer": [] + } + ] + }, + "post": { + "tags": [ + "The account Repository" + ], + "summary": "postCollectionResource-account-post", + "description": "create-account", + "operationId": "postCollectionResource-account-post", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/AccountRequestBody" + } + } + }, + "required": true + }, + "responses": { + "201": { + "description": "Created", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/EntityModelAccount" + } + } + } + } + }, + "security": [ + { + "bearer": [] + } + ] + } + }, + "/accounts/search/findByCustomer": { + "get": { + "tags": [ + "The account Repository" + ], + "summary": "executeSearch-account-get", + "operationId": "executeSearch-account-get", + "parameters": [ + { + "name": "customer", + "in": "query", + "schema": { + "$ref": "#/components/schemas/Customer" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/CollectionModelEntityModelAccount" + } + } + } + }, + "404": { + "description": "Not Found" + } + }, + "security": [ + { + "bearer": [] + } + ] + } + }, + "/accounts/{id}": { + "get": { + "tags": [ + "The account Repository" + ], + "summary": "getItemResource-account-get", + "description": "get-account", + "operationId": "getItemResource-account-get", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/EntityModelAccount" + } + } + } + }, + "404": { + "description": "Not Found" + } + }, + "security": [ + { + "bearer": [] + } + ] + }, + "put": { + "tags": [ + "The account Repository" + ], + "summary": "putItemResource-account-put", + "description": "update-account", + "operationId": "putItemResource-account-put", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/AccountRequestBody" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/EntityModelAccount" + } + } + } + }, + "201": { + "description": "Created", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/EntityModelAccount" + } + } + } + }, + "204": { + "description": "No Content" + } + }, + "security": [ + { + "bearer": [] + } + ] + }, + "delete": { + "tags": [ + "The account Repository" + ], + "summary": "deleteItemResource-account-delete", + "description": "delete-account", + "operationId": "deleteItemResource-account-delete", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "204": { + "description": "No Content" + }, + "404": { + "description": "Not Found" + } + }, + "security": [ + { + "bearer": [] + } + ] + }, + "patch": { + "tags": [ + "The account Repository" + ], + "summary": "patchItemResource-account-patch", + "description": "patch-account", + "operationId": "patchItemResource-account-patch", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/AccountRequestBody" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/EntityModelAccount" + } + } + } + }, + "204": { + "description": "No Content" + } + }, + "security": [ + { + "bearer": [] + } + ] + } + }, + "/accounts/{id}/customer": { + "get": { + "tags": [ + "The account Repository" + ], + "summary": "followPropertyReference-account-get", + "description": "get-customer-by-account-Id", + "operationId": "followPropertyReference-account-get", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/EntityModelCustomer" + } + }, + "text/uri-list": { + "schema": { + "type": "string" + } + } + } + }, + "404": { + "description": "Not Found" + } + }, + "security": [ + { + "bearer": [] + } + ] + }, + "put": { + "tags": [ + "The account Repository" + ], + "summary": "createPropertyReference-account-put", + "description": "update-customer-by-account-Id", + "operationId": "createPropertyReference-account-put", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CollectionModelObject" + } + }, + "application/x-spring-data-compact+json": { + "schema": { + "$ref": "#/components/schemas/CollectionModelObject" + } + }, + "text/uri-list": { + "schema": { + "type": "string" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/EntityModelCustomer" + } + } + } + }, + "201": { + "description": "Created", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/EntityModelCustomer" + } + } + } + }, + "204": { + "description": "No Content" + } + }, + "security": [ + { + "bearer": [] + } + ] + }, + "delete": { + "tags": [ + "The account Repository" + ], + "summary": "deletePropertyReference-account-delete", + "description": "delete-customer-by-account-Id", + "operationId": "deletePropertyReference-account-delete", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "204": { + "description": "No Content" + }, + "404": { + "description": "Not Found" + } + }, + "security": [ + { + "bearer": [] + } + ] + }, + "patch": { + "tags": [ + "The account Repository" + ], + "summary": "createPropertyReference-account-patch", + "description": "patch-customer-by-account-Id", + "operationId": "createPropertyReference-account-patch", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CollectionModelObject" + } + }, + "application/x-spring-data-compact+json": { + "schema": { + "$ref": "#/components/schemas/CollectionModelObject" + } + }, + "text/uri-list": { + "schema": { + "type": "string" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/EntityModelCustomer" + } + } + } + }, + "204": { + "description": "No Content" + } + }, + "security": [ + { + "bearer": [] + } + ] + } + }, + "/accounts/{id}/customer/{propertyId}": { + "get": { + "tags": [ + "The account Repository" + ], + "summary": "followPropertyReference-account-get", + "description": "get-customer-by-account-Id", + "operationId": "followPropertyReference-account-get_1", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "propertyId", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/EntityModelCustomer" + } + } + } + }, + "404": { + "description": "Not Found" + } + }, + "security": [ + { + "bearer": [] + } + ] + }, + "delete": { + "tags": [ + "The account Repository" + ], + "summary": "deletePropertyReferenceId-account-delete", + "description": "delete-customer-by-account-Id", + "operationId": "deletePropertyReferenceId-account-delete", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "propertyId", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "204": { + "description": "No Content" + }, + "404": { + "description": "Not Found" + } + }, + "security": [ + { + "bearer": [] + } + ] + } + }, + "/customers": { + "get": { + "tags": [ + "The customer Repository" + ], + "summary": "getCollectionResource-customer-get", + "description": "get-customer", + "operationId": "getCollectionResource-customer-get", + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/CollectionModelEntityModelCustomer" + } + }, + "application/x-spring-data-compact+json": { + "schema": { + "$ref": "#/components/schemas/CollectionModelEntityModelCustomer" + } + }, + "text/uri-list": { + "schema": { + "type": "string" + } + } + } + } + } + }, + "post": { + "tags": [ + "The customer Repository" + ], + "summary": "postCollectionResource-customer-post", + "description": "create-customer", + "operationId": "postCollectionResource-customer-post", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CustomerRequestBody" + } + } + }, + "required": true + }, + "responses": { + "201": { + "description": "Created", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/EntityModelCustomer" + } + } + } + } + } + } + }, + "/customers/search/findByLastname": { + "get": { + "tags": [ + "The customer Repository" + ], + "summary": "executeSearch-customer-get", + "operationId": "executeSearch-customer-get", + "parameters": [ + { + "name": "lastname", + "in": "query", + "schema": { + "type": "string" + } + }, + { + "name": "page", + "in": "query", + "description": "Zero-based page index (0..N)", + "required": false, + "schema": { + "minimum": 0, + "type": "integer", + "default": 0 + } + }, + { + "name": "size", + "in": "query", + "description": "The size of the page to be returned", + "required": false, + "schema": { + "minimum": 1, + "type": "integer", + "default": 20 + } + }, + { + "name": "sort", + "in": "query", + "description": "Sorting criteria in the format: property,(asc|desc). Default sort order is ascending. Multiple sort criteria are supported.", + "required": false, + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/PagedModelEntityModelCustomer" + } + } + } + }, + "404": { + "description": "Not Found" + } + }, + "security": [ + { + "bearer": [] + } + ] + } + }, + "/customers/{id}": { + "get": { + "tags": [ + "The customer Repository" + ], + "summary": "getItemResource-customer-get", + "description": "get-customer", + "operationId": "getItemResource-customer-get", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/EntityModelCustomer" + } + } + } + }, + "404": { + "description": "Not Found" + } + } + }, + "put": { + "tags": [ + "The customer Repository" + ], + "summary": "putItemResource-customer-put", + "description": "update-customer", + "operationId": "putItemResource-customer-put", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CustomerRequestBody" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/EntityModelCustomer" + } + } + } + }, + "201": { + "description": "Created", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/EntityModelCustomer" + } + } + } + }, + "204": { + "description": "No Content" + } + } + }, + "patch": { + "tags": [ + "The customer Repository" + ], + "summary": "patchItemResource-customer-patch", + "description": "patch-customer", + "operationId": "patchItemResource-customer-patch", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CustomerRequestBody" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/EntityModelCustomer" + } + } + } + }, + "204": { + "description": "No Content" + } + } + } + }, + "/profile": { + "get": { + "tags": [ + "profile-controller" + ], + "summary": "listAllFormsOfMetadata", + "operationId": "listAllFormsOfMetadata", + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/RepresentationModelObject" + } + } + } + } + } + } + }, + "/profile/accounts": { + "get": { + "tags": [ + "profile-controller" + ], + "summary": "descriptor", + "operationId": "descriptor", + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "string" + } + }, + "application/alps+json": { + "schema": { + "type": "string" + } + }, + "application/schema+json": { + "schema": { + "$ref": "#/components/schemas/JsonSchema" + } + } + } + } + } + } + }, + "/profile/customers": { + "get": { + "tags": [ + "profile-controller" + ], + "summary": "descriptor", + "operationId": "descriptor_1", + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "string" + } + }, + "application/alps+json": { + "schema": { + "type": "string" + } + }, + "application/schema+json": { + "schema": { + "$ref": "#/components/schemas/JsonSchema" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "AbstractJsonSchemaPropertyObject": { + "type": "object", + "properties": { + "title": { + "type": "string" + }, + "readOnly": { + "type": "boolean" + } + } + }, + "Item": { + "type": "object", + "properties": { + "type": { + "type": "string" + }, + "properties": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/AbstractJsonSchemaPropertyObject" + } + }, + "requiredProperties": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "JsonSchema": { + "type": "object", + "properties": { + "title": { + "type": "string" + }, + "description": { + "type": "string" + }, + "properties": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/AbstractJsonSchemaPropertyObject" + } + }, + "requiredProperties": { + "type": "array", + "items": { + "type": "string" + } + }, + "definitions": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/Item" + } + }, + "type": { + "type": "string" + }, + "$schema": { + "type": "string" + } + } + }, + "Links": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/Link" + } + }, + "RepresentationModelObject": { + "type": "object", + "properties": { + "_links": { + "$ref": "#/components/schemas/Links" + } + } + }, + "Customer": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "firstname": { + "type": "string" + }, + "lastname": { + "type": "string" + } + } + }, + "EntityModelAccount": { + "type": "object", + "properties": { + "expiryDate": { + "type": "string", + "format": "date-time" + }, + "_links": { + "$ref": "#/components/schemas/Links" + } + } + }, + "CollectionModelEntityModelAccount": { + "type": "object", + "properties": { + "_embedded": { + "type": "object", + "properties": { + "accounts": { + "type": "array", + "items": { + "$ref": "#/components/schemas/EntityModelAccount" + } + } + } + }, + "_links": { + "$ref": "#/components/schemas/Links" + } + } + }, + "EntityModelCustomer": { + "type": "object", + "properties": { + "firstname": { + "type": "string" + }, + "lastname": { + "type": "string" + }, + "_links": { + "$ref": "#/components/schemas/Links" + } + } + }, + "CollectionModelObject": { + "type": "object", + "properties": { + "_embedded": { + "type": "object", + "properties": { + "objects": { + "type": "array", + "items": { + "type": "object" + } + } + } + }, + "_links": { + "$ref": "#/components/schemas/Links" + } + } + }, + "CollectionModelEntityModelCustomer": { + "type": "object", + "properties": { + "_embedded": { + "type": "object", + "properties": { + "customers": { + "type": "array", + "items": { + "$ref": "#/components/schemas/EntityModelCustomer" + } + } + } + }, + "_links": { + "$ref": "#/components/schemas/Links" + } + } + }, + "PageMetadata": { + "type": "object", + "properties": { + "size": { + "type": "integer", + "format": "int64" + }, + "totalElements": { + "type": "integer", + "format": "int64" + }, + "totalPages": { + "type": "integer", + "format": "int64" + }, + "number": { + "type": "integer", + "format": "int64" + } + } + }, + "PagedModelEntityModelCustomer": { + "type": "object", + "properties": { + "_embedded": { + "type": "object", + "properties": { + "customers": { + "type": "array", + "items": { + "$ref": "#/components/schemas/EntityModelCustomer" + } + } + } + }, + "_links": { + "$ref": "#/components/schemas/Links" + }, + "page": { + "$ref": "#/components/schemas/PageMetadata" + } + } + }, + "AccountRequestBody": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "customer": { + "type": "string" + }, + "expiryDate": { + "type": "string", + "format": "date-time" + } + } + }, + "CustomerRequestBody": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "firstname": { + "type": "string" + }, + "lastname": { + "type": "string" + } + } + }, + "Link": { + "type": "object", + "properties": { + "href": { + "type": "string" + }, + "hreflang": { + "type": "string" + }, + "title": { + "type": "string" + }, + "type": { + "type": "string" + }, + "deprecation": { + "type": "string" + }, + "profile": { + "type": "string" + }, + "name": { + "type": "string" + }, + "templated": { + "type": "boolean" + } + } + } + }, + "securitySchemes": { + "bearer": { + "type": "http", + "scheme": "bearer", + "bearerFormat": "JWT" + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.1.0/app17.json b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.1.0/app17.json new file mode 100644 index 000000000..f62a6e888 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.1.0/app17.json @@ -0,0 +1,452 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/childProperties": { + "get": { + "tags": [ + "child-property-entity-controller" + ], + "description": "get-childproperty", + "operationId": "getCollectionResource-childproperty-get", + "parameters": [ + { + "name": "page", + "in": "query", + "description": "Zero-based page index (0..N)", + "required": false, + "schema": { + "minimum": 0, + "type": "integer", + "default": 0 + } + }, + { + "name": "size", + "in": "query", + "description": "The size of the page to be returned", + "required": false, + "schema": { + "minimum": 1, + "type": "integer", + "default": 20 + } + }, + { + "name": "sort", + "in": "query", + "description": "Sorting criteria in the format: property,(asc|desc). Default sort order is ascending. Multiple sort criteria are supported.", + "required": false, + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/PagedModelEntityModelChildProperty" + } + }, + "application/x-spring-data-compact+json": { + "schema": { + "$ref": "#/components/schemas/PagedModelEntityModelChildProperty" + } + }, + "text/uri-list": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/profile": { + "get": { + "tags": [ + "profile-controller" + ], + "operationId": "listAllFormsOfMetadata", + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/RepresentationModelObject" + } + } + } + } + } + } + }, + "/profile/childProperties": { + "get": { + "tags": [ + "profile-controller" + ], + "operationId": "descriptor", + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "string" + } + }, + "application/alps+json": { + "schema": { + "type": "string" + } + }, + "application/schema+json": { + "schema": { + "$ref": "#/components/schemas/JsonSchema" + } + } + } + } + } + } + }, + "/profile/properties": { + "get": { + "tags": [ + "profile-controller" + ], + "operationId": "descriptor_1", + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "string" + } + }, + "application/alps+json": { + "schema": { + "type": "string" + } + }, + "application/schema+json": { + "schema": { + "$ref": "#/components/schemas/JsonSchema" + } + } + } + } + } + } + }, + "/properties": { + "get": { + "tags": [ + "property-entity-controller" + ], + "description": "get-property", + "operationId": "getCollectionResource-property-get", + "parameters": [ + { + "name": "page", + "in": "query", + "description": "Zero-based page index (0..N)", + "required": false, + "schema": { + "minimum": 0, + "type": "integer", + "default": 0 + } + }, + { + "name": "size", + "in": "query", + "description": "The size of the page to be returned", + "required": false, + "schema": { + "minimum": 1, + "type": "integer", + "default": 20 + } + }, + { + "name": "sort", + "in": "query", + "description": "Sorting criteria in the format: property,(asc|desc). Default sort order is ascending. Multiple sort criteria are supported.", + "required": false, + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/PagedModelEntityModelProperty" + } + }, + "application/x-spring-data-compact+json": { + "schema": { + "$ref": "#/components/schemas/PagedModelEntityModelProperty" + } + }, + "text/uri-list": { + "schema": { + "type": "string" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "AbstractJsonSchemaPropertyObject": { + "type": "object", + "properties": { + "title": { + "type": "string" + }, + "readOnly": { + "type": "boolean" + } + } + }, + "Item": { + "type": "object", + "properties": { + "type": { + "type": "string" + }, + "properties": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/AbstractJsonSchemaPropertyObject" + } + }, + "requiredProperties": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "JsonSchema": { + "type": "object", + "properties": { + "title": { + "type": "string" + }, + "description": { + "type": "string" + }, + "properties": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/AbstractJsonSchemaPropertyObject" + } + }, + "requiredProperties": { + "type": "array", + "items": { + "type": "string" + } + }, + "definitions": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/Item" + } + }, + "type": { + "type": "string" + }, + "$schema": { + "type": "string" + } + } + }, + "Links": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/Link" + } + }, + "RepresentationModelObject": { + "type": "object", + "properties": { + "_links": { + "$ref": "#/components/schemas/Links" + } + } + }, + "ChildProperty": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "name": { + "type": "string" + } + } + }, + "EntityModelChildProperty": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "name": { + "type": "string" + }, + "_links": { + "$ref": "#/components/schemas/Links" + } + } + }, + "PageMetadata": { + "type": "object", + "properties": { + "size": { + "type": "integer", + "format": "int64" + }, + "totalElements": { + "type": "integer", + "format": "int64" + }, + "totalPages": { + "type": "integer", + "format": "int64" + }, + "number": { + "type": "integer", + "format": "int64" + } + } + }, + "PagedModelEntityModelChildProperty": { + "type": "object", + "properties": { + "_embedded": { + "type": "object", + "properties": { + "childProperties": { + "type": "array", + "items": { + "$ref": "#/components/schemas/EntityModelChildProperty" + } + } + } + }, + "_links": { + "$ref": "#/components/schemas/Links" + }, + "page": { + "$ref": "#/components/schemas/PageMetadata" + } + } + }, + "EntityModelProperty": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "name": { + "type": "string" + }, + "myChildPropertyName": { + "$ref": "#/components/schemas/ChildProperty" + }, + "_links": { + "$ref": "#/components/schemas/Links" + } + } + }, + "PagedModelEntityModelProperty": { + "type": "object", + "properties": { + "_embedded": { + "type": "object", + "properties": { + "properties": { + "type": "array", + "items": { + "$ref": "#/components/schemas/EntityModelProperty" + } + } + } + }, + "_links": { + "$ref": "#/components/schemas/Links" + }, + "page": { + "$ref": "#/components/schemas/PageMetadata" + } + } + }, + "Link": { + "type": "object", + "properties": { + "href": { + "type": "string" + }, + "hreflang": { + "type": "string" + }, + "title": { + "type": "string" + }, + "type": { + "type": "string" + }, + "deprecation": { + "type": "string" + }, + "profile": { + "type": "string" + }, + "name": { + "type": "string" + }, + "templated": { + "type": "boolean" + } + } + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.1.0/app18.json b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.1.0/app18.json new file mode 100644 index 000000000..fa8936163 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.1.0/app18.json @@ -0,0 +1,123 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/latest/helloWorld/helloWorld": { + "get": { + "tags": [ + "hello-controller" + ], + "summary": "Example endpoint", + "operationId": "helloWorld", + "parameters": [ + { + "name": "abc", + "in": "query", + "description": "Description for abc", + "required": true, + "schema": { + "type": "string" + }, + "example": "def" + }, + { + "name": "thisDate", + "in": "query", + "description": "Description of this date", + "required": true, + "schema": { + "type": "string", + "format": "date" + }, + "example": "2020-10-25" + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/HelloWorldModel" + } + } + } + } + } + } + }, + "/v1/helloWorld/helloWorld": { + "get": { + "tags": [ + "hello-controller" + ], + "summary": "Example endpoint", + "operationId": "helloWorld_1", + "parameters": [ + { + "name": "abc", + "in": "query", + "description": "Description for abc", + "required": true, + "schema": { + "type": "string" + }, + "example": "def" + }, + { + "name": "thisDate", + "in": "query", + "description": "Description of this date", + "required": true, + "schema": { + "type": "string", + "format": "date" + }, + "example": "2020-10-25" + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/HelloWorldModel" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "HelloWorldModel": { + "required": [ + "abc", + "thisDate" + ], + "type": "object", + "properties": { + "abc": { + "type": "string" + }, + "thisDate": { + "type": "string", + "format": "date" + } + } + } + } + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.1.0/app19.json b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.1.0/app19.json new file mode 100644 index 000000000..0013f04e1 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.1.0/app19.json @@ -0,0 +1,62 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/test2": { + "get": { + "tags": [ + "greeting-controller" + ], + "operationId": "sayHello2", + "parameters": [ + { + "name": "test", + "in": "query", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "name", + "in": "query", + "schema": { + "type": "string" + } + }, + { + "name": "icon", + "in": "query", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "type": "object" + } + } + } + } + } + } + } + }, + "components": { + "schemas": {} + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.1.0/app2.json b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.1.0/app2.json new file mode 100644 index 000000000..b745cc8fe --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.1.0/app2.json @@ -0,0 +1,95 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/search": { + "get": { + "tags": [ + "hello-controller" + ], + "operationId": "getAllPets", + "parameters": [ + { + "name": "pageable", + "in": "query", + "required": true, + "schema": { + "$ref": "#/components/schemas/Pageable" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/xml": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/PersonDTO" + } + } + }, + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/PersonDTO" + } + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "Pageable": { + "type": "object", + "properties": { + "page": { + "minimum": 0, + "type": "integer", + "format": "int32" + }, + "size": { + "minimum": 1, + "type": "integer", + "format": "int32" + }, + "sort": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "PersonDTO": { + "type": "object", + "properties": { + "email": { + "type": "string" + }, + "firstName": { + "type": "string" + }, + "lastName": { + "type": "string" + } + } + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.1.0/app20.json b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.1.0/app20.json new file mode 100644 index 000000000..21565f6af --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.1.0/app20.json @@ -0,0 +1,563 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "Core API" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/banks": { + "get": { + "tags": [ + "bank-entity-controller" + ], + "description": "get-bank", + "operationId": "getCollectionResource-bank-get", + "parameters": [ + { + "name": "page", + "in": "query", + "description": "Zero-based page index (0..N)", + "required": false, + "schema": { + "minimum": 0, + "type": "integer", + "default": 0 + } + }, + { + "name": "size", + "in": "query", + "description": "The size of the page to be returned", + "required": false, + "schema": { + "minimum": 1, + "type": "integer", + "default": 20 + } + }, + { + "name": "sort", + "in": "query", + "description": "Sorting criteria in the format: property,(asc|desc). Default sort order is ascending. Multiple sort criteria are supported.", + "required": false, + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/PagedModelEntityModelBank" + } + }, + "application/x-spring-data-compact+json": { + "schema": { + "$ref": "#/components/schemas/PagedModelEntityModelBank" + } + }, + "text/uri-list": { + "schema": { + "type": "string" + } + } + } + } + } + }, + "post": { + "tags": [ + "bank-entity-controller" + ], + "description": "create-bank", + "operationId": "postCollectionResource-bank-post", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/BankRequestBody" + } + } + }, + "required": true + }, + "responses": { + "201": { + "description": "Created", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/EntityModelBank" + } + } + } + } + } + } + }, + "/banks/search/countByCode": { + "get": { + "tags": [ + "bank-search-controller" + ], + "operationId": "executeSearch-bank-get", + "parameters": [ + { + "name": "code", + "in": "query", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "type": "integer", + "format": "int64" + } + } + } + }, + "404": { + "description": "Not Found" + } + } + } + }, + "/banks/search/findOneByCode": { + "get": { + "tags": [ + "bank-search-controller" + ], + "operationId": "executeSearch-bank-get_1", + "parameters": [ + { + "name": "code", + "in": "query", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/EntityModelBank" + } + } + } + }, + "404": { + "description": "Not Found" + } + } + } + }, + "/banks/{id}": { + "get": { + "tags": [ + "bank-entity-controller" + ], + "description": "get-bank", + "operationId": "getItemResource-bank-get", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/EntityModelBank" + } + } + } + }, + "404": { + "description": "Not Found" + } + } + }, + "put": { + "tags": [ + "bank-entity-controller" + ], + "description": "update-bank", + "operationId": "putItemResource-bank-put", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/BankRequestBody" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/EntityModelBank" + } + } + } + }, + "201": { + "description": "Created", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/EntityModelBank" + } + } + } + }, + "204": { + "description": "No Content" + } + } + }, + "delete": { + "tags": [ + "bank-entity-controller" + ], + "description": "delete-bank", + "operationId": "deleteItemResource-bank-delete", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "204": { + "description": "No Content" + }, + "404": { + "description": "Not Found" + } + } + }, + "patch": { + "tags": [ + "bank-entity-controller" + ], + "description": "patch-bank", + "operationId": "patchItemResource-bank-patch", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/BankRequestBody" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/EntityModelBank" + } + } + } + }, + "204": { + "description": "No Content" + } + } + } + }, + "/profile": { + "get": { + "tags": [ + "profile-controller" + ], + "operationId": "listAllFormsOfMetadata", + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/RepresentationModelObject" + } + } + } + } + } + } + }, + "/profile/banks": { + "get": { + "tags": [ + "profile-controller" + ], + "operationId": "descriptor", + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "string" + } + }, + "application/alps+json": { + "schema": { + "type": "string" + } + }, + "application/schema+json": { + "schema": { + "$ref": "#/components/schemas/JsonSchema" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "AbstractJsonSchemaPropertyObject": { + "type": "object", + "properties": { + "title": { + "type": "string" + }, + "readOnly": { + "type": "boolean" + } + } + }, + "Item": { + "type": "object", + "properties": { + "type": { + "type": "string" + }, + "properties": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/AbstractJsonSchemaPropertyObject" + } + }, + "requiredProperties": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "JsonSchema": { + "type": "object", + "properties": { + "title": { + "type": "string" + }, + "description": { + "type": "string" + }, + "properties": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/AbstractJsonSchemaPropertyObject" + } + }, + "requiredProperties": { + "type": "array", + "items": { + "type": "string" + } + }, + "definitions": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/Item" + } + }, + "type": { + "type": "string" + }, + "$schema": { + "type": "string" + } + } + }, + "Links": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/Link" + } + }, + "RepresentationModelObject": { + "type": "object", + "properties": { + "_links": { + "$ref": "#/components/schemas/Links" + } + } + }, + "EntityModelBank": { + "type": "object", + "properties": { + "code": { + "type": "string" + }, + "name": { + "type": "string" + }, + "_links": { + "$ref": "#/components/schemas/Links" + } + } + }, + "PageMetadata": { + "type": "object", + "properties": { + "size": { + "type": "integer", + "format": "int64" + }, + "totalElements": { + "type": "integer", + "format": "int64" + }, + "totalPages": { + "type": "integer", + "format": "int64" + }, + "number": { + "type": "integer", + "format": "int64" + } + } + }, + "PagedModelEntityModelBank": { + "type": "object", + "properties": { + "_embedded": { + "type": "object", + "properties": { + "banks": { + "type": "array", + "items": { + "$ref": "#/components/schemas/EntityModelBank" + } + } + } + }, + "_links": { + "$ref": "#/components/schemas/Links" + }, + "page": { + "$ref": "#/components/schemas/PageMetadata" + } + } + }, + "BankRequestBody": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "code": { + "type": "string" + }, + "name": { + "type": "string" + } + } + }, + "Link": { + "type": "object", + "properties": { + "href": { + "type": "string" + }, + "hreflang": { + "type": "string" + }, + "title": { + "type": "string" + }, + "type": { + "type": "string" + }, + "deprecation": { + "type": "string" + }, + "profile": { + "type": "string" + }, + "name": { + "type": "string" + }, + "templated": { + "type": "boolean" + } + } + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.1.0/app21.json b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.1.0/app21.json new file mode 100644 index 000000000..adc13ea4a --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.1.0/app21.json @@ -0,0 +1,432 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/peopleme": { + "get": { + "tags": [ + "person-entity-controller" + ], + "description": "get-person", + "operationId": "getCollectionResource-person-get", + "parameters": [ + { + "name": "page", + "in": "query", + "description": "Zero-based page index (0..N)", + "required": false, + "schema": { + "minimum": 0, + "type": "integer", + "default": 0 + } + }, + { + "name": "size", + "in": "query", + "description": "The size of the page to be returned", + "required": false, + "schema": { + "minimum": 1, + "type": "integer", + "default": 20 + } + }, + { + "name": "sort", + "in": "query", + "description": "Sorting criteria in the format: property,(asc|desc). Default sort order is ascending. Multiple sort criteria are supported.", + "required": false, + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/PagedModelEntityModelPerson" + } + }, + "application/x-spring-data-compact+json": { + "schema": { + "$ref": "#/components/schemas/PagedModelEntityModelPerson" + } + }, + "text/uri-list": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/peopleme/search/findByFirstName": { + "get": { + "tags": [ + "person-search-controller" + ], + "description": "this is another test", + "operationId": "executeSearch-person-get", + "parameters": [ + { + "name": "firstName", + "in": "query", + "description": "this is for first Name", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "another successful operation", + "content": { + "application/hal+json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Person" + } + } + } + } + }, + "404": { + "description": "another Contact not found", + "content": { + "application/hal+json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Person" + } + } + } + } + } + } + } + }, + "/peopleme/search/findByLastName": { + "get": { + "tags": [ + "person-search-controller" + ], + "description": "this is my test", + "operationId": "executeSearch-person-get_1", + "parameters": [ + { + "name": "lastName", + "in": "query", + "schema": { + "type": "string" + } + } + ], + "responses": { + "400": { + "description": "Invalid ID supplied", + "content": { + "application/hal+json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Person" + } + } + } + } + }, + "200": { + "description": "successful operation", + "content": { + "application/hal+json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Person" + } + } + } + } + }, + "404": { + "description": "Contact not found", + "content": { + "application/hal+json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Person" + } + } + } + } + }, + "405": { + "description": "Validation exception", + "content": { + "application/hal+json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Person" + } + } + } + } + } + } + } + }, + "/profile": { + "get": { + "tags": [ + "profile-controller" + ], + "operationId": "listAllFormsOfMetadata", + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/RepresentationModelObject" + } + } + } + } + } + } + }, + "/profile/peopleme": { + "get": { + "tags": [ + "profile-controller" + ], + "operationId": "descriptor", + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "string" + } + }, + "application/alps+json": { + "schema": { + "type": "string" + } + }, + "application/schema+json": { + "schema": { + "$ref": "#/components/schemas/JsonSchema" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "AbstractJsonSchemaPropertyObject": { + "type": "object", + "properties": { + "title": { + "type": "string" + }, + "readOnly": { + "type": "boolean" + } + } + }, + "Item": { + "type": "object", + "properties": { + "type": { + "type": "string" + }, + "properties": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/AbstractJsonSchemaPropertyObject" + } + }, + "requiredProperties": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "JsonSchema": { + "type": "object", + "properties": { + "title": { + "type": "string" + }, + "description": { + "type": "string" + }, + "properties": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/AbstractJsonSchemaPropertyObject" + } + }, + "requiredProperties": { + "type": "array", + "items": { + "type": "string" + } + }, + "definitions": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/Item" + } + }, + "type": { + "type": "string" + }, + "$schema": { + "type": "string" + } + } + }, + "Links": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/Link" + } + }, + "RepresentationModelObject": { + "type": "object", + "properties": { + "_links": { + "$ref": "#/components/schemas/Links" + } + } + }, + "EntityModelPerson": { + "type": "object", + "properties": { + "firstName": { + "type": "string" + }, + "lastName": { + "type": "string" + }, + "_links": { + "$ref": "#/components/schemas/Links" + } + } + }, + "PageMetadata": { + "type": "object", + "properties": { + "size": { + "type": "integer", + "format": "int64" + }, + "totalElements": { + "type": "integer", + "format": "int64" + }, + "totalPages": { + "type": "integer", + "format": "int64" + }, + "number": { + "type": "integer", + "format": "int64" + } + } + }, + "PagedModelEntityModelPerson": { + "type": "object", + "properties": { + "_embedded": { + "type": "object", + "properties": { + "people": { + "type": "array", + "items": { + "$ref": "#/components/schemas/EntityModelPerson" + } + } + } + }, + "_links": { + "$ref": "#/components/schemas/Links" + }, + "page": { + "$ref": "#/components/schemas/PageMetadata" + } + } + }, + "Person": { + "type": "object", + "properties": { + "firstName": { + "type": "string" + }, + "lastName": { + "type": "string" + } + } + }, + "Link": { + "type": "object", + "properties": { + "href": { + "type": "string" + }, + "hreflang": { + "type": "string" + }, + "title": { + "type": "string" + }, + "type": { + "type": "string" + }, + "deprecation": { + "type": "string" + }, + "profile": { + "type": "string" + }, + "name": { + "type": "string" + }, + "templated": { + "type": "boolean" + } + } + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.1.0/app22.json b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.1.0/app22.json new file mode 100644 index 000000000..d24d579c4 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.1.0/app22.json @@ -0,0 +1,343 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/people": { + "get": { + "tags": [ + "person-entity-controller" + ], + "description": "get-person", + "operationId": "getCollectionResource-person-get", + "parameters": [ + { + "name": "page", + "in": "query", + "description": "Zero-based page index (0..N)", + "required": false, + "schema": { + "minimum": 0, + "type": "integer", + "default": 0 + } + }, + { + "name": "size", + "in": "query", + "description": "The size of the page to be returned", + "required": false, + "schema": { + "minimum": 1, + "type": "integer", + "default": 20 + } + }, + { + "name": "sort", + "in": "query", + "description": "Sorting criteria in the format: property,(asc|desc). Default sort order is ascending. Multiple sort criteria are supported.", + "required": false, + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/PagedModelEntityModelPerson" + } + }, + "application/x-spring-data-compact+json": { + "schema": { + "$ref": "#/components/schemas/PagedModelEntityModelPerson" + } + }, + "text/uri-list": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/profile": { + "get": { + "tags": [ + "profile-controller" + ], + "operationId": "listAllFormsOfMetadata", + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/RepresentationModelObject" + } + } + } + } + } + } + }, + "/profile/people": { + "get": { + "tags": [ + "profile-controller" + ], + "operationId": "descriptor", + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "string" + } + }, + "application/alps+json": { + "schema": { + "type": "string" + } + }, + "application/schema+json": { + "schema": { + "$ref": "#/components/schemas/JsonSchema" + } + } + } + } + } + } + }, + "/people/test": { + "get": { + "tags": [ + "person-api" + ], + "operationId": "test", + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/Person" + } + }, + "application/json": { + "schema": { + "$ref": "#/components/schemas/Person" + } + }, + "application/prs.hal-forms+json": { + "schema": { + "$ref": "#/components/schemas/Person" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "AbstractJsonSchemaPropertyObject": { + "type": "object", + "properties": { + "title": { + "type": "string" + }, + "readOnly": { + "type": "boolean" + } + } + }, + "Item": { + "type": "object", + "properties": { + "type": { + "type": "string" + }, + "properties": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/AbstractJsonSchemaPropertyObject" + } + }, + "requiredProperties": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "JsonSchema": { + "type": "object", + "properties": { + "title": { + "type": "string" + }, + "description": { + "type": "string" + }, + "properties": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/AbstractJsonSchemaPropertyObject" + } + }, + "requiredProperties": { + "type": "array", + "items": { + "type": "string" + } + }, + "definitions": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/Item" + } + }, + "type": { + "type": "string" + }, + "$schema": { + "type": "string" + } + } + }, + "Links": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/Link" + } + }, + "RepresentationModelObject": { + "type": "object", + "properties": { + "_links": { + "$ref": "#/components/schemas/Links" + } + } + }, + "EntityModelPerson": { + "type": "object", + "properties": { + "firstName": { + "type": "string" + }, + "lastName": { + "type": "string" + }, + "_links": { + "$ref": "#/components/schemas/Links" + } + } + }, + "PageMetadata": { + "type": "object", + "properties": { + "size": { + "type": "integer", + "format": "int64" + }, + "totalElements": { + "type": "integer", + "format": "int64" + }, + "totalPages": { + "type": "integer", + "format": "int64" + }, + "number": { + "type": "integer", + "format": "int64" + } + } + }, + "PagedModelEntityModelPerson": { + "type": "object", + "properties": { + "_embedded": { + "type": "object", + "properties": { + "people": { + "type": "array", + "items": { + "$ref": "#/components/schemas/EntityModelPerson" + } + } + } + }, + "_links": { + "$ref": "#/components/schemas/Links" + }, + "page": { + "$ref": "#/components/schemas/PageMetadata" + } + } + }, + "Person": { + "type": "object", + "properties": { + "firstName": { + "type": "string" + }, + "lastName": { + "type": "string" + } + } + }, + "Link": { + "type": "object", + "properties": { + "href": { + "type": "string" + }, + "hreflang": { + "type": "string" + }, + "title": { + "type": "string" + }, + "type": { + "type": "string" + }, + "deprecation": { + "type": "string" + }, + "profile": { + "type": "string" + }, + "name": { + "type": "string" + }, + "templated": { + "type": "boolean" + } + } + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.1.0/app23.json b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.1.0/app23.json new file mode 100644 index 000000000..232b86a03 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.1.0/app23.json @@ -0,0 +1,1026 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/clinics": { + "get": { + "tags": [ + "clinic-entity-controller" + ], + "description": "get-clinic", + "operationId": "getCollectionResource-clinic-get", + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/CollectionModelEntityModelClinic" + } + }, + "application/x-spring-data-compact+json": { + "schema": { + "$ref": "#/components/schemas/CollectionModelEntityModelClinic" + } + }, + "text/uri-list": { + "schema": { + "type": "string" + } + } + } + } + } + }, + "post": { + "tags": [ + "clinic-entity-controller" + ], + "description": "create-clinic", + "operationId": "postCollectionResource-clinic-post", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ClinicRequestBody" + } + } + }, + "required": true + }, + "responses": { + "201": { + "description": "Created", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/EntityModelClinic" + } + } + } + } + } + } + }, + "/clinics/{id}": { + "get": { + "tags": [ + "clinic-entity-controller" + ], + "description": "get-clinic", + "operationId": "getItemResource-clinic-get", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/EntityModelClinic" + } + } + } + }, + "404": { + "description": "Not Found" + } + } + }, + "put": { + "tags": [ + "clinic-entity-controller" + ], + "description": "update-clinic", + "operationId": "putItemResource-clinic-put", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ClinicRequestBody" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/EntityModelClinic" + } + } + } + }, + "201": { + "description": "Created", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/EntityModelClinic" + } + } + } + }, + "204": { + "description": "No Content" + } + } + }, + "delete": { + "tags": [ + "clinic-entity-controller" + ], + "description": "delete-clinic", + "operationId": "deleteItemResource-clinic-delete", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "204": { + "description": "No Content" + }, + "404": { + "description": "Not Found" + } + } + }, + "patch": { + "tags": [ + "clinic-entity-controller" + ], + "description": "patch-clinic", + "operationId": "patchItemResource-clinic-patch", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ClinicRequestBody" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/EntityModelClinic" + } + } + } + }, + "204": { + "description": "No Content" + } + } + } + }, + "/doctors": { + "get": { + "tags": [ + "doctor-entity-controller" + ], + "description": "get-doctor", + "operationId": "getCollectionResource-doctor-get", + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/CollectionModelEntityModelDoctor" + } + }, + "application/x-spring-data-compact+json": { + "schema": { + "$ref": "#/components/schemas/CollectionModelEntityModelDoctor" + } + }, + "text/uri-list": { + "schema": { + "type": "string" + } + } + } + } + } + }, + "post": { + "tags": [ + "doctor-entity-controller" + ], + "description": "create-doctor", + "operationId": "postCollectionResource-doctor-post", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/DoctorRequestBody" + } + } + }, + "required": true + }, + "responses": { + "201": { + "description": "Created", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/EntityModelDoctor" + } + } + } + } + } + } + }, + "/doctors/{id}": { + "get": { + "tags": [ + "doctor-entity-controller" + ], + "description": "get-doctor", + "operationId": "getItemResource-doctor-get", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/EntityModelDoctor" + } + } + } + }, + "404": { + "description": "Not Found" + } + } + }, + "put": { + "tags": [ + "doctor-entity-controller" + ], + "description": "update-doctor", + "operationId": "putItemResource-doctor-put", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/DoctorRequestBody" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/EntityModelDoctor" + } + } + } + }, + "201": { + "description": "Created", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/EntityModelDoctor" + } + } + } + }, + "204": { + "description": "No Content" + } + } + }, + "delete": { + "tags": [ + "doctor-entity-controller" + ], + "description": "delete-doctor", + "operationId": "deleteItemResource-doctor-delete", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "204": { + "description": "No Content" + }, + "404": { + "description": "Not Found" + } + } + }, + "patch": { + "tags": [ + "doctor-entity-controller" + ], + "description": "patch-doctor", + "operationId": "patchItemResource-doctor-patch", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/DoctorRequestBody" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/EntityModelDoctor" + } + } + } + }, + "204": { + "description": "No Content" + } + } + } + }, + "/doctors/{id}/clinics": { + "get": { + "tags": [ + "doctor-property-reference-controller" + ], + "description": "get-clinic-by-doctor-Id", + "operationId": "followPropertyReference-doctor-get", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/CollectionModelClinic" + } + }, + "text/uri-list": { + "schema": { + "type": "string" + } + } + } + }, + "404": { + "description": "Not Found" + } + } + }, + "put": { + "tags": [ + "doctor-property-reference-controller" + ], + "description": "update-clinic-by-doctor-Id", + "operationId": "createPropertyReference-doctor-put", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CollectionModelObject" + } + }, + "application/x-spring-data-compact+json": { + "schema": { + "$ref": "#/components/schemas/CollectionModelObject" + } + }, + "text/uri-list": { + "schema": { + "type": "string" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/CollectionModelClinic" + } + } + } + }, + "201": { + "description": "Created", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/CollectionModelClinic" + } + } + } + }, + "204": { + "description": "No Content" + } + } + }, + "delete": { + "tags": [ + "doctor-property-reference-controller" + ], + "description": "delete-clinic-by-doctor-Id", + "operationId": "deletePropertyReference-doctor-delete", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "204": { + "description": "No Content" + }, + "404": { + "description": "Not Found" + } + } + }, + "patch": { + "tags": [ + "doctor-property-reference-controller" + ], + "description": "patch-clinic-by-doctor-Id", + "operationId": "createPropertyReference-doctor-patch", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CollectionModelObject" + } + }, + "application/x-spring-data-compact+json": { + "schema": { + "$ref": "#/components/schemas/CollectionModelObject" + } + }, + "text/uri-list": { + "schema": { + "type": "string" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/CollectionModelClinic" + } + } + } + }, + "204": { + "description": "No Content" + } + } + } + }, + "/doctors/{id}/clinics/{propertyId}": { + "get": { + "tags": [ + "doctor-property-reference-controller" + ], + "description": "get-clinic-by-doctor-Id", + "operationId": "followPropertyReference-doctor-get_1", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "propertyId", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/CollectionModelClinic" + } + } + } + }, + "404": { + "description": "Not Found" + } + } + }, + "delete": { + "tags": [ + "doctor-property-reference-controller" + ], + "description": "delete-clinic-by-doctor-Id", + "operationId": "deletePropertyReferenceId-doctor-delete", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "propertyId", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "204": { + "description": "No Content" + }, + "404": { + "description": "Not Found" + } + } + } + }, + "/profile": { + "get": { + "tags": [ + "profile-controller" + ], + "operationId": "listAllFormsOfMetadata", + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/RepresentationModelObject" + } + } + } + } + } + } + }, + "/profile/clinics": { + "get": { + "tags": [ + "profile-controller" + ], + "operationId": "descriptor", + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "string" + } + }, + "application/alps+json": { + "schema": { + "type": "string" + } + }, + "application/schema+json": { + "schema": { + "$ref": "#/components/schemas/JsonSchema" + } + } + } + } + } + } + }, + "/profile/doctors": { + "get": { + "tags": [ + "profile-controller" + ], + "operationId": "descriptor_1", + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "string" + } + }, + "application/alps+json": { + "schema": { + "type": "string" + } + }, + "application/schema+json": { + "schema": { + "$ref": "#/components/schemas/JsonSchema" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "AbstractJsonSchemaPropertyObject": { + "type": "object", + "properties": { + "title": { + "type": "string" + }, + "readOnly": { + "type": "boolean" + } + } + }, + "Item": { + "type": "object", + "properties": { + "type": { + "type": "string" + }, + "properties": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/AbstractJsonSchemaPropertyObject" + } + }, + "requiredProperties": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "JsonSchema": { + "type": "object", + "properties": { + "title": { + "type": "string" + }, + "description": { + "type": "string" + }, + "properties": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/AbstractJsonSchemaPropertyObject" + } + }, + "requiredProperties": { + "type": "array", + "items": { + "type": "string" + } + }, + "definitions": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/Item" + } + }, + "type": { + "type": "string" + }, + "$schema": { + "type": "string" + } + } + }, + "Links": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/Link" + } + }, + "RepresentationModelObject": { + "type": "object", + "properties": { + "_links": { + "$ref": "#/components/schemas/Links" + } + } + }, + "EntityModelDoctor": { + "type": "object", + "properties": { + "_links": { + "$ref": "#/components/schemas/Links" + } + } + }, + "CollectionModelEntityModelDoctor": { + "type": "object", + "properties": { + "_embedded": { + "type": "object", + "properties": { + "doctors": { + "type": "array", + "items": { + "$ref": "#/components/schemas/EntityModelDoctor" + } + } + } + }, + "_links": { + "$ref": "#/components/schemas/Links" + } + } + }, + "CollectionModelClinic": { + "type": "object", + "properties": { + "_embedded": { + "type": "object", + "properties": { + "clinics": { + "type": "array", + "items": { + "$ref": "#/components/schemas/ClinicResponse" + } + } + } + }, + "_links": { + "$ref": "#/components/schemas/Links" + } + } + }, + "CollectionModelObject": { + "type": "object", + "properties": { + "_embedded": { + "type": "object", + "properties": { + "objects": { + "type": "array", + "items": { + "type": "object" + } + } + } + }, + "_links": { + "$ref": "#/components/schemas/Links" + } + } + }, + "EntityModelClinic": { + "required": [ + "name" + ], + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "_links": { + "$ref": "#/components/schemas/Links" + } + } + }, + "CollectionModelEntityModelClinic": { + "type": "object", + "properties": { + "_embedded": { + "type": "object", + "properties": { + "clinics": { + "type": "array", + "items": { + "$ref": "#/components/schemas/EntityModelClinic" + } + } + } + }, + "_links": { + "$ref": "#/components/schemas/Links" + } + } + }, + "ClinicRequestBody": { + "required": [ + "name" + ], + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "name": { + "type": "string" + } + } + }, + "DoctorRequestBody": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "clinics": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "ClinicResponse": { + "required": [ + "name" + ], + "type": "object", + "properties": { + "name": { + "type": "string" + } + } + }, + "Link": { + "type": "object", + "properties": { + "href": { + "type": "string" + }, + "hreflang": { + "type": "string" + }, + "title": { + "type": "string" + }, + "type": { + "type": "string" + }, + "deprecation": { + "type": "string" + }, + "profile": { + "type": "string" + }, + "name": { + "type": "string" + }, + "templated": { + "type": "boolean" + } + } + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.1.0/app24.json b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.1.0/app24.json new file mode 100644 index 000000000..76b3a324f --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.1.0/app24.json @@ -0,0 +1,188 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/": { + "get": { + "tags": [ + "teste-resource" + ], + "operationId": "testeQueryDslAndSpringDoc", + "parameters": [ + { + "name": "pageable", + "in": "query", + "required": true, + "schema": { + "$ref": "#/components/schemas/Pageable" + } + }, + { + "name": "name", + "in": "query", + "schema": { + "type": "string" + } + }, + { + "name": "email", + "in": "query", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/PageUser" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "Pageable": { + "type": "object", + "properties": { + "page": { + "minimum": 0, + "type": "integer", + "format": "int32" + }, + "size": { + "minimum": 1, + "type": "integer", + "format": "int32" + }, + "sort": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "PageUser": { + "type": "object", + "properties": { + "totalPages": { + "type": "integer", + "format": "int32" + }, + "totalElements": { + "type": "integer", + "format": "int64" + }, + "size": { + "type": "integer", + "format": "int32" + }, + "content": { + "type": "array", + "items": { + "$ref": "#/components/schemas/User" + } + }, + "number": { + "type": "integer", + "format": "int32" + }, + "sort": { + "$ref": "#/components/schemas/SortObject" + }, + "last": { + "type": "boolean" + }, + "pageable": { + "$ref": "#/components/schemas/PageableObject" + }, + "first": { + "type": "boolean" + }, + "numberOfElements": { + "type": "integer", + "format": "int32" + }, + "empty": { + "type": "boolean" + } + } + }, + "PageableObject": { + "type": "object", + "properties": { + "offset": { + "type": "integer", + "format": "int64" + }, + "sort": { + "$ref": "#/components/schemas/SortObject" + }, + "pageNumber": { + "type": "integer", + "format": "int32" + }, + "pageSize": { + "type": "integer", + "format": "int32" + }, + "paged": { + "type": "boolean" + }, + "unpaged": { + "type": "boolean" + } + } + }, + "SortObject": { + "type": "object", + "properties": { + "empty": { + "type": "boolean" + }, + "sorted": { + "type": "boolean" + }, + "unsorted": { + "type": "boolean" + } + } + }, + "User": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "firstName": { + "type": "string" + }, + "lastName": { + "type": "string" + }, + "email": { + "type": "string" + } + } + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.1.0/app25.json b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.1.0/app25.json new file mode 100644 index 000000000..52c638696 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.1.0/app25.json @@ -0,0 +1,2718 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/clinics": { + "get": { + "tags": [ + "clinic-entity-controller" + ], + "description": "get-clinic", + "operationId": "getCollectionResource-clinic-get", + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/CollectionModelEntityModelClinic" + } + }, + "application/x-spring-data-compact+json": { + "schema": { + "$ref": "#/components/schemas/CollectionModelEntityModelClinic" + } + }, + "text/uri-list": { + "schema": { + "type": "string" + } + } + } + } + } + }, + "post": { + "tags": [ + "clinic-entity-controller" + ], + "description": "create-clinic", + "operationId": "postCollectionResource-clinic-post", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ClinicRequestBody" + } + } + }, + "required": true + }, + "responses": { + "201": { + "description": "Created", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/EntityModelClinic" + } + } + } + } + } + } + }, + "/clinics/{id}": { + "get": { + "tags": [ + "clinic-entity-controller" + ], + "description": "get-clinic", + "operationId": "getItemResource-clinic-get", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/EntityModelClinic" + } + } + } + }, + "404": { + "description": "Not Found" + } + } + }, + "put": { + "tags": [ + "clinic-entity-controller" + ], + "description": "update-clinic", + "operationId": "putItemResource-clinic-put", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ClinicRequestBody" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/EntityModelClinic" + } + } + } + }, + "201": { + "description": "Created", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/EntityModelClinic" + } + } + } + }, + "204": { + "description": "No Content" + } + } + }, + "delete": { + "tags": [ + "clinic-entity-controller" + ], + "description": "delete-clinic", + "operationId": "deleteItemResource-clinic-delete", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "204": { + "description": "No Content" + }, + "404": { + "description": "Not Found" + } + } + }, + "patch": { + "tags": [ + "clinic-entity-controller" + ], + "description": "patch-clinic", + "operationId": "patchItemResource-clinic-patch", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ClinicRequestBody" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/EntityModelClinic" + } + } + } + }, + "204": { + "description": "No Content" + } + } + } + }, + "/doctors": { + "get": { + "tags": [ + "doctor-entity-controller" + ], + "description": "get-doctor", + "operationId": "getCollectionResource-doctor-get", + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/CollectionModelEntityModelDoctor" + } + }, + "application/x-spring-data-compact+json": { + "schema": { + "$ref": "#/components/schemas/CollectionModelEntityModelDoctor" + } + }, + "text/uri-list": { + "schema": { + "type": "string" + } + } + } + } + } + }, + "post": { + "tags": [ + "doctor-entity-controller" + ], + "description": "create-doctor", + "operationId": "postCollectionResource-doctor-post", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/DoctorRequestBody" + } + } + }, + "required": true + }, + "responses": { + "201": { + "description": "Created", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/EntityModelDoctor" + } + } + } + } + } + } + }, + "/doctors/search/findByClinicsContains": { + "get": { + "tags": [ + "doctor-search-controller" + ], + "operationId": "executeSearch-doctor-get", + "parameters": [ + { + "name": "clinic", + "in": "query", + "schema": { + "$ref": "#/components/schemas/Clinic" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/CollectionModelEntityModelDoctor" + } + } + } + }, + "404": { + "description": "Not Found" + } + } + } + }, + "/doctors/{id}": { + "get": { + "tags": [ + "doctor-entity-controller" + ], + "description": "get-doctor", + "operationId": "getItemResource-doctor-get", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/EntityModelDoctor" + } + } + } + }, + "404": { + "description": "Not Found" + } + } + }, + "put": { + "tags": [ + "doctor-entity-controller" + ], + "description": "update-doctor", + "operationId": "putItemResource-doctor-put", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/DoctorRequestBody" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/EntityModelDoctor" + } + } + } + }, + "201": { + "description": "Created", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/EntityModelDoctor" + } + } + } + }, + "204": { + "description": "No Content" + } + } + }, + "delete": { + "tags": [ + "doctor-entity-controller" + ], + "description": "delete-doctor", + "operationId": "deleteItemResource-doctor-delete", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "204": { + "description": "No Content" + }, + "404": { + "description": "Not Found" + } + } + }, + "patch": { + "tags": [ + "doctor-entity-controller" + ], + "description": "patch-doctor", + "operationId": "patchItemResource-doctor-patch", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/DoctorRequestBody" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/EntityModelDoctor" + } + } + } + }, + "204": { + "description": "No Content" + } + } + } + }, + "/doctors/{id}/clinics": { + "get": { + "tags": [ + "doctor-property-reference-controller" + ], + "description": "get-clinic-by-doctor-Id", + "operationId": "followPropertyReference-doctor-get", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/CollectionModelClinic" + } + }, + "text/uri-list": { + "schema": { + "type": "string" + } + } + } + }, + "404": { + "description": "Not Found" + } + } + }, + "put": { + "tags": [ + "doctor-property-reference-controller" + ], + "description": "update-clinic-by-doctor-Id", + "operationId": "createPropertyReference-doctor-put", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CollectionModelObject" + } + }, + "application/x-spring-data-compact+json": { + "schema": { + "$ref": "#/components/schemas/CollectionModelObject" + } + }, + "text/uri-list": { + "schema": { + "type": "string" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/CollectionModelClinic" + } + } + } + }, + "201": { + "description": "Created", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/CollectionModelClinic" + } + } + } + }, + "204": { + "description": "No Content" + } + } + }, + "delete": { + "tags": [ + "doctor-property-reference-controller" + ], + "description": "delete-clinic-by-doctor-Id", + "operationId": "deletePropertyReference-doctor-delete", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "204": { + "description": "No Content" + }, + "404": { + "description": "Not Found" + } + } + }, + "patch": { + "tags": [ + "doctor-property-reference-controller" + ], + "description": "patch-clinic-by-doctor-Id", + "operationId": "createPropertyReference-doctor-patch", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CollectionModelObject" + } + }, + "application/x-spring-data-compact+json": { + "schema": { + "$ref": "#/components/schemas/CollectionModelObject" + } + }, + "text/uri-list": { + "schema": { + "type": "string" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/CollectionModelClinic" + } + } + } + }, + "204": { + "description": "No Content" + } + } + } + }, + "/doctors/{id}/clinics/{propertyId}": { + "get": { + "tags": [ + "doctor-property-reference-controller" + ], + "description": "get-clinic-by-doctor-Id", + "operationId": "followPropertyReference-doctor-get_1", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "propertyId", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/CollectionModelClinic" + } + } + } + }, + "404": { + "description": "Not Found" + } + } + }, + "delete": { + "tags": [ + "doctor-property-reference-controller" + ], + "description": "delete-clinic-by-doctor-Id", + "operationId": "deletePropertyReferenceId-doctor-delete", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "propertyId", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "204": { + "description": "No Content" + }, + "404": { + "description": "Not Found" + } + } + } + }, + "/owners": { + "get": { + "tags": [ + "owner-entity-controller" + ], + "description": "get-owner", + "operationId": "getCollectionResource-owner-get", + "parameters": [ + { + "name": "page", + "in": "query", + "description": "Zero-based page index (0..N)", + "required": false, + "schema": { + "type": "integer", + "default": 0, + "minimum": 0 + } + }, + { + "name": "size", + "in": "query", + "description": "The size of the page to be returned", + "required": false, + "schema": { + "type": "integer", + "default": 20, + "minimum": 1 + } + }, + { + "name": "sort", + "in": "query", + "description": "Sorting criteria in the format: property,(asc|desc). Default sort order is ascending. Multiple sort criteria are supported.", + "required": false, + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/PagedModelEntityModelOwner" + } + }, + "application/x-spring-data-compact+json": { + "schema": { + "$ref": "#/components/schemas/PagedModelEntityModelOwner" + } + }, + "text/uri-list": { + "schema": { + "type": "string" + } + } + } + } + } + }, + "post": { + "tags": [ + "owner-entity-controller" + ], + "description": "create-owner", + "operationId": "postCollectionResource-owner-post", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/OwnerRequestBody" + } + } + }, + "required": true + }, + "responses": { + "201": { + "description": "Created", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/EntityModelOwner" + } + } + } + } + } + } + }, + "/owners/{id}": { + "get": { + "tags": [ + "owner-entity-controller" + ], + "description": "get-owner", + "operationId": "getItemResource-owner-get", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/EntityModelOwner" + } + } + } + }, + "404": { + "description": "Not Found" + } + } + }, + "put": { + "tags": [ + "owner-entity-controller" + ], + "description": "update-owner", + "operationId": "putItemResource-owner-put", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/OwnerRequestBody" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/EntityModelOwner" + } + } + } + }, + "201": { + "description": "Created", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/EntityModelOwner" + } + } + } + }, + "204": { + "description": "No Content" + } + } + }, + "delete": { + "tags": [ + "owner-entity-controller" + ], + "description": "delete-owner", + "operationId": "deleteItemResource-owner-delete", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "204": { + "description": "No Content" + }, + "404": { + "description": "Not Found" + } + } + }, + "patch": { + "tags": [ + "owner-entity-controller" + ], + "description": "patch-owner", + "operationId": "patchItemResource-owner-patch", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/OwnerRequestBody" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/EntityModelOwner" + } + } + } + }, + "204": { + "description": "No Content" + } + } + } + }, + "/owners/{id}/pets": { + "get": { + "tags": [ + "owner-property-reference-controller" + ], + "description": "get-pet-by-owner-Id", + "operationId": "followPropertyReference-owner-get", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/CollectionModelPet" + } + }, + "text/uri-list": { + "schema": { + "type": "string" + } + } + } + }, + "404": { + "description": "Not Found" + } + } + }, + "put": { + "tags": [ + "owner-property-reference-controller" + ], + "description": "update-pet-by-owner-Id", + "operationId": "createPropertyReference-owner-put", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CollectionModelObject" + } + }, + "application/x-spring-data-compact+json": { + "schema": { + "$ref": "#/components/schemas/CollectionModelObject" + } + }, + "text/uri-list": { + "schema": { + "type": "string" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/CollectionModelPet" + } + } + } + }, + "201": { + "description": "Created", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/CollectionModelPet" + } + } + } + }, + "204": { + "description": "No Content" + } + } + }, + "delete": { + "tags": [ + "owner-property-reference-controller" + ], + "description": "delete-pet-by-owner-Id", + "operationId": "deletePropertyReference-owner-delete", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "204": { + "description": "No Content" + }, + "404": { + "description": "Not Found" + } + } + }, + "patch": { + "tags": [ + "owner-property-reference-controller" + ], + "description": "patch-pet-by-owner-Id", + "operationId": "createPropertyReference-owner-patch", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CollectionModelObject" + } + }, + "application/x-spring-data-compact+json": { + "schema": { + "$ref": "#/components/schemas/CollectionModelObject" + } + }, + "text/uri-list": { + "schema": { + "type": "string" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/CollectionModelPet" + } + } + } + }, + "204": { + "description": "No Content" + } + } + } + }, + "/owners/{id}/pets/{propertyId}": { + "get": { + "tags": [ + "owner-property-reference-controller" + ], + "description": "get-pet-by-owner-Id", + "operationId": "followPropertyReference-owner-get_1", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "propertyId", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/CollectionModelPet" + } + } + } + }, + "404": { + "description": "Not Found" + } + } + }, + "delete": { + "tags": [ + "owner-property-reference-controller" + ], + "description": "delete-pet-by-owner-Id", + "operationId": "deletePropertyReferenceId-owner-delete", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "propertyId", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "204": { + "description": "No Content" + }, + "404": { + "description": "Not Found" + } + } + } + }, + "/pets": { + "get": { + "tags": [ + "pet-entity-controller" + ], + "description": "get-pet", + "operationId": "getCollectionResource-pet-get", + "parameters": [ + { + "name": "page", + "in": "query", + "description": "Zero-based page index (0..N)", + "required": false, + "schema": { + "type": "integer", + "default": 0, + "minimum": 0 + } + }, + { + "name": "size", + "in": "query", + "description": "The size of the page to be returned", + "required": false, + "schema": { + "type": "integer", + "default": 20, + "minimum": 1 + } + }, + { + "name": "sort", + "in": "query", + "description": "Sorting criteria in the format: property,(asc|desc). Default sort order is ascending. Multiple sort criteria are supported.", + "required": false, + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/PagedModelEntityModelPet" + } + }, + "application/x-spring-data-compact+json": { + "schema": { + "$ref": "#/components/schemas/PagedModelEntityModelPet" + } + }, + "text/uri-list": { + "schema": { + "type": "string" + } + } + } + } + } + }, + "post": { + "tags": [ + "pet-entity-controller" + ], + "description": "create-pet", + "operationId": "postCollectionResource-pet-post", + "requestBody": { + "content": { + "application/json": { + "schema": { + "oneOf": [ + { + "$ref": "#/components/schemas/PetRequestBody" + }, + { + "$ref": "#/components/schemas/CatRequestBody" + }, + { + "$ref": "#/components/schemas/DogRequestBody" + } + ] + } + } + }, + "required": true + }, + "responses": { + "201": { + "description": "Created", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/EntityModelPet" + } + } + } + } + } + } + }, + "/pets/{id}": { + "get": { + "tags": [ + "pet-entity-controller" + ], + "description": "get-pet", + "operationId": "getItemResource-pet-get", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/EntityModelPet" + } + } + } + }, + "404": { + "description": "Not Found" + } + } + }, + "put": { + "tags": [ + "pet-entity-controller" + ], + "description": "update-pet", + "operationId": "putItemResource-pet-put", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "oneOf": [ + { + "$ref": "#/components/schemas/PetRequestBody" + }, + { + "$ref": "#/components/schemas/CatRequestBody" + }, + { + "$ref": "#/components/schemas/DogRequestBody" + } + ] + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/EntityModelPet" + } + } + } + }, + "201": { + "description": "Created", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/EntityModelPet" + } + } + } + }, + "204": { + "description": "No Content" + } + } + }, + "delete": { + "tags": [ + "pet-entity-controller" + ], + "description": "delete-pet", + "operationId": "deleteItemResource-pet-delete", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "204": { + "description": "No Content" + }, + "404": { + "description": "Not Found" + } + } + }, + "patch": { + "tags": [ + "pet-entity-controller" + ], + "description": "patch-pet", + "operationId": "patchItemResource-pet-patch", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "oneOf": [ + { + "$ref": "#/components/schemas/PetRequestBody" + }, + { + "$ref": "#/components/schemas/CatRequestBody" + }, + { + "$ref": "#/components/schemas/DogRequestBody" + } + ] + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/EntityModelPet" + } + } + } + }, + "204": { + "description": "No Content" + } + } + } + }, + "/pets/{id}/owner": { + "get": { + "tags": [ + "pet-property-reference-controller" + ], + "description": "get-owner-by-pet-Id", + "operationId": "followPropertyReference-pet-get", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/EntityModelOwner" + } + }, + "text/uri-list": { + "schema": { + "type": "string" + } + } + } + }, + "404": { + "description": "Not Found" + } + } + }, + "put": { + "tags": [ + "pet-property-reference-controller" + ], + "description": "update-owner-by-pet-Id", + "operationId": "createPropertyReference-pet-put", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CollectionModelObject" + } + }, + "application/x-spring-data-compact+json": { + "schema": { + "$ref": "#/components/schemas/CollectionModelObject" + } + }, + "text/uri-list": { + "schema": { + "type": "string" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/EntityModelOwner" + } + } + } + }, + "201": { + "description": "Created", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/EntityModelOwner" + } + } + } + }, + "204": { + "description": "No Content" + } + } + }, + "delete": { + "tags": [ + "pet-property-reference-controller" + ], + "description": "delete-owner-by-pet-Id", + "operationId": "deletePropertyReference-pet-delete", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "204": { + "description": "No Content" + }, + "404": { + "description": "Not Found" + } + } + }, + "patch": { + "tags": [ + "pet-property-reference-controller" + ], + "description": "patch-owner-by-pet-Id", + "operationId": "createPropertyReference-pet-patch", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CollectionModelObject" + } + }, + "application/x-spring-data-compact+json": { + "schema": { + "$ref": "#/components/schemas/CollectionModelObject" + } + }, + "text/uri-list": { + "schema": { + "type": "string" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/EntityModelOwner" + } + } + } + }, + "204": { + "description": "No Content" + } + } + } + }, + "/pets/{id}/owner/{propertyId}": { + "get": { + "tags": [ + "pet-property-reference-controller" + ], + "description": "get-owner-by-pet-Id", + "operationId": "followPropertyReference-pet-get_1", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "propertyId", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/EntityModelOwner" + } + } + } + }, + "404": { + "description": "Not Found" + } + } + }, + "delete": { + "tags": [ + "pet-property-reference-controller" + ], + "description": "delete-owner-by-pet-Id", + "operationId": "deletePropertyReferenceId-pet-delete", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "propertyId", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "204": { + "description": "No Content" + }, + "404": { + "description": "Not Found" + } + } + } + }, + "/profile": { + "get": { + "tags": [ + "profile-controller" + ], + "operationId": "listAllFormsOfMetadata", + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/RepresentationModelObject" + } + } + } + } + } + } + }, + "/profile/clinics": { + "get": { + "tags": [ + "profile-controller" + ], + "operationId": "descriptor", + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "string" + } + }, + "application/alps+json": { + "schema": { + "type": "string" + } + }, + "application/schema+json": { + "schema": { + "$ref": "#/components/schemas/JsonSchema" + } + } + } + } + } + } + }, + "/profile/doctors": { + "get": { + "tags": [ + "profile-controller" + ], + "operationId": "descriptor_1", + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "string" + } + }, + "application/alps+json": { + "schema": { + "type": "string" + } + }, + "application/schema+json": { + "schema": { + "$ref": "#/components/schemas/JsonSchema" + } + } + } + } + } + } + }, + "/profile/owners": { + "get": { + "tags": [ + "profile-controller" + ], + "operationId": "descriptor_2", + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "string" + } + }, + "application/alps+json": { + "schema": { + "type": "string" + } + }, + "application/schema+json": { + "schema": { + "$ref": "#/components/schemas/JsonSchema" + } + } + } + } + } + } + }, + "/profile/pets": { + "get": { + "tags": [ + "profile-controller" + ], + "operationId": "descriptor_3", + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "string" + } + }, + "application/alps+json": { + "schema": { + "type": "string" + } + }, + "application/schema+json": { + "schema": { + "$ref": "#/components/schemas/JsonSchema" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "AbstractJsonSchemaPropertyObject": { + "type": "object", + "properties": { + "title": { + "type": "string" + }, + "readOnly": { + "type": "boolean" + } + } + }, + "Item": { + "type": "object", + "properties": { + "type": { + "type": "string" + }, + "properties": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/AbstractJsonSchemaPropertyObject" + } + }, + "requiredProperties": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "JsonSchema": { + "type": "object", + "properties": { + "title": { + "type": "string" + }, + "description": { + "type": "string" + }, + "properties": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/AbstractJsonSchemaPropertyObject" + } + }, + "requiredProperties": { + "type": "array", + "items": { + "type": "string" + } + }, + "definitions": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/Item" + } + }, + "type": { + "type": "string" + }, + "$schema": { + "type": "string" + } + } + }, + "RepresentationModelObject": { + "type": "object", + "properties": { + "_links": { + "$ref": "#/components/schemas/Links" + } + } + }, + "Address": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "street": { + "type": "string" + }, + "number": { + "type": "string" + }, + "zipcode": { + "type": "string" + }, + "city": { + "type": "string" + }, + "country": { + "type": "string" + } + } + }, + "EntityModelOwner": { + "type": "object", + "properties": { + "firstname": { + "type": "string" + }, + "lastname": { + "type": "string" + }, + "addresses": { + "$ref": "#/components/schemas/Address" + }, + "_links": { + "$ref": "#/components/schemas/Links" + } + }, + "required": [ + "addresses", + "lastname" + ] + }, + "PageMetadata": { + "type": "object", + "properties": { + "size": { + "type": "integer", + "format": "int64" + }, + "totalElements": { + "type": "integer", + "format": "int64" + }, + "totalPages": { + "type": "integer", + "format": "int64" + }, + "number": { + "type": "integer", + "format": "int64" + } + } + }, + "PagedModelEntityModelOwner": { + "type": "object", + "properties": { + "_embedded": { + "type": "object", + "properties": { + "owners": { + "type": "array", + "items": { + "$ref": "#/components/schemas/EntityModelOwner" + } + } + } + }, + "_links": { + "$ref": "#/components/schemas/Links" + }, + "page": { + "$ref": "#/components/schemas/PageMetadata" + } + } + }, + "CollectionModelPet": { + "type": "object", + "properties": { + "_embedded": { + "type": "object", + "properties": { + "pets": { + "type": "array", + "items": { + "oneOf": [ + { + "$ref": "#/components/schemas/PetResponse" + }, + { + "$ref": "#/components/schemas/CatResponse" + }, + { + "$ref": "#/components/schemas/DogResponse" + } + ] + } + } + } + }, + "_links": { + "$ref": "#/components/schemas/Links" + } + } + }, + "CollectionModelObject": { + "type": "object", + "properties": { + "_embedded": { + "type": "object", + "properties": { + "objects": { + "type": "array", + "items": { + "type": "object" + } + } + } + }, + "_links": { + "$ref": "#/components/schemas/Links" + } + } + }, + "Clinic": { + "type": "object", + "properties": { + "id": { + "type": "string", + "format": "uuid" + }, + "name": { + "type": "string" + }, + "addresses": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Address" + }, + "maxItems": 2147483647, + "minItems": 1, + "uniqueItems": true + } + }, + "required": [ + "name" + ] + }, + "EntityModelDoctor": { + "type": "object", + "properties": { + "firstname": { + "type": "string" + }, + "lastname": { + "type": "string" + }, + "specialty": { + "type": "string", + "enum": [ + "ALLERGY_AND_IMMUNOLOGY", + "ADOLESCENT_MEDICINE", + "ANESTHESIOLOGY", + "AEROSPACE_MEDICINE", + "BARIATRICS", + "CARDIOLOGY", + "CARDIOTHORACIC_SURGERY", + "CHILD_AND_ADOLESCENT_PSYCHIATRY", + "CLINICAL_NEUROPHYSIOLOGY", + "COLORECTAL_SURGERY", + "DERMATOLOGY", + "DEVELOPMENTAL_PEDIATRICS", + "EMERGENCY_MEDICINE", + "ENDOCRINOLOGY", + "FAMILY_MEDICINE", + "FORENSIC_PATHOLOGY", + "FORENSIC_PSYCHIATRY", + "GASTROENTEROLOGY", + "GENERAL_SURGERY", + "GENERAL_SURGICAL_ONCOLOGY", + "GERIATRICS", + "GERIATRIC_PSYCHIATRY", + "GYNECOLOGIC_ONCOLOGY", + "HEMATOLOGY", + "HEMATOLOGIC_PATHOLOGY", + "INFECTIOUS_DISEASE", + "INTERNAL_MEDICINE", + "INTERVENTIONAL_RADIOLOGY", + "INTENSIVE_CARE_MEDICINE", + "MATERNAL_FETAL_MEDICINE", + "MEDICAL_BIOCHEMISTRY", + "MEDICAL_GENETICS", + "MEDICAL_ONCOLOGY", + "NEONATOLOGY", + "NEPHROLOGY", + "NEUROLOGY", + "NEUROPATHOLOGY", + "NEUROSURGERY", + "NUCLEAR_MEDICINE", + "OBSTETRICS_AND_GYNECOLOGY", + "OCCUPATIONAL_MEDICINE", + "OPHTHALMOLOGY", + "ORTHOPEDIC_SURGERY", + "ORAL_AND_MAXILLOFACIAL_SURGERY", + "OTORHINOLARYNGOLOGY", + "PALLIATIVE_CARE", + "PATHOLOGY", + "PEDIATRICS", + "PEDIATRIC_ALLERGY_AND_IMMUNOLOGY", + "PEDIATRIC_CARDIOLOGY", + "PEDIATRIC_EMERGENCY_MEDICINE", + "PEDIATRIC_ENDOCRINOLOGY", + "PEDIATRIC_GASTROENTEROLOGY", + "PEDIATRIC_HEMATOLOGY_AND_ONCOLOGY", + "PEDIATRIC_INFECTIOUS_DISEASE", + "PEDIATRIC_NEPHROLOGY", + "PEDIATRIC_RESPIRATORY_MEDICINE", + "PEDIATRIC_RHEUMATOLOGY", + "PEDIATRIC_SURGERY", + "PHYSICAL_MEDICINE_AND_REHABILITATION", + "PLASTIC_RECONSTRUCTIVE_AND_AESTHETIC_SURGERY", + "PSYCHIATRY", + "PUBLIC_HEALTH", + "RADIATION_ONCOLOGY", + "RADIOLOGY", + "REPRODUCTIVE_ENDOCRINOLOGY_AND_INFERTILITY", + "RESPIRATORY_MEDICINE", + "RHEUMATOLOGY", + "SPORTS_MEDICINE", + "THORACIC_SURGERY", + "NEURORADIOLOGY", + "UROLOGY", + "VASCULAR_SURGERY" + ] + }, + "_links": { + "$ref": "#/components/schemas/Links" + } + }, + "required": [ + "firstname", + "lastname" + ] + }, + "CollectionModelEntityModelDoctor": { + "type": "object", + "properties": { + "_embedded": { + "type": "object", + "properties": { + "doctors": { + "type": "array", + "items": { + "$ref": "#/components/schemas/EntityModelDoctor" + } + } + } + }, + "_links": { + "$ref": "#/components/schemas/Links" + } + } + }, + "CollectionModelClinic": { + "type": "object", + "properties": { + "_embedded": { + "type": "object", + "properties": { + "clinics": { + "type": "array", + "items": { + "$ref": "#/components/schemas/ClinicResponse" + } + } + } + }, + "_links": { + "$ref": "#/components/schemas/Links" + } + } + }, + "EntityModelClinic": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "addresses": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Address" + }, + "maxItems": 2147483647, + "minItems": 1, + "uniqueItems": true + }, + "_links": { + "$ref": "#/components/schemas/Links" + } + }, + "required": [ + "name" + ] + }, + "CollectionModelEntityModelClinic": { + "type": "object", + "properties": { + "_embedded": { + "type": "object", + "properties": { + "clinics": { + "type": "array", + "items": { + "$ref": "#/components/schemas/EntityModelClinic" + } + } + } + }, + "_links": { + "$ref": "#/components/schemas/Links" + } + } + }, + "EntityModelPet": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "_type": { + "type": "string" + }, + "_links": { + "$ref": "#/components/schemas/Links" + } + }, + "required": [ + "_type", + "name" + ] + }, + "PagedModelEntityModelPet": { + "type": "object", + "properties": { + "_embedded": { + "type": "object", + "properties": { + "pets": { + "type": "array", + "items": { + "$ref": "#/components/schemas/EntityModelPet" + } + } + } + }, + "_links": { + "$ref": "#/components/schemas/Links" + }, + "page": { + "$ref": "#/components/schemas/PageMetadata" + } + } + }, + "ClinicRequestBody": { + "type": "object", + "properties": { + "id": { + "type": "string", + "format": "uuid" + }, + "name": { + "type": "string" + }, + "addresses": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Address" + }, + "maxItems": 2147483647, + "minItems": 1, + "uniqueItems": true + } + }, + "required": [ + "name" + ] + }, + "DoctorRequestBody": { + "type": "object", + "properties": { + "id": { + "type": "string", + "format": "uuid" + }, + "firstname": { + "type": "string" + }, + "lastname": { + "type": "string" + }, + "specialty": { + "type": "string", + "enum": [ + "ALLERGY_AND_IMMUNOLOGY", + "ADOLESCENT_MEDICINE", + "ANESTHESIOLOGY", + "AEROSPACE_MEDICINE", + "BARIATRICS", + "CARDIOLOGY", + "CARDIOTHORACIC_SURGERY", + "CHILD_AND_ADOLESCENT_PSYCHIATRY", + "CLINICAL_NEUROPHYSIOLOGY", + "COLORECTAL_SURGERY", + "DERMATOLOGY", + "DEVELOPMENTAL_PEDIATRICS", + "EMERGENCY_MEDICINE", + "ENDOCRINOLOGY", + "FAMILY_MEDICINE", + "FORENSIC_PATHOLOGY", + "FORENSIC_PSYCHIATRY", + "GASTROENTEROLOGY", + "GENERAL_SURGERY", + "GENERAL_SURGICAL_ONCOLOGY", + "GERIATRICS", + "GERIATRIC_PSYCHIATRY", + "GYNECOLOGIC_ONCOLOGY", + "HEMATOLOGY", + "HEMATOLOGIC_PATHOLOGY", + "INFECTIOUS_DISEASE", + "INTERNAL_MEDICINE", + "INTERVENTIONAL_RADIOLOGY", + "INTENSIVE_CARE_MEDICINE", + "MATERNAL_FETAL_MEDICINE", + "MEDICAL_BIOCHEMISTRY", + "MEDICAL_GENETICS", + "MEDICAL_ONCOLOGY", + "NEONATOLOGY", + "NEPHROLOGY", + "NEUROLOGY", + "NEUROPATHOLOGY", + "NEUROSURGERY", + "NUCLEAR_MEDICINE", + "OBSTETRICS_AND_GYNECOLOGY", + "OCCUPATIONAL_MEDICINE", + "OPHTHALMOLOGY", + "ORTHOPEDIC_SURGERY", + "ORAL_AND_MAXILLOFACIAL_SURGERY", + "OTORHINOLARYNGOLOGY", + "PALLIATIVE_CARE", + "PATHOLOGY", + "PEDIATRICS", + "PEDIATRIC_ALLERGY_AND_IMMUNOLOGY", + "PEDIATRIC_CARDIOLOGY", + "PEDIATRIC_EMERGENCY_MEDICINE", + "PEDIATRIC_ENDOCRINOLOGY", + "PEDIATRIC_GASTROENTEROLOGY", + "PEDIATRIC_HEMATOLOGY_AND_ONCOLOGY", + "PEDIATRIC_INFECTIOUS_DISEASE", + "PEDIATRIC_NEPHROLOGY", + "PEDIATRIC_RESPIRATORY_MEDICINE", + "PEDIATRIC_RHEUMATOLOGY", + "PEDIATRIC_SURGERY", + "PHYSICAL_MEDICINE_AND_REHABILITATION", + "PLASTIC_RECONSTRUCTIVE_AND_AESTHETIC_SURGERY", + "PSYCHIATRY", + "PUBLIC_HEALTH", + "RADIATION_ONCOLOGY", + "RADIOLOGY", + "REPRODUCTIVE_ENDOCRINOLOGY_AND_INFERTILITY", + "RESPIRATORY_MEDICINE", + "RHEUMATOLOGY", + "SPORTS_MEDICINE", + "THORACIC_SURGERY", + "NEURORADIOLOGY", + "UROLOGY", + "VASCULAR_SURGERY" + ] + }, + "clinics": { + "type": "array", + "items": { + "type": "string" + } + } + }, + "required": [ + "firstname", + "lastname" + ] + }, + "ClinicResponse": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "addresses": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Address" + }, + "maxItems": 2147483647, + "minItems": 1, + "uniqueItems": true + } + }, + "required": [ + "name" + ] + }, + "CatRequestBody": { + "allOf": [ + { + "$ref": "#/components/schemas/PetRequestBody" + }, + { + "type": "object", + "properties": { + "coat": { + "type": "string", + "enum": [ + "TABBY", + "TOROISE", + "COLORPOINT", + "BICOLOR", + "TRICOLOR", + "SOLID" + ] + } + } + } + ], + "required": [ + "name" + ] + }, + "DogRequestBody": { + "allOf": [ + { + "$ref": "#/components/schemas/PetRequestBody" + }, + { + "type": "object", + "properties": { + "coat": { + "type": "string", + "enum": [ + "SMOOTH", + "SHORT", + "COMBINATION", + "DOUBLE", + "HEAVY", + "SILKY", + "LONG", + "CURLY", + "WIRE", + "HAIRLESS" + ] + } + } + } + ], + "required": [ + "name" + ] + }, + "OwnerRequestBody": { + "type": "object", + "properties": { + "id": { + "type": "string", + "format": "uuid" + }, + "firstname": { + "type": "string" + }, + "lastname": { + "type": "string" + }, + "addresses": { + "$ref": "#/components/schemas/Address" + }, + "pets": { + "type": "array", + "items": { + "type": "string" + } + } + }, + "required": [ + "addresses", + "lastname" + ] + }, + "PetRequestBody": { + "type": "object", + "discriminator": { + "propertyName": "_type" + }, + "properties": { + "id": { + "type": "string", + "format": "uuid" + }, + "name": { + "type": "string" + }, + "owner": { + "type": "string" + }, + "_type": { + "type": "string" + } + }, + "required": [ + "_type", + "name" + ] + }, + "CatResponse": { + "allOf": [ + { + "$ref": "#/components/schemas/PetResponse" + }, + { + "type": "object", + "properties": { + "coat": { + "type": "string", + "enum": [ + "TABBY", + "TOROISE", + "COLORPOINT", + "BICOLOR", + "TRICOLOR", + "SOLID" + ] + } + } + } + ], + "required": [ + "name" + ] + }, + "DogResponse": { + "allOf": [ + { + "$ref": "#/components/schemas/PetResponse" + }, + { + "type": "object", + "properties": { + "coat": { + "type": "string", + "enum": [ + "SMOOTH", + "SHORT", + "COMBINATION", + "DOUBLE", + "HEAVY", + "SILKY", + "LONG", + "CURLY", + "WIRE", + "HAIRLESS" + ] + } + } + } + ], + "required": [ + "name" + ] + }, + "PetResponse": { + "type": "object", + "discriminator": { + "propertyName": "_type" + }, + "properties": { + "name": { + "type": "string" + }, + "_type": { + "type": "string" + } + }, + "required": [ + "_type", + "name" + ] + }, + "Link": { + "type": "object", + "properties": { + "href": { + "type": "string" + }, + "hreflang": { + "type": "string" + }, + "title": { + "type": "string" + }, + "type": { + "type": "string" + }, + "deprecation": { + "type": "string" + }, + "profile": { + "type": "string" + }, + "name": { + "type": "string" + }, + "templated": { + "type": "boolean" + } + } + }, + "Links": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/Link" + } + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.1.0/app26.json b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.1.0/app26.json new file mode 100644 index 000000000..06cd6bc64 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.1.0/app26.json @@ -0,0 +1,373 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/peopleme": { + "get": { + "tags": [ + "person-entity-controller" + ], + "description": "get-person", + "operationId": "getCollectionResource-person-get", + "parameters": [ + { + "name": "page", + "in": "query", + "description": "Zero-based page index (0..N)", + "required": false, + "schema": { + "minimum": 0, + "type": "integer", + "default": 0 + } + }, + { + "name": "size", + "in": "query", + "description": "The size of the page to be returned", + "required": false, + "schema": { + "minimum": 1, + "type": "integer", + "default": 20 + } + }, + { + "name": "sort", + "in": "query", + "description": "Sorting criteria in the format: property,(asc|desc). Default sort order is ascending. Multiple sort criteria are supported.", + "required": false, + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/PagedModelEntityModelPerson" + } + }, + "application/x-spring-data-compact+json": { + "schema": { + "$ref": "#/components/schemas/PagedModelEntityModelPerson" + } + }, + "text/uri-list": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/peopleme/search/findByLastName": { + "get": { + "tags": [ + "person-search-controller" + ], + "operationId": "executeSearch-person-get", + "parameters": [ + { + "name": "name", + "in": "query", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/CollectionModelEntityModelPerson" + } + } + } + }, + "404": { + "description": "Not Found" + } + } + } + }, + "/peopleme/search/testQuery": { + "get": { + "tags": [ + "person-search-controller" + ], + "operationId": "executeSearch-person-get_1", + "responses": { + "200": { + "description": "OK" + }, + "404": { + "description": "Not Found" + } + } + } + }, + "/profile": { + "get": { + "tags": [ + "profile-controller" + ], + "operationId": "listAllFormsOfMetadata", + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/RepresentationModelObject" + } + } + } + } + } + } + }, + "/profile/peopleme": { + "get": { + "tags": [ + "profile-controller" + ], + "operationId": "descriptor", + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "string" + } + }, + "application/alps+json": { + "schema": { + "type": "string" + } + }, + "application/schema+json": { + "schema": { + "$ref": "#/components/schemas/JsonSchema" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "AbstractJsonSchemaPropertyObject": { + "type": "object", + "properties": { + "title": { + "type": "string" + }, + "readOnly": { + "type": "boolean" + } + } + }, + "Item": { + "type": "object", + "properties": { + "type": { + "type": "string" + }, + "properties": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/AbstractJsonSchemaPropertyObject" + } + }, + "requiredProperties": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "JsonSchema": { + "type": "object", + "properties": { + "title": { + "type": "string" + }, + "description": { + "type": "string" + }, + "properties": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/AbstractJsonSchemaPropertyObject" + } + }, + "requiredProperties": { + "type": "array", + "items": { + "type": "string" + } + }, + "definitions": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/Item" + } + }, + "type": { + "type": "string" + }, + "$schema": { + "type": "string" + } + } + }, + "Links": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/Link" + } + }, + "RepresentationModelObject": { + "type": "object", + "properties": { + "_links": { + "$ref": "#/components/schemas/Links" + } + } + }, + "EntityModelPerson": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "firstName": { + "type": "string" + }, + "lastName": { + "type": "string" + }, + "_links": { + "$ref": "#/components/schemas/Links" + } + } + }, + "PageMetadata": { + "type": "object", + "properties": { + "size": { + "type": "integer", + "format": "int64" + }, + "totalElements": { + "type": "integer", + "format": "int64" + }, + "totalPages": { + "type": "integer", + "format": "int64" + }, + "number": { + "type": "integer", + "format": "int64" + } + } + }, + "PagedModelEntityModelPerson": { + "type": "object", + "properties": { + "_embedded": { + "type": "object", + "properties": { + "people": { + "type": "array", + "items": { + "$ref": "#/components/schemas/EntityModelPerson" + } + } + } + }, + "_links": { + "$ref": "#/components/schemas/Links" + }, + "page": { + "$ref": "#/components/schemas/PageMetadata" + } + } + }, + "CollectionModelEntityModelPerson": { + "type": "object", + "properties": { + "_embedded": { + "type": "object", + "properties": { + "people": { + "type": "array", + "items": { + "$ref": "#/components/schemas/EntityModelPerson" + } + } + } + }, + "_links": { + "$ref": "#/components/schemas/Links" + } + } + }, + "Link": { + "type": "object", + "properties": { + "href": { + "type": "string" + }, + "hreflang": { + "type": "string" + }, + "title": { + "type": "string" + }, + "type": { + "type": "string" + }, + "deprecation": { + "type": "string" + }, + "profile": { + "type": "string" + }, + "name": { + "type": "string" + }, + "templated": { + "type": "boolean" + } + } + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.1.0/app27.json b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.1.0/app27.json new file mode 100644 index 000000000..36a615f73 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.1.0/app27.json @@ -0,0 +1,114 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/search": { + "get": { + "tags": [ + "hello-controller" + ], + "operationId": "getAllPets", + "parameters": [ + { + "name": "pageable", + "in": "query", + "required": true, + "schema": { + "$ref": "#/components/schemas/Pageable" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/xml": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/PersonDTO" + } + } + }, + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/PersonDTO" + } + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "Pageable": { + "type": "object", + "properties": { + "offset": { + "type": "integer", + "format": "int64" + }, + "sort": { + "$ref": "#/components/schemas/SortObject" + }, + "pageNumber": { + "type": "integer", + "format": "int32" + }, + "pageSize": { + "type": "integer", + "format": "int32" + }, + "paged": { + "type": "boolean" + }, + "unpaged": { + "type": "boolean" + } + } + }, + "SortObject": { + "type": "object", + "properties": { + "empty": { + "type": "boolean" + }, + "sorted": { + "type": "boolean" + }, + "unsorted": { + "type": "boolean" + } + } + }, + "PersonDTO": { + "type": "object", + "properties": { + "email": { + "type": "string" + }, + "firstName": { + "type": "string" + }, + "lastName": { + "type": "string" + } + } + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.1.0/app28.json b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.1.0/app28.json new file mode 100644 index 000000000..2148e0ae7 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.1.0/app28.json @@ -0,0 +1,77 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/api/items/nested": { + "get": { + "tags": [ + "hello-controller" + ], + "operationId": "showNestedItem", + "parameters": [ + { + "name": "something", + "in": "query", + "description": "Anything", + "required": false, + "schema": { + "type": "integer", + "format": "int32" + } + }, + { + "name": "page", + "in": "query", + "description": "Zero-based page index (0..N)", + "required": false, + "schema": { + "minimum": 0, + "type": "integer", + "default": 0 + } + }, + { + "name": "size", + "in": "query", + "description": "The size of the page to be returned", + "required": false, + "schema": { + "minimum": 1, + "type": "integer", + "default": 20 + } + }, + { + "name": "sort", + "in": "query", + "description": "Sorting criteria in the format: property,(asc|desc). Default sort order is ascending. Multiple sort criteria are supported.", + "required": false, + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + } + ], + "responses": { + "200": { + "description": "OK" + } + } + } + } + }, + "components": { + "schemas": {} + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.1.0/app29.json b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.1.0/app29.json new file mode 100644 index 000000000..c692e756d --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.1.0/app29.json @@ -0,0 +1,333 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/people": { + "get": { + "tags": [ + "person-entity-controller" + ], + "description": "get-person", + "operationId": "getCollectionResource-person-get", + "parameters": [ + { + "name": "page", + "in": "query", + "description": "Zero-based page index (0..N)", + "required": false, + "schema": { + "minimum": 0, + "type": "integer", + "default": 0 + } + }, + { + "name": "size", + "in": "query", + "description": "The size of the page to be returned", + "required": false, + "schema": { + "minimum": 1, + "type": "integer", + "default": 20 + } + }, + { + "name": "sort", + "in": "query", + "description": "Sorting criteria in the format: property,(asc|desc). Default sort order is ascending. Multiple sort criteria are supported.", + "required": false, + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/PagedModelEntityModelPerson" + } + }, + "application/x-spring-data-compact+json": { + "schema": { + "$ref": "#/components/schemas/PagedModelEntityModelPerson" + } + }, + "text/uri-list": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/profile": { + "get": { + "tags": [ + "profile-controller" + ], + "operationId": "listAllFormsOfMetadata", + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/RepresentationModelObject" + } + } + } + } + } + } + }, + "/profile/people": { + "get": { + "tags": [ + "profile-controller" + ], + "operationId": "descriptor", + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "string" + } + }, + "application/alps+json": { + "schema": { + "type": "string" + } + }, + "application/schema+json": { + "schema": { + "$ref": "#/components/schemas/JsonSchema" + } + } + } + } + } + } + }, + "/people/test": { + "get": { + "tags": [ + "person-api" + ], + "operationId": "test", + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/Person" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "AbstractJsonSchemaPropertyObject": { + "type": "object", + "properties": { + "title": { + "type": "string" + }, + "readOnly": { + "type": "boolean" + } + } + }, + "Item": { + "type": "object", + "properties": { + "type": { + "type": "string" + }, + "properties": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/AbstractJsonSchemaPropertyObject" + } + }, + "requiredProperties": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "JsonSchema": { + "type": "object", + "properties": { + "title": { + "type": "string" + }, + "description": { + "type": "string" + }, + "properties": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/AbstractJsonSchemaPropertyObject" + } + }, + "requiredProperties": { + "type": "array", + "items": { + "type": "string" + } + }, + "definitions": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/Item" + } + }, + "type": { + "type": "string" + }, + "$schema": { + "type": "string" + } + } + }, + "Links": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/Link" + } + }, + "RepresentationModelObject": { + "type": "object", + "properties": { + "_links": { + "$ref": "#/components/schemas/Links" + } + } + }, + "EntityModelPerson": { + "type": "object", + "properties": { + "firstName": { + "type": "string" + }, + "lastName": { + "type": "string" + }, + "_links": { + "$ref": "#/components/schemas/Links" + } + } + }, + "PageMetadata": { + "type": "object", + "properties": { + "size": { + "type": "integer", + "format": "int64" + }, + "totalElements": { + "type": "integer", + "format": "int64" + }, + "totalPages": { + "type": "integer", + "format": "int64" + }, + "number": { + "type": "integer", + "format": "int64" + } + } + }, + "PagedModelEntityModelPerson": { + "type": "object", + "properties": { + "_embedded": { + "type": "object", + "properties": { + "people": { + "type": "array", + "items": { + "$ref": "#/components/schemas/EntityModelPerson" + } + } + } + }, + "_links": { + "$ref": "#/components/schemas/Links" + }, + "page": { + "$ref": "#/components/schemas/PageMetadata" + } + } + }, + "Person": { + "type": "object", + "properties": { + "firstName": { + "type": "string" + }, + "lastName": { + "type": "string" + } + } + }, + "Link": { + "type": "object", + "properties": { + "href": { + "type": "string" + }, + "hreflang": { + "type": "string" + }, + "title": { + "type": "string" + }, + "type": { + "type": "string" + }, + "deprecation": { + "type": "string" + }, + "profile": { + "type": "string" + }, + "name": { + "type": "string" + }, + "templated": { + "type": "boolean" + } + } + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.1.0/app3.json b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.1.0/app3.json new file mode 100644 index 000000000..0123f829a --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.1.0/app3.json @@ -0,0 +1,102 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/demo/operation5": { + "get": { + "tags": [ + "hello-controller" + ], + "operationId": "operation5", + "parameters": [ + { + "name": "sort", + "in": "query", + "description": "Sorting criteria in the format: property,(asc|desc). Default sort order is ascending. Multiple sort criteria are supported.", + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "text/plain": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/demo/operation4": { + "get": { + "tags": [ + "hello-controller" + ], + "operationId": "operation4", + "parameters": [ + { + "name": "page", + "in": "query", + "description": "Zero-based page index (0..N)", + "schema": { + "type": "integer", + "default": 0 + } + }, + { + "name": "size", + "in": "query", + "description": "The size of the page to be returned", + "schema": { + "type": "integer", + "default": 20 + } + }, + { + "name": "sort", + "in": "query", + "description": "Sorting criteria in the format: property,(asc|desc). Default sort order is ascending. Multiple sort criteria are supported.", + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "text/plain": { + "schema": { + "type": "string" + } + } + } + } + } + } + } + }, + "components": { + "schemas": {} + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.1.0/app30.json b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.1.0/app30.json new file mode 100644 index 000000000..bbb90bbe9 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.1.0/app30.json @@ -0,0 +1,73 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/": { + "get": { + "tags": [ + "hello-controller" + ], + "operationId": "testQueryDslAndSpringDoc", + "parameters": [ + { + "name": "name", + "in": "query", + "schema": { + "type": "string" + } + }, + { + "name": "email", + "in": "query", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/User" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "User": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "firstName": { + "type": "string" + }, + "lastName": { + "type": "string" + }, + "email": { + "type": "string" + } + } + } + } + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.1.0/app301.json b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.1.0/app301.json new file mode 100644 index 000000000..4b199f6cc --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.1.0/app301.json @@ -0,0 +1,17 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": {}, + "components": { + "schemas": {} + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.1.0/app31.json b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.1.0/app31.json new file mode 100644 index 000000000..80178d3af --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.1.0/app31.json @@ -0,0 +1,275 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/test4": { + "get": { + "tags": [ + "hello-controller" + ], + "operationId": "getPatientList4", + "parameters": [ + { + "name": "page", + "in": "query", + "description": "Zero-based page index (0..N)", + "required": false, + "schema": { + "type": "integer", + "default": 0, + "minimum": 0 + } + }, + { + "name": "size", + "in": "query", + "description": "The size of the page to be returned", + "required": false, + "schema": { + "type": "integer", + "default": 20, + "minimum": 1 + } + }, + { + "name": "sort", + "in": "query", + "description": "Sorting criteria in the format: property,(asc|desc). Default sort order is ascending. Multiple sort criteria are supported.", + "required": false, + "schema": { + "type": "array", + "default": [ + "someField,DESC" + ], + "items": { + "type": "string" + } + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/test3": { + "get": { + "tags": [ + "hello-controller" + ], + "operationId": "getPatientList3", + "parameters": [ + { + "name": "page", + "in": "query", + "description": "Zero-based page index (0..N)", + "required": false, + "schema": { + "type": "integer", + "default": 0, + "minimum": 0 + } + }, + { + "name": "size", + "in": "query", + "description": "The size of the page to be returned", + "required": false, + "schema": { + "type": "integer", + "default": 20, + "minimum": 1 + } + }, + { + "name": "sort", + "in": "query", + "description": "Sorting criteria in the format: property,(asc|desc). Default sort order is ascending. Multiple sort criteria are supported.", + "required": false, + "schema": { + "type": "array", + "default": [ + "someField,DESC", + "someoTHER,DESC" + ], + "items": { + "type": "string" + } + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/test2": { + "get": { + "tags": [ + "hello-controller" + ], + "operationId": "getPatientList2", + "parameters": [ + { + "name": "sort", + "in": "query", + "description": "Sorting criteria in the format: property,(asc|desc). Default sort order is ascending. Multiple sort criteria are supported.", + "required": false, + "schema": { + "type": "array", + "default": [ + "someField,DESC" + ], + "items": { + "type": "string" + } + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/test1": { + "get": { + "tags": [ + "hello-controller" + ], + "operationId": "getPatientList1", + "parameters": [ + { + "name": "sort", + "in": "query", + "description": "Sorting criteria in the format: property,(asc|desc). Default sort order is ascending. Multiple sort criteria are supported.", + "required": false, + "schema": { + "type": "array", + "default": [ + "someField,DESC", + "someoTHER,DESC" + ], + "items": { + "type": "string" + } + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/search": { + "get": { + "tags": [ + "hello-controller" + ], + "operationId": "getAllPets", + "parameters": [ + { + "name": "sort", + "in": "query", + "description": "Sorting criteria in the format: property,(asc|desc). Default sort order is ascending. Multiple sort criteria are supported.", + "required": false, + "schema": { + "type": "array", + "default": [ + "name,ASC" + ], + "items": { + "type": "string" + } + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/xml": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/PersonDTO" + } + } + }, + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/PersonDTO" + } + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "PersonDTO": { + "type": "object", + "properties": { + "email": { + "type": "string" + }, + "firstName": { + "type": "string" + }, + "lastName": { + "type": "string" + } + } + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.1.0/app32.json b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.1.0/app32.json new file mode 100644 index 000000000..7f4e53f17 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.1.0/app32.json @@ -0,0 +1,78 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/search": { + "get": { + "tags": [ + "hello-controller" + ], + "operationId": "getAllPets", + "parameters": [ + { + "name": "sorts", + "in": "query", + "description": "Sorting criteria in the format: property,(asc|desc). Default sort order is ascending. Multiple sort criteria are supported.", + "required": false, + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/xml": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/PersonDTO" + } + } + }, + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/PersonDTO" + } + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "PersonDTO": { + "type": "object", + "properties": { + "email": { + "type": "string" + }, + "firstName": { + "type": "string" + }, + "lastName": { + "type": "string" + } + } + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.1.0/app33.json b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.1.0/app33.json new file mode 100644 index 000000000..6a190f0ee --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.1.0/app33.json @@ -0,0 +1,55 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/api/items/nested": { + "get": { + "tags": [ + "hello-controller" + ], + "operationId": "showNestedItem", + "parameters": [ + { + "name": "something", + "in": "query", + "description": "Anything", + "required": false, + "schema": { + "type": "integer", + "format": "int32" + } + }, + { + "name": "sort", + "in": "query", + "description": "Sorting criteria in the format: property,(asc|desc). Default sort order is ascending. Multiple sort criteria are supported.", + "required": false, + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + } + ], + "responses": { + "200": { + "description": "OK" + } + } + } + } + }, + "components": { + "schemas": {} + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.1.0/app34.json b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.1.0/app34.json new file mode 100644 index 000000000..60caa7048 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.1.0/app34.json @@ -0,0 +1,1477 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "My App", + "description": "Some long and useful description", + "license": { + "name": "Apache 2.0", + "url": "https://www.apache.org/licenses/LICENSE-2.0" + }, + "version": "v1" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/accounts": { + "get": { + "tags": [ + "The account Repository" + ], + "description": "get-account", + "operationId": "getCollectionResource-account-get", + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/CollectionModelEntityModelAccount" + } + }, + "application/x-spring-data-compact+json": { + "schema": { + "$ref": "#/components/schemas/CollectionModelEntityModelAccount" + } + }, + "text/uri-list": { + "schema": { + "type": "string" + } + } + } + } + }, + "security": [ + { + "bearer": [] + } + ] + }, + "post": { + "tags": [ + "The account Repository" + ], + "description": "create-account", + "operationId": "postCollectionResource-account-post", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/AccountRequestBody" + } + } + }, + "required": true + }, + "responses": { + "201": { + "description": "Created", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/EntityModelAccount" + } + } + } + } + }, + "security": [ + { + "bearer": [] + } + ] + } + }, + "/accounts/search/findByCustomer": { + "get": { + "tags": [ + "The account Repository" + ], + "operationId": "executeSearch-account-get", + "parameters": [ + { + "name": "customer", + "in": "query", + "schema": { + "$ref": "#/components/schemas/Customer" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/CollectionModelEntityModelAccount" + } + } + } + }, + "404": { + "description": "Not Found" + } + }, + "security": [ + { + "bearer": [] + } + ] + } + }, + "/accounts/{id}": { + "get": { + "tags": [ + "The account Repository" + ], + "description": "get-account", + "operationId": "getItemResource-account-get", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/EntityModelAccount" + } + } + } + }, + "404": { + "description": "Not Found" + } + }, + "security": [ + { + "bearer": [] + } + ] + }, + "put": { + "tags": [ + "The account Repository" + ], + "description": "update-account", + "operationId": "putItemResource-account-put", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/AccountRequestBody" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/EntityModelAccount" + } + } + } + }, + "201": { + "description": "Created", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/EntityModelAccount" + } + } + } + }, + "204": { + "description": "No Content" + } + }, + "security": [ + { + "bearer": [] + } + ] + }, + "delete": { + "tags": [ + "The account Repository" + ], + "description": "delete-account", + "operationId": "deleteItemResource-account-delete", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "204": { + "description": "No Content" + }, + "404": { + "description": "Not Found" + } + }, + "security": [ + { + "bearer": [] + } + ] + }, + "patch": { + "tags": [ + "The account Repository" + ], + "description": "patch-account", + "operationId": "patchItemResource-account-patch", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/AccountRequestBody" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/EntityModelAccount" + } + } + } + }, + "204": { + "description": "No Content" + } + }, + "security": [ + { + "bearer": [] + } + ] + } + }, + "/accounts/{id}/customer": { + "get": { + "tags": [ + "The account Repository" + ], + "description": "get-customer-by-account-Id", + "operationId": "followPropertyReference-account-get", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/EntityModelCustomer" + } + }, + "text/uri-list": { + "schema": { + "type": "string" + } + } + } + }, + "404": { + "description": "Not Found" + } + }, + "security": [ + { + "bearer": [] + } + ] + }, + "put": { + "tags": [ + "The account Repository" + ], + "description": "update-customer-by-account-Id", + "operationId": "createPropertyReference-account-put", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CollectionModelObject" + } + }, + "application/x-spring-data-compact+json": { + "schema": { + "$ref": "#/components/schemas/CollectionModelObject" + } + }, + "text/uri-list": { + "schema": { + "type": "string" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/EntityModelCustomer" + } + } + } + }, + "201": { + "description": "Created", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/EntityModelCustomer" + } + } + } + }, + "204": { + "description": "No Content" + } + }, + "security": [ + { + "bearer": [] + } + ] + }, + "delete": { + "tags": [ + "The account Repository" + ], + "description": "delete-customer-by-account-Id", + "operationId": "deletePropertyReference-account-delete", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "204": { + "description": "No Content" + }, + "404": { + "description": "Not Found" + } + }, + "security": [ + { + "bearer": [] + } + ] + }, + "patch": { + "tags": [ + "The account Repository" + ], + "description": "patch-customer-by-account-Id", + "operationId": "createPropertyReference-account-patch", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CollectionModelObject" + } + }, + "application/x-spring-data-compact+json": { + "schema": { + "$ref": "#/components/schemas/CollectionModelObject" + } + }, + "text/uri-list": { + "schema": { + "type": "string" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/EntityModelCustomer" + } + } + } + }, + "204": { + "description": "No Content" + } + }, + "security": [ + { + "bearer": [] + } + ] + } + }, + "/accounts/{id}/customer/{propertyId}": { + "get": { + "tags": [ + "The account Repository" + ], + "description": "get-customer-by-account-Id", + "operationId": "followPropertyReference-account-get_1", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "propertyId", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/EntityModelCustomer" + } + } + } + }, + "404": { + "description": "Not Found" + } + }, + "security": [ + { + "bearer": [] + } + ] + }, + "delete": { + "tags": [ + "The account Repository" + ], + "description": "delete-customer-by-account-Id", + "operationId": "deletePropertyReferenceId-account-delete", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "propertyId", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "204": { + "description": "No Content" + }, + "404": { + "description": "Not Found" + } + }, + "security": [ + { + "bearer": [] + } + ] + } + }, + "/customers": { + "get": { + "tags": [ + "The customer Repository" + ], + "description": "get-customer", + "operationId": "getCollectionResource-customer-get", + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/CollectionModelEntityModelCustomer" + } + }, + "application/x-spring-data-compact+json": { + "schema": { + "$ref": "#/components/schemas/CollectionModelEntityModelCustomer" + } + }, + "text/uri-list": { + "schema": { + "type": "string" + } + } + } + } + } + }, + "post": { + "tags": [ + "The customer Repository" + ], + "description": "create-customer", + "operationId": "postCollectionResource-customer-post", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CustomerRequestBody" + } + } + }, + "required": true + }, + "responses": { + "201": { + "description": "Created", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/EntityModelCustomer" + } + } + } + } + } + } + }, + "/customers/search/findByLastname": { + "get": { + "tags": [ + "The customer Repository" + ], + "operationId": "executeSearch-customer-get", + "parameters": [ + { + "name": "lastname", + "in": "query", + "schema": { + "type": "string" + } + }, + { + "name": "page", + "in": "query", + "description": "Zero-based page index (0..N)", + "required": false, + "schema": { + "minimum": 0, + "type": "integer", + "default": 0 + } + }, + { + "name": "size", + "in": "query", + "description": "The size of the page to be returned", + "required": false, + "schema": { + "minimum": 1, + "type": "integer", + "default": 20 + } + }, + { + "name": "sort", + "in": "query", + "description": "Sorting criteria in the format: property,(asc|desc). Default sort order is ascending. Multiple sort criteria are supported.", + "required": false, + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/PagedModelEntityModelCustomer" + } + } + } + }, + "404": { + "description": "Not Found" + } + }, + "security": [ + { + "bearer": [] + } + ] + } + }, + "/customers/{id}": { + "get": { + "tags": [ + "The customer Repository" + ], + "description": "get-customer", + "operationId": "getItemResource-customer-get", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/EntityModelCustomer" + } + } + } + }, + "404": { + "description": "Not Found" + } + } + }, + "put": { + "tags": [ + "The customer Repository" + ], + "description": "update-customer", + "operationId": "putItemResource-customer-put", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CustomerRequestBody" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/EntityModelCustomer" + } + } + } + }, + "201": { + "description": "Created", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/EntityModelCustomer" + } + } + } + }, + "204": { + "description": "No Content" + } + } + }, + "patch": { + "tags": [ + "The customer Repository" + ], + "description": "patch-customer", + "operationId": "patchItemResource-customer-patch", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CustomerRequestBody" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/EntityModelCustomer" + } + } + } + }, + "204": { + "description": "No Content" + } + } + } + }, + "/customers/{id}/accounts": { + "get": { + "tags": [ + "The customer Repository" + ], + "description": "get-account-by-customer-Id", + "operationId": "followPropertyReference-customer-get", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/CollectionModelAccount" + } + }, + "text/uri-list": { + "schema": { + "type": "string" + } + } + } + }, + "404": { + "description": "Not Found" + } + } + }, + "put": { + "tags": [ + "The customer Repository" + ], + "description": "update-account-by-customer-Id", + "operationId": "createPropertyReference-customer-put", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CollectionModelObject" + } + }, + "application/x-spring-data-compact+json": { + "schema": { + "$ref": "#/components/schemas/CollectionModelObject" + } + }, + "text/uri-list": { + "schema": { + "type": "string" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/CollectionModelAccount" + } + } + } + }, + "201": { + "description": "Created", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/CollectionModelAccount" + } + } + } + }, + "204": { + "description": "No Content" + } + } + }, + "patch": { + "tags": [ + "The customer Repository" + ], + "description": "patch-account-by-customer-Id", + "operationId": "createPropertyReference-customer-patch", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CollectionModelObject" + } + }, + "application/x-spring-data-compact+json": { + "schema": { + "$ref": "#/components/schemas/CollectionModelObject" + } + }, + "text/uri-list": { + "schema": { + "type": "string" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/CollectionModelAccount" + } + } + } + }, + "204": { + "description": "No Content" + } + } + } + }, + "/customers/{id}/accounts/{propertyId}": { + "get": { + "tags": [ + "The customer Repository" + ], + "description": "get-account-by-customer-Id", + "operationId": "followPropertyReference-customer-get_1", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "propertyId", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/CollectionModelAccount" + } + } + } + }, + "404": { + "description": "Not Found" + } + } + } + }, + "/profile": { + "get": { + "tags": [ + "profile-controller" + ], + "operationId": "listAllFormsOfMetadata", + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/RepresentationModelObject" + } + } + } + } + } + } + }, + "/profile/accounts": { + "get": { + "tags": [ + "profile-controller" + ], + "operationId": "descriptor", + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "string" + } + }, + "application/alps+json": { + "schema": { + "type": "string" + } + }, + "application/schema+json": { + "schema": { + "$ref": "#/components/schemas/JsonSchema" + } + } + } + } + } + } + }, + "/profile/customers": { + "get": { + "tags": [ + "profile-controller" + ], + "operationId": "descriptor_1", + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "string" + } + }, + "application/alps+json": { + "schema": { + "type": "string" + } + }, + "application/schema+json": { + "schema": { + "$ref": "#/components/schemas/JsonSchema" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "AbstractJsonSchemaPropertyObject": { + "type": "object", + "properties": { + "title": { + "type": "string" + }, + "readOnly": { + "type": "boolean" + } + } + }, + "Item": { + "type": "object", + "properties": { + "type": { + "type": "string" + }, + "properties": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/AbstractJsonSchemaPropertyObject" + } + }, + "requiredProperties": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "JsonSchema": { + "type": "object", + "properties": { + "title": { + "type": "string" + }, + "description": { + "type": "string" + }, + "properties": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/AbstractJsonSchemaPropertyObject" + } + }, + "requiredProperties": { + "type": "array", + "items": { + "type": "string" + } + }, + "definitions": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/Item" + } + }, + "type": { + "type": "string" + }, + "$schema": { + "type": "string" + } + } + }, + "Links": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/Link" + } + }, + "RepresentationModelObject": { + "type": "object", + "properties": { + "_links": { + "$ref": "#/components/schemas/Links" + } + } + }, + "Account": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "customer": { + "$ref": "#/components/schemas/Customer" + }, + "expiryDate": { + "type": "string", + "format": "date-time" + } + } + }, + "Customer": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "firstname": { + "type": "string" + }, + "lastname": { + "type": "string" + }, + "accounts": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Account" + } + } + } + }, + "EntityModelAccount": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "expiryDate": { + "type": "string", + "format": "date-time" + }, + "_links": { + "$ref": "#/components/schemas/Links" + } + } + }, + "CollectionModelEntityModelAccount": { + "type": "object", + "properties": { + "_embedded": { + "type": "object", + "properties": { + "accounts": { + "type": "array", + "items": { + "$ref": "#/components/schemas/EntityModelAccount" + } + } + } + }, + "_links": { + "$ref": "#/components/schemas/Links" + } + } + }, + "EntityModelCustomer": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "firstname": { + "type": "string" + }, + "lastname": { + "type": "string" + }, + "_links": { + "$ref": "#/components/schemas/Links" + } + } + }, + "CollectionModelObject": { + "type": "object", + "properties": { + "_embedded": { + "type": "object", + "properties": { + "objects": { + "type": "array", + "items": { + "type": "object" + } + } + } + }, + "_links": { + "$ref": "#/components/schemas/Links" + } + } + }, + "CollectionModelEntityModelCustomer": { + "type": "object", + "properties": { + "_embedded": { + "type": "object", + "properties": { + "customers": { + "type": "array", + "items": { + "$ref": "#/components/schemas/EntityModelCustomer" + } + } + } + }, + "_links": { + "$ref": "#/components/schemas/Links" + } + } + }, + "CollectionModelAccount": { + "type": "object", + "properties": { + "_embedded": { + "type": "object", + "properties": { + "accounts": { + "type": "array", + "items": { + "$ref": "#/components/schemas/AccountResponse" + } + } + } + }, + "_links": { + "$ref": "#/components/schemas/Links" + } + } + }, + "PageMetadata": { + "type": "object", + "properties": { + "size": { + "type": "integer", + "format": "int64" + }, + "totalElements": { + "type": "integer", + "format": "int64" + }, + "totalPages": { + "type": "integer", + "format": "int64" + }, + "number": { + "type": "integer", + "format": "int64" + } + } + }, + "PagedModelEntityModelCustomer": { + "type": "object", + "properties": { + "_embedded": { + "type": "object", + "properties": { + "customers": { + "type": "array", + "items": { + "$ref": "#/components/schemas/EntityModelCustomer" + } + } + } + }, + "_links": { + "$ref": "#/components/schemas/Links" + }, + "page": { + "$ref": "#/components/schemas/PageMetadata" + } + } + }, + "AccountRequestBody": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "customer": { + "type": "string" + }, + "expiryDate": { + "type": "string", + "format": "date-time" + } + } + }, + "CustomerRequestBody": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "firstname": { + "type": "string" + }, + "lastname": { + "type": "string" + }, + "accounts": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "AccountResponse": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "expiryDate": { + "type": "string", + "format": "date-time" + } + } + }, + "Link": { + "type": "object", + "properties": { + "href": { + "type": "string" + }, + "hreflang": { + "type": "string" + }, + "title": { + "type": "string" + }, + "type": { + "type": "string" + }, + "deprecation": { + "type": "string" + }, + "profile": { + "type": "string" + }, + "name": { + "type": "string" + }, + "templated": { + "type": "boolean" + } + } + } + }, + "securitySchemes": { + "bearer": { + "type": "http", + "scheme": "bearer", + "bearerFormat": "JWT" + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.1.0/app35.json b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.1.0/app35.json new file mode 100644 index 000000000..4b199f6cc --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.1.0/app35.json @@ -0,0 +1,17 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": {}, + "components": { + "schemas": {} + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.1.0/app36.json b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.1.0/app36.json new file mode 100644 index 000000000..b148f585a --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.1.0/app36.json @@ -0,0 +1,167 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/enumFieldHolders/search/findAllByEnumField": { + "get": { + "tags": [ + "enum-field-holder-search-controller" + ], + "operationId": "executeSearch-enumfieldholder-get", + "parameters": [ + { + "name": "enumField", + "in": "query", + "schema": { + "type": "string", + "enum": [ + "FOO", + "BAR" + ] + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/CollectionModelEntityModelEnumFieldHolder" + } + } + } + }, + "404": { + "description": "Not Found" + } + } + } + }, + "/enumFieldHolders/search/findAllByEnumFieldIn": { + "get": { + "tags": [ + "enum-field-holder-search-controller" + ], + "operationId": "executeSearch-enumfieldholder-get_1", + "parameters": [ + { + "name": "enumFields", + "in": "query", + "schema": { + "type": "array", + "items": { + "type": "string", + "enum": [ + "FOO", + "BAR" + ] + } + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/CollectionModelEntityModelEnumFieldHolder" + } + } + } + }, + "404": { + "description": "Not Found" + } + } + } + } + }, + "components": { + "schemas": { + "CollectionModelEntityModelEnumFieldHolder": { + "type": "object", + "properties": { + "_embedded": { + "type": "object", + "properties": { + "enumFieldHolders": { + "type": "array", + "items": { + "$ref": "#/components/schemas/EntityModelEnumFieldHolder" + } + } + } + }, + "_links": { + "$ref": "#/components/schemas/Links" + } + } + }, + "EntityModelEnumFieldHolder": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "enumField": { + "type": "string", + "enum": [ + "FOO", + "BAR" + ] + }, + "_links": { + "$ref": "#/components/schemas/Links" + } + } + }, + "Link": { + "type": "object", + "properties": { + "deprecation": { + "type": "string" + }, + "href": { + "type": "string" + }, + "hreflang": { + "type": "string" + }, + "name": { + "type": "string" + }, + "profile": { + "type": "string" + }, + "templated": { + "type": "boolean" + }, + "title": { + "type": "string" + }, + "type": { + "type": "string" + } + } + }, + "Links": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/Link" + } + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.1.0/app37.json b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.1.0/app37.json new file mode 100644 index 000000000..7759dead0 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.1.0/app37.json @@ -0,0 +1,835 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/product": { + "get": { + "tags": [ + "product-entity-entity-controller" + ], + "description": "get-productentity", + "operationId": "getCollectionResource-productentity-get", + "parameters": [ + { + "name": "page", + "in": "query", + "description": "Zero-based page index (0..N)", + "required": false, + "schema": { + "minimum": 0, + "type": "integer", + "default": 0 + } + }, + { + "name": "size", + "in": "query", + "description": "The size of the page to be returned", + "required": false, + "schema": { + "minimum": 1, + "type": "integer", + "default": 20 + } + }, + { + "name": "sort", + "in": "query", + "description": "Sorting criteria in the format: property,(asc|desc). Default sort order is ascending. Multiple sort criteria are supported.", + "required": false, + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/PagedModelEntityModelProductEntity" + } + }, + "application/x-spring-data-compact+json": { + "schema": { + "$ref": "#/components/schemas/PagedModelEntityModelProductEntity" + } + }, + "text/uri-list": { + "schema": { + "type": "string" + } + } + } + } + } + }, + "post": { + "tags": [ + "product-entity-entity-controller" + ], + "description": "create-productentity", + "operationId": "postCollectionResource-productentity-post", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ProductEntityRequestBody" + } + } + }, + "required": true + }, + "responses": { + "201": { + "description": "Created", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/EntityModelProductEntity" + } + } + } + } + } + } + }, + "/product/search/findByDateBefore": { + "get": { + "tags": [ + "product-entity-search-controller" + ], + "operationId": "executeSearch-productentity-get", + "parameters": [ + { + "name": "end2", + "in": "query", + "required": true, + "schema": { + "type": "string", + "format": "date" + } + }, + { + "name": "end", + "in": "query", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/CollectionModelEntityModelProductEntity" + } + } + } + }, + "404": { + "description": "Not Found" + } + } + } + }, + "/product/search/findByName": { + "get": { + "tags": [ + "product-entity-search-controller" + ], + "operationId": "executeSearch-productentity-get_1", + "parameters": [ + { + "name": "name2", + "in": "query", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "name", + "in": "query", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/CollectionModelEntityModelProductEntity" + } + } + } + }, + "404": { + "description": "Not Found" + } + } + } + }, + "/product/search/findByNameContainingIgnoreCase": { + "get": { + "tags": [ + "product-entity-search-controller" + ], + "operationId": "executeSearch-productentity-get_2", + "parameters": [ + { + "name": "name2", + "in": "query", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "name", + "in": "query", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/CollectionModelEntityModelProductEntity" + } + } + } + }, + "404": { + "description": "Not Found" + } + } + } + }, + "/product/search/findByNameContainingIgnoreCaseAndDateBefore": { + "get": { + "tags": [ + "product-entity-search-controller" + ], + "operationId": "executeSearch-productentity-get_3", + "parameters": [ + { + "name": "name2", + "in": "query", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "end2", + "in": "query", + "required": true, + "schema": { + "type": "string", + "format": "date" + } + }, + { + "name": "name", + "in": "query", + "schema": { + "type": "string" + } + }, + { + "name": "end", + "in": "query", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/CollectionModelEntityModelProductEntity" + } + } + } + }, + "404": { + "description": "Not Found" + } + } + } + }, + "/product/search/findByNameContainingIgnoreCaseOrderByDateDesc": { + "get": { + "tags": [ + "product-entity-search-controller" + ], + "operationId": "executeSearch-productentity-get_4", + "parameters": [ + { + "name": "name2", + "in": "query", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "name", + "in": "query", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/CollectionModelEntityModelProductEntity" + } + } + } + }, + "404": { + "description": "Not Found" + } + } + } + }, + "/product/search/findByPrice": { + "get": { + "tags": [ + "product-entity-search-controller" + ], + "operationId": "executeSearch-productentity-get_5", + "parameters": [ + { + "name": "price", + "in": "query", + "description": "test desc", + "required": true, + "schema": { + "type": "number" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/CollectionModelEntityModelProductEntity" + } + } + } + }, + "404": { + "description": "Not Found" + } + } + } + }, + "/product/search/findTopByNameOrderByDateDesc": { + "get": { + "tags": [ + "product-entity-search-controller" + ], + "operationId": "executeSearch-productentity-get_6", + "parameters": [ + { + "name": "name2", + "in": "query", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "name", + "in": "query", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/EntityModelProductEntity" + } + } + } + }, + "404": { + "description": "Not Found" + } + } + } + }, + "/product/{id}": { + "get": { + "tags": [ + "product-entity-entity-controller" + ], + "description": "get-productentity", + "operationId": "getItemResource-productentity-get", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/EntityModelProductEntity" + } + } + } + }, + "404": { + "description": "Not Found" + } + } + }, + "put": { + "tags": [ + "product-entity-entity-controller" + ], + "description": "update-productentity", + "operationId": "putItemResource-productentity-put", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ProductEntityRequestBody" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/EntityModelProductEntity" + } + } + } + }, + "201": { + "description": "Created", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/EntityModelProductEntity" + } + } + } + }, + "204": { + "description": "No Content" + } + } + }, + "delete": { + "tags": [ + "product-entity-entity-controller" + ], + "description": "delete-productentity", + "operationId": "deleteItemResource-productentity-delete", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "204": { + "description": "No Content" + }, + "404": { + "description": "Not Found" + } + } + }, + "patch": { + "tags": [ + "product-entity-entity-controller" + ], + "description": "patch-productentity", + "operationId": "patchItemResource-productentity-patch", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ProductEntityRequestBody" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/EntityModelProductEntity" + } + } + } + }, + "204": { + "description": "No Content" + } + } + } + }, + "/profile": { + "get": { + "tags": [ + "profile-controller" + ], + "operationId": "listAllFormsOfMetadata", + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/RepresentationModelObject" + } + } + } + } + } + } + }, + "/profile/product": { + "get": { + "tags": [ + "profile-controller" + ], + "operationId": "descriptor", + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "string" + } + }, + "application/alps+json": { + "schema": { + "type": "string" + } + }, + "application/schema+json": { + "schema": { + "$ref": "#/components/schemas/JsonSchema" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "AbstractJsonSchemaPropertyObject": { + "type": "object", + "properties": { + "title": { + "type": "string" + }, + "readOnly": { + "type": "boolean" + } + } + }, + "Item": { + "type": "object", + "properties": { + "type": { + "type": "string" + }, + "properties": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/AbstractJsonSchemaPropertyObject" + } + }, + "requiredProperties": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "JsonSchema": { + "type": "object", + "properties": { + "title": { + "type": "string" + }, + "description": { + "type": "string" + }, + "properties": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/AbstractJsonSchemaPropertyObject" + } + }, + "requiredProperties": { + "type": "array", + "items": { + "type": "string" + } + }, + "definitions": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/Item" + } + }, + "type": { + "type": "string" + }, + "$schema": { + "type": "string" + } + } + }, + "Links": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/Link" + } + }, + "RepresentationModelObject": { + "type": "object", + "properties": { + "_links": { + "$ref": "#/components/schemas/Links" + } + } + }, + "EntityModelProductEntity": { + "required": [ + "date", + "name", + "price" + ], + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "price": { + "type": "number" + }, + "date": { + "type": "string", + "format": "date" + }, + "valid": { + "type": "boolean" + }, + "_links": { + "$ref": "#/components/schemas/Links" + } + } + }, + "PageMetadata": { + "type": "object", + "properties": { + "size": { + "type": "integer", + "format": "int64" + }, + "totalElements": { + "type": "integer", + "format": "int64" + }, + "totalPages": { + "type": "integer", + "format": "int64" + }, + "number": { + "type": "integer", + "format": "int64" + } + } + }, + "PagedModelEntityModelProductEntity": { + "type": "object", + "properties": { + "_embedded": { + "type": "object", + "properties": { + "productEntities": { + "type": "array", + "items": { + "$ref": "#/components/schemas/EntityModelProductEntity" + } + } + } + }, + "_links": { + "$ref": "#/components/schemas/Links" + }, + "page": { + "$ref": "#/components/schemas/PageMetadata" + } + } + }, + "CollectionModelEntityModelProductEntity": { + "type": "object", + "properties": { + "_embedded": { + "type": "object", + "properties": { + "productEntities": { + "type": "array", + "items": { + "$ref": "#/components/schemas/EntityModelProductEntity" + } + } + } + }, + "_links": { + "$ref": "#/components/schemas/Links" + } + } + }, + "ProductEntityRequestBody": { + "required": [ + "date", + "name", + "price" + ], + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "name": { + "type": "string" + }, + "price": { + "type": "number" + }, + "date": { + "type": "string", + "format": "date" + }, + "valid": { + "type": "boolean" + } + } + }, + "Link": { + "type": "object", + "properties": { + "href": { + "type": "string" + }, + "hreflang": { + "type": "string" + }, + "title": { + "type": "string" + }, + "type": { + "type": "string" + }, + "deprecation": { + "type": "string" + }, + "profile": { + "type": "string" + }, + "name": { + "type": "string" + }, + "templated": { + "type": "boolean" + } + } + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.1.0/app38.json b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.1.0/app38.json new file mode 100644 index 000000000..44e97f0a1 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.1.0/app38.json @@ -0,0 +1,55 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/test1": { + "get": { + "tags": [ + "default-flat-param-object-controller" + ], + "operationId": "test1", + "parameters": [ + { + "name": "sort", + "in": "query", + "description": "Sorting criteria in the format: property,(asc|desc). Default sort order is ascending. Multiple sort criteria are supported.", + "required": false, + "schema": { + "type": "array", + "default": [ + "name,ASC" + ], + "items": { + "type": "string" + } + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "type": "string" + } + } + } + } + } + } + } + }, + "components": { + "schemas": {} + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.1.0/app4.json b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.1.0/app4.json new file mode 100644 index 000000000..09eb17db0 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.1.0/app4.json @@ -0,0 +1,223 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/employees": { + "get": { + "tags": [ + "employee-controller" + ], + "operationId": "findAll", + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/CollectionModelEntityModelEmployee" + } + } + } + } + } + }, + "post": { + "tags": [ + "employee-controller" + ], + "operationId": "newEmployee", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Employee" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/EntityModelEmployee" + } + } + } + } + } + } + }, + "/employees/{id}": { + "get": { + "tags": [ + "employee-controller" + ], + "operationId": "findOne", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "integer", + "format": "int64" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/EntityModelEmployee" + } + } + } + } + } + }, + "put": { + "tags": [ + "employee-controller" + ], + "operationId": "updateEmployee", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "integer", + "format": "int64" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Employee" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "OK" + } + } + } + } + }, + "components": { + "schemas": { + "CollectionModelEntityModelEmployee": { + "type": "object", + "properties": { + "_embedded": { + "type": "object", + "properties": { + "employees": { + "type": "array", + "items": { + "$ref": "#/components/schemas/EntityModelEmployee" + } + } + } + }, + "_links": { + "$ref": "#/components/schemas/Links" + } + } + }, + "Employee": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "firstName": { + "type": "string" + }, + "lastName": { + "type": "string" + }, + "role": { + "type": "string" + } + } + }, + "EntityModelEmployee": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "firstName": { + "type": "string" + }, + "lastName": { + "type": "string" + }, + "role": { + "type": "string" + }, + "_links": { + "$ref": "#/components/schemas/Links" + } + } + }, + "Links": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/Link" + } + }, + "Link": { + "type": "object", + "properties": { + "href": { + "type": "string" + }, + "hreflang": { + "type": "string" + }, + "title": { + "type": "string" + }, + "type": { + "type": "string" + }, + "deprecation": { + "type": "string" + }, + "profile": { + "type": "string" + }, + "name": { + "type": "string" + }, + "templated": { + "type": "boolean" + } + } + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.1.0/app5.json b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.1.0/app5.json new file mode 100644 index 000000000..e46116a9f --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.1.0/app5.json @@ -0,0 +1,102 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/test": { + "get": { + "tags": [ + "greeting-controller" + ], + "operationId": "sayHello2", + "parameters": [ + { + "name": "statuses", + "in": "query", + "required": true, + "schema": { + "type": "array", + "items": { + "type": "string", + "enum": [ + "ACTIVE", + "INACTIVE" + ] + } + } + }, + { + "name": "code", + "in": "query", + "schema": { + "type": "string" + } + }, + { + "name": "name", + "in": "query", + "schema": { + "type": "string" + } + }, + { + "name": "postCode", + "in": "query", + "schema": { + "type": "string" + } + }, + { + "name": "id", + "in": "query", + "schema": { + "type": "integer", + "format": "int64" + } + }, + { + "name": "shortName", + "in": "query", + "schema": { + "type": "string" + } + }, + { + "name": "status", + "in": "query", + "schema": { + "type": "string", + "enum": [ + "ACTIVE", + "INACTIVE" + ] + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "type": "object" + } + } + } + } + } + } + } + }, + "components": { + "schemas": {} + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.1.0/app6.json b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.1.0/app6.json new file mode 100644 index 000000000..0d368ee00 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.1.0/app6.json @@ -0,0 +1,124 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/employees/{id}": { + "get": { + "tags": [ + "employee-controller" + ], + "operationId": "findOne", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "integer", + "format": "int64" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/EntityModelEmployee" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "Employee": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "firstName": { + "type": "string" + }, + "lastName": { + "type": "string" + }, + "role": { + "type": "string" + } + } + }, + "EntityModelEmployee": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "firstName": { + "type": "string" + }, + "lastName": { + "type": "string" + }, + "role": { + "type": "string" + }, + "_links": { + "$ref": "#/components/schemas/Links" + } + } + }, + "Links": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/Link" + } + }, + "Link": { + "type": "object", + "properties": { + "href": { + "type": "string" + }, + "hreflang": { + "type": "string" + }, + "title": { + "type": "string" + }, + "type": { + "type": "string" + }, + "deprecation": { + "type": "string" + }, + "profile": { + "type": "string" + }, + "name": { + "type": "string" + }, + "templated": { + "type": "boolean" + } + } + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.1.0/app7.json b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.1.0/app7.json new file mode 100644 index 000000000..8549f6460 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.1.0/app7.json @@ -0,0 +1,100 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/search": { + "get": { + "tags": [ + "hello-controller" + ], + "operationId": "getAllPets", + "parameters": [ + { + "name": "page", + "in": "query", + "description": "Zero-based page index (0..N)", + "required": false, + "schema": { + "type": "integer", + "default": 0, + "minimum": 0 + } + }, + { + "name": "size", + "in": "query", + "description": "The size of the page to be returned", + "required": false, + "schema": { + "type": "integer", + "default": 20, + "minimum": 1 + } + }, + { + "name": "sort", + "in": "query", + "description": "Sorting criteria in the format: property,(asc|desc). Default sort order is ascending. Multiple sort criteria are supported.", + "required": false, + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/xml": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/PersonDTO" + } + } + }, + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/PersonDTO" + } + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "PersonDTO": { + "type": "object", + "properties": { + "email": { + "type": "string" + }, + "firstName": { + "type": "string" + }, + "lastName": { + "type": "string" + } + } + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.1.0/app8.json b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.1.0/app8.json new file mode 100644 index 000000000..6fbcf3fd7 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.1.0/app8.json @@ -0,0 +1,131 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/api/albums": { + "get": { + "tags": [ + "album-controller" + ], + "operationId": "getAllAlbums", + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/PagedModelAlbum" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "Album": { + "type": "object", + "properties": { + "title": { + "type": "string" + }, + "description": { + "type": "string" + }, + "releaseDate": { + "type": "string" + } + } + }, + "Links": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/Link" + } + }, + "PageMetadata": { + "type": "object", + "properties": { + "size": { + "type": "integer", + "format": "int64" + }, + "totalElements": { + "type": "integer", + "format": "int64" + }, + "totalPages": { + "type": "integer", + "format": "int64" + }, + "number": { + "type": "integer", + "format": "int64" + } + } + }, + "PagedModelAlbum": { + "type": "object", + "properties": { + "_embedded": { + "type": "object", + "properties": { + "albums": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Album" + } + } + } + }, + "_links": { + "$ref": "#/components/schemas/Links" + }, + "page": { + "$ref": "#/components/schemas/PageMetadata" + } + } + }, + "Link": { + "type": "object", + "properties": { + "href": { + "type": "string" + }, + "hreflang": { + "type": "string" + }, + "title": { + "type": "string" + }, + "type": { + "type": "string" + }, + "deprecation": { + "type": "string" + }, + "profile": { + "type": "string" + }, + "name": { + "type": "string" + }, + "templated": { + "type": "boolean" + } + } + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.1.0/app9.json b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.1.0/app9.json new file mode 100644 index 000000000..f02a7f25b --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-data-rest-tests/src/test/resources/results/3.1.0/app9.json @@ -0,0 +1,218 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "Demo Springdoc Issue #401", + "description": "A demo API to illustrate Springdoc Issue #401.", + "version": "0.0.1-SNAPSHOT" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "components", + "description": "Everything about components" + } + ], + "paths": { + "/components": { + "get": { + "tags": [ + "components" + ], + "summary": "List the components", + "operationId": "findAll", + "parameters": [ + { + "name": "page", + "in": "query", + "description": "Zero-based page index (0..N)", + "schema": { + "type": "integer", + "default": 0 + } + }, + { + "name": "size", + "in": "query", + "description": "The size of the page to be returned", + "schema": { + "type": "integer", + "default": 20 + } + }, + { + "name": "sort", + "in": "query", + "description": "Sorting criteria in the format: property,(asc|desc). Default sort order is ascending. Multiple sort criteria are supported.", + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/PagedModelRepresentationModelEntityModelDemoComponentDto" + } + } + } + } + } + } + }, + "/components/{componentId}": { + "get": { + "tags": [ + "components" + ], + "summary": "Get one component by its ID", + "description": "Returns a single component", + "operationId": "findById", + "parameters": [ + { + "name": "componentId", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "Component found", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/EntityModelDemoComponentDto" + } + } + } + }, + "404": { + "description": "Component not found" + } + } + } + } + }, + "components": { + "schemas": { + "Link": { + "type": "object", + "properties": { + "rel": { + "type": "string" + }, + "href": { + "type": "string" + }, + "hreflang": { + "type": "string" + }, + "media": { + "type": "string" + }, + "title": { + "type": "string" + }, + "type": { + "type": "string" + }, + "deprecation": { + "type": "string" + }, + "profile": { + "type": "string" + }, + "name": { + "type": "string" + } + } + }, + "PageMetadata": { + "type": "object", + "properties": { + "size": { + "type": "integer", + "format": "int64" + }, + "totalElements": { + "type": "integer", + "format": "int64" + }, + "totalPages": { + "type": "integer", + "format": "int64" + }, + "number": { + "type": "integer", + "format": "int64" + } + } + }, + "PagedModelRepresentationModelEntityModelDemoComponentDto": { + "type": "object", + "properties": { + "links": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Link" + } + }, + "content": { + "type": "array", + "items": { + "$ref": "#/components/schemas/RepresentationModelEntityModelDemoComponentDto" + } + }, + "page": { + "$ref": "#/components/schemas/PageMetadata" + } + } + }, + "RepresentationModelEntityModelDemoComponentDto": { + "type": "object", + "properties": { + "links": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Link" + } + } + } + }, + "EntityModelDemoComponentDto": { + "type": "object", + "properties": { + "id": { + "type": "string", + "description": "Some ID", + "example": 1 + }, + "payload": { + "type": "string", + "description": "Some dummy payload", + "example": "Hello World" + }, + "links": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Link" + } + } + } + } + } + } +} 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 94f84bb86..01fd244fa 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.1 + 2.8.2 4.0.0 diff --git a/springdoc-openapi-tests/springdoc-openapi-function-webflux-tests/src/test/java/test/org/springdoc/api/AbstractCommonTest.java b/springdoc-openapi-tests/springdoc-openapi-function-webflux-tests/src/test/java/test/org/springdoc/api/AbstractCommonTest.java deleted file mode 100644 index 3f94f121c..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-function-webflux-tests/src/test/java/test/org/springdoc/api/AbstractCommonTest.java +++ /dev/null @@ -1,37 +0,0 @@ -package test.org.springdoc.api; - -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.web.reactive.AutoConfigureWebTestClient; -import org.springframework.test.context.ActiveProfiles; -import org.springframework.test.context.TestPropertySource; -import org.springframework.test.web.reactive.server.WebTestClient; - -@AutoConfigureWebTestClient(timeout = "3600000") -@ActiveProfiles("test") -@TestPropertySource(properties = "springdoc.api-docs.version=openapi_3_0" ) -public abstract class AbstractCommonTest { - - protected static final Logger LOGGER = LoggerFactory.getLogger(AbstractCommonTest.class); - - @Autowired - protected WebTestClient webTestClient; - - protected String getContent(String fileName) { - try { - Path path = Paths.get(AbstractCommonTest.class.getClassLoader().getResource(fileName).toURI()); - byte[] fileBytes = Files.readAllBytes(path); - return new String(fileBytes, StandardCharsets.UTF_8); - } - catch (Exception e) { - throw new RuntimeException("Failed to read file: " + fileName, e); - } - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-function-webflux-tests/src/test/java/test/org/springdoc/api/AbstractSpringDocFunctionTest.java b/springdoc-openapi-tests/springdoc-openapi-function-webflux-tests/src/test/java/test/org/springdoc/api/AbstractSpringDocFunctionTest.java deleted file mode 100644 index e8332bd55..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-function-webflux-tests/src/test/java/test/org/springdoc/api/AbstractSpringDocFunctionTest.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * - * * Copyright 2019-2020 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; - -import org.json.JSONException; -import org.junit.jupiter.api.Test; -import org.springdoc.core.utils.Constants; - -import org.springframework.boot.test.autoconfigure.web.reactive.AutoConfigureWebTestClient; -import org.springframework.cloud.function.context.test.FunctionalSpringBootTest; -import org.springframework.test.web.reactive.server.EntityExchangeResult; - -import static org.skyscreamer.jsonassert.JSONAssert.assertEquals; - - -@FunctionalSpringBootTest -@AutoConfigureWebTestClient(timeout = "3600000") -public abstract class AbstractSpringDocFunctionTest extends AbstractCommonTest { - - protected String groupName = ""; - - - @Test - void testApp() { - String result = null; - try { - EntityExchangeResult getResult = webTestClient.get().uri(Constants.DEFAULT_API_DOCS_URL + groupName).exchange() - .expectStatus().isOk().expectBody().returnResult(); - - result = new String(getResult.getResponseBody()); - String className = getClass().getSimpleName(); - String testNumber = className.replaceAll("[^0-9]", ""); - String expected = getContent("results/app" + testNumber + ".json"); - assertEquals(expected, result, true); - } - catch (AssertionError e) { - LOGGER.error(result); - throw e; - } - catch (JSONException e) { - LOGGER.error(result); - throw new RuntimeException(e); - } - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-function-webflux-tests/src/test/java/test/org/springdoc/api/app154/PersonDTO.java b/springdoc-openapi-tests/springdoc-openapi-function-webflux-tests/src/test/java/test/org/springdoc/api/app154/PersonDTO.java deleted file mode 100644 index c435f526e..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-function-webflux-tests/src/test/java/test/org/springdoc/api/app154/PersonDTO.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app154; - -public class PersonDTO { - private String email; - - private String firstName; - - private String lastName; - - public PersonDTO() { - } - - public PersonDTO(final String email, final String firstName, final String lastName) { - this.email = email; - this.firstName = firstName; - this.lastName = lastName; - } - - public String getEmail() { - return email; - } - - public void setEmail(final String email) { - this.email = email; - } - - public String getFirstName() { - return firstName; - } - - public void setFirstName(final String firstName) { - this.firstName = firstName; - } - - public String getLastName() { - return lastName; - } - - public void setLastName(final String lastName) { - this.lastName = lastName; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-function-webflux-tests/src/test/java/test/org/springdoc/api/app154/SpringDocApp154Test.java b/springdoc-openapi-tests/springdoc-openapi-function-webflux-tests/src/test/java/test/org/springdoc/api/app154/SpringDocApp154Test.java deleted file mode 100644 index 9c7f8c66c..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-function-webflux-tests/src/test/java/test/org/springdoc/api/app154/SpringDocApp154Test.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * - * * - * * * Copyright 2019-2020 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.app154; - -import java.util.function.Function; -import java.util.function.Supplier; - -import reactor.core.publisher.Flux; -import test.org.springdoc.api.AbstractSpringDocFunctionTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.cloud.function.context.config.ContextFunctionCatalogAutoConfiguration; -import org.springframework.cloud.function.web.mvc.ReactorAutoConfiguration; -import org.springframework.cloud.function.web.source.FunctionExporterAutoConfiguration; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Import; -import org.springframework.test.context.TestPropertySource; - -@Import({ ReactorAutoConfiguration.class, FunctionExporterAutoConfiguration.class, ContextFunctionCatalogAutoConfiguration.class }) -@TestPropertySource(properties = "spring.cloud.function.web.path=/toto") -public class SpringDocApp154Test extends AbstractSpringDocFunctionTest { - - @SpringBootApplication - @ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.app154" }) - static class SpringDocTestApp { - @Bean - public Function reverseString() { - return value -> new StringBuilder(value).reverse().toString(); - } - - @Bean - public Function uppercase() { - return String::toUpperCase; - } - - @Bean - public Function, Flux> lowercase() { - return flux -> flux.map(String::toLowerCase); - } - - @Bean(name = "titi") - public Supplier hello() { - return PersonDTO::new; - } - - @Bean - public Supplier> words() { - return () -> Flux.fromArray(new String[] { "foo", "bar" }); - } - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-function-webflux-tests/src/test/java/test/org/springdoc/api/v30/AbstractCommonTest.java b/springdoc-openapi-tests/springdoc-openapi-function-webflux-tests/src/test/java/test/org/springdoc/api/v30/AbstractCommonTest.java new file mode 100644 index 000000000..a26b7e6f2 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-function-webflux-tests/src/test/java/test/org/springdoc/api/v30/AbstractCommonTest.java @@ -0,0 +1,63 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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; + +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.reactive.AutoConfigureWebTestClient; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.context.TestPropertySource; +import org.springframework.test.web.reactive.server.WebTestClient; + +@AutoConfigureWebTestClient(timeout = "3600000") +@ActiveProfiles("test") +@TestPropertySource(properties = "springdoc.api-docs.version=openapi_3_0" ) +public abstract class AbstractCommonTest { + + protected static final Logger LOGGER = LoggerFactory.getLogger(AbstractCommonTest.class); + + @Autowired + protected WebTestClient webTestClient; + + protected String getContent(String fileName) { + try { + Path path = Paths.get(AbstractCommonTest.class.getClassLoader().getResource(fileName).toURI()); + byte[] fileBytes = Files.readAllBytes(path); + return new String(fileBytes, StandardCharsets.UTF_8); + } + catch (Exception e) { + throw new RuntimeException("Failed to read file: " + fileName, e); + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-function-webflux-tests/src/test/java/test/org/springdoc/api/v30/AbstractSpringDocFunctionTest.java b/springdoc-openapi-tests/springdoc-openapi-function-webflux-tests/src/test/java/test/org/springdoc/api/v30/AbstractSpringDocFunctionTest.java new file mode 100644 index 000000000..3530b3608 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-function-webflux-tests/src/test/java/test/org/springdoc/api/v30/AbstractSpringDocFunctionTest.java @@ -0,0 +1,69 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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; + +import org.json.JSONException; +import org.junit.jupiter.api.Test; +import org.springdoc.core.utils.Constants; + +import org.springframework.boot.test.autoconfigure.web.reactive.AutoConfigureWebTestClient; +import org.springframework.cloud.function.context.test.FunctionalSpringBootTest; +import org.springframework.test.web.reactive.server.EntityExchangeResult; + +import static org.skyscreamer.jsonassert.JSONAssert.assertEquals; + + +@FunctionalSpringBootTest +@AutoConfigureWebTestClient(timeout = "3600000") +public abstract class AbstractSpringDocFunctionTest extends AbstractCommonTest { + + protected String groupName = ""; + + + @Test + void testApp() { + String result = null; + try { + EntityExchangeResult getResult = webTestClient.get().uri(Constants.DEFAULT_API_DOCS_URL + groupName).exchange() + .expectStatus().isOk().expectBody().returnResult(); + + result = new String(getResult.getResponseBody()); + String className = getClass().getSimpleName(); + String testNumber = className.replaceAll("[^0-9]", ""); + String expected = getContent("results/3.0.1/app" + testNumber + ".json"); + assertEquals(expected, result, true); + } + catch (AssertionError e) { + LOGGER.error(result); + throw e; + } + catch (JSONException e) { + LOGGER.error(result); + throw new RuntimeException(e); + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-function-webflux-tests/src/test/java/test/org/springdoc/api/v30/app154/PersonDTO.java b/springdoc-openapi-tests/springdoc-openapi-function-webflux-tests/src/test/java/test/org/springdoc/api/v30/app154/PersonDTO.java new file mode 100644 index 000000000..8735e622a --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-function-webflux-tests/src/test/java/test/org/springdoc/api/v30/app154/PersonDTO.java @@ -0,0 +1,60 @@ +/* + * + * * Copyright 2019-2020 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.app154; + +public class PersonDTO { + private String email; + + private String firstName; + + private String lastName; + + public PersonDTO() { + } + + public PersonDTO(final String email, final String firstName, final String lastName) { + this.email = email; + this.firstName = firstName; + this.lastName = lastName; + } + + public String getEmail() { + return email; + } + + public void setEmail(final String email) { + this.email = email; + } + + public String getFirstName() { + return firstName; + } + + public void setFirstName(final String firstName) { + this.firstName = firstName; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(final String lastName) { + this.lastName = lastName; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-function-webflux-tests/src/test/java/test/org/springdoc/api/v30/app154/SpringDocApp154Test.java b/springdoc-openapi-tests/springdoc-openapi-function-webflux-tests/src/test/java/test/org/springdoc/api/v30/app154/SpringDocApp154Test.java new file mode 100644 index 000000000..37de65ef3 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-function-webflux-tests/src/test/java/test/org/springdoc/api/v30/app154/SpringDocApp154Test.java @@ -0,0 +1,71 @@ +/* + * + * * + * * * Copyright 2019-2020 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.app154; + +import java.util.function.Function; +import java.util.function.Supplier; + +import reactor.core.publisher.Flux; +import test.org.springdoc.api.v30.AbstractSpringDocFunctionTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.cloud.function.context.config.ContextFunctionCatalogAutoConfiguration; +import org.springframework.cloud.function.web.mvc.ReactorAutoConfiguration; +import org.springframework.cloud.function.web.source.FunctionExporterAutoConfiguration; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Import; +import org.springframework.test.context.TestPropertySource; + +@Import({ ReactorAutoConfiguration.class, FunctionExporterAutoConfiguration.class, ContextFunctionCatalogAutoConfiguration.class }) +@TestPropertySource(properties = "spring.cloud.function.web.path=/toto") +public class SpringDocApp154Test extends AbstractSpringDocFunctionTest { + + @SpringBootApplication + @ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.v30.app154" }) + static class SpringDocTestApp { + @Bean + public Function reverseString() { + return value -> new StringBuilder(value).reverse().toString(); + } + + @Bean + public Function uppercase() { + return String::toUpperCase; + } + + @Bean + public Function, Flux> lowercase() { + return flux -> flux.map(String::toLowerCase); + } + + @Bean(name = "titi") + public Supplier hello() { + return PersonDTO::new; + } + + @Bean + public Supplier> words() { + return () -> Flux.fromArray(new String[] { "foo", "bar" }); + } + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-function-webflux-tests/src/test/java/test/org/springdoc/api/v31/AbstractCommonTest.java b/springdoc-openapi-tests/springdoc-openapi-function-webflux-tests/src/test/java/test/org/springdoc/api/v31/AbstractCommonTest.java new file mode 100644 index 000000000..4dedd2868 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-function-webflux-tests/src/test/java/test/org/springdoc/api/v31/AbstractCommonTest.java @@ -0,0 +1,61 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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; + +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.reactive.AutoConfigureWebTestClient; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.web.reactive.server.WebTestClient; + +@AutoConfigureWebTestClient(timeout = "3600000") +@ActiveProfiles("test") +public abstract class AbstractCommonTest { + + protected static final Logger LOGGER = LoggerFactory.getLogger(AbstractCommonTest.class); + + @Autowired + protected WebTestClient webTestClient; + + protected String getContent(String fileName) { + try { + Path path = Paths.get(AbstractCommonTest.class.getClassLoader().getResource(fileName).toURI()); + byte[] fileBytes = Files.readAllBytes(path); + return new String(fileBytes, StandardCharsets.UTF_8); + } + catch (Exception e) { + throw new RuntimeException("Failed to read file: " + fileName, e); + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-function-webflux-tests/src/test/java/test/org/springdoc/api/v31/AbstractSpringDocFunctionTest.java b/springdoc-openapi-tests/springdoc-openapi-function-webflux-tests/src/test/java/test/org/springdoc/api/v31/AbstractSpringDocFunctionTest.java new file mode 100644 index 000000000..006206529 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-function-webflux-tests/src/test/java/test/org/springdoc/api/v31/AbstractSpringDocFunctionTest.java @@ -0,0 +1,69 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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; + +import org.json.JSONException; +import org.junit.jupiter.api.Test; +import org.springdoc.core.utils.Constants; + +import org.springframework.boot.test.autoconfigure.web.reactive.AutoConfigureWebTestClient; +import org.springframework.cloud.function.context.test.FunctionalSpringBootTest; +import org.springframework.test.web.reactive.server.EntityExchangeResult; + +import static org.skyscreamer.jsonassert.JSONAssert.assertEquals; + + +@FunctionalSpringBootTest +@AutoConfigureWebTestClient(timeout = "3600000") +public abstract class AbstractSpringDocFunctionTest extends AbstractCommonTest { + + protected String groupName = ""; + + + @Test + void testApp() { + String result = null; + try { + EntityExchangeResult getResult = webTestClient.get().uri(Constants.DEFAULT_API_DOCS_URL + groupName).exchange() + .expectStatus().isOk().expectBody().returnResult(); + + result = new String(getResult.getResponseBody()); + String className = getClass().getSimpleName(); + String testNumber = className.replaceAll("[^0-9]", ""); + String expected = getContent("results/3.1.0/app" + testNumber + ".json"); + assertEquals(expected, result, true); + } + catch (AssertionError e) { + LOGGER.error(result); + throw e; + } + catch (JSONException e) { + LOGGER.error(result); + throw new RuntimeException(e); + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-function-webflux-tests/src/test/java/test/org/springdoc/api/v31/app154/PersonDTO.java b/springdoc-openapi-tests/springdoc-openapi-function-webflux-tests/src/test/java/test/org/springdoc/api/v31/app154/PersonDTO.java new file mode 100644 index 000000000..3a49b397b --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-function-webflux-tests/src/test/java/test/org/springdoc/api/v31/app154/PersonDTO.java @@ -0,0 +1,60 @@ +/* + * + * * Copyright 2019-2020 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.app154; + +public class PersonDTO { + private String email; + + private String firstName; + + private String lastName; + + public PersonDTO() { + } + + public PersonDTO(final String email, final String firstName, final String lastName) { + this.email = email; + this.firstName = firstName; + this.lastName = lastName; + } + + public String getEmail() { + return email; + } + + public void setEmail(final String email) { + this.email = email; + } + + public String getFirstName() { + return firstName; + } + + public void setFirstName(final String firstName) { + this.firstName = firstName; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(final String lastName) { + this.lastName = lastName; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-function-webflux-tests/src/test/java/test/org/springdoc/api/v31/app154/SpringDocApp154Test.java b/springdoc-openapi-tests/springdoc-openapi-function-webflux-tests/src/test/java/test/org/springdoc/api/v31/app154/SpringDocApp154Test.java new file mode 100644 index 000000000..5909969b5 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-function-webflux-tests/src/test/java/test/org/springdoc/api/v31/app154/SpringDocApp154Test.java @@ -0,0 +1,71 @@ +/* + * + * * + * * * Copyright 2019-2020 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.app154; + +import java.util.function.Function; +import java.util.function.Supplier; + +import reactor.core.publisher.Flux; +import test.org.springdoc.api.v31.AbstractSpringDocFunctionTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.cloud.function.context.config.ContextFunctionCatalogAutoConfiguration; +import org.springframework.cloud.function.web.mvc.ReactorAutoConfiguration; +import org.springframework.cloud.function.web.source.FunctionExporterAutoConfiguration; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Import; +import org.springframework.test.context.TestPropertySource; + +@Import({ ReactorAutoConfiguration.class, FunctionExporterAutoConfiguration.class, ContextFunctionCatalogAutoConfiguration.class }) +@TestPropertySource(properties = "spring.cloud.function.web.path=/toto") +public class SpringDocApp154Test extends AbstractSpringDocFunctionTest { + + @SpringBootApplication + @ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.v31.app154" }) + static class SpringDocTestApp { + @Bean + public Function reverseString() { + return value -> new StringBuilder(value).reverse().toString(); + } + + @Bean + public Function uppercase() { + return String::toUpperCase; + } + + @Bean + public Function, Flux> lowercase() { + return flux -> flux.map(String::toLowerCase); + } + + @Bean(name = "titi") + public Supplier hello() { + return PersonDTO::new; + } + + @Bean + public Supplier> words() { + return () -> Flux.fromArray(new String[] { "foo", "bar" }); + } + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-function-webflux-tests/src/test/resources/results/app154.json b/springdoc-openapi-tests/springdoc-openapi-function-webflux-tests/src/test/resources/results/3.0.1/app154.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-function-webflux-tests/src/test/resources/results/app154.json rename to springdoc-openapi-tests/springdoc-openapi-function-webflux-tests/src/test/resources/results/3.0.1/app154.json diff --git a/springdoc-openapi-tests/springdoc-openapi-function-webflux-tests/src/test/resources/results/3.1.0/app154.json b/springdoc-openapi-tests/springdoc-openapi-function-webflux-tests/src/test/resources/results/3.1.0/app154.json new file mode 100644 index 000000000..4e3b84627 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-function-webflux-tests/src/test/resources/results/3.1.0/app154.json @@ -0,0 +1,303 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "", + "description": "Generated server url" + } + ], + "paths": { + "/toto/lowercase": { + "post": { + "description": "lowercase function", + "operationId": "lowercase_POST", + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + }, + "text/plain": { + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + } + } + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + }, + "text/plain": { + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + } + } + } + } + } + }, + "/toto/lowercase/{lowercase}": { + "get": { + "description": "lowercase function", + "operationId": "lowercase_GET", + "parameters": [ + { + "name": "lowercase", + "in": "path", + "required": true, + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + }, + "text/plain": { + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + } + } + } + } + } + }, + "/toto/reverseString": { + "post": { + "description": "reverseString function", + "operationId": "reverseString_POST", + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "string" + } + }, + "text/plain": { + "schema": { + "type": "string" + } + } + } + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "string" + } + }, + "text/plain": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/toto/reverseString/{reverseString}": { + "get": { + "description": "reverseString function", + "operationId": "reverseString_GET", + "parameters": [ + { + "name": "reverseString", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "string" + } + }, + "text/plain": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/toto/titi": { + "get": { + "description": "titi supplier", + "operationId": "titi_GET", + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/PersonDTO" + } + } + } + } + } + } + }, + "/toto/uppercase": { + "post": { + "description": "uppercase function", + "operationId": "uppercase_POST", + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "string" + } + }, + "text/plain": { + "schema": { + "type": "string" + } + } + } + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "string" + } + }, + "text/plain": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/toto/uppercase/{uppercase}": { + "get": { + "description": "uppercase function", + "operationId": "uppercase_GET", + "parameters": [ + { + "name": "uppercase", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "string" + } + }, + "text/plain": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/toto/words": { + "get": { + "description": "words supplier", + "operationId": "words_GET", + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "PersonDTO": { + "type": "object", + "properties": { + "email": { + "type": "string" + }, + "firstName": { + "type": "string" + }, + "lastName": { + "type": "string" + } + } + } + } + } +} 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 c2ca0d6df..b247d1d08 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.1 + 2.8.2 4.0.0 diff --git a/springdoc-openapi-tests/springdoc-openapi-function-webmvc-tests/src/test/java/test/org/springdoc/api/AbstractCommonTest.java b/springdoc-openapi-tests/springdoc-openapi-function-webmvc-tests/src/test/java/test/org/springdoc/api/AbstractCommonTest.java deleted file mode 100644 index 7ba22b811..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-function-webmvc-tests/src/test/java/test/org/springdoc/api/AbstractCommonTest.java +++ /dev/null @@ -1,32 +0,0 @@ -package test.org.springdoc.api; - -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; -import org.springframework.test.context.ActiveProfiles; -import org.springframework.test.context.TestPropertySource; -import org.springframework.test.web.servlet.MockMvc; - -@AutoConfigureMockMvc -@ActiveProfiles("test") -@TestPropertySource(properties = "springdoc.api-docs.version=openapi_3_0" ) -public abstract class AbstractCommonTest { - - @Autowired - protected MockMvc mockMvc; - - protected String getContent(String fileName) throws Exception { - try { - Path path = Paths.get(AbstractCommonTest.class.getClassLoader().getResource(fileName).toURI()); - byte[] fileBytes = Files.readAllBytes(path); - return new String(fileBytes, StandardCharsets.UTF_8); - } - catch (Exception e) { - throw new RuntimeException("Failed to read file: " + fileName, e); - } - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-function-webmvc-tests/src/test/java/test/org/springdoc/api/AbstractSpringDocTest.java b/springdoc-openapi-tests/springdoc-openapi-function-webmvc-tests/src/test/java/test/org/springdoc/api/AbstractSpringDocTest.java deleted file mode 100644 index d15f27c5f..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-function-webmvc-tests/src/test/java/test/org/springdoc/api/AbstractSpringDocTest.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * - * * Copyright 2019-2020 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; - -import org.junit.jupiter.api.Test; -import org.springdoc.core.utils.Constants; - -import org.springframework.boot.test.context.SpringBootTest; -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; - -@SpringBootTest -public abstract class AbstractSpringDocTest extends AbstractCommonTest { - - public static String className; - - @Test - void testApp() throws Exception { - className = getClass().getSimpleName(); - String testNumber = className.replaceAll("[^0-9]", ""); - MvcResult mockMvcResult = mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL)).andExpect(status().isOk()) - .andExpect(jsonPath("$.openapi", is("3.0.1"))).andReturn(); - String result = mockMvcResult.getResponse().getContentAsString(); - String expected = getContent("results/app" + testNumber + ".json"); - assertEquals(expected, result, true); - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-function-webmvc-tests/src/test/java/test/org/springdoc/api/app174/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-function-webmvc-tests/src/test/java/test/org/springdoc/api/app174/HelloController.java deleted file mode 100644 index 55674e934..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-function-webmvc-tests/src/test/java/test/org/springdoc/api/app174/HelloController.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * - * * - * * * - * * * * - * * * * * 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.app174; - -import reactor.core.publisher.Flux; - -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -@RestController -public class HelloController { - - @GetMapping("/test") - public void printHello() { - System.out.println("Hello"); - } - - @GetMapping("/toto") - public Flux test() { - return null; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-function-webmvc-tests/src/test/java/test/org/springdoc/api/app174/PersonDTO.java b/springdoc-openapi-tests/springdoc-openapi-function-webmvc-tests/src/test/java/test/org/springdoc/api/app174/PersonDTO.java deleted file mode 100644 index 2ba7bc4fb..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-function-webmvc-tests/src/test/java/test/org/springdoc/api/app174/PersonDTO.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app174; - -public class PersonDTO { - private String email; - - private String firstName; - - private String lastName; - - public PersonDTO() { - } - - public PersonDTO(final String email, final String firstName, final String lastName) { - this.email = email; - this.firstName = firstName; - this.lastName = lastName; - } - - public String getEmail() { - return email; - } - - public void setEmail(final String email) { - this.email = email; - } - - public String getFirstName() { - return firstName; - } - - public void setFirstName(final String firstName) { - this.firstName = firstName; - } - - public String getLastName() { - return lastName; - } - - public void setLastName(final String lastName) { - this.lastName = lastName; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-function-webmvc-tests/src/test/java/test/org/springdoc/api/app174/SpringDocApp174Test.java b/springdoc-openapi-tests/springdoc-openapi-function-webmvc-tests/src/test/java/test/org/springdoc/api/app174/SpringDocApp174Test.java deleted file mode 100644 index 06352925b..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-function-webmvc-tests/src/test/java/test/org/springdoc/api/app174/SpringDocApp174Test.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app174; - -import java.util.Arrays; -import java.util.List; -import java.util.function.Consumer; -import java.util.function.Function; -import java.util.function.Supplier; - -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.media.ArraySchema; -import io.swagger.v3.oas.annotations.media.Content; -import io.swagger.v3.oas.annotations.media.Schema; -import io.swagger.v3.oas.annotations.responses.ApiResponse; -import org.springdoc.core.annotations.RouterOperation; -import org.springdoc.core.annotations.RouterOperations; -import test.org.springdoc.api.AbstractSpringDocTest; -import test.org.springdoc.api.app175.PersonDTO; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.Bean; -import org.springframework.web.bind.annotation.RequestMethod; - -public class SpringDocApp174Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp { - @Bean - public Function reverseString() { - return value -> new StringBuilder(value).reverse().toString(); - } - - @Bean - public Function uppercase() { - return String::toUpperCase; - } - - @Bean - @RouterOperations({ - @RouterOperation(method = RequestMethod.GET, operation = @Operation(description = "Say hello GET", operationId = "lowercaseGET", tags = "positions", - responses = @ApiResponse(responseCode = "200", content = @Content(array = @ArraySchema(schema = @Schema(implementation = String.class)))))), - @RouterOperation(method = RequestMethod.POST, operation = @Operation(description = "Say hello POST", operationId = "lowercasePOST", tags = "positions", - responses = @ApiResponse(responseCode = "200", description = "new desc", content = @Content(array = @ArraySchema(schema = @Schema(implementation = String.class)))))) - }) - public Function, List> lowercase() { - return list -> list.stream().map(String::toLowerCase).toList(); - } - - @Bean(name = "titi") - @RouterOperation(operation = @Operation(description = "Say hello By Id", operationId = "hellome", tags = "persons", - responses = @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = PersonDTO.class))))) - public Supplier helloSupplier() { - return PersonDTO::new; - } - - @Bean - public Consumer helloConsumer() { - return PersonDTO::getFirstName; - } - - @Bean - public Supplier> words() { - return () -> Arrays.asList("foo", "bar"); - } - - } - -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-function-webmvc-tests/src/test/java/test/org/springdoc/api/app175/PersonDTO.java b/springdoc-openapi-tests/springdoc-openapi-function-webmvc-tests/src/test/java/test/org/springdoc/api/app175/PersonDTO.java deleted file mode 100644 index ee4ed2488..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-function-webmvc-tests/src/test/java/test/org/springdoc/api/app175/PersonDTO.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app175; - -public class PersonDTO { - private String email; - - private String firstName; - - private String lastName; - - public PersonDTO() { - } - - public PersonDTO(final String email, final String firstName, final String lastName) { - this.email = email; - this.firstName = firstName; - this.lastName = lastName; - } - - public String getEmail() { - return email; - } - - public void setEmail(final String email) { - this.email = email; - } - - public String getFirstName() { - return firstName; - } - - public void setFirstName(final String firstName) { - this.firstName = firstName; - } - - public String getLastName() { - return lastName; - } - - public void setLastName(final String lastName) { - this.lastName = lastName; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-function-webmvc-tests/src/test/java/test/org/springdoc/api/app175/SpringDocApp175Test.java b/springdoc-openapi-tests/springdoc-openapi-function-webmvc-tests/src/test/java/test/org/springdoc/api/app175/SpringDocApp175Test.java deleted file mode 100644 index 0ffbc2bea..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-function-webmvc-tests/src/test/java/test/org/springdoc/api/app175/SpringDocApp175Test.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app175; - -import java.util.Arrays; -import java.util.List; -import java.util.function.Consumer; -import java.util.function.Function; -import java.util.function.Supplier; - -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.media.ArraySchema; -import io.swagger.v3.oas.annotations.media.Content; -import io.swagger.v3.oas.annotations.media.Schema; -import io.swagger.v3.oas.annotations.responses.ApiResponse; -import org.springdoc.core.annotations.RouterOperation; -import org.springdoc.core.annotations.RouterOperations; -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.Bean; -import org.springframework.test.context.TestPropertySource; -import org.springframework.web.bind.annotation.RequestMethod; - -@TestPropertySource(properties = "springdoc.show-spring-cloud-functions=false") -public class SpringDocApp175Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp { - @Bean - public Function reverseString() { - return value -> new StringBuilder(value).reverse().toString(); - } - - @Bean - public Function uppercase() { - return String::toUpperCase; - } - - @Bean - @RouterOperations({ - @RouterOperation(method = RequestMethod.GET, operation = @Operation(description = "Say hello GET", operationId = "lowercaseGET", tags = "positions", - responses = @ApiResponse(responseCode = "200", content = @Content(array = @ArraySchema(schema = @Schema(implementation = String.class)))))), - @RouterOperation(method = RequestMethod.POST, operation = @Operation(description = "Say hello POST", operationId = "lowercasePOST", tags = "positions", - responses = @ApiResponse(responseCode = "200", description = "new desc", content = @Content(array = @ArraySchema(schema = @Schema(implementation = String.class)))))) - }) - public Function, List> lowercase() { - return list -> list.stream().map(String::toLowerCase).toList(); - } - - @Bean(name = "titi") - @RouterOperation(operation = @Operation(description = "Say hello By Id", operationId = "hellome", tags = "persons", - responses = @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = PersonDTO.class))))) - public Supplier helloSupplier() { - return PersonDTO::new; - } - - @Bean - public Consumer helloConsumer() { - return PersonDTO::getFirstName; - } - - @Bean - public Supplier> words() { - return () -> Arrays.asList("foo", "bar"); - } - - } - -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-function-webmvc-tests/src/test/java/test/org/springdoc/api/v30/AbstractCommonTest.java b/springdoc-openapi-tests/springdoc-openapi-function-webmvc-tests/src/test/java/test/org/springdoc/api/v30/AbstractCommonTest.java new file mode 100644 index 000000000..853053296 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-function-webmvc-tests/src/test/java/test/org/springdoc/api/v30/AbstractCommonTest.java @@ -0,0 +1,58 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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; + +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.context.TestPropertySource; +import org.springframework.test.web.servlet.MockMvc; + +@AutoConfigureMockMvc +@ActiveProfiles("test") +@TestPropertySource(properties = "springdoc.api-docs.version=openapi_3_0" ) +public abstract class AbstractCommonTest { + + @Autowired + protected MockMvc mockMvc; + + protected String getContent(String fileName) throws Exception { + try { + Path path = Paths.get(AbstractCommonTest.class.getClassLoader().getResource(fileName).toURI()); + byte[] fileBytes = Files.readAllBytes(path); + return new String(fileBytes, StandardCharsets.UTF_8); + } + catch (Exception e) { + throw new RuntimeException("Failed to read file: " + fileName, e); + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-function-webmvc-tests/src/test/java/test/org/springdoc/api/v30/AbstractSpringDocTest.java b/springdoc-openapi-tests/springdoc-openapi-function-webmvc-tests/src/test/java/test/org/springdoc/api/v30/AbstractSpringDocTest.java new file mode 100644 index 000000000..1f28f3fa6 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-function-webmvc-tests/src/test/java/test/org/springdoc/api/v30/AbstractSpringDocTest.java @@ -0,0 +1,56 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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; + +import org.junit.jupiter.api.Test; +import org.springdoc.core.utils.Constants; + +import org.springframework.boot.test.context.SpringBootTest; +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; + +@SpringBootTest +public abstract class AbstractSpringDocTest extends AbstractCommonTest { + + public static String className; + + @Test + void testApp() throws Exception { + className = getClass().getSimpleName(); + String testNumber = className.replaceAll("[^0-9]", ""); + MvcResult mockMvcResult = mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL)).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 + ".json"); + assertEquals(expected, result, true); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-function-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app174/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-function-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app174/HelloController.java new file mode 100644 index 000000000..74a350f4e --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-function-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app174/HelloController.java @@ -0,0 +1,44 @@ +/* + * + * * + * * * + * * * * + * * * * * 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.app174; + +import reactor.core.publisher.Flux; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class HelloController { + + @GetMapping("/test") + public void printHello() { + System.out.println("Hello"); + } + + @GetMapping("/toto") + public Flux test() { + return null; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-function-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app174/PersonDTO.java b/springdoc-openapi-tests/springdoc-openapi-function-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app174/PersonDTO.java new file mode 100644 index 000000000..e5d6b2f47 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-function-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app174/PersonDTO.java @@ -0,0 +1,60 @@ +/* + * + * * Copyright 2019-2020 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.app174; + +public class PersonDTO { + private String email; + + private String firstName; + + private String lastName; + + public PersonDTO() { + } + + public PersonDTO(final String email, final String firstName, final String lastName) { + this.email = email; + this.firstName = firstName; + this.lastName = lastName; + } + + public String getEmail() { + return email; + } + + public void setEmail(final String email) { + this.email = email; + } + + public String getFirstName() { + return firstName; + } + + public void setFirstName(final String firstName) { + this.firstName = firstName; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(final String lastName) { + this.lastName = lastName; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-function-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app174/SpringDocApp174Test.java b/springdoc-openapi-tests/springdoc-openapi-function-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app174/SpringDocApp174Test.java new file mode 100644 index 000000000..b9ae68edb --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-function-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app174/SpringDocApp174Test.java @@ -0,0 +1,85 @@ +/* + * + * * Copyright 2019-2020 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.app174; + +import java.util.Arrays; +import java.util.List; +import java.util.function.Consumer; +import java.util.function.Function; +import java.util.function.Supplier; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.media.ArraySchema; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import org.springdoc.core.annotations.RouterOperation; +import org.springdoc.core.annotations.RouterOperations; +import test.org.springdoc.api.v30.AbstractSpringDocTest; +import test.org.springdoc.api.v30.app175.PersonDTO; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; +import org.springframework.web.bind.annotation.RequestMethod; + +public class SpringDocApp174Test extends AbstractSpringDocTest { + + @SpringBootApplication + static class SpringDocTestApp { + @Bean + public Function reverseString() { + return value -> new StringBuilder(value).reverse().toString(); + } + + @Bean + public Function uppercase() { + return String::toUpperCase; + } + + @Bean + @RouterOperations({ + @RouterOperation(method = RequestMethod.GET, operation = @Operation(description = "Say hello GET", operationId = "lowercaseGET", tags = "positions", + responses = @ApiResponse(responseCode = "200", content = @Content(array = @ArraySchema(schema = @Schema(implementation = String.class)))))), + @RouterOperation(method = RequestMethod.POST, operation = @Operation(description = "Say hello POST", operationId = "lowercasePOST", tags = "positions", + responses = @ApiResponse(responseCode = "200", description = "new desc", content = @Content(array = @ArraySchema(schema = @Schema(implementation = String.class)))))) + }) + public Function, List> lowercase() { + return list -> list.stream().map(String::toLowerCase).toList(); + } + + @Bean(name = "titi") + @RouterOperation(operation = @Operation(description = "Say hello By Id", operationId = "hellome", tags = "persons", + responses = @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = PersonDTO.class))))) + public Supplier helloSupplier() { + return PersonDTO::new; + } + + @Bean + public Consumer helloConsumer() { + return PersonDTO::getFirstName; + } + + @Bean + public Supplier> words() { + return () -> Arrays.asList("foo", "bar"); + } + + } + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-function-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app175/PersonDTO.java b/springdoc-openapi-tests/springdoc-openapi-function-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app175/PersonDTO.java new file mode 100644 index 000000000..6a026d62d --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-function-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app175/PersonDTO.java @@ -0,0 +1,60 @@ +/* + * + * * Copyright 2019-2020 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.app175; + +public class PersonDTO { + private String email; + + private String firstName; + + private String lastName; + + public PersonDTO() { + } + + public PersonDTO(final String email, final String firstName, final String lastName) { + this.email = email; + this.firstName = firstName; + this.lastName = lastName; + } + + public String getEmail() { + return email; + } + + public void setEmail(final String email) { + this.email = email; + } + + public String getFirstName() { + return firstName; + } + + public void setFirstName(final String firstName) { + this.firstName = firstName; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(final String lastName) { + this.lastName = lastName; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-function-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app175/SpringDocApp175Test.java b/springdoc-openapi-tests/springdoc-openapi-function-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app175/SpringDocApp175Test.java new file mode 100644 index 000000000..01cb2b1a8 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-function-webmvc-tests/src/test/java/test/org/springdoc/api/v30/app175/SpringDocApp175Test.java @@ -0,0 +1,86 @@ +/* + * + * * Copyright 2019-2020 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.app175; + +import java.util.Arrays; +import java.util.List; +import java.util.function.Consumer; +import java.util.function.Function; +import java.util.function.Supplier; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.media.ArraySchema; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import org.springdoc.core.annotations.RouterOperation; +import org.springdoc.core.annotations.RouterOperations; +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; +import org.springframework.test.context.TestPropertySource; +import org.springframework.web.bind.annotation.RequestMethod; + +@TestPropertySource(properties = "springdoc.show-spring-cloud-functions=false") +public class SpringDocApp175Test extends AbstractSpringDocTest { + + @SpringBootApplication + static class SpringDocTestApp { + @Bean + public Function reverseString() { + return value -> new StringBuilder(value).reverse().toString(); + } + + @Bean + public Function uppercase() { + return String::toUpperCase; + } + + @Bean + @RouterOperations({ + @RouterOperation(method = RequestMethod.GET, operation = @Operation(description = "Say hello GET", operationId = "lowercaseGET", tags = "positions", + responses = @ApiResponse(responseCode = "200", content = @Content(array = @ArraySchema(schema = @Schema(implementation = String.class)))))), + @RouterOperation(method = RequestMethod.POST, operation = @Operation(description = "Say hello POST", operationId = "lowercasePOST", tags = "positions", + responses = @ApiResponse(responseCode = "200", description = "new desc", content = @Content(array = @ArraySchema(schema = @Schema(implementation = String.class)))))) + }) + public Function, List> lowercase() { + return list -> list.stream().map(String::toLowerCase).toList(); + } + + @Bean(name = "titi") + @RouterOperation(operation = @Operation(description = "Say hello By Id", operationId = "hellome", tags = "persons", + responses = @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = PersonDTO.class))))) + public Supplier helloSupplier() { + return PersonDTO::new; + } + + @Bean + public Consumer helloConsumer() { + return PersonDTO::getFirstName; + } + + @Bean + public Supplier> words() { + return () -> Arrays.asList("foo", "bar"); + } + + } + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-function-webmvc-tests/src/test/java/test/org/springdoc/api/v31/AbstractCommonTest.java b/springdoc-openapi-tests/springdoc-openapi-function-webmvc-tests/src/test/java/test/org/springdoc/api/v31/AbstractCommonTest.java new file mode 100644 index 000000000..4534f8803 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-function-webmvc-tests/src/test/java/test/org/springdoc/api/v31/AbstractCommonTest.java @@ -0,0 +1,56 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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; + +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.web.servlet.MockMvc; + +@AutoConfigureMockMvc +@ActiveProfiles("test") +public abstract class AbstractCommonTest { + + @Autowired + protected MockMvc mockMvc; + + protected String getContent(String fileName) throws Exception { + try { + Path path = Paths.get(AbstractCommonTest.class.getClassLoader().getResource(fileName).toURI()); + byte[] fileBytes = Files.readAllBytes(path); + return new String(fileBytes, StandardCharsets.UTF_8); + } + catch (Exception e) { + throw new RuntimeException("Failed to read file: " + fileName, e); + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-function-webmvc-tests/src/test/java/test/org/springdoc/api/v31/AbstractSpringDocTest.java b/springdoc-openapi-tests/springdoc-openapi-function-webmvc-tests/src/test/java/test/org/springdoc/api/v31/AbstractSpringDocTest.java new file mode 100644 index 000000000..ee9336ca1 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-function-webmvc-tests/src/test/java/test/org/springdoc/api/v31/AbstractSpringDocTest.java @@ -0,0 +1,56 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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; + +import org.junit.jupiter.api.Test; +import org.springdoc.core.utils.Constants; + +import org.springframework.boot.test.context.SpringBootTest; +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; + +@SpringBootTest +public abstract class AbstractSpringDocTest extends AbstractCommonTest { + + public static String className; + + @Test + void testApp() throws Exception { + className = getClass().getSimpleName(); + String testNumber = className.replaceAll("[^0-9]", ""); + MvcResult mockMvcResult = mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL)).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 + ".json"); + assertEquals(expected, result, true); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-function-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app174/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-function-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app174/HelloController.java new file mode 100644 index 000000000..06e5068cd --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-function-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app174/HelloController.java @@ -0,0 +1,44 @@ +/* + * + * * + * * * + * * * * + * * * * * 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.app174; + +import reactor.core.publisher.Flux; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class HelloController { + + @GetMapping("/test") + public void printHello() { + System.out.println("Hello"); + } + + @GetMapping("/toto") + public Flux test() { + return null; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-function-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app174/PersonDTO.java b/springdoc-openapi-tests/springdoc-openapi-function-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app174/PersonDTO.java new file mode 100644 index 000000000..e5ee6ef6d --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-function-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app174/PersonDTO.java @@ -0,0 +1,60 @@ +/* + * + * * Copyright 2019-2020 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.app174; + +public class PersonDTO { + private String email; + + private String firstName; + + private String lastName; + + public PersonDTO() { + } + + public PersonDTO(final String email, final String firstName, final String lastName) { + this.email = email; + this.firstName = firstName; + this.lastName = lastName; + } + + public String getEmail() { + return email; + } + + public void setEmail(final String email) { + this.email = email; + } + + public String getFirstName() { + return firstName; + } + + public void setFirstName(final String firstName) { + this.firstName = firstName; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(final String lastName) { + this.lastName = lastName; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-function-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app174/SpringDocApp174Test.java b/springdoc-openapi-tests/springdoc-openapi-function-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app174/SpringDocApp174Test.java new file mode 100644 index 000000000..5d246066b --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-function-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app174/SpringDocApp174Test.java @@ -0,0 +1,85 @@ +/* + * + * * Copyright 2019-2020 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.app174; + +import java.util.Arrays; +import java.util.List; +import java.util.function.Consumer; +import java.util.function.Function; +import java.util.function.Supplier; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.media.ArraySchema; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import org.springdoc.core.annotations.RouterOperation; +import org.springdoc.core.annotations.RouterOperations; +import test.org.springdoc.api.v31.AbstractSpringDocTest; +import test.org.springdoc.api.v31.app175.PersonDTO; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; +import org.springframework.web.bind.annotation.RequestMethod; + +public class SpringDocApp174Test extends AbstractSpringDocTest { + + @SpringBootApplication + static class SpringDocTestApp { + @Bean + public Function reverseString() { + return value -> new StringBuilder(value).reverse().toString(); + } + + @Bean + public Function uppercase() { + return String::toUpperCase; + } + + @Bean + @RouterOperations({ + @RouterOperation(method = RequestMethod.GET, operation = @Operation(description = "Say hello GET", operationId = "lowercaseGET", tags = "positions", + responses = @ApiResponse(responseCode = "200", content = @Content(array = @ArraySchema(schema = @Schema(implementation = String.class)))))), + @RouterOperation(method = RequestMethod.POST, operation = @Operation(description = "Say hello POST", operationId = "lowercasePOST", tags = "positions", + responses = @ApiResponse(responseCode = "200", description = "new desc", content = @Content(array = @ArraySchema(schema = @Schema(implementation = String.class)))))) + }) + public Function, List> lowercase() { + return list -> list.stream().map(String::toLowerCase).toList(); + } + + @Bean(name = "titi") + @RouterOperation(operation = @Operation(description = "Say hello By Id", operationId = "hellome", tags = "persons", + responses = @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = PersonDTO.class))))) + public Supplier helloSupplier() { + return PersonDTO::new; + } + + @Bean + public Consumer helloConsumer() { + return PersonDTO::getFirstName; + } + + @Bean + public Supplier> words() { + return () -> Arrays.asList("foo", "bar"); + } + + } + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-function-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app175/PersonDTO.java b/springdoc-openapi-tests/springdoc-openapi-function-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app175/PersonDTO.java new file mode 100644 index 000000000..23a12e0d4 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-function-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app175/PersonDTO.java @@ -0,0 +1,60 @@ +/* + * + * * Copyright 2019-2020 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.app175; + +public class PersonDTO { + private String email; + + private String firstName; + + private String lastName; + + public PersonDTO() { + } + + public PersonDTO(final String email, final String firstName, final String lastName) { + this.email = email; + this.firstName = firstName; + this.lastName = lastName; + } + + public String getEmail() { + return email; + } + + public void setEmail(final String email) { + this.email = email; + } + + public String getFirstName() { + return firstName; + } + + public void setFirstName(final String firstName) { + this.firstName = firstName; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(final String lastName) { + this.lastName = lastName; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-function-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app175/SpringDocApp175Test.java b/springdoc-openapi-tests/springdoc-openapi-function-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app175/SpringDocApp175Test.java new file mode 100644 index 000000000..1a20134b7 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-function-webmvc-tests/src/test/java/test/org/springdoc/api/v31/app175/SpringDocApp175Test.java @@ -0,0 +1,86 @@ +/* + * + * * Copyright 2019-2020 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.app175; + +import java.util.Arrays; +import java.util.List; +import java.util.function.Consumer; +import java.util.function.Function; +import java.util.function.Supplier; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.media.ArraySchema; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import org.springdoc.core.annotations.RouterOperation; +import org.springdoc.core.annotations.RouterOperations; +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; +import org.springframework.test.context.TestPropertySource; +import org.springframework.web.bind.annotation.RequestMethod; + +@TestPropertySource(properties = "springdoc.show-spring-cloud-functions=false") +public class SpringDocApp175Test extends AbstractSpringDocTest { + + @SpringBootApplication + static class SpringDocTestApp { + @Bean + public Function reverseString() { + return value -> new StringBuilder(value).reverse().toString(); + } + + @Bean + public Function uppercase() { + return String::toUpperCase; + } + + @Bean + @RouterOperations({ + @RouterOperation(method = RequestMethod.GET, operation = @Operation(description = "Say hello GET", operationId = "lowercaseGET", tags = "positions", + responses = @ApiResponse(responseCode = "200", content = @Content(array = @ArraySchema(schema = @Schema(implementation = String.class)))))), + @RouterOperation(method = RequestMethod.POST, operation = @Operation(description = "Say hello POST", operationId = "lowercasePOST", tags = "positions", + responses = @ApiResponse(responseCode = "200", description = "new desc", content = @Content(array = @ArraySchema(schema = @Schema(implementation = String.class)))))) + }) + public Function, List> lowercase() { + return list -> list.stream().map(String::toLowerCase).toList(); + } + + @Bean(name = "titi") + @RouterOperation(operation = @Operation(description = "Say hello By Id", operationId = "hellome", tags = "persons", + responses = @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = PersonDTO.class))))) + public Supplier helloSupplier() { + return PersonDTO::new; + } + + @Bean + public Consumer helloConsumer() { + return PersonDTO::getFirstName; + } + + @Bean + public Supplier> words() { + return () -> Arrays.asList("foo", "bar"); + } + + } + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-function-webmvc-tests/src/test/resources/results/app174.json b/springdoc-openapi-tests/springdoc-openapi-function-webmvc-tests/src/test/resources/results/3.0.1/app174.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-function-webmvc-tests/src/test/resources/results/app174.json rename to springdoc-openapi-tests/springdoc-openapi-function-webmvc-tests/src/test/resources/results/3.0.1/app174.json diff --git a/springdoc-openapi-tests/springdoc-openapi-function-webmvc-tests/src/test/resources/results/app175.json b/springdoc-openapi-tests/springdoc-openapi-function-webmvc-tests/src/test/resources/results/3.0.1/app175.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-function-webmvc-tests/src/test/resources/results/app175.json rename to springdoc-openapi-tests/springdoc-openapi-function-webmvc-tests/src/test/resources/results/3.0.1/app175.json diff --git a/springdoc-openapi-tests/springdoc-openapi-function-webmvc-tests/src/test/resources/results/3.1.0/app174.json b/springdoc-openapi-tests/springdoc-openapi-function-webmvc-tests/src/test/resources/results/3.1.0/app174.json new file mode 100644 index 000000000..1b504b480 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-function-webmvc-tests/src/test/resources/results/3.1.0/app174.json @@ -0,0 +1,379 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/toto": { + "get": { + "tags": [ + "hello-controller" + ], + "operationId": "test", + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + } + } + } + } + } + }, + "/test": { + "get": { + "tags": [ + "hello-controller" + ], + "operationId": "printHello", + "responses": { + "200": { + "description": "OK" + } + } + } + }, + "/helloConsumer": { + "post": { + "description": "helloConsumer consumer", + "operationId": "helloConsumer_POST", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/PersonDTO" + } + }, + "text/plain": { + "schema": { + "$ref": "#/components/schemas/PersonDTO" + } + } + } + }, + "responses": { + "202": { + "description": "Accepted", + "content": {} + } + } + } + }, + "/lowercase": { + "post": { + "tags": [ + "positions" + ], + "description": "Say hello POST", + "operationId": "lowercasePOST", + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + }, + "text/plain": { + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + } + } + }, + "responses": { + "200": { + "description": "new desc", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + }, + "text/plain": { + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + } + } + } + } + } + }, + "/lowercase/{lowercase}": { + "get": { + "tags": [ + "positions" + ], + "description": "Say hello GET", + "operationId": "lowercaseGET", + "parameters": [ + { + "name": "lowercase", + "in": "path", + "required": true, + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + }, + "text/plain": { + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + } + } + } + } + } + }, + "/reverseString": { + "post": { + "description": "reverseString function", + "operationId": "reverseString_POST", + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "string" + } + }, + "text/plain": { + "schema": { + "type": "string" + } + } + } + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "string" + } + }, + "text/plain": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/reverseString/{reverseString}": { + "get": { + "description": "reverseString function", + "operationId": "reverseString_GET", + "parameters": [ + { + "name": "reverseString", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "string" + } + }, + "text/plain": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/titi": { + "get": { + "tags": [ + "persons" + ], + "description": "Say hello By Id", + "operationId": "hellome", + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/PersonDTO" + } + }, + "text/plain": { + "schema": { + "$ref": "#/components/schemas/PersonDTO" + } + } + } + } + } + } + }, + "/uppercase": { + "post": { + "description": "uppercase function", + "operationId": "uppercase_POST", + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "string" + } + }, + "text/plain": { + "schema": { + "type": "string" + } + } + } + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "string" + } + }, + "text/plain": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/uppercase/{uppercase}": { + "get": { + "description": "uppercase function", + "operationId": "uppercase_GET", + "parameters": [ + { + "name": "uppercase", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "string" + } + }, + "text/plain": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/words": { + "get": { + "description": "words supplier", + "operationId": "words_GET", + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "PersonDTO": { + "type": "object", + "properties": { + "email": { + "type": "string" + }, + "firstName": { + "type": "string" + }, + "lastName": { + "type": "string" + } + } + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-function-webmvc-tests/src/test/resources/results/3.1.0/app175.json b/springdoc-openapi-tests/springdoc-openapi-function-webmvc-tests/src/test/resources/results/3.1.0/app175.json new file mode 100644 index 000000000..16823bacd --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-function-webmvc-tests/src/test/resources/results/3.1.0/app175.json @@ -0,0 +1,15 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": {}, + "components": {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-groovy-tests/pom.xml b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/pom.xml index e7139e131..a0634cf53 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.1 + 2.8.2 springdoc-openapi-groovy-tests diff --git a/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/AbstractSpringDocTest.java b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/AbstractSpringDocTest.java deleted file mode 100644 index 3cc8d4828..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/AbstractSpringDocTest.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * - * * Copyright 2019-2020 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; - -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; - -import org.junit.jupiter.api.Test; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springdoc.core.utils.Constants; - -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.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; - -@ActiveProfiles("test") -@SpringBootTest -@AutoConfigureMockMvc -@TestPropertySource(properties = "springdoc.api-docs.version=openapi_3_0" ) -public abstract class AbstractSpringDocTest { - - protected static final Logger LOGGER = LoggerFactory.getLogger(AbstractSpringDocTest.class); - - public static String className; - - @Autowired - protected MockMvc mockMvc; - - public static String getContent(String fileName) throws Exception { - try { - Path path = Paths.get(AbstractSpringDocTest.class.getClassLoader().getResource(fileName).toURI()); - byte[] fileBytes = Files.readAllBytes(path); - return new String(fileBytes, StandardCharsets.UTF_8); - } - catch (Exception e) { - throw new RuntimeException("Failed to read file: " + fileName, e); - } - } - - @Test - void testApp() throws Exception { - className = getClass().getSimpleName(); - String testNumber = className.replaceAll("[^0-9]", ""); - MvcResult mockMvcResult = mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL)).andExpect(status().isOk()) - .andExpect(jsonPath("$.openapi", is("3.0.1"))).andReturn(); - String result = mockMvcResult.getResponse().getContentAsString(); - String expected = getContent("results/app" + testNumber + ".json"); - assertEquals(expected, result, true); - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/app1/Car.groovy b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/app1/Car.groovy deleted file mode 100644 index 14712b71f..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/app1/Car.groovy +++ /dev/null @@ -1,27 +0,0 @@ -/* - * - * * - * * * Copyright 2019-2020 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.app1 - -class Car { - Long id - - String name -} diff --git a/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/app1/CarController.groovy b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/app1/CarController.groovy deleted file mode 100644 index 3bc1a246e..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/app1/CarController.groovy +++ /dev/null @@ -1,51 +0,0 @@ -/* - * - * * - * * * Copyright 2019-2020 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.app1 - -import org.springdoc.core.annotations.ParameterObject - -import org.springframework.web.bind.annotation.GetMapping -import org.springframework.web.bind.annotation.PathVariable -import org.springframework.web.bind.annotation.RestController - -@RestController -class CarController { - - CarService carService - - CarController(CarService carService) { - this.carService = carService - } - - @GetMapping(path = 'cars/{carId}') - Car getCar(@PathVariable(value = 'carId') Long carId) { - return carService.getCar(carId) - } - - @GetMapping(path = '/cars') - List getCars(@ParameterObject CarsFilter filter) { - return carService.getCars() - } - - static class CarsFilter { - String name; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/app1/CarService.groovy b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/app1/CarService.groovy deleted file mode 100644 index ad98f3582..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/app1/CarService.groovy +++ /dev/null @@ -1,44 +0,0 @@ -/* - * - * * - * * * Copyright 2019-2020 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.app1 - - -import org.springframework.stereotype.Service - -@Service -class CarService { - List getCars() { - return [ - new Car(id: 1L, name: 'Car 1'), - new Car(id: 2L, name: 'Car 2'), - new Car(id: 3L, name: 'Car 3'), - new Car(id: 4L, name: 'Car 4'), - new Car(id: 5L, name: 'Car 5'), - ] - } - - Car getCar(Long carId) { - return new Car( - id: carId, - name: "Car $carId" - ) - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/app1/OpenApiConfiguration.groovy b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/app1/OpenApiConfiguration.groovy deleted file mode 100644 index 9f3ceee14..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/app1/OpenApiConfiguration.groovy +++ /dev/null @@ -1,45 +0,0 @@ -/* - * - * * - * * * Copyright 2019-2020 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.app1 - -import io.swagger.v3.oas.annotations.OpenAPIDefinition -import io.swagger.v3.oas.models.Components -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 - -@OpenAPIDefinition -@Configuration -class OpenApiConfiguration { - - @Bean - OpenAPI customOpenAPI() { - return new OpenAPI() - .components(new Components()) - .info( - new Info() - .title('Issue OpenAPI with Groovy') - .description('Special Groovy Metaclass Test Issue') - ) - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/app1/SpringDocApp1Test.java b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/app1/SpringDocApp1Test.java deleted file mode 100644 index c3ec82343..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/app1/SpringDocApp1Test.java +++ /dev/null @@ -1,26 +0,0 @@ -package test.org.springdoc.api.app1; - -import groovy.lang.MetaClass; -import org.junit.jupiter.api.AfterAll; -import org.junit.jupiter.api.BeforeAll; -import org.springdoc.core.utils.SpringDocUtils; -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.test.context.TestPropertySource; - -@TestPropertySource(properties = "springdoc.enable-groovy=false") -public class SpringDocApp1Test extends AbstractSpringDocTest { - @BeforeAll - public static void init() { - SpringDocUtils.getConfig().removeJavaTypeToIgnore(MetaClass.class); - } - - @AfterAll - public static void clean() { - SpringDocUtils.getConfig().addJavaTypeToIgnore(MetaClass.class); - } - - @SpringBootApplication - static class SpringDocTestApp {} -} diff --git a/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/app10/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/app10/HelloController.java deleted file mode 100644 index 0e76f81ef..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/app10/HelloController.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app10; - -import java.util.List; - -import org.springdoc.core.annotations.ParameterObject; - -import org.springframework.data.domain.Pageable; -import org.springframework.data.domain.Sort.Direction; -import org.springframework.data.web.PageableDefault; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -@RestController -public class HelloController { - - @GetMapping(value = "/search", produces = { "application/xml", "application/json" }) - public ResponseEntity> getAllPets(@PageableDefault(size = 5, sort = "name") @ParameterObject Pageable pageable) { - return null; - } - - - @GetMapping("/test1") - public String getPatientList1(@PageableDefault(size = 100, sort = { "someField", "someoTHER" }, - direction = Direction.DESC) - @ParameterObject Pageable pageable) { - return "bla"; - } - - @GetMapping("/test2") - public String getPatientList2(@PageableDefault(size = 100, sort = "someField", - direction = Direction.DESC) - @ParameterObject Pageable pageable) { - return "bla"; - } - - @GetMapping("/test3") - public String getPatientList3(@PageableDefault(size = 100) - @ParameterObject Pageable pageable) { - return "bla"; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/app10/PersonDTO.java b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/app10/PersonDTO.java deleted file mode 100644 index 5d719d0dc..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/app10/PersonDTO.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app10; - -import io.swagger.v3.oas.annotations.media.Schema; - -@Schema -public class PersonDTO { - private String email; - - private String firstName; - - private String lastName; - - public PersonDTO() { - } - - public PersonDTO(final String email, final String firstName, final String lastName) { - this.email = email; - this.firstName = firstName; - this.lastName = lastName; - } - - public String getEmail() { - return email; - } - - public void setEmail(final String email) { - this.email = email; - } - - public String getFirstName() { - return firstName; - } - - public void setFirstName(final String firstName) { - this.firstName = firstName; - } - - public String getLastName() { - return lastName; - } - - public void setLastName(final String lastName) { - this.lastName = lastName; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/app10/SpringDocApp10Test.java b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/app10/SpringDocApp10Test.java deleted file mode 100644 index 2247bcc40..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/app10/SpringDocApp10Test.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * - * * - * * * - * * * * Copyright 2019-2020 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.app10; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -public class SpringDocApp10Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp {} - -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/app11/SpringDocApp11Test.java b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/app11/SpringDocApp11Test.java deleted file mode 100644 index cca9804c5..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/app11/SpringDocApp11Test.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * - * * - * * * - * * * * Copyright 2019-2020 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.app11; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -public class SpringDocApp11Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp {} - -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/app11/TestController.java b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/app11/TestController.java deleted file mode 100644 index 78d5fe5e7..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/app11/TestController.java +++ /dev/null @@ -1,25 +0,0 @@ -package test.org.springdoc.api.app11; - -/** - * @author bnasslahsen - */ - -import io.swagger.v3.oas.annotations.responses.ApiResponse; - -import org.springframework.http.HttpStatus; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.ResponseStatus; -import org.springframework.web.bind.annotation.RestController; - -@RestController -@RequestMapping("/test") -public class TestController { - @PostMapping - @ApiResponse(responseCode = "200", description = "Random endpoint.") - @ResponseStatus(HttpStatus.OK) - public void testingMethod(@RequestBody TestRequest testRequest) { - System.out.println("Method was run!"); - } -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/app11/TestRequest.java b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/app11/TestRequest.java deleted file mode 100644 index 2c4df632f..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/app11/TestRequest.java +++ /dev/null @@ -1,22 +0,0 @@ -package test.org.springdoc.api.app11; - -/** - * @author bnasslahsen - */ - -import java.util.Map; - -import io.swagger.v3.oas.annotations.media.Schema; - -public class TestRequest { - @Schema(description = "Joe was here with a tuna melt!") - private String joeWasHere; - - @Schema(description = "This is an example of a map that does not work.!") - private Map testingTheMap; - - public String getJoeWasHere() { return joeWasHere; } - public void setJoeWasHere(String joeWasHere) { this.joeWasHere = joeWasHere; } - public Map getTestingTheMap() { return testingTheMap; } - public void setTestingTheMap(Map testingTheMap) { this.testingTheMap = testingTheMap; } -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/app191/GlobalExceptionHandler.java b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/app191/GlobalExceptionHandler.java deleted file mode 100644 index b5b7f838b..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/app191/GlobalExceptionHandler.java +++ /dev/null @@ -1,19 +0,0 @@ -package test.org.springdoc.api.app191; - -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.ControllerAdvice; -import org.springframework.web.bind.annotation.ExceptionHandler; -import org.springframework.web.bind.annotation.ResponseStatus; - - -@ControllerAdvice -class GlobalExceptionHandler { - - @ResponseStatus(code = HttpStatus.FORBIDDEN) - @ExceptionHandler(MyException.class) - public ResponseEntity handleException(MyException myException) { - return ResponseEntity.status(HttpStatus.FORBIDDEN) - .body(myException.getMessage()); - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/app191/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/app191/HelloController.java deleted file mode 100644 index 6942db26f..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/app191/HelloController.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * - * * - * * * - * * * * 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.app191; - -import java.util.List; - -import io.swagger.v3.oas.annotations.Operation; -import org.springdoc.core.annotations.ParameterObject; - -import org.springframework.data.domain.Pageable; -import org.springframework.data.domain.Sort; -import org.springframework.data.domain.Sort.Direction; -import org.springframework.data.web.SortDefault; -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.ExceptionHandler; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.ResponseStatus; -import org.springframework.web.bind.annotation.RestController; - -@RestController -public class HelloController { - - @GetMapping(value = "/search", produces = { "application/xml", "application/json" }) - public ResponseEntity> getAllPets(@SortDefault("name") @ParameterObject Sort sort) { - return null; - } - - - @GetMapping("/test1") - public String getPatientList1(@SortDefault(sort = { "someField", "someoTHER" }, - direction = Direction.DESC) - @ParameterObject Sort sort) { - return "bla"; - } - - @GetMapping("/test2") - public String getPatientList2(@SortDefault(sort = "someField", - direction = Direction.DESC) - @ParameterObject Sort sort) { - return "bla"; - } - - @GetMapping("/test3") - public String getPatientList3(@SortDefault(sort = { "someField", "someoTHER" }, - direction = Direction.DESC) - @ParameterObject Pageable pageable) { - return "bla"; - } - - @GetMapping("/test4") - public String getPatientList4(@SortDefault(sort = "someField", - direction = Direction.DESC) - @ParameterObject Pageable pageable) { - return "bla"; - } - - @GetMapping(value = "/hello", produces = MediaType.TEXT_PLAIN_VALUE) - @Operation(summary = "Says hello") - public ResponseEntity getHello() { - return ResponseEntity - .status(HttpStatus.OK) - .body("Hello!"); - } - - @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR) - @ExceptionHandler(RuntimeException.class) - public ResponseEntity handleException(RuntimeException runtimeException) { - return ResponseEntity - .status(HttpStatus.INTERNAL_SERVER_ERROR) - .body(runtimeException.getMessage()); - } -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/app191/MyException.java b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/app191/MyException.java deleted file mode 100644 index 47f68b33a..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/app191/MyException.java +++ /dev/null @@ -1,7 +0,0 @@ -package test.org.springdoc.api.app191; - -public class MyException extends RuntimeException { - public MyException(String message) { - super(message); - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/app191/PersonDTO.java b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/app191/PersonDTO.java deleted file mode 100644 index 99568fdf2..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/app191/PersonDTO.java +++ /dev/null @@ -1,67 +0,0 @@ -package test.org.springdoc.api.app191; - -/* - * - * * - * * * - * * * * 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. - * * * - * * - * - */ - -import io.swagger.v3.oas.annotations.media.Schema; - -@Schema -public class PersonDTO { - private String email; - - private String firstName; - - private String lastName; - - public PersonDTO() { - } - - public PersonDTO(final String email, final String firstName, final String lastName) { - this.email = email; - this.firstName = firstName; - this.lastName = lastName; - } - - public String getEmail() { - return email; - } - - public void setEmail(final String email) { - this.email = email; - } - - public String getFirstName() { - return firstName; - } - - public void setFirstName(final String firstName) { - this.firstName = firstName; - } - - public String getLastName() { - return lastName; - } - - public void setLastName(final String lastName) { - this.lastName = lastName; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/app191/SpringDocApp191Test.java b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/app191/SpringDocApp191Test.java deleted file mode 100644 index dec9ecf71..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/app191/SpringDocApp191Test.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * - * * - * * * - * * * * 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.app191; - - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -public class SpringDocApp191Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp {} - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/app2/Car.groovy b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/app2/Car.groovy deleted file mode 100644 index acc95f5a3..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/app2/Car.groovy +++ /dev/null @@ -1,27 +0,0 @@ -/* - * - * * - * * * Copyright 2019-2020 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.app2 - -class Car { - Long id - - String name -} diff --git a/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/app2/CarController.groovy b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/app2/CarController.groovy deleted file mode 100644 index 0e76487e8..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/app2/CarController.groovy +++ /dev/null @@ -1,51 +0,0 @@ -/* - * - * * - * * * Copyright 2019-2020 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.app2 - -import org.springdoc.core.annotations.ParameterObject - -import org.springframework.web.bind.annotation.GetMapping -import org.springframework.web.bind.annotation.PathVariable -import org.springframework.web.bind.annotation.RestController - -@RestController -class CarController { - - test.org.springdoc.api.app2.CarService carService - - CarController(test.org.springdoc.api.app2.CarService carService) { - this.carService = carService - } - - @GetMapping(path = '/cars') - List getCars(@ParameterObject CarsFilter filter) { - return carService.getCars() - } - - static class CarsFilter { - String name; - } - - @GetMapping(path = 'cars/{carId}') - test.org.springdoc.api.app2.Car getCar(@PathVariable(value = 'carId') Long carId) { - return carService.getCar(carId) - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/app2/CarService.groovy b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/app2/CarService.groovy deleted file mode 100644 index df6dcb602..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/app2/CarService.groovy +++ /dev/null @@ -1,44 +0,0 @@ -/* - * - * * - * * * Copyright 2019-2020 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.app2 - - -import org.springframework.stereotype.Service - -@Service -class CarService { - List getCars() { - return [ - new test.org.springdoc.api.app2.Car(id: 1L, name: 'Car 1'), - new test.org.springdoc.api.app2.Car(id: 2L, name: 'Car 2'), - new test.org.springdoc.api.app2.Car(id: 3L, name: 'Car 3'), - new test.org.springdoc.api.app2.Car(id: 4L, name: 'Car 4'), - new test.org.springdoc.api.app2.Car(id: 5L, name: 'Car 5'), - ] - } - - test.org.springdoc.api.app2.Car getCar(Long carId) { - return new test.org.springdoc.api.app2.Car( - id: carId, - name: "Car $carId" - ) - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/app2/OpenApiConfiguration.groovy b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/app2/OpenApiConfiguration.groovy deleted file mode 100644 index f3a1b4506..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/app2/OpenApiConfiguration.groovy +++ /dev/null @@ -1,45 +0,0 @@ -/* - * - * * - * * * Copyright 2019-2020 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.app2 - -import io.swagger.v3.oas.annotations.OpenAPIDefinition -import io.swagger.v3.oas.models.Components -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 - -@OpenAPIDefinition -@Configuration -class OpenApiConfiguration { - - @Bean - OpenAPI customOpenAPI() { - return new OpenAPI() - .components(new Components()) - .info( - new Info() - .title('Issue OpenAPI with Groovy') - .description('Special Groovy Metaclass Test Issue') - ) - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/app2/SpringDocApp2Test.java b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/app2/SpringDocApp2Test.java deleted file mode 100644 index 7c4cb0620..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/app2/SpringDocApp2Test.java +++ /dev/null @@ -1,11 +0,0 @@ -package test.org.springdoc.api.app2; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -public class SpringDocApp2Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp {} -} diff --git a/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/app9/DeprecatedEntity.java b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/app9/DeprecatedEntity.java deleted file mode 100644 index 7419871f4..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/app9/DeprecatedEntity.java +++ /dev/null @@ -1,32 +0,0 @@ -package test.org.springdoc.api.app9; - -import io.swagger.v3.oas.annotations.media.Schema; - -/** - * @author bnasslahsen - */ -public class DeprecatedEntity { - @Schema(deprecated = false) - private String myNonDeprecatedField; - - @Schema(deprecated = true) - private String mydeprecatedField; - - public String getMyNonDeprecatedField() { - return myNonDeprecatedField; - } - - @Deprecated - public DeprecatedEntity setMyNonDeprecatedField(String myNonDeprecatedField) { - this.myNonDeprecatedField = myNonDeprecatedField; - return this; - } - - public String getMydeprecatedField() { - return mydeprecatedField; - } - - public void setMydeprecatedField(String mydeprecatedField) { - this.mydeprecatedField = mydeprecatedField; - } -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/app9/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/app9/HelloController.java deleted file mode 100644 index b95b01100..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/app9/HelloController.java +++ /dev/null @@ -1,24 +0,0 @@ -package test.org.springdoc.api.app9; - -import jakarta.validation.constraints.NotNull; -import org.springdoc.core.annotations.ParameterObject; - -import org.springframework.data.domain.Pageable; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * @author bnasslahsen - */ -@RestController -public class HelloController { - - @GetMapping(value = "/search", produces = { "application/xml", "application/json" }) - public DeprecatedEntity getAllPets(@NotNull String toto) { - return null; - } - - @GetMapping(value = "/search2", produces = { "application/xml", "application/json" }) - public void getAllPets2(@ParameterObject Pageable pageable) { - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/app9/SpringDocApp9Test.java b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/app9/SpringDocApp9Test.java deleted file mode 100644 index 5c1682776..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/app9/SpringDocApp9Test.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * - * * - * * * - * * * * Copyright 2019-2020 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.app9; - -import java.util.Optional; - -import io.swagger.v3.core.converter.ModelConverter; -import io.swagger.v3.core.converter.ModelConverters; -import org.junit.jupiter.api.AfterAll; -import org.junit.jupiter.api.BeforeAll; -import org.springdoc.core.converters.SchemaPropertyDeprecatingConverter; -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.test.context.TestPropertySource; - - -/** - * Tests Spring meta-annotations as method parameters - */ -@TestPropertySource(properties = "springdoc.model-converters.deprecating-converter.enabled=false") -public class SpringDocApp9Test extends AbstractSpringDocTest { - - @BeforeAll - public static void init() { - Optional deprecatingConverterOptional = - ModelConverters.getInstance().getConverters() - .stream().filter(modelConverter -> modelConverter instanceof SchemaPropertyDeprecatingConverter).findAny(); - deprecatingConverterOptional.ifPresent(ModelConverters.getInstance()::removeConverter); - } - - @AfterAll - public static void clean() { - Optional deprecatingConverterOptional = - ModelConverters.getInstance().getConverters() - .stream().filter(modelConverter -> modelConverter instanceof SchemaPropertyDeprecatingConverter).findAny(); - deprecatingConverterOptional.ifPresent(ModelConverters.getInstance()::addConverter); - } - - @SpringBootApplication - static class SpringDocTestApp {} - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v30/AbstractSpringDocTest.java b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v30/AbstractSpringDocTest.java new file mode 100644 index 000000000..a904460dc --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v30/AbstractSpringDocTest.java @@ -0,0 +1,83 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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; + +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; + +import org.junit.jupiter.api.Test; +import org.springdoc.core.utils.Constants; + +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.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; + +@ActiveProfiles("test") +@SpringBootTest +@AutoConfigureMockMvc +@TestPropertySource(properties = "springdoc.api-docs.version=openapi_3_0" ) +public abstract class AbstractSpringDocTest { + + public static String className; + + @Autowired + protected MockMvc mockMvc; + + public static String getContent(String fileName) { + try { + Path path = Paths.get(AbstractSpringDocTest.class.getClassLoader().getResource(fileName).toURI()); + byte[] fileBytes = Files.readAllBytes(path); + return new String(fileBytes, StandardCharsets.UTF_8); + } + catch (Exception e) { + throw new RuntimeException("Failed to read file: " + fileName, e); + } + } + + @Test + void testApp() throws Exception { + className = getClass().getSimpleName(); + String testNumber = className.replaceAll("[^0-9]", ""); + MvcResult mockMvcResult = mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL)).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 + ".json"); + assertEquals(expected, result, true); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v30/app1/Car.groovy b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v30/app1/Car.groovy new file mode 100644 index 000000000..fa7bb4d6d --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v30/app1/Car.groovy @@ -0,0 +1,33 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app1 + +class Car { + Long id + + String name +} diff --git a/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v30/app1/CarController.groovy b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v30/app1/CarController.groovy new file mode 100644 index 000000000..2344c2d11 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v30/app1/CarController.groovy @@ -0,0 +1,57 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app1 + +import org.springdoc.core.annotations.ParameterObject + +import org.springframework.web.bind.annotation.GetMapping +import org.springframework.web.bind.annotation.PathVariable +import org.springframework.web.bind.annotation.RestController + +@RestController +class CarController { + + CarService carService + + CarController(CarService carService) { + this.carService = carService + } + + @GetMapping(path = 'cars/{carId}') + Car getCar(@PathVariable(value = 'carId') Long carId) { + return carService.getCar(carId) + } + + @GetMapping(path = '/cars') + List getCars(@ParameterObject CarsFilter filter) { + return carService.getCars() + } + + static class CarsFilter { + String name; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v30/app1/CarService.groovy b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v30/app1/CarService.groovy new file mode 100644 index 000000000..bd02bbc70 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v30/app1/CarService.groovy @@ -0,0 +1,50 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app1 + + +import org.springframework.stereotype.Service + +@Service +class CarService { + List getCars() { + return [ + new Car(id: 1L, name: 'Car 1'), + new Car(id: 2L, name: 'Car 2'), + new Car(id: 3L, name: 'Car 3'), + new Car(id: 4L, name: 'Car 4'), + new Car(id: 5L, name: 'Car 5'), + ] + } + + Car getCar(Long carId) { + return new Car( + id: carId, + name: "Car $carId" + ) + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v30/app1/OpenApiConfiguration.groovy b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v30/app1/OpenApiConfiguration.groovy new file mode 100644 index 000000000..af3dc8861 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v30/app1/OpenApiConfiguration.groovy @@ -0,0 +1,51 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app1 + +import io.swagger.v3.oas.annotations.OpenAPIDefinition +import io.swagger.v3.oas.models.Components +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 + +@OpenAPIDefinition +@Configuration +class OpenApiConfiguration { + + @Bean + OpenAPI customOpenAPI() { + return new OpenAPI() + .components(new Components()) + .info( + new Info() + .title('Issue OpenAPI with Groovy') + .description('Special Groovy Metaclass Test Issue') + ) + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v30/app1/SpringDocApp1Test.java b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v30/app1/SpringDocApp1Test.java new file mode 100644 index 000000000..7c374d615 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v30/app1/SpringDocApp1Test.java @@ -0,0 +1,52 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app1; + +import groovy.lang.MetaClass; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.springdoc.core.utils.SpringDocUtils; +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.test.context.TestPropertySource; + +@TestPropertySource(properties = "springdoc.enable-groovy=false") +public class SpringDocApp1Test extends AbstractSpringDocTest { + @BeforeAll + public static void init() { + SpringDocUtils.getConfig().removeJavaTypeToIgnore(MetaClass.class); + } + + @AfterAll + public static void clean() { + SpringDocUtils.getConfig().addJavaTypeToIgnore(MetaClass.class); + } + + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v30/app10/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v30/app10/HelloController.java new file mode 100644 index 000000000..a518e9705 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v30/app10/HelloController.java @@ -0,0 +1,68 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app10; + +import java.util.List; + +import org.springdoc.core.annotations.ParameterObject; + +import org.springframework.data.domain.Pageable; +import org.springframework.data.domain.Sort.Direction; +import org.springframework.data.web.PageableDefault; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class HelloController { + + @GetMapping(value = "/search", produces = { "application/xml", "application/json" }) + public ResponseEntity> getAllPets(@PageableDefault(size = 5, sort = "name") @ParameterObject Pageable pageable) { + return null; + } + + + @GetMapping("/test1") + public String getPatientList1(@PageableDefault(size = 100, sort = { "someField", "someoTHER" }, + direction = Direction.DESC) + @ParameterObject Pageable pageable) { + return "bla"; + } + + @GetMapping("/test2") + public String getPatientList2(@PageableDefault(size = 100, sort = "someField", + direction = Direction.DESC) + @ParameterObject Pageable pageable) { + return "bla"; + } + + @GetMapping("/test3") + public String getPatientList3(@PageableDefault(size = 100) + @ParameterObject Pageable pageable) { + return "bla"; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v30/app10/PersonDTO.java b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v30/app10/PersonDTO.java new file mode 100644 index 000000000..2486bdc17 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v30/app10/PersonDTO.java @@ -0,0 +1,71 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app10; + +import io.swagger.v3.oas.annotations.media.Schema; + +@Schema +public class PersonDTO { + private String email; + + private String firstName; + + private String lastName; + + public PersonDTO() { + } + + public PersonDTO(final String email, final String firstName, final String lastName) { + this.email = email; + this.firstName = firstName; + this.lastName = lastName; + } + + public String getEmail() { + return email; + } + + public void setEmail(final String email) { + this.email = email; + } + + public String getFirstName() { + return firstName; + } + + public void setFirstName(final String firstName) { + this.firstName = firstName; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(final String lastName) { + this.lastName = lastName; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v30/app10/SpringDocApp10Test.java b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v30/app10/SpringDocApp10Test.java new file mode 100644 index 000000000..d77535f8c --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v30/app10/SpringDocApp10Test.java @@ -0,0 +1,38 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app10; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp10Test extends AbstractSpringDocTest { + + @SpringBootApplication + static class SpringDocTestApp {} + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v30/app11/SpringDocApp11Test.java b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v30/app11/SpringDocApp11Test.java new file mode 100644 index 000000000..0b9b89f36 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v30/app11/SpringDocApp11Test.java @@ -0,0 +1,38 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app11; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp11Test extends AbstractSpringDocTest { + + @SpringBootApplication + static class SpringDocTestApp {} + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v30/app11/TestController.java b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v30/app11/TestController.java new file mode 100644 index 000000000..67995ec4a --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v30/app11/TestController.java @@ -0,0 +1,51 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app11; + +/** + * @author bnasslahsen + */ + +import io.swagger.v3.oas.annotations.responses.ApiResponse; + +import org.springframework.http.HttpStatus; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseStatus; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequestMapping("/test") +public class TestController { + @PostMapping + @ApiResponse(responseCode = "200", description = "Random endpoint.") + @ResponseStatus(HttpStatus.OK) + public void testingMethod(@RequestBody TestRequest testRequest) { + System.out.println("Method was run!"); + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v30/app11/TestRequest.java b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v30/app11/TestRequest.java new file mode 100644 index 000000000..278cdf504 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v30/app11/TestRequest.java @@ -0,0 +1,48 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app11; + +/** + * @author bnasslahsen + */ + +import java.util.Map; + +import io.swagger.v3.oas.annotations.media.Schema; + +public class TestRequest { + @Schema(description = "Joe was here with a tuna melt!") + private String joeWasHere; + + @Schema(description = "This is an example of a map that does not work.!") + private Map testingTheMap; + + public String getJoeWasHere() { return joeWasHere; } + public void setJoeWasHere(String joeWasHere) { this.joeWasHere = joeWasHere; } + public Map getTestingTheMap() { return testingTheMap; } + public void setTestingTheMap(Map testingTheMap) { this.testingTheMap = testingTheMap; } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v30/app191/GlobalExceptionHandler.java b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v30/app191/GlobalExceptionHandler.java new file mode 100644 index 000000000..0d105db0b --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v30/app191/GlobalExceptionHandler.java @@ -0,0 +1,45 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app191; + +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.ControllerAdvice; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.ResponseStatus; + + +@ControllerAdvice +class GlobalExceptionHandler { + + @ResponseStatus(code = HttpStatus.FORBIDDEN) + @ExceptionHandler(MyException.class) + public ResponseEntity handleException(MyException myException) { + return ResponseEntity.status(HttpStatus.FORBIDDEN) + .body(myException.getMessage()); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v30/app191/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v30/app191/HelloController.java new file mode 100644 index 000000000..0e4bae95c --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v30/app191/HelloController.java @@ -0,0 +1,98 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app191; + +import java.util.List; + +import io.swagger.v3.oas.annotations.Operation; +import org.springdoc.core.annotations.ParameterObject; + +import org.springframework.data.domain.Pageable; +import org.springframework.data.domain.Sort; +import org.springframework.data.domain.Sort.Direction; +import org.springframework.data.web.SortDefault; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.ResponseStatus; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class HelloController { + + @GetMapping(value = "/search", produces = { "application/xml", "application/json" }) + public ResponseEntity> getAllPets(@SortDefault("name") @ParameterObject Sort sort) { + return null; + } + + + @GetMapping("/test1") + public String getPatientList1(@SortDefault(sort = { "someField", "someoTHER" }, + direction = Direction.DESC) + @ParameterObject Sort sort) { + return "bla"; + } + + @GetMapping("/test2") + public String getPatientList2(@SortDefault(sort = "someField", + direction = Direction.DESC) + @ParameterObject Sort sort) { + return "bla"; + } + + @GetMapping("/test3") + public String getPatientList3(@SortDefault(sort = { "someField", "someoTHER" }, + direction = Direction.DESC) + @ParameterObject Pageable pageable) { + return "bla"; + } + + @GetMapping("/test4") + public String getPatientList4(@SortDefault(sort = "someField", + direction = Direction.DESC) + @ParameterObject Pageable pageable) { + return "bla"; + } + + @GetMapping(value = "/hello", produces = MediaType.TEXT_PLAIN_VALUE) + @Operation(summary = "Says hello") + public ResponseEntity getHello() { + return ResponseEntity + .status(HttpStatus.OK) + .body("Hello!"); + } + + @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR) + @ExceptionHandler(RuntimeException.class) + public ResponseEntity handleException(RuntimeException runtimeException) { + return ResponseEntity + .status(HttpStatus.INTERNAL_SERVER_ERROR) + .body(runtimeException.getMessage()); + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v30/app191/MyException.java b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v30/app191/MyException.java new file mode 100644 index 000000000..76741b5ce --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v30/app191/MyException.java @@ -0,0 +1,33 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app191; + +public class MyException extends RuntimeException { + public MyException(String message) { + super(message); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v30/app191/PersonDTO.java b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v30/app191/PersonDTO.java new file mode 100644 index 000000000..853cb549e --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v30/app191/PersonDTO.java @@ -0,0 +1,71 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app191; + +import io.swagger.v3.oas.annotations.media.Schema; + +@Schema +public class PersonDTO { + private String email; + + private String firstName; + + private String lastName; + + public PersonDTO() { + } + + public PersonDTO(final String email, final String firstName, final String lastName) { + this.email = email; + this.firstName = firstName; + this.lastName = lastName; + } + + public String getEmail() { + return email; + } + + public void setEmail(final String email) { + this.email = email; + } + + public String getFirstName() { + return firstName; + } + + public void setFirstName(final String firstName) { + this.firstName = firstName; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(final String lastName) { + this.lastName = lastName; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v30/app191/SpringDocApp191Test.java b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v30/app191/SpringDocApp191Test.java new file mode 100644 index 000000000..42114150b --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v30/app191/SpringDocApp191Test.java @@ -0,0 +1,39 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app191; + + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp191Test extends AbstractSpringDocTest { + + @SpringBootApplication + static class SpringDocTestApp {} + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v30/app2/Car.groovy b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v30/app2/Car.groovy new file mode 100644 index 000000000..5e37361c0 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v30/app2/Car.groovy @@ -0,0 +1,33 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app2 + +class Car { + Long id + + String name +} diff --git a/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v30/app2/CarController.groovy b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v30/app2/CarController.groovy new file mode 100644 index 000000000..674a5b478 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v30/app2/CarController.groovy @@ -0,0 +1,57 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app2 + +import org.springdoc.core.annotations.ParameterObject + +import org.springframework.web.bind.annotation.GetMapping +import org.springframework.web.bind.annotation.PathVariable +import org.springframework.web.bind.annotation.RestController + +@RestController +class CarController { + + CarService carService + + CarController(CarService carService) { + this.carService = carService + } + + @GetMapping(path = '/cars') + List getCars(@ParameterObject CarsFilter filter) { + return carService.getCars() + } + + static class CarsFilter { + String name; + } + + @GetMapping(path = 'cars/{carId}') + Car getCar(@PathVariable(value = 'carId') Long carId) { + return carService.getCar(carId) + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v30/app2/CarService.groovy b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v30/app2/CarService.groovy new file mode 100644 index 000000000..6cbf33b4f --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v30/app2/CarService.groovy @@ -0,0 +1,50 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app2 + + +import org.springframework.stereotype.Service + +@Service +class CarService { + List getCars() { + return [ + new test.org.springdoc.api.v30.app2.Car(id: 1L, name: 'Car 1'), + new test.org.springdoc.api.v30.app2.Car(id: 2L, name: 'Car 2'), + new test.org.springdoc.api.v30.app2.Car(id: 3L, name: 'Car 3'), + new test.org.springdoc.api.v30.app2.Car(id: 4L, name: 'Car 4'), + new test.org.springdoc.api.v30.app2.Car(id: 5L, name: 'Car 5'), + ] + } + + test.org.springdoc.api.v30.app2.Car getCar(Long carId) { + return new test.org.springdoc.api.v30.app2.Car( + id: carId, + name: "Car $carId" + ) + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v30/app2/OpenApiConfiguration.groovy b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v30/app2/OpenApiConfiguration.groovy new file mode 100644 index 000000000..12eecb655 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v30/app2/OpenApiConfiguration.groovy @@ -0,0 +1,51 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app2 + +import io.swagger.v3.oas.annotations.OpenAPIDefinition +import io.swagger.v3.oas.models.Components +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 + +@OpenAPIDefinition +@Configuration +class OpenApiConfiguration { + + @Bean + OpenAPI customOpenAPI() { + return new OpenAPI() + .components(new Components()) + .info( + new Info() + .title('Issue OpenAPI with Groovy') + .description('Special Groovy Metaclass Test Issue') + ) + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v30/app2/SpringDocApp2Test.java b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v30/app2/SpringDocApp2Test.java new file mode 100644 index 000000000..0b1e69f90 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v30/app2/SpringDocApp2Test.java @@ -0,0 +1,37 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app2; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp2Test extends AbstractSpringDocTest { + + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v30/app9/DeprecatedEntity.java b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v30/app9/DeprecatedEntity.java new file mode 100644 index 000000000..2bc85606d --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v30/app9/DeprecatedEntity.java @@ -0,0 +1,58 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app9; + +import io.swagger.v3.oas.annotations.media.Schema; + +/** + * @author bnasslahsen + */ +public class DeprecatedEntity { + @Schema(deprecated = false) + private String myNonDeprecatedField; + + @Schema(deprecated = true) + private String mydeprecatedField; + + public String getMyNonDeprecatedField() { + return myNonDeprecatedField; + } + + @Deprecated + public DeprecatedEntity setMyNonDeprecatedField(String myNonDeprecatedField) { + this.myNonDeprecatedField = myNonDeprecatedField; + return this; + } + + public String getMydeprecatedField() { + return mydeprecatedField; + } + + public void setMydeprecatedField(String mydeprecatedField) { + this.mydeprecatedField = mydeprecatedField; + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v30/app9/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v30/app9/HelloController.java new file mode 100644 index 000000000..7ac731d4f --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v30/app9/HelloController.java @@ -0,0 +1,50 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app9; + +import jakarta.validation.constraints.NotNull; +import org.springdoc.core.annotations.ParameterObject; + +import org.springframework.data.domain.Pageable; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * @author bnasslahsen + */ +@RestController +public class HelloController { + + @GetMapping(value = "/search", produces = { "application/xml", "application/json" }) + public DeprecatedEntity getAllPets(@NotNull String toto) { + return null; + } + + @GetMapping(value = "/search2", produces = { "application/xml", "application/json" }) + public void getAllPets2(@ParameterObject Pageable pageable) { + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v30/app9/SpringDocApp9Test.java b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v30/app9/SpringDocApp9Test.java new file mode 100644 index 000000000..23d86759b --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v30/app9/SpringDocApp9Test.java @@ -0,0 +1,66 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app9; + +import java.util.Optional; + +import io.swagger.v3.core.converter.ModelConverter; +import io.swagger.v3.core.converter.ModelConverters; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.springdoc.core.converters.SchemaPropertyDeprecatingConverter; +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.test.context.TestPropertySource; + + +/** + * Tests Spring meta-annotations as method parameters + */ +@TestPropertySource(properties = "springdoc.model-converters.deprecating-converter.enabled=false") +public class SpringDocApp9Test extends AbstractSpringDocTest { + + @BeforeAll + public static void init() { + Optional deprecatingConverterOptional = + ModelConverters.getInstance().getConverters() + .stream().filter(modelConverter -> modelConverter instanceof SchemaPropertyDeprecatingConverter).findAny(); + deprecatingConverterOptional.ifPresent(ModelConverters.getInstance()::removeConverter); + } + + @AfterAll + public static void clean() { + Optional deprecatingConverterOptional = + ModelConverters.getInstance().getConverters() + .stream().filter(modelConverter -> modelConverter instanceof SchemaPropertyDeprecatingConverter).findAny(); + deprecatingConverterOptional.ifPresent(ModelConverters.getInstance()::addConverter); + } + + @SpringBootApplication + static class SpringDocTestApp {} + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v31/AbstractSpringDocTest.java b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v31/AbstractSpringDocTest.java new file mode 100644 index 000000000..e2e449a88 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v31/AbstractSpringDocTest.java @@ -0,0 +1,81 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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; + +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; + +import org.junit.jupiter.api.Test; +import org.springdoc.core.utils.Constants; + +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.web.servlet.MockMvc; +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; + +@ActiveProfiles("test") +@SpringBootTest +@AutoConfigureMockMvc +public abstract class AbstractSpringDocTest { + + public static String className; + + @Autowired + protected MockMvc mockMvc; + + public static String getContent(String fileName){ + try { + Path path = Paths.get(AbstractSpringDocTest.class.getClassLoader().getResource(fileName).toURI()); + byte[] fileBytes = Files.readAllBytes(path); + return new String(fileBytes, StandardCharsets.UTF_8); + } + catch (Exception e) { + throw new RuntimeException("Failed to read file: " + fileName, e); + } + } + + @Test + void testApp() throws Exception { + className = getClass().getSimpleName(); + String testNumber = className.replaceAll("[^0-9]", ""); + MvcResult mockMvcResult = mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL)).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 + ".json"); + assertEquals(expected, result, true); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v31/app1/Car.groovy b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v31/app1/Car.groovy new file mode 100644 index 000000000..ebe64a6b7 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v31/app1/Car.groovy @@ -0,0 +1,33 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app1 + +class Car { + Long id + + String name +} diff --git a/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v31/app1/CarController.groovy b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v31/app1/CarController.groovy new file mode 100644 index 000000000..917285c9d --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v31/app1/CarController.groovy @@ -0,0 +1,57 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app1 + +import org.springdoc.core.annotations.ParameterObject + +import org.springframework.web.bind.annotation.GetMapping +import org.springframework.web.bind.annotation.PathVariable +import org.springframework.web.bind.annotation.RestController + +@RestController +class CarController { + + test.org.springdoc.api.v31.app1.CarService carService + + CarController(test.org.springdoc.api.v31.app1.CarService carService) { + this.carService = carService + } + + @GetMapping(path = 'cars/{carId}') + test.org.springdoc.api.v31.app1.Car getCar(@PathVariable(value = 'carId') Long carId) { + return carService.getCar(carId) + } + + @GetMapping(path = '/cars') + List getCars(@ParameterObject CarsFilter filter) { + return carService.getCars() + } + + static class CarsFilter { + String name; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v31/app1/CarService.groovy b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v31/app1/CarService.groovy new file mode 100644 index 000000000..c177621b9 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v31/app1/CarService.groovy @@ -0,0 +1,50 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app1 + + +import org.springframework.stereotype.Service + +@Service +class CarService { + List getCars() { + return [ + new Car(id: 1L, name: 'Car 1'), + new Car(id: 2L, name: 'Car 2'), + new Car(id: 3L, name: 'Car 3'), + new Car(id: 4L, name: 'Car 4'), + new Car(id: 5L, name: 'Car 5'), + ] + } + + Car getCar(Long carId) { + return new Car( + id: carId, + name: "Car $carId" + ) + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v31/app1/OpenApiConfiguration.groovy b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v31/app1/OpenApiConfiguration.groovy new file mode 100644 index 000000000..95b083178 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v31/app1/OpenApiConfiguration.groovy @@ -0,0 +1,51 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app1 + +import io.swagger.v3.oas.annotations.OpenAPIDefinition +import io.swagger.v3.oas.models.Components +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 + +@OpenAPIDefinition +@Configuration +class OpenApiConfiguration { + + @Bean + OpenAPI customOpenAPI() { + return new OpenAPI() + .components(new Components()) + .info( + new Info() + .title('Issue OpenAPI with Groovy') + .description('Special Groovy Metaclass Test Issue') + ) + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v31/app1/SpringDocApp1Test.java b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v31/app1/SpringDocApp1Test.java new file mode 100644 index 000000000..ce8cc1925 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v31/app1/SpringDocApp1Test.java @@ -0,0 +1,52 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app1; + +import groovy.lang.MetaClass; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.springdoc.core.utils.SpringDocUtils; +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.test.context.TestPropertySource; + +@TestPropertySource(properties = "springdoc.enable-groovy=false") +public class SpringDocApp1Test extends AbstractSpringDocTest { + @BeforeAll + public static void init() { + SpringDocUtils.getConfig().removeJavaTypeToIgnore(MetaClass.class); + } + + @AfterAll + public static void clean() { + SpringDocUtils.getConfig().addJavaTypeToIgnore(MetaClass.class); + } + + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v31/app10/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v31/app10/HelloController.java new file mode 100644 index 000000000..64f15154d --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v31/app10/HelloController.java @@ -0,0 +1,68 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app10; + +import java.util.List; + +import org.springdoc.core.annotations.ParameterObject; + +import org.springframework.data.domain.Pageable; +import org.springframework.data.domain.Sort.Direction; +import org.springframework.data.web.PageableDefault; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class HelloController { + + @GetMapping(value = "/search", produces = { "application/xml", "application/json" }) + public ResponseEntity> getAllPets(@PageableDefault(size = 5, sort = "name") @ParameterObject Pageable pageable) { + return null; + } + + + @GetMapping("/test1") + public String getPatientList1(@PageableDefault(size = 100, sort = { "someField", "someoTHER" }, + direction = Direction.DESC) + @ParameterObject Pageable pageable) { + return "bla"; + } + + @GetMapping("/test2") + public String getPatientList2(@PageableDefault(size = 100, sort = "someField", + direction = Direction.DESC) + @ParameterObject Pageable pageable) { + return "bla"; + } + + @GetMapping("/test3") + public String getPatientList3(@PageableDefault(size = 100) + @ParameterObject Pageable pageable) { + return "bla"; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v31/app10/PersonDTO.java b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v31/app10/PersonDTO.java new file mode 100644 index 000000000..c4a62e445 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v31/app10/PersonDTO.java @@ -0,0 +1,71 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app10; + +import io.swagger.v3.oas.annotations.media.Schema; + +@Schema +public class PersonDTO { + private String email; + + private String firstName; + + private String lastName; + + public PersonDTO() { + } + + public PersonDTO(final String email, final String firstName, final String lastName) { + this.email = email; + this.firstName = firstName; + this.lastName = lastName; + } + + public String getEmail() { + return email; + } + + public void setEmail(final String email) { + this.email = email; + } + + public String getFirstName() { + return firstName; + } + + public void setFirstName(final String firstName) { + this.firstName = firstName; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(final String lastName) { + this.lastName = lastName; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v31/app10/SpringDocApp10Test.java b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v31/app10/SpringDocApp10Test.java new file mode 100644 index 000000000..100636623 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v31/app10/SpringDocApp10Test.java @@ -0,0 +1,38 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app10; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp10Test extends AbstractSpringDocTest { + + @SpringBootApplication + static class SpringDocTestApp {} + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v31/app11/SpringDocApp11Test.java b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v31/app11/SpringDocApp11Test.java new file mode 100644 index 000000000..71914ef53 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v31/app11/SpringDocApp11Test.java @@ -0,0 +1,38 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app11; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp11Test extends AbstractSpringDocTest { + + @SpringBootApplication + static class SpringDocTestApp {} + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v31/app11/TestController.java b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v31/app11/TestController.java new file mode 100644 index 000000000..28c883d48 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v31/app11/TestController.java @@ -0,0 +1,51 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app11; + +/** + * @author bnasslahsen + */ + +import io.swagger.v3.oas.annotations.responses.ApiResponse; + +import org.springframework.http.HttpStatus; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseStatus; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequestMapping("/test") +public class TestController { + @PostMapping + @ApiResponse(responseCode = "200", description = "Random endpoint.") + @ResponseStatus(HttpStatus.OK) + public void testingMethod(@RequestBody TestRequest testRequest) { + System.out.println("Method was run!"); + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v31/app11/TestRequest.java b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v31/app11/TestRequest.java new file mode 100644 index 000000000..87325d36a --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v31/app11/TestRequest.java @@ -0,0 +1,48 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app11; + +/** + * @author bnasslahsen + */ + +import java.util.Map; + +import io.swagger.v3.oas.annotations.media.Schema; + +public class TestRequest { + @Schema(description = "Joe was here with a tuna melt!") + private String joeWasHere; + + @Schema(description = "This is an example of a map that does not work.!") + private Map testingTheMap; + + public String getJoeWasHere() { return joeWasHere; } + public void setJoeWasHere(String joeWasHere) { this.joeWasHere = joeWasHere; } + public Map getTestingTheMap() { return testingTheMap; } + public void setTestingTheMap(Map testingTheMap) { this.testingTheMap = testingTheMap; } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v31/app191/GlobalExceptionHandler.java b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v31/app191/GlobalExceptionHandler.java new file mode 100644 index 000000000..58ad154f0 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v31/app191/GlobalExceptionHandler.java @@ -0,0 +1,45 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app191; + +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.ControllerAdvice; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.ResponseStatus; + + +@ControllerAdvice +class GlobalExceptionHandler { + + @ResponseStatus(code = HttpStatus.FORBIDDEN) + @ExceptionHandler(MyException.class) + public ResponseEntity handleException(MyException myException) { + return ResponseEntity.status(HttpStatus.FORBIDDEN) + .body(myException.getMessage()); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v31/app191/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v31/app191/HelloController.java new file mode 100644 index 000000000..88820dca8 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v31/app191/HelloController.java @@ -0,0 +1,98 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app191; + +import java.util.List; + +import io.swagger.v3.oas.annotations.Operation; +import org.springdoc.core.annotations.ParameterObject; + +import org.springframework.data.domain.Pageable; +import org.springframework.data.domain.Sort; +import org.springframework.data.domain.Sort.Direction; +import org.springframework.data.web.SortDefault; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.ResponseStatus; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class HelloController { + + @GetMapping(value = "/search", produces = { "application/xml", "application/json" }) + public ResponseEntity> getAllPets(@SortDefault("name") @ParameterObject Sort sort) { + return null; + } + + + @GetMapping("/test1") + public String getPatientList1(@SortDefault(sort = { "someField", "someoTHER" }, + direction = Direction.DESC) + @ParameterObject Sort sort) { + return "bla"; + } + + @GetMapping("/test2") + public String getPatientList2(@SortDefault(sort = "someField", + direction = Direction.DESC) + @ParameterObject Sort sort) { + return "bla"; + } + + @GetMapping("/test3") + public String getPatientList3(@SortDefault(sort = { "someField", "someoTHER" }, + direction = Direction.DESC) + @ParameterObject Pageable pageable) { + return "bla"; + } + + @GetMapping("/test4") + public String getPatientList4(@SortDefault(sort = "someField", + direction = Direction.DESC) + @ParameterObject Pageable pageable) { + return "bla"; + } + + @GetMapping(value = "/hello", produces = MediaType.TEXT_PLAIN_VALUE) + @Operation(summary = "Says hello") + public ResponseEntity getHello() { + return ResponseEntity + .status(HttpStatus.OK) + .body("Hello!"); + } + + @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR) + @ExceptionHandler(RuntimeException.class) + public ResponseEntity handleException(RuntimeException runtimeException) { + return ResponseEntity + .status(HttpStatus.INTERNAL_SERVER_ERROR) + .body(runtimeException.getMessage()); + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v31/app191/MyException.java b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v31/app191/MyException.java new file mode 100644 index 000000000..7ba1f9beb --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v31/app191/MyException.java @@ -0,0 +1,33 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app191; + +public class MyException extends RuntimeException { + public MyException(String message) { + super(message); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v31/app191/PersonDTO.java b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v31/app191/PersonDTO.java new file mode 100644 index 000000000..ccfbc95d5 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v31/app191/PersonDTO.java @@ -0,0 +1,71 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app191; + +import io.swagger.v3.oas.annotations.media.Schema; + +@Schema +public class PersonDTO { + private String email; + + private String firstName; + + private String lastName; + + public PersonDTO() { + } + + public PersonDTO(final String email, final String firstName, final String lastName) { + this.email = email; + this.firstName = firstName; + this.lastName = lastName; + } + + public String getEmail() { + return email; + } + + public void setEmail(final String email) { + this.email = email; + } + + public String getFirstName() { + return firstName; + } + + public void setFirstName(final String firstName) { + this.firstName = firstName; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(final String lastName) { + this.lastName = lastName; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v31/app191/SpringDocApp191Test.java b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v31/app191/SpringDocApp191Test.java new file mode 100644 index 000000000..af7eafa27 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v31/app191/SpringDocApp191Test.java @@ -0,0 +1,39 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app191; + + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp191Test extends AbstractSpringDocTest { + + @SpringBootApplication + static class SpringDocTestApp {} + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v31/app2/Car.groovy b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v31/app2/Car.groovy new file mode 100644 index 000000000..514b56a4e --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v31/app2/Car.groovy @@ -0,0 +1,33 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app2 + +class Car { + Long id + + String name +} diff --git a/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v31/app2/CarController.groovy b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v31/app2/CarController.groovy new file mode 100644 index 000000000..846d3a47f --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v31/app2/CarController.groovy @@ -0,0 +1,57 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app2 + +import org.springdoc.core.annotations.ParameterObject + +import org.springframework.web.bind.annotation.GetMapping +import org.springframework.web.bind.annotation.PathVariable +import org.springframework.web.bind.annotation.RestController + +@RestController +class CarController { + + test.org.springdoc.api.v31.app2.CarService carService + + CarController(test.org.springdoc.api.v31.app2.CarService carService) { + this.carService = carService + } + + @GetMapping(path = '/cars') + List getCars(@ParameterObject CarsFilter filter) { + return carService.getCars() + } + + static class CarsFilter { + String name; + } + + @GetMapping(path = 'cars/{carId}') + test.org.springdoc.api.v31.app2.Car getCar(@PathVariable(value = 'carId') Long carId) { + return carService.getCar(carId) + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v31/app2/CarService.groovy b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v31/app2/CarService.groovy new file mode 100644 index 000000000..085039156 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v31/app2/CarService.groovy @@ -0,0 +1,50 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app2 + + +import org.springframework.stereotype.Service + +@Service +class CarService { + List getCars() { + return [ + new Car(id: 1L, name: 'Car 1'), + new Car(id: 2L, name: 'Car 2'), + new Car(id: 3L, name: 'Car 3'), + new Car(id: 4L, name: 'Car 4'), + new Car(id: 5L, name: 'Car 5'), + ] + } + + Car getCar(Long carId) { + return new Car( + id: carId, + name: "Car $carId" + ) + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v31/app2/OpenApiConfiguration.groovy b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v31/app2/OpenApiConfiguration.groovy new file mode 100644 index 000000000..b1446eef8 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v31/app2/OpenApiConfiguration.groovy @@ -0,0 +1,51 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app2 + +import io.swagger.v3.oas.annotations.OpenAPIDefinition +import io.swagger.v3.oas.models.Components +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 + +@OpenAPIDefinition +@Configuration +class OpenApiConfiguration { + + @Bean + OpenAPI customOpenAPI() { + return new OpenAPI() + .components(new Components()) + .info( + new Info() + .title('Issue OpenAPI with Groovy') + .description('Special Groovy Metaclass Test Issue') + ) + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v31/app2/SpringDocApp2Test.java b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v31/app2/SpringDocApp2Test.java new file mode 100644 index 000000000..11c23a735 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v31/app2/SpringDocApp2Test.java @@ -0,0 +1,37 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app2; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp2Test extends AbstractSpringDocTest { + + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v31/app9/DeprecatedEntity.java b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v31/app9/DeprecatedEntity.java new file mode 100644 index 000000000..7c32aebeb --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v31/app9/DeprecatedEntity.java @@ -0,0 +1,58 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app9; + +import io.swagger.v3.oas.annotations.media.Schema; + +/** + * @author bnasslahsen + */ +public class DeprecatedEntity { + @Schema(deprecated = false) + private String myNonDeprecatedField; + + @Schema(deprecated = true) + private String mydeprecatedField; + + public String getMyNonDeprecatedField() { + return myNonDeprecatedField; + } + + @Deprecated + public DeprecatedEntity setMyNonDeprecatedField(String myNonDeprecatedField) { + this.myNonDeprecatedField = myNonDeprecatedField; + return this; + } + + public String getMydeprecatedField() { + return mydeprecatedField; + } + + public void setMydeprecatedField(String mydeprecatedField) { + this.mydeprecatedField = mydeprecatedField; + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v31/app9/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v31/app9/HelloController.java new file mode 100644 index 000000000..c1000c244 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v31/app9/HelloController.java @@ -0,0 +1,50 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app9; + +import jakarta.validation.constraints.NotNull; +import org.springdoc.core.annotations.ParameterObject; + +import org.springframework.data.domain.Pageable; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * @author bnasslahsen + */ +@RestController +public class HelloController { + + @GetMapping(value = "/search", produces = { "application/xml", "application/json" }) + public DeprecatedEntity getAllPets(@NotNull String toto) { + return null; + } + + @GetMapping(value = "/search2", produces = { "application/xml", "application/json" }) + public void getAllPets2(@ParameterObject Pageable pageable) { + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v31/app9/SpringDocApp9Test.java b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v31/app9/SpringDocApp9Test.java new file mode 100644 index 000000000..0c8486e6f --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/groovy/test/org/springdoc/api/v31/app9/SpringDocApp9Test.java @@ -0,0 +1,66 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app9; + +import java.util.Optional; + +import io.swagger.v3.core.converter.ModelConverter; +import io.swagger.v3.core.converter.ModelConverters; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.springdoc.core.converters.SchemaPropertyDeprecatingConverter; +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.test.context.TestPropertySource; + + +/** + * Tests Spring meta-annotations as method parameters + */ +@TestPropertySource(properties = "springdoc.model-converters.deprecating-converter.enabled=false") +public class SpringDocApp9Test extends AbstractSpringDocTest { + + @BeforeAll + public static void init() { + Optional deprecatingConverterOptional = + ModelConverters.getInstance(true).getConverters() + .stream().filter(modelConverter -> modelConverter instanceof SchemaPropertyDeprecatingConverter).findAny(); + deprecatingConverterOptional.ifPresent(ModelConverters.getInstance(true)::removeConverter); + } + + @AfterAll + public static void clean() { + Optional deprecatingConverterOptional = + ModelConverters.getInstance(true).getConverters() + .stream().filter(modelConverter -> modelConverter instanceof SchemaPropertyDeprecatingConverter).findAny(); + deprecatingConverterOptional.ifPresent(ModelConverters.getInstance(true)::addConverter); + } + + @SpringBootApplication + static class SpringDocTestApp {} + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/resources/results/app1.json b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/resources/results/3.0.1/app1.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/resources/results/app1.json rename to springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/resources/results/3.0.1/app1.json diff --git a/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/resources/results/app10.json b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/resources/results/3.0.1/app10.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/resources/results/app10.json rename to springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/resources/results/3.0.1/app10.json diff --git a/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/resources/results/app11.json b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/resources/results/3.0.1/app11.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/resources/results/app11.json rename to springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/resources/results/3.0.1/app11.json diff --git a/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/resources/results/app191.json b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/resources/results/3.0.1/app191.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/resources/results/app191.json rename to springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/resources/results/3.0.1/app191.json diff --git a/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/resources/results/app2.json b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/resources/results/3.0.1/app2.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/resources/results/app2.json rename to springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/resources/results/3.0.1/app2.json diff --git a/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/resources/results/app9.json b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/resources/results/3.0.1/app9.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/resources/results/app9.json rename to springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/resources/results/3.0.1/app9.json diff --git a/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/resources/results/3.1.0/app1.json b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/resources/results/3.1.0/app1.json new file mode 100644 index 000000000..abd4acc2a --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/resources/results/3.1.0/app1.json @@ -0,0 +1,7275 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "Issue OpenAPI with Groovy", + "description": "Special Groovy Metaclass Test Issue" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/cars": { + "get": { + "tags": [ + "car-controller" + ], + "operationId": "getCars", + "parameters": [ + { + "name": "name", + "in": "query", + "required": false, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Car" + } + } + } + } + } + } + } + }, + "/cars/{carId}": { + "get": { + "tags": [ + "car-controller" + ], + "operationId": "getCar", + "parameters": [ + { + "name": "carId", + "in": "path", + "required": true, + "schema": { + "type": "integer", + "format": "int64" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/Car" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "ASTNode": { + "type": "object", + "properties": { + "lineNumber": { + "type": "integer", + "format": "int32" + }, + "columnNumber": { + "type": "integer", + "format": "int32" + }, + "lastLineNumber": { + "type": "integer", + "format": "int32" + }, + "lastColumnNumber": { + "type": "integer", + "format": "int32" + }, + "metaDataMap": { + "type": "object", + "additionalProperties": { + "type": "object" + } + }, + "text": { + "type": "string" + }, + "sourcePosition": { + "$ref": "#/components/schemas/ASTNode" + }, + "nodeMetaData": { + "type": "object", + "additionalProperties": { + "type": "object" + } + } + } + }, + "AnnotatedNode": { + "type": "object", + "properties": { + "lineNumber": { + "type": "integer", + "format": "int32" + }, + "columnNumber": { + "type": "integer", + "format": "int32" + }, + "lastLineNumber": { + "type": "integer", + "format": "int32" + }, + "lastColumnNumber": { + "type": "integer", + "format": "int32" + }, + "metaDataMap": { + "type": "object", + "additionalProperties": { + "type": "object" + } + }, + "declaringClass": { + "$ref": "#/components/schemas/ClassNode" + }, + "synthetic": { + "type": "boolean" + }, + "instance": { + "$ref": "#/components/schemas/AnnotatedNode" + }, + "hasNoRealSourcePosition": { + "type": "boolean", + "writeOnly": true + }, + "groovydoc": { + "$ref": "#/components/schemas/Groovydoc" + }, + "text": { + "type": "string" + }, + "sourcePosition": { + "$ref": "#/components/schemas/ASTNode", + "writeOnly": true + }, + "nodeMetaData": { + "type": "object", + "additionalProperties": { + "type": "object" + } + } + } + }, + "AnnotationNode": { + "type": "object", + "properties": { + "lineNumber": { + "type": "integer", + "format": "int32" + }, + "columnNumber": { + "type": "integer", + "format": "int32" + }, + "lastLineNumber": { + "type": "integer", + "format": "int32" + }, + "lastColumnNumber": { + "type": "integer", + "format": "int32" + }, + "metaDataMap": { + "type": "object", + "additionalProperties": { + "type": "object" + } + }, + "classNode": { + "$ref": "#/components/schemas/ClassNode" + }, + "members": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/Expression" + } + }, + "runtimeRetention": { + "type": "boolean", + "writeOnly": true + }, + "sourceRetention": { + "type": "boolean", + "writeOnly": true + }, + "classRetention": { + "type": "boolean", + "writeOnly": true + }, + "allowedTargets": { + "type": "integer", + "format": "int32", + "writeOnly": true + }, + "text": { + "type": "string" + }, + "builtIn": { + "type": "boolean" + }, + "sourcePosition": { + "$ref": "#/components/schemas/ASTNode", + "writeOnly": true + }, + "nodeMetaData": { + "type": "object", + "additionalProperties": { + "type": "object" + } + } + } + }, + "BlockStatement": { + "type": "object", + "properties": { + "lineNumber": { + "type": "integer", + "format": "int32" + }, + "columnNumber": { + "type": "integer", + "format": "int32" + }, + "lastLineNumber": { + "type": "integer", + "format": "int32" + }, + "lastColumnNumber": { + "type": "integer", + "format": "int32" + }, + "metaDataMap": { + "type": "object", + "additionalProperties": { + "type": "object" + } + }, + "statementLabels": { + "type": "array", + "items": { + "type": "string" + } + }, + "statements": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Statement" + } + }, + "empty": { + "type": "boolean" + }, + "text": { + "type": "string" + }, + "variableScope": { + "$ref": "#/components/schemas/VariableScope" + }, + "statementLabel": { + "type": "string", + "deprecated": true + }, + "sourcePosition": { + "$ref": "#/components/schemas/ASTNode", + "writeOnly": true + }, + "nodeMetaData": { + "type": "object", + "additionalProperties": { + "type": "object" + } + } + } + }, + "BytecodeProcessor": { + "type": "object" + }, + "CSTNode": { + "type": "object", + "properties": { + "empty": { + "type": "boolean" + }, + "root": { + "$ref": "#/components/schemas/Token" + }, + "type": { + "type": "integer", + "format": "int32" + }, + "description": { + "type": "string" + }, + "startLine": { + "type": "integer", + "format": "int32" + }, + "startColumn": { + "type": "integer", + "format": "int32" + }, + "meaning": { + "type": "integer", + "format": "int32" + }, + "rootText": { + "type": "string" + }, + "anExpression": { + "type": "boolean" + } + } + }, + "CachedClass": { + "type": "object", + "properties": { + "fields": { + "type": "array", + "items": { + "$ref": "#/components/schemas/CachedField" + } + }, + "constructors": { + "type": "array", + "items": { + "$ref": "#/components/schemas/CachedConstructor" + } + }, + "methods": { + "type": "array", + "items": { + "$ref": "#/components/schemas/CachedMethod" + } + }, + "cachedSuperClass": { + "$ref": "#/components/schemas/CachedClass" + }, + "hierarchy": { + "type": "array", + "items": { + "$ref": "#/components/schemas/ClassInfo" + } + }, + "declaredInterfaces": { + "type": "array", + "items": { + "$ref": "#/components/schemas/CachedClass" + }, + "uniqueItems": true + }, + "interfaces": { + "type": "array", + "items": { + "$ref": "#/components/schemas/CachedClass" + }, + "uniqueItems": true + }, + "cachedClass": { + "$ref": "#/components/schemas/CachedClass" + }, + "classInfo": { + "$ref": "#/components/schemas/ClassInfo" + }, + "isArray": { + "type": "boolean" + }, + "isPrimitive": { + "type": "boolean" + }, + "modifiers": { + "type": "integer", + "format": "int32" + }, + "isInterface": { + "type": "boolean" + }, + "isNumber": { + "type": "boolean" + }, + "mopMethods": { + "type": "array", + "items": { + "$ref": "#/components/schemas/CachedMethod" + } + }, + "name": { + "type": "string" + }, + "interface": { + "type": "boolean" + }, + "primitive": { + "type": "boolean" + }, + "void": { + "type": "boolean" + }, + "typeDescription": { + "type": "string" + }, + "superClassDistance": { + "type": "integer", + "format": "int32" + }, + "newMetaMethods": { + "type": "array", + "items": { + "$ref": "#/components/schemas/MetaMethod" + } + }, + "callSiteLoader": { + "$ref": "#/components/schemas/CallSiteClassLoader" + } + } + }, + "CachedConstructor": { + "type": "object", + "properties": { + "cachedConstructor": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "modifiers": { + "type": "integer", + "format": "int32" + }, + "typeParameters": { + "type": "array", + "items": { + "type": "object", + "properties": { + "genericDeclaration": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "modifiers": { + "type": "integer", + "format": "int32" + }, + "synthetic": { + "type": "boolean" + }, + "declaredAnnotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "accessible": { + "type": "boolean", + "deprecated": true + }, + "varArgs": { + "type": "boolean" + }, + "parameterCount": { + "type": "integer", + "format": "int32" + }, + "parameterAnnotations": { + "type": "array", + "items": { + "type": "array", + "items": { + "type": "object" + } + } + }, + "genericParameterTypes": { + "type": "array", + "items": { + "type": "object", + "properties": { + "typeName": { + "type": "string" + } + } + } + }, + "genericExceptionTypes": { + "type": "array", + "items": { + "type": "object", + "properties": { + "typeName": { + "type": "string" + } + } + } + }, + "annotatedReturnType": { + "type": "object", + "properties": { + "annotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "declaredAnnotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "type": { + "type": "object", + "properties": { + "typeName": { + "type": "string" + } + } + } + } + }, + "annotatedReceiverType": { + "type": "object", + "properties": { + "annotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "declaredAnnotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "type": { + "type": "object", + "properties": { + "typeName": { + "type": "string" + } + } + } + } + }, + "annotatedParameterTypes": { + "type": "array", + "items": { + "type": "object", + "properties": { + "annotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "declaredAnnotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "type": { + "type": "object", + "properties": { + "typeName": { + "type": "string" + } + } + } + } + } + }, + "parameters": { + "type": "array", + "items": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "modifiers": { + "type": "integer", + "format": "int32" + }, + "synthetic": { + "type": "boolean" + }, + "annotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "declaredAnnotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "annotatedType": { + "type": "object", + "properties": { + "annotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "declaredAnnotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "type": { + "type": "object", + "properties": { + "typeName": { + "type": "string" + } + } + } + } + }, + "parameterizedType": { + "type": "object", + "properties": { + "typeName": { + "type": "string" + } + } + }, + "varArgs": { + "type": "boolean" + }, + "namePresent": { + "type": "boolean" + }, + "declaringExecutable": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "modifiers": { + "type": "integer", + "format": "int32" + }, + "typeParameters": { + "type": "array", + "items": { + "type": "object", + "properties": { + "genericDeclaration": { + "type": "object" + }, + "annotatedBounds": { + "type": "array", + "items": { + "type": "object", + "properties": { + "annotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "declaredAnnotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "type": { + "type": "object", + "properties": { + "typeName": { + "type": "string" + } + } + } + } + } + }, + "name": { + "type": "string" + }, + "bounds": { + "type": "array", + "items": { + "type": "object", + "properties": { + "typeName": { + "type": "string" + } + } + } + }, + "typeName": { + "type": "string" + }, + "annotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "declaredAnnotations": { + "type": "array", + "items": { + "type": "object" + } + } + } + } + }, + "synthetic": { + "type": "boolean" + }, + "declaredAnnotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "varArgs": { + "type": "boolean" + }, + "annotatedParameterTypes": { + "type": "array", + "items": { + "type": "object", + "properties": { + "annotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "declaredAnnotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "type": { + "type": "object", + "properties": { + "typeName": { + "type": "string" + } + } + } + } + } + }, + "parameterCount": { + "type": "integer", + "format": "int32" + }, + "parameterAnnotations": { + "type": "array", + "items": { + "type": "array", + "items": { + "type": "object" + } + } + }, + "genericParameterTypes": { + "type": "array", + "items": { + "type": "object", + "properties": { + "typeName": { + "type": "string" + } + } + } + }, + "genericExceptionTypes": { + "type": "array", + "items": { + "type": "object", + "properties": { + "typeName": { + "type": "string" + } + } + } + }, + "annotatedReturnType": { + "type": "object", + "properties": { + "annotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "declaredAnnotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "type": { + "type": "object", + "properties": { + "typeName": { + "type": "string" + } + } + } + } + }, + "annotatedReceiverType": { + "type": "object", + "properties": { + "annotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "declaredAnnotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "type": { + "type": "object", + "properties": { + "typeName": { + "type": "string" + } + } + } + } + }, + "annotatedExceptionTypes": { + "type": "array", + "items": { + "type": "object", + "properties": { + "annotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "declaredAnnotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "type": { + "type": "object", + "properties": { + "typeName": { + "type": "string" + } + } + } + } + } + }, + "annotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "accessible": { + "type": "boolean", + "deprecated": true + } + } + }, + "implicit": { + "type": "boolean" + } + } + } + }, + "annotatedExceptionTypes": { + "type": "array", + "items": { + "type": "object", + "properties": { + "annotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "declaredAnnotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "type": { + "type": "object", + "properties": { + "typeName": { + "type": "string" + } + } + } + } + } + }, + "annotations": { + "type": "array", + "items": { + "type": "object" + } + } + } + }, + "annotatedBounds": { + "type": "array", + "items": { + "type": "object", + "properties": { + "annotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "declaredAnnotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "type": { + "type": "object", + "properties": { + "typeName": { + "type": "string" + } + } + } + } + } + }, + "name": { + "type": "string" + }, + "bounds": { + "type": "array", + "items": { + "type": "object", + "properties": { + "typeName": { + "type": "string" + } + } + } + }, + "typeName": { + "type": "string" + }, + "annotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "declaredAnnotations": { + "type": "array", + "items": { + "type": "object" + } + } + } + } + }, + "synthetic": { + "type": "boolean" + }, + "declaredAnnotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "accessible": { + "type": "boolean", + "deprecated": true + }, + "varArgs": { + "type": "boolean" + }, + "parameterCount": { + "type": "integer", + "format": "int32" + }, + "parameterAnnotations": { + "type": "array", + "items": { + "type": "array", + "items": { + "type": "object" + } + } + }, + "genericParameterTypes": { + "type": "array", + "items": { + "type": "object", + "properties": { + "typeName": { + "type": "string" + } + } + } + }, + "genericExceptionTypes": { + "type": "array", + "items": { + "type": "object", + "properties": { + "typeName": { + "type": "string" + } + } + } + }, + "annotatedReturnType": { + "type": "object", + "properties": { + "annotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "declaredAnnotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "type": { + "type": "object", + "properties": { + "typeName": { + "type": "string" + } + } + } + } + }, + "annotatedReceiverType": { + "type": "object", + "properties": { + "annotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "declaredAnnotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "type": { + "type": "object", + "properties": { + "typeName": { + "type": "string" + } + } + } + } + }, + "annotatedParameterTypes": { + "type": "array", + "items": { + "type": "object", + "properties": { + "annotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "declaredAnnotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "type": { + "type": "object", + "properties": { + "typeName": { + "type": "string" + } + } + } + } + } + }, + "parameters": { + "type": "array", + "items": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "modifiers": { + "type": "integer", + "format": "int32" + }, + "synthetic": { + "type": "boolean" + }, + "annotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "declaredAnnotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "annotatedType": { + "type": "object", + "properties": { + "annotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "declaredAnnotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "type": { + "type": "object", + "properties": { + "typeName": { + "type": "string" + } + } + } + } + }, + "parameterizedType": { + "type": "object", + "properties": { + "typeName": { + "type": "string" + } + } + }, + "varArgs": { + "type": "boolean" + }, + "namePresent": { + "type": "boolean" + }, + "declaringExecutable": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "modifiers": { + "type": "integer", + "format": "int32" + }, + "typeParameters": { + "type": "array", + "items": { + "type": "object", + "properties": { + "genericDeclaration": { + "type": "object" + }, + "annotatedBounds": { + "type": "array", + "items": { + "type": "object", + "properties": { + "annotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "declaredAnnotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "type": { + "type": "object", + "properties": { + "typeName": { + "type": "string" + } + } + } + } + } + }, + "name": { + "type": "string" + }, + "bounds": { + "type": "array", + "items": { + "type": "object", + "properties": { + "typeName": { + "type": "string" + } + } + } + }, + "typeName": { + "type": "string" + }, + "annotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "declaredAnnotations": { + "type": "array", + "items": { + "type": "object" + } + } + } + } + }, + "synthetic": { + "type": "boolean" + }, + "declaredAnnotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "varArgs": { + "type": "boolean" + }, + "annotatedParameterTypes": { + "type": "array", + "items": { + "type": "object", + "properties": { + "annotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "declaredAnnotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "type": { + "type": "object", + "properties": { + "typeName": { + "type": "string" + } + } + } + } + } + }, + "parameterCount": { + "type": "integer", + "format": "int32" + }, + "parameterAnnotations": { + "type": "array", + "items": { + "type": "array", + "items": { + "type": "object" + } + } + }, + "genericParameterTypes": { + "type": "array", + "items": { + "type": "object", + "properties": { + "typeName": { + "type": "string" + } + } + } + }, + "genericExceptionTypes": { + "type": "array", + "items": { + "type": "object", + "properties": { + "typeName": { + "type": "string" + } + } + } + }, + "annotatedReturnType": { + "type": "object", + "properties": { + "annotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "declaredAnnotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "type": { + "type": "object", + "properties": { + "typeName": { + "type": "string" + } + } + } + } + }, + "annotatedReceiverType": { + "type": "object", + "properties": { + "annotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "declaredAnnotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "type": { + "type": "object", + "properties": { + "typeName": { + "type": "string" + } + } + } + } + }, + "annotatedExceptionTypes": { + "type": "array", + "items": { + "type": "object", + "properties": { + "annotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "declaredAnnotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "type": { + "type": "object", + "properties": { + "typeName": { + "type": "string" + } + } + } + } + } + }, + "annotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "accessible": { + "type": "boolean", + "deprecated": true + } + } + }, + "implicit": { + "type": "boolean" + } + } + } + }, + "annotatedExceptionTypes": { + "type": "array", + "items": { + "type": "object", + "properties": { + "annotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "declaredAnnotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "type": { + "type": "object", + "properties": { + "typeName": { + "type": "string" + } + } + } + } + } + }, + "annotations": { + "type": "array", + "items": { + "type": "object" + } + } + } + }, + "modifiers": { + "type": "integer", + "format": "int32" + }, + "cachedClass": { + "$ref": "#/components/schemas/CachedClass" + }, + "vargsMethod": { + "type": "boolean" + } + } + }, + "CachedField": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "modifiers": { + "type": "integer", + "format": "int32" + }, + "final": { + "type": "boolean" + }, + "static": { + "type": "boolean" + }, + "cachedField": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "modifiers": { + "type": "integer", + "format": "int32" + }, + "synthetic": { + "type": "boolean" + }, + "declaredAnnotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "accessible": { + "type": "boolean", + "deprecated": true + }, + "genericType": { + "type": "object", + "properties": { + "typeName": { + "type": "string" + } + } + }, + "enumConstant": { + "type": "boolean" + }, + "annotatedType": { + "type": "object", + "properties": { + "annotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "declaredAnnotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "type": { + "type": "object", + "properties": { + "typeName": { + "type": "string" + } + } + } + } + }, + "annotations": { + "type": "array", + "items": { + "type": "object" + } + } + } + } + } + }, + "CachedMethod": { + "type": "object", + "properties": { + "signature": { + "type": "string" + }, + "mopName": { + "type": "string" + }, + "cachedClass": { + "$ref": "#/components/schemas/CachedClass" + }, + "cachedMethod": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "modifiers": { + "type": "integer", + "format": "int32" + }, + "typeParameters": { + "type": "array", + "items": { + "type": "object", + "properties": { + "annotatedBounds": { + "type": "array", + "items": { + "type": "object", + "properties": { + "annotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "declaredAnnotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "type": { + "type": "object", + "properties": { + "typeName": { + "type": "string" + } + } + } + } + } + }, + "name": { + "type": "string" + }, + "bounds": { + "type": "array", + "items": { + "type": "object", + "properties": { + "typeName": { + "type": "string" + } + } + } + }, + "typeName": { + "type": "string" + }, + "annotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "declaredAnnotations": { + "type": "array", + "items": { + "type": "object" + } + } + } + } + }, + "synthetic": { + "type": "boolean" + }, + "declaredAnnotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "accessible": { + "type": "boolean", + "deprecated": true + }, + "varArgs": { + "type": "boolean" + }, + "parameterCount": { + "type": "integer", + "format": "int32" + }, + "parameterAnnotations": { + "type": "array", + "items": { + "type": "array", + "items": { + "type": "object" + } + } + }, + "genericParameterTypes": { + "type": "array", + "items": { + "type": "object", + "properties": { + "typeName": { + "type": "string" + } + } + } + }, + "genericExceptionTypes": { + "type": "array", + "items": { + "type": "object", + "properties": { + "typeName": { + "type": "string" + } + } + } + }, + "default": { + "type": "boolean" + }, + "genericReturnType": { + "type": "object", + "properties": { + "typeName": { + "type": "string" + } + } + }, + "bridge": { + "type": "boolean" + }, + "defaultValue": { + "type": "object" + }, + "annotatedReturnType": { + "type": "object", + "properties": { + "annotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "declaredAnnotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "type": { + "type": "object", + "properties": { + "typeName": { + "type": "string" + } + } + } + } + }, + "annotatedParameterTypes": { + "type": "array", + "items": { + "type": "object", + "properties": { + "annotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "declaredAnnotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "type": { + "type": "object", + "properties": { + "typeName": { + "type": "string" + } + } + } + } + } + }, + "parameters": { + "type": "array", + "items": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "modifiers": { + "type": "integer", + "format": "int32" + }, + "synthetic": { + "type": "boolean" + }, + "annotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "declaredAnnotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "annotatedType": { + "type": "object", + "properties": { + "annotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "declaredAnnotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "type": { + "type": "object", + "properties": { + "typeName": { + "type": "string" + } + } + } + } + }, + "parameterizedType": { + "type": "object", + "properties": { + "typeName": { + "type": "string" + } + } + }, + "varArgs": { + "type": "boolean" + }, + "namePresent": { + "type": "boolean" + }, + "declaringExecutable": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "modifiers": { + "type": "integer", + "format": "int32" + }, + "typeParameters": { + "type": "array", + "items": { + "type": "object", + "properties": { + "genericDeclaration": { + "type": "object" + }, + "annotatedBounds": { + "type": "array", + "items": { + "type": "object", + "properties": { + "annotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "declaredAnnotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "type": { + "type": "object", + "properties": { + "typeName": { + "type": "string" + } + } + } + } + } + }, + "name": { + "type": "string" + }, + "bounds": { + "type": "array", + "items": { + "type": "object", + "properties": { + "typeName": { + "type": "string" + } + } + } + }, + "typeName": { + "type": "string" + }, + "annotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "declaredAnnotations": { + "type": "array", + "items": { + "type": "object" + } + } + } + } + }, + "synthetic": { + "type": "boolean" + }, + "declaredAnnotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "varArgs": { + "type": "boolean" + }, + "annotatedParameterTypes": { + "type": "array", + "items": { + "type": "object", + "properties": { + "annotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "declaredAnnotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "type": { + "type": "object", + "properties": { + "typeName": { + "type": "string" + } + } + } + } + } + }, + "parameterCount": { + "type": "integer", + "format": "int32" + }, + "parameterAnnotations": { + "type": "array", + "items": { + "type": "array", + "items": { + "type": "object" + } + } + }, + "genericParameterTypes": { + "type": "array", + "items": { + "type": "object", + "properties": { + "typeName": { + "type": "string" + } + } + } + }, + "genericExceptionTypes": { + "type": "array", + "items": { + "type": "object", + "properties": { + "typeName": { + "type": "string" + } + } + } + }, + "annotatedReturnType": { + "type": "object", + "properties": { + "annotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "declaredAnnotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "type": { + "type": "object", + "properties": { + "typeName": { + "type": "string" + } + } + } + } + }, + "annotatedReceiverType": { + "type": "object", + "properties": { + "annotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "declaredAnnotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "type": { + "type": "object", + "properties": { + "typeName": { + "type": "string" + } + } + } + } + }, + "annotatedExceptionTypes": { + "type": "array", + "items": { + "type": "object", + "properties": { + "annotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "declaredAnnotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "type": { + "type": "object", + "properties": { + "typeName": { + "type": "string" + } + } + } + } + } + }, + "annotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "accessible": { + "type": "boolean", + "deprecated": true + } + } + }, + "implicit": { + "type": "boolean" + } + } + } + }, + "annotatedReceiverType": { + "type": "object", + "properties": { + "annotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "declaredAnnotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "type": { + "type": "object", + "properties": { + "typeName": { + "type": "string" + } + } + } + } + }, + "annotatedExceptionTypes": { + "type": "array", + "items": { + "type": "object", + "properties": { + "annotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "declaredAnnotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "type": { + "type": "object", + "properties": { + "typeName": { + "type": "string" + } + } + } + } + } + }, + "annotations": { + "type": "array", + "items": { + "type": "object" + } + } + } + }, + "transformedMethod": { + "$ref": "#/components/schemas/CachedMethod" + }, + "name": { + "type": "string" + }, + "modifiers": { + "type": "integer", + "format": "int32" + }, + "descriptor": { + "type": "string" + }, + "synthetic": { + "type": "boolean" + }, + "static": { + "type": "boolean" + }, + "declaringClass": { + "$ref": "#/components/schemas/CachedClass" + }, + "paramsCount": { + "type": "integer", + "format": "int32" + }, + "paramTypes": { + "$ref": "#/components/schemas/ParameterTypes" + }, + "public": { + "type": "boolean" + }, + "protected": { + "type": "boolean" + }, + "default": { + "type": "boolean" + }, + "abstract": { + "type": "boolean" + }, + "private": { + "type": "boolean" + }, + "cacheable": { + "type": "boolean" + }, + "vargsMethod": { + "type": "boolean" + } + } + }, + "CallSiteClassLoader": { + "type": "object", + "properties": { + "klazz": { + "type": "object", + "properties": { + "enqueued": { + "type": "boolean", + "deprecated": true + } + } + }, + "name": { + "type": "string" + }, + "registeredAsParallelCapable": { + "type": "boolean" + }, + "parent": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "registeredAsParallelCapable": { + "type": "boolean" + }, + "unnamedModule": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "classLoader": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "registeredAsParallelCapable": { + "type": "boolean" + }, + "definedPackages": { + "type": "array", + "items": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "annotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "declaredAnnotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "sealed": { + "type": "boolean" + }, + "specificationTitle": { + "type": "string" + }, + "specificationVersion": { + "type": "string" + }, + "specificationVendor": { + "type": "string" + }, + "implementationTitle": { + "type": "string" + }, + "implementationVersion": { + "type": "string" + }, + "implementationVendor": { + "type": "string" + } + } + } + }, + "defaultAssertionStatus": { + "type": "boolean", + "writeOnly": true + } + } + }, + "descriptor": { + "type": "object", + "properties": { + "open": { + "type": "boolean" + }, + "automatic": { + "type": "boolean" + } + } + }, + "named": { + "type": "boolean" + }, + "annotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "declaredAnnotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "packages": { + "type": "array", + "items": { + "type": "string" + }, + "uniqueItems": true + }, + "nativeAccessEnabled": { + "type": "boolean" + }, + "layer": { + "type": "object" + } + } + }, + "definedPackages": { + "type": "array", + "items": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "annotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "declaredAnnotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "sealed": { + "type": "boolean" + }, + "specificationTitle": { + "type": "string" + }, + "specificationVersion": { + "type": "string" + }, + "specificationVendor": { + "type": "string" + }, + "implementationTitle": { + "type": "string" + }, + "implementationVersion": { + "type": "string" + }, + "implementationVendor": { + "type": "string" + } + } + } + }, + "defaultAssertionStatus": { + "type": "boolean", + "writeOnly": true + } + } + }, + "unnamedModule": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "classLoader": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "registeredAsParallelCapable": { + "type": "boolean" + }, + "definedPackages": { + "type": "array", + "items": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "annotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "declaredAnnotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "sealed": { + "type": "boolean" + }, + "specificationTitle": { + "type": "string" + }, + "specificationVersion": { + "type": "string" + }, + "specificationVendor": { + "type": "string" + }, + "implementationTitle": { + "type": "string" + }, + "implementationVersion": { + "type": "string" + }, + "implementationVendor": { + "type": "string" + } + } + } + }, + "defaultAssertionStatus": { + "type": "boolean", + "writeOnly": true + } + } + }, + "descriptor": { + "type": "object", + "properties": { + "open": { + "type": "boolean" + }, + "automatic": { + "type": "boolean" + } + } + }, + "named": { + "type": "boolean" + }, + "annotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "declaredAnnotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "packages": { + "type": "array", + "items": { + "type": "string" + }, + "uniqueItems": true + }, + "nativeAccessEnabled": { + "type": "boolean" + }, + "layer": { + "type": "object" + } + } + }, + "definedPackages": { + "type": "array", + "items": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "annotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "declaredAnnotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "sealed": { + "type": "boolean" + }, + "specificationTitle": { + "type": "string" + }, + "specificationVersion": { + "type": "string" + }, + "specificationVendor": { + "type": "string" + }, + "implementationTitle": { + "type": "string" + }, + "implementationVersion": { + "type": "string" + }, + "implementationVendor": { + "type": "string" + } + } + } + }, + "defaultAssertionStatus": { + "type": "boolean", + "writeOnly": true + } + } + }, + "Car": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "name": { + "type": "string" + }, + "metaClass": { + "$ref": "#/components/schemas/MetaClass", + "writeOnly": true + } + } + }, + "ClassInfo": { + "type": "object", + "properties": { + "artifactClassLoader": { + "$ref": "#/components/schemas/ClassLoaderForClassArtifacts" + }, + "hash": { + "type": "integer", + "format": "int32" + }, + "version": { + "type": "integer", + "format": "int32" + }, + "strongMetaClass": { + "$ref": "#/components/schemas/MetaClass" + }, + "weakMetaClass": { + "$ref": "#/components/schemas/MetaClass" + }, + "cachedClass": { + "$ref": "#/components/schemas/CachedClass" + }, + "modifiedExpando": { + "$ref": "#/components/schemas/ExpandoMetaClass" + }, + "metaClassForClass": { + "$ref": "#/components/schemas/MetaClass" + } + } + }, + "ClassLoaderForClassArtifacts": { + "type": "object", + "properties": { + "klazz": { + "type": "object", + "properties": { + "enqueued": { + "type": "boolean", + "deprecated": true + } + } + }, + "name": { + "type": "string" + }, + "registeredAsParallelCapable": { + "type": "boolean" + }, + "parent": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "registeredAsParallelCapable": { + "type": "boolean" + }, + "unnamedModule": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "classLoader": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "registeredAsParallelCapable": { + "type": "boolean" + }, + "definedPackages": { + "type": "array", + "items": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "annotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "declaredAnnotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "sealed": { + "type": "boolean" + }, + "specificationTitle": { + "type": "string" + }, + "specificationVersion": { + "type": "string" + }, + "specificationVendor": { + "type": "string" + }, + "implementationTitle": { + "type": "string" + }, + "implementationVersion": { + "type": "string" + }, + "implementationVendor": { + "type": "string" + } + } + } + }, + "defaultAssertionStatus": { + "type": "boolean", + "writeOnly": true + } + } + }, + "descriptor": { + "type": "object", + "properties": { + "open": { + "type": "boolean" + }, + "automatic": { + "type": "boolean" + } + } + }, + "named": { + "type": "boolean" + }, + "annotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "declaredAnnotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "packages": { + "type": "array", + "items": { + "type": "string" + }, + "uniqueItems": true + }, + "nativeAccessEnabled": { + "type": "boolean" + }, + "layer": { + "type": "object" + } + } + }, + "definedPackages": { + "type": "array", + "items": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "annotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "declaredAnnotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "sealed": { + "type": "boolean" + }, + "specificationTitle": { + "type": "string" + }, + "specificationVersion": { + "type": "string" + }, + "specificationVendor": { + "type": "string" + }, + "implementationTitle": { + "type": "string" + }, + "implementationVersion": { + "type": "string" + }, + "implementationVendor": { + "type": "string" + } + } + } + }, + "defaultAssertionStatus": { + "type": "boolean", + "writeOnly": true + } + } + }, + "unnamedModule": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "classLoader": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "registeredAsParallelCapable": { + "type": "boolean" + }, + "definedPackages": { + "type": "array", + "items": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "annotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "declaredAnnotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "sealed": { + "type": "boolean" + }, + "specificationTitle": { + "type": "string" + }, + "specificationVersion": { + "type": "string" + }, + "specificationVendor": { + "type": "string" + }, + "implementationTitle": { + "type": "string" + }, + "implementationVersion": { + "type": "string" + }, + "implementationVendor": { + "type": "string" + } + } + } + }, + "defaultAssertionStatus": { + "type": "boolean", + "writeOnly": true + } + } + }, + "descriptor": { + "type": "object", + "properties": { + "open": { + "type": "boolean" + }, + "automatic": { + "type": "boolean" + } + } + }, + "named": { + "type": "boolean" + }, + "annotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "declaredAnnotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "packages": { + "type": "array", + "items": { + "type": "string" + }, + "uniqueItems": true + }, + "nativeAccessEnabled": { + "type": "boolean" + }, + "layer": { + "type": "object" + } + } + }, + "definedPackages": { + "type": "array", + "items": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "annotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "declaredAnnotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "sealed": { + "type": "boolean" + }, + "specificationTitle": { + "type": "string" + }, + "specificationVersion": { + "type": "string" + }, + "specificationVendor": { + "type": "string" + }, + "implementationTitle": { + "type": "string" + }, + "implementationVersion": { + "type": "string" + }, + "implementationVendor": { + "type": "string" + } + } + } + }, + "defaultAssertionStatus": { + "type": "boolean", + "writeOnly": true + } + } + }, + "ClassNode": { + "type": "object", + "properties": { + "lineNumber": { + "type": "integer", + "format": "int32" + }, + "columnNumber": { + "type": "integer", + "format": "int32" + }, + "lastLineNumber": { + "type": "integer", + "format": "int32" + }, + "lastColumnNumber": { + "type": "integer", + "format": "int32" + }, + "metaDataMap": { + "type": "object", + "additionalProperties": { + "type": "object" + } + }, + "annotations": { + "type": "array", + "items": { + "$ref": "#/components/schemas/AnnotationNode" + } + }, + "declaringClass": { + "$ref": "#/components/schemas/ClassNode" + }, + "synthetic": { + "type": "boolean" + }, + "name": { + "type": "string" + }, + "modifiers": { + "type": "integer", + "format": "int32" + }, + "syntheticPublic": { + "type": "boolean" + }, + "interfaces": { + "type": "array", + "items": { + "$ref": "#/components/schemas/ClassNode" + } + }, + "mixins": { + "type": "array", + "items": { + "$ref": "#/components/schemas/MixinNode" + } + }, + "methods": { + "type": "array", + "items": { + "$ref": "#/components/schemas/MethodNode" + } + }, + "fields": { + "type": "array", + "items": { + "$ref": "#/components/schemas/FieldNode" + } + }, + "properties": { + "type": "array", + "items": { + "$ref": "#/components/schemas/PropertyNode" + } + }, + "fieldIndex": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/FieldNode" + } + }, + "module": { + "$ref": "#/components/schemas/ModuleNode" + }, + "compileUnit": { + "$ref": "#/components/schemas/CompileUnit" + }, + "staticClass": { + "type": "boolean" + }, + "scriptBody": { + "type": "boolean" + }, + "script": { + "type": "boolean" + }, + "superClass": { + "$ref": "#/components/schemas/ClassNode" + }, + "innerClasses": { + "type": "object" + }, + "permittedSubclasses": { + "type": "array", + "items": { + "$ref": "#/components/schemas/ClassNode" + } + }, + "typeAnnotations": { + "type": "array", + "items": { + "$ref": "#/components/schemas/AnnotationNode" + } + }, + "recordComponents": { + "type": "array", + "items": { + "$ref": "#/components/schemas/RecordComponentNode" + } + }, + "componentType": { + "$ref": "#/components/schemas/ClassNode" + }, + "redirect": { + "$ref": "#/components/schemas/ClassNode" + }, + "annotated": { + "type": "boolean" + }, + "genericsTypes": { + "type": "array", + "items": { + "$ref": "#/components/schemas/GenericsType" + } + }, + "enclosingMethod": { + "$ref": "#/components/schemas/MethodNode" + }, + "interface": { + "type": "boolean" + }, + "array": { + "type": "boolean" + }, + "enum": { + "type": "boolean" + }, + "record": { + "type": "boolean" + }, + "packageName": { + "type": "string" + }, + "package": { + "$ref": "#/components/schemas/PackageNode" + }, + "declaredConstructors": { + "type": "array", + "items": { + "$ref": "#/components/schemas/ConstructorNode" + } + }, + "sealed": { + "type": "boolean" + }, + "resolved": { + "type": "boolean" + }, + "abstract": { + "type": "boolean" + }, + "unresolvedName": { + "type": "string" + }, + "text": { + "type": "string" + }, + "objectInitializerStatements": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Statement" + } + }, + "derivedFromGroovyObject": { + "type": "boolean" + }, + "unresolvedSuperClass": { + "$ref": "#/components/schemas/ClassNode" + }, + "unresolvedInterfaces": { + "type": "array", + "items": { + "$ref": "#/components/schemas/ClassNode" + } + }, + "recordComponentNodes": { + "type": "array", + "deprecated": true, + "items": { + "$ref": "#/components/schemas/RecordComponentNode" + } + }, + "outerClass": { + "$ref": "#/components/schemas/ClassNode" + }, + "redirectNode": { + "type": "boolean" + }, + "allDeclaredMethods": { + "type": "array", + "items": { + "$ref": "#/components/schemas/MethodNode" + } + }, + "allInterfaces": { + "type": "array", + "items": { + "$ref": "#/components/schemas/ClassNode" + }, + "uniqueItems": true + }, + "abstractMethods": { + "type": "array", + "items": { + "$ref": "#/components/schemas/MethodNode" + } + }, + "genericsPlaceHolder": { + "type": "boolean" + }, + "primaryClassNode": { + "type": "boolean" + }, + "usingGenerics": { + "type": "boolean" + }, + "declaredMethodsMap": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/MethodNode" + } + }, + "outerClasses": { + "type": "array", + "items": { + "$ref": "#/components/schemas/ClassNode" + } + }, + "nameWithoutPackage": { + "type": "string" + }, + "annotationDefinition": { + "type": "boolean" + }, + "plainNodeReference": { + "$ref": "#/components/schemas/ClassNode" + }, + "instance": { + "$ref": "#/components/schemas/AnnotatedNode" + }, + "hasNoRealSourcePosition": { + "type": "boolean", + "writeOnly": true + }, + "groovydoc": { + "$ref": "#/components/schemas/Groovydoc" + }, + "sourcePosition": { + "$ref": "#/components/schemas/ASTNode", + "writeOnly": true + }, + "nodeMetaData": { + "type": "object", + "additionalProperties": { + "type": "object" + } + } + } + }, + "CompilationCustomizer": { + "type": "object", + "properties": { + "phase": { + "type": "string", + "enum": [ + "INITIALIZATION", + "PARSING", + "CONVERSION", + "SEMANTIC_ANALYSIS", + "CANONICALIZATION", + "INSTRUCTION_SELECTION", + "CLASS_GENERATION", + "OUTPUT", + "FINALIZATION" + ] + } + } + }, + "CompileUnit": { + "type": "object", + "properties": { + "config": { + "$ref": "#/components/schemas/CompilerConfiguration" + }, + "codeSource": { + "type": "object", + "properties": { + "location": { + "type": "string", + "format": "url" + }, + "certificates": { + "type": "array", + "items": { + "type": "object", + "properties": { + "type": { + "type": "string" + }, + "encoded": { + "type": "string", + "format": "byte" + }, + "publicKey": { + "type": "object", + "properties": { + "encoded": { + "type": "string", + "format": "byte" + }, + "format": { + "type": "string" + }, + "algorithm": { + "type": "string" + } + } + } + } + } + }, + "codeSigners": { + "type": "array", + "items": { + "type": "object", + "properties": { + "signerCertPath": { + "type": "object", + "properties": { + "encodings": { + "type": "object" + }, + "certificates": { + "type": "array", + "items": { + "type": "object", + "properties": { + "type": { + "type": "string" + }, + "encoded": { + "type": "string", + "format": "byte" + }, + "publicKey": { + "type": "object", + "properties": { + "encoded": { + "type": "string", + "format": "byte" + }, + "format": { + "type": "string" + }, + "algorithm": { + "type": "string" + } + } + } + } + } + }, + "type": { + "type": "string" + }, + "encoded": { + "type": "string", + "format": "byte" + } + } + }, + "timestamp": { + "type": "object", + "properties": { + "timestamp": { + "type": "string", + "format": "date-time" + }, + "signerCertPath": { + "type": "object", + "properties": { + "encodings": { + "type": "object" + }, + "certificates": { + "type": "array", + "items": { + "type": "object", + "properties": { + "type": { + "type": "string" + }, + "encoded": { + "type": "string", + "format": "byte" + }, + "publicKey": { + "type": "object", + "properties": { + "encoded": { + "type": "string", + "format": "byte" + }, + "format": { + "type": "string" + }, + "algorithm": { + "type": "string" + } + } + } + } + } + }, + "type": { + "type": "string" + }, + "encoded": { + "type": "string", + "format": "byte" + } + } + } + } + } + } + } + } + } + }, + "metaDataMap": { + "type": "object", + "additionalProperties": { + "type": "object" + } + }, + "modules": { + "type": "array", + "items": { + "$ref": "#/components/schemas/ModuleNode" + } + }, + "classes": { + "type": "array", + "items": { + "$ref": "#/components/schemas/ClassNode" + } + }, + "classesToCompile": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/ClassNode" + } + }, + "generatedInnerClasses": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/InnerClassNode" + } + }, + "classLoader": { + "$ref": "#/components/schemas/GroovyClassLoader" + }, + "nodeMetaData": { + "type": "object", + "additionalProperties": { + "type": "object" + } + } + } + }, + "CompilerConfiguration": { + "type": "object", + "properties": { + "warningLevel": { + "type": "integer", + "format": "int32" + }, + "sourceEncoding": { + "type": "string" + }, + "output": { + "type": "object", + "deprecated": true + }, + "targetDirectory": { + "type": "string", + "format": "binary" + }, + "classpath": { + "type": "array", + "items": { + "type": "string" + } + }, + "verbose": { + "type": "boolean" + }, + "debug": { + "type": "boolean" + }, + "parameters": { + "type": "boolean" + }, + "tolerance": { + "type": "integer", + "format": "int32" + }, + "scriptBaseClass": { + "type": "string" + }, + "pluginFactory": { + "$ref": "#/components/schemas/ParserPluginFactory" + }, + "defaultScriptExtension": { + "type": "string" + }, + "scriptExtensions": { + "type": "array", + "items": { + "type": "string" + }, + "uniqueItems": true + }, + "recompileGroovySource": { + "type": "boolean" + }, + "minimumRecompilationInterval": { + "type": "integer", + "format": "int32" + }, + "targetBytecode": { + "type": "string" + }, + "previewFeatures": { + "type": "boolean" + }, + "logClassgen": { + "type": "boolean" + }, + "logClassgenStackTraceMaxDepth": { + "type": "integer", + "format": "int32" + }, + "jointCompilationOptions": { + "type": "object", + "additionalProperties": { + "type": "object" + } + }, + "optimizationOptions": { + "type": "object", + "additionalProperties": { + "type": "boolean" + } + }, + "compilationCustomizers": { + "type": "array", + "items": { + "$ref": "#/components/schemas/CompilationCustomizer" + } + }, + "disabledGlobalASTTransformations": { + "type": "array", + "items": { + "type": "string" + }, + "uniqueItems": true + }, + "bytecodePostprocessor": { + "$ref": "#/components/schemas/BytecodeProcessor" + }, + "targetBytecodeIfValid": { + "type": "string", + "writeOnly": true + }, + "runtimeGroovydocEnabled": { + "type": "boolean" + }, + "indyEnabled": { + "type": "boolean" + }, + "targetDirectorySafe": { + "type": "string", + "writeOnly": true + }, + "classpathList": { + "type": "array", + "items": { + "type": "string" + }, + "writeOnly": true + }, + "bytecodeVersion": { + "type": "integer", + "format": "int32" + }, + "groovydocEnabled": { + "type": "boolean" + } + } + }, + "ConstructorNode": { + "type": "object", + "properties": { + "lineNumber": { + "type": "integer", + "format": "int32" + }, + "columnNumber": { + "type": "integer", + "format": "int32" + }, + "lastLineNumber": { + "type": "integer", + "format": "int32" + }, + "lastColumnNumber": { + "type": "integer", + "format": "int32" + }, + "metaDataMap": { + "type": "object", + "additionalProperties": { + "type": "object" + } + }, + "annotations": { + "type": "array", + "items": { + "$ref": "#/components/schemas/AnnotationNode" + } + }, + "declaringClass": { + "$ref": "#/components/schemas/ClassNode" + }, + "synthetic": { + "type": "boolean" + }, + "name": { + "type": "string" + }, + "modifiers": { + "type": "integer", + "format": "int32" + }, + "syntheticPublic": { + "type": "boolean" + }, + "returnType": { + "$ref": "#/components/schemas/ClassNode" + }, + "parameters": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Parameter" + } + }, + "code": { + "$ref": "#/components/schemas/Statement" + }, + "dynamicReturnType": { + "type": "boolean" + }, + "variableScope": { + "$ref": "#/components/schemas/VariableScope" + }, + "exceptions": { + "type": "array", + "items": { + "$ref": "#/components/schemas/ClassNode" + } + }, + "genericsTypes": { + "type": "array", + "items": { + "$ref": "#/components/schemas/GenericsType" + } + }, + "typeDescriptor": { + "type": "string" + }, + "constructor": { + "type": "boolean" + }, + "final": { + "type": "boolean" + }, + "static": { + "type": "boolean" + }, + "public": { + "type": "boolean" + }, + "protected": { + "type": "boolean" + }, + "default": { + "type": "boolean" + }, + "abstract": { + "type": "boolean" + }, + "private": { + "type": "boolean" + }, + "text": { + "type": "string" + }, + "voidMethod": { + "type": "boolean" + }, + "packageScope": { + "type": "boolean" + }, + "scriptBody": { + "type": "boolean" + }, + "firstStatement": { + "$ref": "#/components/schemas/Statement" + }, + "staticConstructor": { + "type": "boolean" + }, + "annotationDefault": { + "type": "boolean", + "writeOnly": true + }, + "instance": { + "$ref": "#/components/schemas/AnnotatedNode" + }, + "hasNoRealSourcePosition": { + "type": "boolean", + "writeOnly": true + }, + "groovydoc": { + "$ref": "#/components/schemas/Groovydoc" + }, + "sourcePosition": { + "$ref": "#/components/schemas/ASTNode", + "writeOnly": true + }, + "nodeMetaData": { + "type": "object", + "additionalProperties": { + "type": "object" + } + } + } + }, + "ErrorCollector": { + "type": "object", + "properties": { + "errors": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Message" + } + }, + "warnings": { + "type": "array", + "items": { + "$ref": "#/components/schemas/WarningMessage" + } + }, + "configuration": { + "$ref": "#/components/schemas/CompilerConfiguration" + }, + "errorCount": { + "type": "integer", + "format": "int32" + }, + "lastError": { + "$ref": "#/components/schemas/Message" + }, + "warningCount": { + "type": "integer", + "format": "int32" + } + } + }, + "ExpandoMetaClass": { + "type": "object", + "properties": { + "theCachedClass": { + "$ref": "#/components/schemas/CachedClass" + }, + "additionalMetaMethods": { + "type": "array", + "items": { + "$ref": "#/components/schemas/MetaMethod" + } + }, + "registry": { + "$ref": "#/components/schemas/MetaClassRegistry" + }, + "classNode": { + "$ref": "#/components/schemas/ClassNode" + }, + "initialized": { + "type": "boolean", + "writeOnly": true + }, + "permissivePropertyAccess": { + "type": "boolean" + }, + "modified": { + "type": "boolean" + }, + "inRegistry": { + "type": "boolean" + }, + "expandoSubclassMethods": { + "type": "array", + "items": { + "type": "object" + } + }, + "expandoProperties": { + "type": "array", + "items": { + "$ref": "#/components/schemas/MetaProperty" + } + }, + "properties": { + "type": "array", + "items": { + "$ref": "#/components/schemas/MetaProperty" + } + }, + "metaClass": { + "$ref": "#/components/schemas/MetaClass", + "writeOnly": true + }, + "version": { + "type": "integer", + "format": "int32" + }, + "classInfo": { + "$ref": "#/components/schemas/ClassInfo" + }, + "groovyObject": { + "type": "boolean" + }, + "upProperties": { + "type": "array", + "items": { + "type": "object", + "properties": { + "expert": { + "type": "boolean" + }, + "hidden": { + "type": "boolean" + }, + "preferred": { + "type": "boolean" + }, + "shortDescription": { + "type": "string" + }, + "name": { + "type": "string" + }, + "displayName": { + "type": "string" + }, + "bound": { + "type": "boolean" + }, + "constrained": { + "type": "boolean" + }, + "readMethod": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "modifiers": { + "type": "integer", + "format": "int32" + }, + "typeParameters": { + "type": "array", + "items": { + "type": "object", + "properties": { + "annotatedBounds": { + "type": "array", + "items": { + "type": "object", + "properties": { + "annotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "declaredAnnotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "type": { + "type": "object", + "properties": { + "typeName": { + "type": "string" + } + } + } + } + } + }, + "name": { + "type": "string" + }, + "bounds": { + "type": "array", + "items": { + "type": "object", + "properties": { + "typeName": { + "type": "string" + } + } + } + }, + "typeName": { + "type": "string" + }, + "annotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "declaredAnnotations": { + "type": "array", + "items": { + "type": "object" + } + } + } + } + }, + "synthetic": { + "type": "boolean" + }, + "declaredAnnotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "accessible": { + "type": "boolean", + "deprecated": true + }, + "varArgs": { + "type": "boolean" + }, + "parameterCount": { + "type": "integer", + "format": "int32" + }, + "parameterAnnotations": { + "type": "array", + "items": { + "type": "array", + "items": { + "type": "object" + } + } + }, + "genericParameterTypes": { + "type": "array", + "items": { + "type": "object", + "properties": { + "typeName": { + "type": "string" + } + } + } + }, + "genericExceptionTypes": { + "type": "array", + "items": { + "type": "object", + "properties": { + "typeName": { + "type": "string" + } + } + } + }, + "default": { + "type": "boolean" + }, + "genericReturnType": { + "type": "object", + "properties": { + "typeName": { + "type": "string" + } + } + }, + "bridge": { + "type": "boolean" + }, + "defaultValue": { + "type": "object" + }, + "annotatedReturnType": { + "type": "object", + "properties": { + "annotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "declaredAnnotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "type": { + "type": "object", + "properties": { + "typeName": { + "type": "string" + } + } + } + } + }, + "annotatedParameterTypes": { + "type": "array", + "items": { + "type": "object", + "properties": { + "annotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "declaredAnnotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "type": { + "type": "object", + "properties": { + "typeName": { + "type": "string" + } + } + } + } + } + }, + "parameters": { + "type": "array", + "items": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "modifiers": { + "type": "integer", + "format": "int32" + }, + "synthetic": { + "type": "boolean" + }, + "annotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "declaredAnnotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "annotatedType": { + "type": "object", + "properties": { + "annotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "declaredAnnotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "type": { + "type": "object", + "properties": { + "typeName": { + "type": "string" + } + } + } + } + }, + "parameterizedType": { + "type": "object", + "properties": { + "typeName": { + "type": "string" + } + } + }, + "varArgs": { + "type": "boolean" + }, + "namePresent": { + "type": "boolean" + }, + "declaringExecutable": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "modifiers": { + "type": "integer", + "format": "int32" + }, + "typeParameters": { + "type": "array", + "items": { + "type": "object", + "properties": { + "genericDeclaration": { + "type": "object" + }, + "annotatedBounds": { + "type": "array", + "items": { + "type": "object", + "properties": { + "annotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "declaredAnnotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "type": { + "type": "object", + "properties": { + "typeName": { + "type": "string" + } + } + } + } + } + }, + "name": { + "type": "string" + }, + "bounds": { + "type": "array", + "items": { + "type": "object", + "properties": { + "typeName": { + "type": "string" + } + } + } + }, + "typeName": { + "type": "string" + }, + "annotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "declaredAnnotations": { + "type": "array", + "items": { + "type": "object" + } + } + } + } + }, + "synthetic": { + "type": "boolean" + }, + "declaredAnnotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "varArgs": { + "type": "boolean" + }, + "annotatedParameterTypes": { + "type": "array", + "items": { + "type": "object", + "properties": { + "annotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "declaredAnnotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "type": { + "type": "object", + "properties": { + "typeName": { + "type": "string" + } + } + } + } + } + }, + "parameterCount": { + "type": "integer", + "format": "int32" + }, + "parameterAnnotations": { + "type": "array", + "items": { + "type": "array", + "items": { + "type": "object" + } + } + }, + "genericParameterTypes": { + "type": "array", + "items": { + "type": "object", + "properties": { + "typeName": { + "type": "string" + } + } + } + }, + "genericExceptionTypes": { + "type": "array", + "items": { + "type": "object", + "properties": { + "typeName": { + "type": "string" + } + } + } + }, + "annotatedReturnType": { + "type": "object", + "properties": { + "annotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "declaredAnnotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "type": { + "type": "object", + "properties": { + "typeName": { + "type": "string" + } + } + } + } + }, + "annotatedReceiverType": { + "type": "object", + "properties": { + "annotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "declaredAnnotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "type": { + "type": "object", + "properties": { + "typeName": { + "type": "string" + } + } + } + } + }, + "annotatedExceptionTypes": { + "type": "array", + "items": { + "type": "object", + "properties": { + "annotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "declaredAnnotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "type": { + "type": "object", + "properties": { + "typeName": { + "type": "string" + } + } + } + } + } + }, + "annotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "accessible": { + "type": "boolean", + "deprecated": true + } + } + }, + "implicit": { + "type": "boolean" + } + } + } + }, + "annotatedReceiverType": { + "type": "object", + "properties": { + "annotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "declaredAnnotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "type": { + "type": "object", + "properties": { + "typeName": { + "type": "string" + } + } + } + } + }, + "annotatedExceptionTypes": { + "type": "array", + "items": { + "type": "object", + "properties": { + "annotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "declaredAnnotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "type": { + "type": "object", + "properties": { + "typeName": { + "type": "string" + } + } + } + } + } + }, + "annotations": { + "type": "array", + "items": { + "type": "object" + } + } + } + }, + "writeMethod": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "modifiers": { + "type": "integer", + "format": "int32" + }, + "typeParameters": { + "type": "array", + "items": { + "type": "object", + "properties": { + "annotatedBounds": { + "type": "array", + "items": { + "type": "object", + "properties": { + "annotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "declaredAnnotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "type": { + "type": "object", + "properties": { + "typeName": { + "type": "string" + } + } + } + } + } + }, + "name": { + "type": "string" + }, + "bounds": { + "type": "array", + "items": { + "type": "object", + "properties": { + "typeName": { + "type": "string" + } + } + } + }, + "typeName": { + "type": "string" + }, + "annotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "declaredAnnotations": { + "type": "array", + "items": { + "type": "object" + } + } + } + } + }, + "synthetic": { + "type": "boolean" + }, + "declaredAnnotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "accessible": { + "type": "boolean", + "deprecated": true + }, + "varArgs": { + "type": "boolean" + }, + "parameterCount": { + "type": "integer", + "format": "int32" + }, + "parameterAnnotations": { + "type": "array", + "items": { + "type": "array", + "items": { + "type": "object" + } + } + }, + "genericParameterTypes": { + "type": "array", + "items": { + "type": "object", + "properties": { + "typeName": { + "type": "string" + } + } + } + }, + "genericExceptionTypes": { + "type": "array", + "items": { + "type": "object", + "properties": { + "typeName": { + "type": "string" + } + } + } + }, + "default": { + "type": "boolean" + }, + "genericReturnType": { + "type": "object", + "properties": { + "typeName": { + "type": "string" + } + } + }, + "bridge": { + "type": "boolean" + }, + "defaultValue": { + "type": "object" + }, + "annotatedReturnType": { + "type": "object", + "properties": { + "annotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "declaredAnnotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "type": { + "type": "object", + "properties": { + "typeName": { + "type": "string" + } + } + } + } + }, + "annotatedParameterTypes": { + "type": "array", + "items": { + "type": "object", + "properties": { + "annotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "declaredAnnotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "type": { + "type": "object", + "properties": { + "typeName": { + "type": "string" + } + } + } + } + } + }, + "parameters": { + "type": "array", + "items": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "modifiers": { + "type": "integer", + "format": "int32" + }, + "synthetic": { + "type": "boolean" + }, + "annotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "declaredAnnotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "annotatedType": { + "type": "object", + "properties": { + "annotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "declaredAnnotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "type": { + "type": "object", + "properties": { + "typeName": { + "type": "string" + } + } + } + } + }, + "parameterizedType": { + "type": "object", + "properties": { + "typeName": { + "type": "string" + } + } + }, + "varArgs": { + "type": "boolean" + }, + "namePresent": { + "type": "boolean" + }, + "declaringExecutable": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "modifiers": { + "type": "integer", + "format": "int32" + }, + "typeParameters": { + "type": "array", + "items": { + "type": "object", + "properties": { + "genericDeclaration": { + "type": "object" + }, + "annotatedBounds": { + "type": "array", + "items": { + "type": "object", + "properties": { + "annotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "declaredAnnotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "type": { + "type": "object", + "properties": { + "typeName": { + "type": "string" + } + } + } + } + } + }, + "name": { + "type": "string" + }, + "bounds": { + "type": "array", + "items": { + "type": "object", + "properties": { + "typeName": { + "type": "string" + } + } + } + }, + "typeName": { + "type": "string" + }, + "annotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "declaredAnnotations": { + "type": "array", + "items": { + "type": "object" + } + } + } + } + }, + "synthetic": { + "type": "boolean" + }, + "declaredAnnotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "varArgs": { + "type": "boolean" + }, + "annotatedParameterTypes": { + "type": "array", + "items": { + "type": "object", + "properties": { + "annotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "declaredAnnotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "type": { + "type": "object", + "properties": { + "typeName": { + "type": "string" + } + } + } + } + } + }, + "parameterCount": { + "type": "integer", + "format": "int32" + }, + "parameterAnnotations": { + "type": "array", + "items": { + "type": "array", + "items": { + "type": "object" + } + } + }, + "genericParameterTypes": { + "type": "array", + "items": { + "type": "object", + "properties": { + "typeName": { + "type": "string" + } + } + } + }, + "genericExceptionTypes": { + "type": "array", + "items": { + "type": "object", + "properties": { + "typeName": { + "type": "string" + } + } + } + }, + "annotatedReturnType": { + "type": "object", + "properties": { + "annotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "declaredAnnotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "type": { + "type": "object", + "properties": { + "typeName": { + "type": "string" + } + } + } + } + }, + "annotatedReceiverType": { + "type": "object", + "properties": { + "annotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "declaredAnnotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "type": { + "type": "object", + "properties": { + "typeName": { + "type": "string" + } + } + } + } + }, + "annotatedExceptionTypes": { + "type": "array", + "items": { + "type": "object", + "properties": { + "annotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "declaredAnnotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "type": { + "type": "object", + "properties": { + "typeName": { + "type": "string" + } + } + } + } + } + }, + "annotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "accessible": { + "type": "boolean", + "deprecated": true + } + } + }, + "implicit": { + "type": "boolean" + } + } + } + }, + "annotatedReceiverType": { + "type": "object", + "properties": { + "annotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "declaredAnnotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "type": { + "type": "object", + "properties": { + "typeName": { + "type": "string" + } + } + } + } + }, + "annotatedExceptionTypes": { + "type": "array", + "items": { + "type": "object", + "properties": { + "annotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "declaredAnnotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "type": { + "type": "object", + "properties": { + "typeName": { + "type": "string" + } + } + } + } + } + }, + "annotations": { + "type": "array", + "items": { + "type": "object" + } + } + } + } + } + }, + "writeOnly": true + } + } + }, + "Expression": { + "type": "object", + "properties": { + "lineNumber": { + "type": "integer", + "format": "int32" + }, + "columnNumber": { + "type": "integer", + "format": "int32" + }, + "lastLineNumber": { + "type": "integer", + "format": "int32" + }, + "lastColumnNumber": { + "type": "integer", + "format": "int32" + }, + "metaDataMap": { + "type": "object", + "additionalProperties": { + "type": "object" + } + }, + "declaringClass": { + "$ref": "#/components/schemas/ClassNode" + }, + "synthetic": { + "type": "boolean" + }, + "type": { + "$ref": "#/components/schemas/ClassNode" + }, + "instance": { + "$ref": "#/components/schemas/AnnotatedNode" + }, + "hasNoRealSourcePosition": { + "type": "boolean", + "writeOnly": true + }, + "groovydoc": { + "$ref": "#/components/schemas/Groovydoc" + }, + "text": { + "type": "string" + }, + "sourcePosition": { + "$ref": "#/components/schemas/ASTNode", + "writeOnly": true + }, + "nodeMetaData": { + "type": "object", + "additionalProperties": { + "type": "object" + } + } + } + }, + "FieldNode": { + "type": "object", + "properties": { + "lineNumber": { + "type": "integer", + "format": "int32" + }, + "columnNumber": { + "type": "integer", + "format": "int32" + }, + "lastLineNumber": { + "type": "integer", + "format": "int32" + }, + "lastColumnNumber": { + "type": "integer", + "format": "int32" + }, + "metaDataMap": { + "type": "object", + "additionalProperties": { + "type": "object" + } + }, + "annotations": { + "type": "array", + "items": { + "$ref": "#/components/schemas/AnnotationNode" + } + }, + "declaringClass": { + "$ref": "#/components/schemas/ClassNode" + }, + "synthetic": { + "type": "boolean" + }, + "name": { + "type": "string" + }, + "modifiers": { + "type": "integer", + "format": "int32" + }, + "type": { + "$ref": "#/components/schemas/ClassNode" + }, + "owner": { + "$ref": "#/components/schemas/ClassNode" + }, + "initialValueExpression": { + "$ref": "#/components/schemas/Expression" + }, + "dynamicTyped": { + "type": "boolean" + }, + "holder": { + "type": "boolean" + }, + "originType": { + "$ref": "#/components/schemas/ClassNode" + }, + "enum": { + "type": "boolean" + }, + "final": { + "type": "boolean" + }, + "static": { + "type": "boolean" + }, + "public": { + "type": "boolean" + }, + "protected": { + "type": "boolean" + }, + "volatile": { + "type": "boolean" + }, + "private": { + "type": "boolean" + }, + "closureSharedVariable": { + "type": "boolean", + "deprecated": true + }, + "initialExpression": { + "$ref": "#/components/schemas/Expression" + }, + "inStaticContext": { + "type": "boolean" + }, + "instance": { + "$ref": "#/components/schemas/AnnotatedNode" + }, + "hasNoRealSourcePosition": { + "type": "boolean", + "writeOnly": true + }, + "groovydoc": { + "$ref": "#/components/schemas/Groovydoc" + }, + "text": { + "type": "string" + }, + "sourcePosition": { + "$ref": "#/components/schemas/ASTNode", + "writeOnly": true + }, + "nodeMetaData": { + "type": "object", + "additionalProperties": { + "type": "object" + } + } + } + }, + "GenericsType": { + "type": "object", + "properties": { + "lineNumber": { + "type": "integer", + "format": "int32" + }, + "columnNumber": { + "type": "integer", + "format": "int32" + }, + "lastLineNumber": { + "type": "integer", + "format": "int32" + }, + "lastColumnNumber": { + "type": "integer", + "format": "int32" + }, + "metaDataMap": { + "type": "object", + "additionalProperties": { + "type": "object" + } + }, + "name": { + "type": "string" + }, + "type": { + "$ref": "#/components/schemas/ClassNode" + }, + "lowerBound": { + "$ref": "#/components/schemas/ClassNode" + }, + "upperBounds": { + "type": "array", + "items": { + "$ref": "#/components/schemas/ClassNode" + } + }, + "placeholder": { + "type": "boolean" + }, + "resolved": { + "type": "boolean" + }, + "wildcard": { + "type": "boolean" + }, + "text": { + "type": "string" + }, + "sourcePosition": { + "$ref": "#/components/schemas/ASTNode", + "writeOnly": true + }, + "nodeMetaData": { + "type": "object", + "additionalProperties": { + "type": "object" + } + } + } + }, + "GroovyClassLoader": { + "type": "object", + "properties": { + "resourceLoader": { + "$ref": "#/components/schemas/GroovyResourceLoader" + }, + "shouldRecompile": { + "type": "boolean" + }, + "urls": { + "type": "array", + "items": { + "type": "string", + "format": "url" + } + }, + "name": { + "type": "string" + }, + "registeredAsParallelCapable": { + "type": "boolean" + }, + "parent": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "registeredAsParallelCapable": { + "type": "boolean" + }, + "unnamedModule": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "classLoader": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "registeredAsParallelCapable": { + "type": "boolean" + }, + "definedPackages": { + "type": "array", + "items": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "annotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "declaredAnnotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "sealed": { + "type": "boolean" + }, + "specificationTitle": { + "type": "string" + }, + "specificationVersion": { + "type": "string" + }, + "specificationVendor": { + "type": "string" + }, + "implementationTitle": { + "type": "string" + }, + "implementationVersion": { + "type": "string" + }, + "implementationVendor": { + "type": "string" + } + } + } + }, + "defaultAssertionStatus": { + "type": "boolean", + "writeOnly": true + } + } + }, + "descriptor": { + "type": "object", + "properties": { + "open": { + "type": "boolean" + }, + "automatic": { + "type": "boolean" + } + } + }, + "named": { + "type": "boolean" + }, + "annotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "declaredAnnotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "packages": { + "type": "array", + "items": { + "type": "string" + }, + "uniqueItems": true + }, + "nativeAccessEnabled": { + "type": "boolean" + }, + "layer": { + "type": "object" + } + } + }, + "definedPackages": { + "type": "array", + "items": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "annotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "declaredAnnotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "sealed": { + "type": "boolean" + }, + "specificationTitle": { + "type": "string" + }, + "specificationVersion": { + "type": "string" + }, + "specificationVendor": { + "type": "string" + }, + "implementationTitle": { + "type": "string" + }, + "implementationVersion": { + "type": "string" + }, + "implementationVendor": { + "type": "string" + } + } + } + }, + "defaultAssertionStatus": { + "type": "boolean", + "writeOnly": true + } + } + }, + "unnamedModule": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "classLoader": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "registeredAsParallelCapable": { + "type": "boolean" + }, + "definedPackages": { + "type": "array", + "items": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "annotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "declaredAnnotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "sealed": { + "type": "boolean" + }, + "specificationTitle": { + "type": "string" + }, + "specificationVersion": { + "type": "string" + }, + "specificationVendor": { + "type": "string" + }, + "implementationTitle": { + "type": "string" + }, + "implementationVersion": { + "type": "string" + }, + "implementationVendor": { + "type": "string" + } + } + } + }, + "defaultAssertionStatus": { + "type": "boolean", + "writeOnly": true + } + } + }, + "descriptor": { + "type": "object", + "properties": { + "open": { + "type": "boolean" + }, + "automatic": { + "type": "boolean" + } + } + }, + "named": { + "type": "boolean" + }, + "annotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "declaredAnnotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "packages": { + "type": "array", + "items": { + "type": "string" + }, + "uniqueItems": true + }, + "nativeAccessEnabled": { + "type": "boolean" + }, + "layer": { + "type": "object" + } + } + }, + "definedPackages": { + "type": "array", + "items": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "annotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "declaredAnnotations": { + "type": "array", + "items": { + "type": "object" + } + }, + "sealed": { + "type": "boolean" + }, + "specificationTitle": { + "type": "string" + }, + "specificationVersion": { + "type": "string" + }, + "specificationVendor": { + "type": "string" + }, + "implementationTitle": { + "type": "string" + }, + "implementationVersion": { + "type": "string" + }, + "implementationVendor": { + "type": "string" + } + } + } + }, + "defaultAssertionStatus": { + "type": "boolean", + "writeOnly": true + } + } + }, + "GroovyResourceLoader": { + "type": "object" + }, + "Groovydoc": { + "type": "object", + "properties": { + "content": { + "type": "string" + }, + "tagList": { + "type": "array", + "items": { + "$ref": "#/components/schemas/GroovydocTag" + } + }, + "holder": { + "$ref": "#/components/schemas/GroovydocHolder" + }, + "present": { + "type": "boolean" + } + } + }, + "GroovydocHolder": { + "type": "object", + "properties": { + "instance": { + "type": "object" + }, + "groovydoc": { + "$ref": "#/components/schemas/Groovydoc" + } + } + }, + "GroovydocTag": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "content": { + "type": "string" + }, + "groovydoc": { + "$ref": "#/components/schemas/Groovydoc" + } + } + }, + "ImportNode": { + "type": "object", + "properties": { + "lineNumber": { + "type": "integer", + "format": "int32" + }, + "columnNumber": { + "type": "integer", + "format": "int32" + }, + "lastLineNumber": { + "type": "integer", + "format": "int32" + }, + "lastColumnNumber": { + "type": "integer", + "format": "int32" + }, + "metaDataMap": { + "type": "object", + "additionalProperties": { + "type": "object" + } + }, + "annotations": { + "type": "array", + "items": { + "$ref": "#/components/schemas/AnnotationNode" + } + }, + "declaringClass": { + "$ref": "#/components/schemas/ClassNode" + }, + "synthetic": { + "type": "boolean" + }, + "type": { + "$ref": "#/components/schemas/ClassNode" + }, + "alias": { + "type": "string" + }, + "fieldName": { + "type": "string" + }, + "packageName": { + "type": "string" + }, + "static": { + "type": "boolean" + }, + "className": { + "type": "string" + }, + "text": { + "type": "string" + }, + "star": { + "type": "boolean" + }, + "instance": { + "$ref": "#/components/schemas/AnnotatedNode" + }, + "hasNoRealSourcePosition": { + "type": "boolean", + "writeOnly": true + }, + "groovydoc": { + "$ref": "#/components/schemas/Groovydoc" + }, + "sourcePosition": { + "$ref": "#/components/schemas/ASTNode", + "writeOnly": true + }, + "nodeMetaData": { + "type": "object", + "additionalProperties": { + "type": "object" + } + } + } + }, + "InnerClassNode": { + "type": "object", + "properties": { + "lineNumber": { + "type": "integer", + "format": "int32" + }, + "columnNumber": { + "type": "integer", + "format": "int32" + }, + "lastLineNumber": { + "type": "integer", + "format": "int32" + }, + "lastColumnNumber": { + "type": "integer", + "format": "int32" + }, + "metaDataMap": { + "type": "object", + "additionalProperties": { + "type": "object" + } + }, + "annotations": { + "type": "array", + "items": { + "$ref": "#/components/schemas/AnnotationNode" + } + }, + "declaringClass": { + "$ref": "#/components/schemas/ClassNode" + }, + "synthetic": { + "type": "boolean" + }, + "name": { + "type": "string" + }, + "modifiers": { + "type": "integer", + "format": "int32" + }, + "syntheticPublic": { + "type": "boolean" + }, + "interfaces": { + "type": "array", + "items": { + "$ref": "#/components/schemas/ClassNode" + } + }, + "methods": { + "type": "array", + "items": { + "$ref": "#/components/schemas/MethodNode" + } + }, + "fields": { + "type": "array", + "items": { + "$ref": "#/components/schemas/FieldNode" + } + }, + "properties": { + "type": "array", + "items": { + "$ref": "#/components/schemas/PropertyNode" + } + }, + "fieldIndex": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/FieldNode" + } + }, + "module": { + "$ref": "#/components/schemas/ModuleNode" + }, + "compileUnit": { + "$ref": "#/components/schemas/CompileUnit" + }, + "staticClass": { + "type": "boolean" + }, + "scriptBody": { + "type": "boolean" + }, + "script": { + "type": "boolean" + }, + "superClass": { + "$ref": "#/components/schemas/ClassNode" + }, + "innerClasses": { + "type": "object" + }, + "permittedSubclasses": { + "type": "array", + "items": { + "$ref": "#/components/schemas/ClassNode" + } + }, + "typeAnnotations": { + "type": "array", + "items": { + "$ref": "#/components/schemas/AnnotationNode" + } + }, + "recordComponents": { + "type": "array", + "items": { + "$ref": "#/components/schemas/RecordComponentNode" + } + }, + "componentType": { + "$ref": "#/components/schemas/ClassNode" + }, + "redirect": { + "$ref": "#/components/schemas/ClassNode" + }, + "annotated": { + "type": "boolean" + }, + "genericsTypes": { + "type": "array", + "items": { + "$ref": "#/components/schemas/GenericsType" + } + }, + "enclosingMethod": { + "$ref": "#/components/schemas/MethodNode" + }, + "outerClass": { + "$ref": "#/components/schemas/ClassNode" + }, + "anonymous": { + "type": "boolean" + }, + "outerMostClass": { + "$ref": "#/components/schemas/ClassNode" + }, + "variableScope": { + "$ref": "#/components/schemas/VariableScope" + }, + "interface": { + "type": "boolean" + }, + "array": { + "type": "boolean" + }, + "enum": { + "type": "boolean" + }, + "record": { + "type": "boolean" + }, + "packageName": { + "type": "string" + }, + "package": { + "$ref": "#/components/schemas/PackageNode" + }, + "declaredConstructors": { + "type": "array", + "items": { + "$ref": "#/components/schemas/ConstructorNode" + } + }, + "sealed": { + "type": "boolean" + }, + "resolved": { + "type": "boolean" + }, + "abstract": { + "type": "boolean" + }, + "unresolvedName": { + "type": "string" + }, + "text": { + "type": "string" + }, + "objectInitializerStatements": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Statement" + } + }, + "derivedFromGroovyObject": { + "type": "boolean" + }, + "unresolvedSuperClass": { + "$ref": "#/components/schemas/ClassNode" + }, + "unresolvedInterfaces": { + "type": "array", + "items": { + "$ref": "#/components/schemas/ClassNode" + } + }, + "recordComponentNodes": { + "type": "array", + "deprecated": true, + "items": { + "$ref": "#/components/schemas/RecordComponentNode" + } + }, + "redirectNode": { + "type": "boolean" + }, + "allDeclaredMethods": { + "type": "array", + "items": { + "$ref": "#/components/schemas/MethodNode" + } + }, + "allInterfaces": { + "type": "array", + "items": { + "$ref": "#/components/schemas/ClassNode" + }, + "uniqueItems": true + }, + "abstractMethods": { + "type": "array", + "items": { + "$ref": "#/components/schemas/MethodNode" + } + }, + "genericsPlaceHolder": { + "type": "boolean" + }, + "primaryClassNode": { + "type": "boolean" + }, + "usingGenerics": { + "type": "boolean" + }, + "declaredMethodsMap": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/MethodNode" + } + }, + "outerClasses": { + "type": "array", + "items": { + "$ref": "#/components/schemas/ClassNode" + } + }, + "nameWithoutPackage": { + "type": "string" + }, + "annotationDefinition": { + "type": "boolean" + }, + "plainNodeReference": { + "$ref": "#/components/schemas/ClassNode" + }, + "instance": { + "$ref": "#/components/schemas/AnnotatedNode" + }, + "hasNoRealSourcePosition": { + "type": "boolean", + "writeOnly": true + }, + "groovydoc": { + "$ref": "#/components/schemas/Groovydoc" + }, + "sourcePosition": { + "$ref": "#/components/schemas/ASTNode", + "writeOnly": true + }, + "nodeMetaData": { + "type": "object", + "additionalProperties": { + "type": "object" + } + } + } + }, + "Message": { + "type": "object" + }, + "MetaClass": { + "type": "object", + "properties": { + "methods": { + "type": "array", + "items": { + "$ref": "#/components/schemas/MetaMethod" + } + }, + "properties": { + "type": "array", + "items": { + "$ref": "#/components/schemas/MetaProperty" + } + }, + "classNode": { + "$ref": "#/components/schemas/ClassNode" + }, + "metaMethods": { + "type": "array", + "items": { + "$ref": "#/components/schemas/MetaMethod" + } + } + } + }, + "MetaClassCreationHandle": { + "type": "object", + "properties": { + "disableCustomMetaClassLookup": { + "type": "boolean" + } + } + }, + "MetaClassRegistry": { + "type": "object", + "properties": { + "metaClassCreationHandler": { + "$ref": "#/components/schemas/MetaClassCreationHandle" + }, + "metaClassCreationHandle": { + "$ref": "#/components/schemas/MetaClassCreationHandle", + "writeOnly": true + }, + "metaClassRegistryChangeEventListeners": { + "type": "array", + "items": { + "$ref": "#/components/schemas/MetaClassRegistryChangeEventListener" + } + } + } + }, + "MetaClassRegistryChangeEventListener": { + "type": "object" + }, + "MetaMethod": { + "type": "object", + "properties": { + "parameterTypes": { + "type": "array", + "items": { + "$ref": "#/components/schemas/CachedClass" + } + }, + "signature": { + "type": "string" + }, + "mopName": { + "type": "string" + }, + "name": { + "type": "string" + }, + "modifiers": { + "type": "integer", + "format": "int32" + }, + "descriptor": { + "type": "string" + }, + "static": { + "type": "boolean" + }, + "declaringClass": { + "$ref": "#/components/schemas/CachedClass" + }, + "public": { + "type": "boolean" + }, + "protected": { + "type": "boolean" + }, + "default": { + "type": "boolean" + }, + "abstract": { + "type": "boolean" + }, + "private": { + "type": "boolean" + }, + "cacheable": { + "type": "boolean" + }, + "vargsMethod": { + "type": "boolean" + }, + "parametersTypes": { + "type": "array", + "items": { + "$ref": "#/components/schemas/CachedClass" + }, + "writeOnly": true + } + } + }, + "MetaProperty": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "modifiers": { + "type": "integer", + "format": "int32" + } + } + }, + "MethodNode": { + "type": "object", + "properties": { + "lineNumber": { + "type": "integer", + "format": "int32" + }, + "columnNumber": { + "type": "integer", + "format": "int32" + }, + "lastLineNumber": { + "type": "integer", + "format": "int32" + }, + "lastColumnNumber": { + "type": "integer", + "format": "int32" + }, + "metaDataMap": { + "type": "object", + "additionalProperties": { + "type": "object" + } + }, + "annotations": { + "type": "array", + "items": { + "$ref": "#/components/schemas/AnnotationNode" + } + }, + "declaringClass": { + "$ref": "#/components/schemas/ClassNode" + }, + "synthetic": { + "type": "boolean" + }, + "name": { + "type": "string" + }, + "modifiers": { + "type": "integer", + "format": "int32" + }, + "syntheticPublic": { + "type": "boolean" + }, + "returnType": { + "$ref": "#/components/schemas/ClassNode" + }, + "parameters": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Parameter" + } + }, + "code": { + "$ref": "#/components/schemas/Statement" + }, + "dynamicReturnType": { + "type": "boolean" + }, + "variableScope": { + "$ref": "#/components/schemas/VariableScope" + }, + "exceptions": { + "type": "array", + "items": { + "$ref": "#/components/schemas/ClassNode" + } + }, + "genericsTypes": { + "type": "array", + "items": { + "$ref": "#/components/schemas/GenericsType" + } + }, + "typeDescriptor": { + "type": "string" + }, + "constructor": { + "type": "boolean" + }, + "final": { + "type": "boolean" + }, + "static": { + "type": "boolean" + }, + "public": { + "type": "boolean" + }, + "protected": { + "type": "boolean" + }, + "default": { + "type": "boolean" + }, + "abstract": { + "type": "boolean" + }, + "private": { + "type": "boolean" + }, + "text": { + "type": "string" + }, + "voidMethod": { + "type": "boolean" + }, + "packageScope": { + "type": "boolean" + }, + "scriptBody": { + "type": "boolean" + }, + "firstStatement": { + "$ref": "#/components/schemas/Statement" + }, + "staticConstructor": { + "type": "boolean" + }, + "annotationDefault": { + "type": "boolean", + "writeOnly": true + }, + "instance": { + "$ref": "#/components/schemas/AnnotatedNode" + }, + "hasNoRealSourcePosition": { + "type": "boolean", + "writeOnly": true + }, + "groovydoc": { + "$ref": "#/components/schemas/Groovydoc" + }, + "sourcePosition": { + "$ref": "#/components/schemas/ASTNode", + "writeOnly": true + }, + "nodeMetaData": { + "type": "object", + "additionalProperties": { + "type": "object" + } + } + } + }, + "MixinNode": { + "type": "object", + "properties": { + "lineNumber": { + "type": "integer", + "format": "int32" + }, + "columnNumber": { + "type": "integer", + "format": "int32" + }, + "lastLineNumber": { + "type": "integer", + "format": "int32" + }, + "lastColumnNumber": { + "type": "integer", + "format": "int32" + }, + "metaDataMap": { + "type": "object", + "additionalProperties": { + "type": "object" + } + }, + "annotations": { + "type": "array", + "items": { + "$ref": "#/components/schemas/AnnotationNode" + } + }, + "declaringClass": { + "$ref": "#/components/schemas/ClassNode" + }, + "synthetic": { + "type": "boolean" + }, + "name": { + "type": "string" + }, + "modifiers": { + "type": "integer", + "format": "int32" + }, + "syntheticPublic": { + "type": "boolean" + }, + "interfaces": { + "type": "array", + "items": { + "$ref": "#/components/schemas/ClassNode" + } + }, + "methods": { + "type": "array", + "items": { + "$ref": "#/components/schemas/MethodNode" + } + }, + "fields": { + "type": "array", + "items": { + "$ref": "#/components/schemas/FieldNode" + } + }, + "properties": { + "type": "array", + "items": { + "$ref": "#/components/schemas/PropertyNode" + } + }, + "fieldIndex": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/FieldNode" + } + }, + "module": { + "$ref": "#/components/schemas/ModuleNode" + }, + "compileUnit": { + "$ref": "#/components/schemas/CompileUnit" + }, + "staticClass": { + "type": "boolean" + }, + "scriptBody": { + "type": "boolean" + }, + "script": { + "type": "boolean" + }, + "superClass": { + "$ref": "#/components/schemas/ClassNode" + }, + "innerClasses": { + "type": "object" + }, + "permittedSubclasses": { + "type": "array", + "items": { + "$ref": "#/components/schemas/ClassNode" + } + }, + "typeAnnotations": { + "type": "array", + "items": { + "$ref": "#/components/schemas/AnnotationNode" + } + }, + "recordComponents": { + "type": "array", + "items": { + "$ref": "#/components/schemas/RecordComponentNode" + } + }, + "componentType": { + "$ref": "#/components/schemas/ClassNode" + }, + "redirect": { + "$ref": "#/components/schemas/ClassNode" + }, + "annotated": { + "type": "boolean" + }, + "genericsTypes": { + "type": "array", + "items": { + "$ref": "#/components/schemas/GenericsType" + } + }, + "enclosingMethod": { + "$ref": "#/components/schemas/MethodNode" + }, + "interface": { + "type": "boolean" + }, + "array": { + "type": "boolean" + }, + "enum": { + "type": "boolean" + }, + "record": { + "type": "boolean" + }, + "packageName": { + "type": "string" + }, + "package": { + "$ref": "#/components/schemas/PackageNode" + }, + "declaredConstructors": { + "type": "array", + "items": { + "$ref": "#/components/schemas/ConstructorNode" + } + }, + "sealed": { + "type": "boolean" + }, + "resolved": { + "type": "boolean" + }, + "abstract": { + "type": "boolean" + }, + "unresolvedName": { + "type": "string" + }, + "text": { + "type": "string" + }, + "objectInitializerStatements": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Statement" + } + }, + "derivedFromGroovyObject": { + "type": "boolean" + }, + "unresolvedSuperClass": { + "$ref": "#/components/schemas/ClassNode" + }, + "unresolvedInterfaces": { + "type": "array", + "items": { + "$ref": "#/components/schemas/ClassNode" + } + }, + "recordComponentNodes": { + "type": "array", + "deprecated": true, + "items": { + "$ref": "#/components/schemas/RecordComponentNode" + } + }, + "outerClass": { + "$ref": "#/components/schemas/ClassNode" + }, + "redirectNode": { + "type": "boolean" + }, + "allDeclaredMethods": { + "type": "array", + "items": { + "$ref": "#/components/schemas/MethodNode" + } + }, + "allInterfaces": { + "type": "array", + "items": { + "$ref": "#/components/schemas/ClassNode" + }, + "uniqueItems": true + }, + "abstractMethods": { + "type": "array", + "items": { + "$ref": "#/components/schemas/MethodNode" + } + }, + "genericsPlaceHolder": { + "type": "boolean" + }, + "primaryClassNode": { + "type": "boolean" + }, + "usingGenerics": { + "type": "boolean" + }, + "declaredMethodsMap": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/MethodNode" + } + }, + "outerClasses": { + "type": "array", + "items": { + "$ref": "#/components/schemas/ClassNode" + } + }, + "nameWithoutPackage": { + "type": "string" + }, + "annotationDefinition": { + "type": "boolean" + }, + "plainNodeReference": { + "$ref": "#/components/schemas/ClassNode" + }, + "instance": { + "$ref": "#/components/schemas/AnnotatedNode" + }, + "hasNoRealSourcePosition": { + "type": "boolean", + "writeOnly": true + }, + "groovydoc": { + "$ref": "#/components/schemas/Groovydoc" + }, + "sourcePosition": { + "$ref": "#/components/schemas/ASTNode", + "writeOnly": true + }, + "nodeMetaData": { + "type": "object", + "additionalProperties": { + "type": "object" + } + } + } + }, + "ModuleNode": { + "type": "object", + "properties": { + "lineNumber": { + "type": "integer", + "format": "int32" + }, + "columnNumber": { + "type": "integer", + "format": "int32" + }, + "lastLineNumber": { + "type": "integer", + "format": "int32" + }, + "lastColumnNumber": { + "type": "integer", + "format": "int32" + }, + "metaDataMap": { + "type": "object", + "additionalProperties": { + "type": "object" + } + }, + "classes": { + "type": "array", + "items": { + "$ref": "#/components/schemas/ClassNode" + } + }, + "methods": { + "type": "array", + "items": { + "$ref": "#/components/schemas/MethodNode" + } + }, + "imports": { + "type": "array", + "items": { + "$ref": "#/components/schemas/ImportNode" + } + }, + "starImports": { + "type": "array", + "items": { + "$ref": "#/components/schemas/ImportNode" + } + }, + "staticImports": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/ImportNode" + } + }, + "staticStarImports": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/ImportNode" + } + }, + "unit": { + "$ref": "#/components/schemas/CompileUnit" + }, + "description": { + "type": "string" + }, + "importsResolved": { + "type": "boolean", + "writeOnly": true + }, + "mainClassName": { + "type": "string" + }, + "statementBlock": { + "$ref": "#/components/schemas/BlockStatement" + }, + "packageName": { + "type": "string" + }, + "empty": { + "type": "boolean" + }, + "package": { + "$ref": "#/components/schemas/PackageNode" + }, + "context": { + "$ref": "#/components/schemas/SourceUnit" + }, + "scriptBaseClassFromConfig": { + "$ref": "#/components/schemas/ClassNode" + }, + "scriptClassDummy": { + "$ref": "#/components/schemas/ClassNode" + }, + "text": { + "type": "string" + }, + "sourcePosition": { + "$ref": "#/components/schemas/ASTNode", + "writeOnly": true + }, + "nodeMetaData": { + "type": "object", + "additionalProperties": { + "type": "object" + } + } + } + }, + "PackageNode": { + "type": "object", + "properties": { + "lineNumber": { + "type": "integer", + "format": "int32" + }, + "columnNumber": { + "type": "integer", + "format": "int32" + }, + "lastLineNumber": { + "type": "integer", + "format": "int32" + }, + "lastColumnNumber": { + "type": "integer", + "format": "int32" + }, + "metaDataMap": { + "type": "object", + "additionalProperties": { + "type": "object" + } + }, + "annotations": { + "type": "array", + "items": { + "$ref": "#/components/schemas/AnnotationNode" + } + }, + "declaringClass": { + "$ref": "#/components/schemas/ClassNode" + }, + "synthetic": { + "type": "boolean" + }, + "name": { + "type": "string" + }, + "text": { + "type": "string" + }, + "instance": { + "$ref": "#/components/schemas/AnnotatedNode" + }, + "hasNoRealSourcePosition": { + "type": "boolean", + "writeOnly": true + }, + "groovydoc": { + "$ref": "#/components/schemas/Groovydoc" + }, + "sourcePosition": { + "$ref": "#/components/schemas/ASTNode", + "writeOnly": true + }, + "nodeMetaData": { + "type": "object", + "additionalProperties": { + "type": "object" + } + } + } + }, + "Parameter": { + "type": "object", + "properties": { + "lineNumber": { + "type": "integer", + "format": "int32" + }, + "columnNumber": { + "type": "integer", + "format": "int32" + }, + "lastLineNumber": { + "type": "integer", + "format": "int32" + }, + "lastColumnNumber": { + "type": "integer", + "format": "int32" + }, + "metaDataMap": { + "type": "object", + "additionalProperties": { + "type": "object" + } + }, + "annotations": { + "type": "array", + "items": { + "$ref": "#/components/schemas/AnnotationNode" + } + }, + "declaringClass": { + "$ref": "#/components/schemas/ClassNode" + }, + "synthetic": { + "type": "boolean" + }, + "type": { + "$ref": "#/components/schemas/ClassNode" + }, + "name": { + "type": "string" + }, + "originType": { + "$ref": "#/components/schemas/ClassNode" + }, + "dynamicTyped": { + "type": "boolean" + }, + "defaultValue": { + "$ref": "#/components/schemas/Expression" + }, + "inStaticContext": { + "type": "boolean" + }, + "modifiers": { + "type": "integer", + "format": "int32" + }, + "closureSharedVariable": { + "type": "boolean" + }, + "initialExpression": { + "$ref": "#/components/schemas/Expression" + }, + "instance": { + "$ref": "#/components/schemas/AnnotatedNode" + }, + "hasNoRealSourcePosition": { + "type": "boolean", + "writeOnly": true + }, + "groovydoc": { + "$ref": "#/components/schemas/Groovydoc" + }, + "text": { + "type": "string" + }, + "sourcePosition": { + "$ref": "#/components/schemas/ASTNode", + "writeOnly": true + }, + "nodeMetaData": { + "type": "object", + "additionalProperties": { + "type": "object" + } + } + } + }, + "ParameterTypes": { + "type": "object", + "properties": { + "vargsMethod": { + "type": "boolean" + } + } + }, + "ParserPluginFactory": { + "type": "object" + }, + "PropertyNode": { + "type": "object", + "properties": { + "lineNumber": { + "type": "integer", + "format": "int32" + }, + "columnNumber": { + "type": "integer", + "format": "int32" + }, + "lastLineNumber": { + "type": "integer", + "format": "int32" + }, + "lastColumnNumber": { + "type": "integer", + "format": "int32" + }, + "metaDataMap": { + "type": "object", + "additionalProperties": { + "type": "object" + } + }, + "annotations": { + "type": "array", + "items": { + "$ref": "#/components/schemas/AnnotationNode" + } + }, + "declaringClass": { + "$ref": "#/components/schemas/ClassNode" + }, + "synthetic": { + "type": "boolean" + }, + "field": { + "$ref": "#/components/schemas/FieldNode" + }, + "getterBlock": { + "$ref": "#/components/schemas/Statement" + }, + "setterBlock": { + "$ref": "#/components/schemas/Statement" + }, + "getterName": { + "type": "string" + }, + "setterName": { + "type": "string" + }, + "modifiers": { + "type": "integer", + "format": "int32" + }, + "type": { + "$ref": "#/components/schemas/ClassNode" + }, + "name": { + "type": "string" + }, + "static": { + "type": "boolean" + }, + "public": { + "type": "boolean" + }, + "private": { + "type": "boolean" + }, + "closureSharedVariable": { + "type": "boolean", + "deprecated": true + }, + "dynamicTyped": { + "type": "boolean" + }, + "originType": { + "$ref": "#/components/schemas/ClassNode" + }, + "getterNameOrDefault": { + "type": "string" + }, + "setterNameOrDefault": { + "type": "string" + }, + "initialExpression": { + "$ref": "#/components/schemas/Expression" + }, + "inStaticContext": { + "type": "boolean" + }, + "instance": { + "$ref": "#/components/schemas/AnnotatedNode" + }, + "hasNoRealSourcePosition": { + "type": "boolean", + "writeOnly": true + }, + "groovydoc": { + "$ref": "#/components/schemas/Groovydoc" + }, + "text": { + "type": "string" + }, + "sourcePosition": { + "$ref": "#/components/schemas/ASTNode", + "writeOnly": true + }, + "nodeMetaData": { + "type": "object", + "additionalProperties": { + "type": "object" + } + } + } + }, + "ReaderSource": { + "type": "object", + "properties": { + "uri": { + "type": "string", + "format": "uri" + }, + "reader": { + "type": "object" + } + } + }, + "RecordComponentNode": { + "type": "object", + "properties": { + "lineNumber": { + "type": "integer", + "format": "int32" + }, + "columnNumber": { + "type": "integer", + "format": "int32" + }, + "lastLineNumber": { + "type": "integer", + "format": "int32" + }, + "lastColumnNumber": { + "type": "integer", + "format": "int32" + }, + "metaDataMap": { + "type": "object", + "additionalProperties": { + "type": "object" + } + }, + "annotations": { + "type": "array", + "items": { + "$ref": "#/components/schemas/AnnotationNode" + } + }, + "declaringClass": { + "$ref": "#/components/schemas/ClassNode" + }, + "synthetic": { + "type": "boolean" + }, + "name": { + "type": "string" + }, + "type": { + "$ref": "#/components/schemas/ClassNode" + }, + "instance": { + "$ref": "#/components/schemas/AnnotatedNode" + }, + "hasNoRealSourcePosition": { + "type": "boolean", + "writeOnly": true + }, + "groovydoc": { + "$ref": "#/components/schemas/Groovydoc" + }, + "text": { + "type": "string" + }, + "sourcePosition": { + "$ref": "#/components/schemas/ASTNode", + "writeOnly": true + }, + "nodeMetaData": { + "type": "object", + "additionalProperties": { + "type": "object" + } + } + } + }, + "Reduction": { + "type": "object", + "properties": { + "empty": { + "type": "boolean" + }, + "root": { + "$ref": "#/components/schemas/Token" + }, + "anExpression": { + "type": "boolean" + }, + "type": { + "type": "integer", + "format": "int32" + }, + "description": { + "type": "string" + }, + "startLine": { + "type": "integer", + "format": "int32" + }, + "startColumn": { + "type": "integer", + "format": "int32" + }, + "meaning": { + "type": "integer", + "format": "int32" + }, + "rootText": { + "type": "string" + } + } + }, + "SourceUnit": { + "type": "object", + "properties": { + "phase": { + "type": "integer", + "format": "int32" + }, + "phaseComplete": { + "type": "boolean" + }, + "configuration": { + "$ref": "#/components/schemas/CompilerConfiguration" + }, + "classLoader": { + "$ref": "#/components/schemas/GroovyClassLoader" + }, + "errorCollector": { + "$ref": "#/components/schemas/ErrorCollector" + }, + "source": { + "$ref": "#/components/schemas/ReaderSource" + }, + "name": { + "type": "string" + }, + "cst": { + "$ref": "#/components/schemas/Reduction" + }, + "ast": { + "$ref": "#/components/schemas/ModuleNode" + }, + "phaseDescription": { + "type": "string" + } + } + }, + "Statement": { + "type": "object", + "properties": { + "lineNumber": { + "type": "integer", + "format": "int32" + }, + "columnNumber": { + "type": "integer", + "format": "int32" + }, + "lastLineNumber": { + "type": "integer", + "format": "int32" + }, + "lastColumnNumber": { + "type": "integer", + "format": "int32" + }, + "metaDataMap": { + "type": "object", + "additionalProperties": { + "type": "object" + } + }, + "statementLabels": { + "type": "array", + "items": { + "type": "string" + } + }, + "empty": { + "type": "boolean" + }, + "statementLabel": { + "type": "string", + "deprecated": true + }, + "text": { + "type": "string" + }, + "sourcePosition": { + "$ref": "#/components/schemas/ASTNode", + "writeOnly": true + }, + "nodeMetaData": { + "type": "object", + "additionalProperties": { + "type": "object" + } + } + } + }, + "Token": { + "type": "object", + "properties": { + "type": { + "type": "integer", + "format": "int32" + }, + "meaning": { + "type": "integer", + "format": "int32" + }, + "text": { + "type": "string" + }, + "startLine": { + "type": "integer", + "format": "int32" + }, + "startColumn": { + "type": "integer", + "format": "int32" + }, + "root": { + "$ref": "#/components/schemas/Token" + }, + "rootText": { + "type": "string" + }, + "empty": { + "type": "boolean" + }, + "description": { + "type": "string" + }, + "anExpression": { + "type": "boolean" + } + } + }, + "Variable": { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "modifiers": { + "type": "integer", + "format": "int32" + }, + "type": { + "$ref": "#/components/schemas/ClassNode" + }, + "closureSharedVariable": { + "type": "boolean" + }, + "dynamicTyped": { + "type": "boolean" + }, + "originType": { + "$ref": "#/components/schemas/ClassNode" + }, + "initialExpression": { + "$ref": "#/components/schemas/Expression" + }, + "inStaticContext": { + "type": "boolean" + } + } + }, + "VariableScope": { + "type": "object", + "properties": { + "parent": { + "$ref": "#/components/schemas/VariableScope" + }, + "classScope": { + "$ref": "#/components/schemas/ClassNode" + }, + "inStaticContext": { + "type": "boolean" + }, + "declaredVariables": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/Variable" + } + }, + "referencedClassVariables": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/Variable" + } + }, + "root": { + "type": "boolean" + }, + "declaredVariablesIterator": { + "type": "object" + }, + "referencedLocalVariablesCount": { + "type": "integer", + "format": "int32" + }, + "referencedLocalVariablesIterator": { + "type": "object" + }, + "referencedClassVariablesIterator": { + "type": "object" + } + } + }, + "WarningMessage": { + "type": "object", + "properties": { + "message": { + "type": "string" + }, + "context": { + "$ref": "#/components/schemas/CSTNode" + } + } + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/resources/results/3.1.0/app10.json b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/resources/results/3.1.0/app10.json new file mode 100644 index 000000000..7a7ea671d --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/resources/results/3.1.0/app10.json @@ -0,0 +1,278 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/test3": { + "get": { + "tags": [ + "hello-controller" + ], + "operationId": "getPatientList3", + "parameters": [ + { + "name": "page", + "in": "query", + "description": "Zero-based page index (0..N)", + "required": false, + "schema": { + "minimum": 0, + "type": "integer", + "default": 0 + } + }, + { + "name": "size", + "in": "query", + "description": "The size of the page to be returned", + "required": false, + "schema": { + "minimum": 1, + "type": "integer", + "default": 100 + } + }, + { + "name": "sort", + "in": "query", + "description": "Sorting criteria in the format: property,(asc|desc). Default sort order is ascending. Multiple sort criteria are supported.", + "required": false, + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/test2": { + "get": { + "tags": [ + "hello-controller" + ], + "operationId": "getPatientList2", + "parameters": [ + { + "name": "page", + "in": "query", + "description": "Zero-based page index (0..N)", + "required": false, + "schema": { + "minimum": 0, + "type": "integer", + "default": 0 + } + }, + { + "name": "size", + "in": "query", + "description": "The size of the page to be returned", + "required": false, + "schema": { + "minimum": 1, + "type": "integer", + "default": 100 + } + }, + { + "name": "sort", + "in": "query", + "description": "Sorting criteria in the format: property,(asc|desc). Default sort order is ascending. Multiple sort criteria are supported.", + "required": false, + "schema": { + "type": "array", + "items": { + "type": "string" + }, + "default": [ + "someField,DESC" + ] + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/test1": { + "get": { + "tags": [ + "hello-controller" + ], + "operationId": "getPatientList1", + "parameters": [ + { + "name": "page", + "in": "query", + "description": "Zero-based page index (0..N)", + "required": false, + "schema": { + "minimum": 0, + "type": "integer", + "default": 0 + } + }, + { + "name": "size", + "in": "query", + "description": "The size of the page to be returned", + "required": false, + "schema": { + "minimum": 1, + "type": "integer", + "default": 100 + } + }, + { + "name": "sort", + "in": "query", + "description": "Sorting criteria in the format: property,(asc|desc). Default sort order is ascending. Multiple sort criteria are supported.", + "required": false, + "schema": { + "type": "array", + "items": { + "type": "string" + }, + "default": [ + "someField,DESC", + "someoTHER,DESC" + ] + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/search": { + "get": { + "tags": [ + "hello-controller" + ], + "operationId": "getAllPets", + "parameters": [ + { + "name": "page", + "in": "query", + "description": "Zero-based page index (0..N)", + "required": false, + "schema": { + "minimum": 0, + "type": "integer", + "default": 0 + } + }, + { + "name": "size", + "in": "query", + "description": "The size of the page to be returned", + "required": false, + "schema": { + "minimum": 1, + "type": "integer", + "default": 5 + } + }, + { + "name": "sort", + "in": "query", + "description": "Sorting criteria in the format: property,(asc|desc). Default sort order is ascending. Multiple sort criteria are supported.", + "required": false, + "schema": { + "type": "array", + "items": { + "type": "string" + }, + "default": [ + "name,ASC" + ] + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/xml": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/PersonDTO" + } + } + }, + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/PersonDTO" + } + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "PersonDTO": { + "type": "object", + "properties": { + "email": { + "type": "string" + }, + "firstName": { + "type": "string" + }, + "lastName": { + "type": "string" + } + } + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/resources/results/3.1.0/app11.json b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/resources/results/3.1.0/app11.json new file mode 100644 index 000000000..5ddab455a --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/resources/results/3.1.0/app11.json @@ -0,0 +1,58 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/test": { + "post": { + "tags": [ + "test-controller" + ], + "operationId": "testingMethod", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/TestRequest" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "Random endpoint." + } + } + } + } + }, + "components": { + "schemas": { + "TestRequest": { + "type": "object", + "properties": { + "joeWasHere": { + "type": "string", + "description": "Joe was here with a tuna melt!" + }, + "testingTheMap": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "description": "This is an example of a map that does not work.!" + } + } + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/resources/results/3.1.0/app191.json b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/resources/results/3.1.0/app191.json new file mode 100644 index 000000000..cd49babb2 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/resources/results/3.1.0/app191.json @@ -0,0 +1,416 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/test4": { + "get": { + "tags": [ + "hello-controller" + ], + "operationId": "getPatientList4", + "parameters": [ + { + "name": "page", + "in": "query", + "description": "Zero-based page index (0..N)", + "required": false, + "schema": { + "minimum": 0, + "type": "integer", + "default": 0 + } + }, + { + "name": "size", + "in": "query", + "description": "The size of the page to be returned", + "required": false, + "schema": { + "minimum": 1, + "type": "integer", + "default": 20 + } + }, + { + "name": "sort", + "in": "query", + "description": "Sorting criteria in the format: property,(asc|desc). Default sort order is ascending. Multiple sort criteria are supported.", + "required": false, + "schema": { + "type": "array", + "items": { + "type": "string" + }, + "default": [ + "someField,DESC" + ] + } + } + ], + "responses": { + "403": { + "description": "Forbidden", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + }, + "500": { + "description": "Internal Server Error", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + }, + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/test3": { + "get": { + "tags": [ + "hello-controller" + ], + "operationId": "getPatientList3", + "parameters": [ + { + "name": "page", + "in": "query", + "description": "Zero-based page index (0..N)", + "required": false, + "schema": { + "minimum": 0, + "type": "integer", + "default": 0 + } + }, + { + "name": "size", + "in": "query", + "description": "The size of the page to be returned", + "required": false, + "schema": { + "minimum": 1, + "type": "integer", + "default": 20 + } + }, + { + "name": "sort", + "in": "query", + "description": "Sorting criteria in the format: property,(asc|desc). Default sort order is ascending. Multiple sort criteria are supported.", + "required": false, + "schema": { + "type": "array", + "items": { + "type": "string" + }, + "default": [ + "someField,DESC", + "someoTHER,DESC" + ] + } + } + ], + "responses": { + "403": { + "description": "Forbidden", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + }, + "500": { + "description": "Internal Server Error", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + }, + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/test2": { + "get": { + "tags": [ + "hello-controller" + ], + "operationId": "getPatientList2", + "parameters": [ + { + "name": "sort", + "in": "query", + "description": "Sorting criteria in the format: property,(asc|desc). Default sort order is ascending. Multiple sort criteria are supported.", + "required": false, + "schema": { + "type": "array", + "items": { + "type": "string" + }, + "default": [ + "someField,DESC" + ] + } + } + ], + "responses": { + "403": { + "description": "Forbidden", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + }, + "500": { + "description": "Internal Server Error", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + }, + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/test1": { + "get": { + "tags": [ + "hello-controller" + ], + "operationId": "getPatientList1", + "parameters": [ + { + "name": "sort", + "in": "query", + "description": "Sorting criteria in the format: property,(asc|desc). Default sort order is ascending. Multiple sort criteria are supported.", + "required": false, + "schema": { + "type": "array", + "items": { + "type": "string" + }, + "default": [ + "someField,DESC", + "someoTHER,DESC" + ] + } + } + ], + "responses": { + "403": { + "description": "Forbidden", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + }, + "500": { + "description": "Internal Server Error", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + }, + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/search": { + "get": { + "tags": [ + "hello-controller" + ], + "operationId": "getAllPets", + "parameters": [ + { + "name": "sort", + "in": "query", + "description": "Sorting criteria in the format: property,(asc|desc). Default sort order is ascending. Multiple sort criteria are supported.", + "required": false, + "schema": { + "type": "array", + "items": { + "type": "string" + }, + "default": [ + "name,ASC" + ] + } + } + ], + "responses": { + "403": { + "description": "Forbidden", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + }, + "500": { + "description": "Internal Server Error", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + }, + "200": { + "description": "OK", + "content": { + "application/xml": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/PersonDTO" + } + } + }, + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/PersonDTO" + } + } + } + } + } + } + } + }, + "/hello": { + "get": { + "tags": [ + "hello-controller" + ], + "summary": "Says hello", + "operationId": "getHello", + "responses": { + "403": { + "description": "Forbidden", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + }, + "500": { + "description": "Internal Server Error", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + }, + "200": { + "description": "OK", + "content": { + "text/plain": { + "schema": { + "type": "string" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "PersonDTO": { + "type": "object", + "properties": { + "email": { + "type": "string" + }, + "firstName": { + "type": "string" + }, + "lastName": { + "type": "string" + } + } + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/resources/results/3.1.0/app2.json b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/resources/results/3.1.0/app2.json new file mode 100644 index 000000000..9a6d39f7c --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/resources/results/3.1.0/app2.json @@ -0,0 +1,95 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "Issue OpenAPI with Groovy", + "description": "Special Groovy Metaclass Test Issue" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/cars": { + "get": { + "tags": [ + "car-controller" + ], + "operationId": "getCars", + "parameters": [ + { + "name": "name", + "in": "query", + "required": false, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Car" + } + } + } + } + } + } + } + }, + "/cars/{carId}": { + "get": { + "tags": [ + "car-controller" + ], + "operationId": "getCar", + "parameters": [ + { + "name": "carId", + "in": "path", + "required": true, + "schema": { + "type": "integer", + "format": "int64" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/Car" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "Car": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "name": { + "type": "string" + } + } + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/resources/results/3.1.0/app9.json b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/resources/results/3.1.0/app9.json new file mode 100644 index 000000000..04ec4dda2 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-groovy-tests/src/test/resources/results/3.1.0/app9.json @@ -0,0 +1,115 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/search": { + "get": { + "tags": [ + "hello-controller" + ], + "operationId": "getAllPets", + "parameters": [ + { + "name": "toto", + "in": "query", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/xml": { + "schema": { + "$ref": "#/components/schemas/DeprecatedEntity" + } + }, + "application/json": { + "schema": { + "$ref": "#/components/schemas/DeprecatedEntity" + } + } + } + } + } + } + }, + "/search2": { + "get": { + "tags": [ + "hello-controller" + ], + "operationId": "getAllPets2", + "parameters": [ + { + "name": "page", + "in": "query", + "description": "Zero-based page index (0..N)", + "required": false, + "schema": { + "minimum": 0, + "type": "integer", + "default": 0 + } + }, + { + "name": "size", + "in": "query", + "description": "The size of the page to be returned", + "required": false, + "schema": { + "minimum": 1, + "type": "integer", + "default": 20 + } + }, + { + "name": "sort", + "in": "query", + "description": "Sorting criteria in the format: property,(asc|desc). Default sort order is ascending. Multiple sort criteria are supported.", + "required": false, + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + } + ], + "responses": { + "200": { + "description": "OK" + } + } + } + } + }, + "components": { + "schemas": { + "DeprecatedEntity": { + "type": "object", + "properties": { + "myNonDeprecatedField": { + "type": "string" + }, + "mydeprecatedField": { + "type": "string", + "deprecated": true + } + } + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/pom.xml b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/pom.xml index 881e243ad..159fb82cd 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.1 + 2.8.2 4.0.0 springdoc-openapi-hateoas-tests diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/AbstractSpringDocTest.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/AbstractSpringDocTest.java deleted file mode 100644 index c5a3f253e..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/AbstractSpringDocTest.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * - * * - * * * - * * * * - * * * * * 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; - -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; - -import org.junit.jupiter.api.Test; -import org.springdoc.core.utils.Constants; - -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.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; - -@ActiveProfiles("test") -@SpringBootTest -@AutoConfigureMockMvc -@TestPropertySource(properties = "springdoc.api-docs.version=openapi_3_0" ) -public abstract class AbstractSpringDocTest { - - public static String className; - - @Autowired - protected MockMvc mockMvc; - - public static String getContent(String fileName) { - try { - Path path = Paths.get(AbstractSpringDocTest.class.getClassLoader().getResource(fileName).toURI()); - byte[] fileBytes = Files.readAllBytes(path); - return new String(fileBytes, StandardCharsets.UTF_8); - } - catch (Exception e) { - throw new RuntimeException("Failed to read file: " + fileName, e); - } - } - - @Test - protected void testApp() throws Exception { - className = getClass().getSimpleName(); - String testNumber = className.replaceAll("[^0-9]", ""); - MvcResult mockMvcResult = mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL)).andExpect(status().isOk()) - .andExpect(jsonPath("$.openapi", is("3.0.1"))).andReturn(); - String result = mockMvcResult.getResponse().getContentAsString(); - Path path = Paths.get(getClass().getClassLoader().getResource("results/app" + testNumber + ".json").toURI()); - byte[] fileBytes = Files.readAllBytes(path); - String expected = new String(fileBytes); - assertEquals(expected, result, true); - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app1/DatabaseLoader.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app1/DatabaseLoader.java deleted file mode 100644 index 019739022..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app1/DatabaseLoader.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app1; - -import org.springframework.boot.CommandLineRunner; -import org.springframework.context.annotation.Bean; -import org.springframework.stereotype.Component; - -/** - * Pre-load some data using a Spring Boot {@link CommandLineRunner}. - * - * @author Greg Turnquist - */ -@Component -class DatabaseLoader { - - /** - * Use Spring to inject a {@link EmployeeRepository} that can then load data. Since this will run only after the app - * is operational, the database will be up. - * - * @param repository - */ - @Bean - CommandLineRunner init(EmployeeRepository repository) { - - return args -> { - repository.save(new Employee("Frodo", "Baggins", "ring bearer")); - repository.save(new Employee("Bilbo", "Baggins", "burglar")); - }; - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app1/Employee.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app1/Employee.java deleted file mode 100644 index 249032474..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app1/Employee.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app1; - -import jakarta.persistence.Entity; -import jakarta.persistence.GeneratedValue; -import jakarta.persistence.Id; -import lombok.AccessLevel; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -/** - * Domain object representing a company employee. Project Lombok keeps actual code at a minimum. {@code @Data} - - * Generates getters, setters, toString, hash, and equals functions {@code @Entity} - JPA annotation to flag this class - * for DB persistence {@code @NoArgsConstructor} - Create a constructor with no args to support JPA - * {@code @AllArgsConstructor} - Create a constructor with all args to support testing - * {@code @JsonIgnoreProperties(ignoreUnknow=true)} When converting JSON to Java, ignore any unrecognized attributes. - * This is critical for REST because it encourages adding new fields in later versions that won't break. It also allows - * things like _links to be ignore as well, meaning HAL documents can be fetched and later posted to the server without - * adjustment. - * - * @author Greg Turnquist - */ -@Data -@Entity -@NoArgsConstructor(access = AccessLevel.PRIVATE) -@AllArgsConstructor -class Employee { - - @Id - @GeneratedValue - private Long id; - - private String firstName; - - private String lastName; - - private String role; - - /** - * Useful constructor when id is not yet known. - * - * @param firstName - * @param lastName - * @param role - */ - Employee(String firstName, String lastName, String role) { - - this.firstName = firstName; - this.lastName = lastName; - this.role = role; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app1/EmployeeController.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app1/EmployeeController.java deleted file mode 100644 index b237cb7be..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app1/EmployeeController.java +++ /dev/null @@ -1,131 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app1; - -import java.net.URI; -import java.net.URISyntaxException; -import java.util.List; -import java.util.stream.StreamSupport; - -import org.springframework.hateoas.CollectionModel; -import org.springframework.hateoas.EntityModel; -import org.springframework.hateoas.IanaLinkRelations; -import org.springframework.hateoas.Link; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.ResponseStatus; -import org.springframework.web.bind.annotation.RestController; - -import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.linkTo; -import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.methodOn; - -/** - * Spring Web {@link RestController} used to generate a REST API. - * - * @author Greg Turnquist - */ -@RestController -class EmployeeController { - - private final EmployeeRepository repository; - - EmployeeController(EmployeeRepository repository) { - this.repository = repository; - } - - /** - * Look up all employees, and transform them into a REST collection resource. Then return them through Spring Web's - * {@link ResponseEntity} fluent API. - */ - @GetMapping("/employees") - ResponseEntity>> findAll() { - - List> employees = StreamSupport.stream(repository.findAll().spliterator(), false) - .map(employee -> EntityModel.of(employee, // - linkTo(methodOn(EmployeeController.class).findOne(employee.getId())).withSelfRel(), // - linkTo(methodOn(EmployeeController.class).findAll()).withRel("employees"))) // - .toList(); - - return ResponseEntity.ok( // - CollectionModel.of(employees, // - linkTo(methodOn(EmployeeController.class).findAll()).withSelfRel())); - } - - @PostMapping("/employees") - @ResponseStatus(HttpStatus.CREATED) - ResponseEntity> newEmployee(@RequestBody Employee employee) { - - try { - Employee savedEmployee = repository.save(employee); - - EntityModel employeeResource = EntityModel.of(savedEmployee, // - linkTo(methodOn(EmployeeController.class).findOne(savedEmployee.getId())).withSelfRel()); - - return ResponseEntity // - .created(new URI(employeeResource.getRequiredLink(IanaLinkRelations.SELF).getHref())) // - .body(employeeResource); - } - catch (URISyntaxException e) { - return ResponseEntity.badRequest().body(null); - } - } - - /** - * Look up a single {@link Employee} and transform it into a REST resource. Then return it through Spring Web's - * {@link ResponseEntity} fluent API. - * - * @param id - */ - @GetMapping("/employees/{id}") - ResponseEntity> findOne(@PathVariable long id) { - - return repository.findById(id) // - .map(employee -> EntityModel.of(employee, // - linkTo(methodOn(EmployeeController.class).findOne(employee.getId())).withSelfRel(), // - linkTo(methodOn(EmployeeController.class).findAll()).withRel("employees"))) // - .map(ResponseEntity::ok) // - .orElse(ResponseEntity.notFound().build()); - } - - /** - * Update existing employee then return a Location header. - * - * @param employee - * @param id - * @return - */ - @PutMapping("/employees/{id}") - @ResponseStatus(HttpStatus.NO_CONTENT) - ResponseEntity updateEmployee(@RequestBody Employee employee, @PathVariable long id) throws URISyntaxException { - - Employee employeeToUpdate = employee; - employeeToUpdate.setId(id); - repository.save(employeeToUpdate); - - Link newlyCreatedLink = linkTo(methodOn(EmployeeController.class).findOne(id)).withSelfRel(); - - return ResponseEntity.noContent().location(new URI(newlyCreatedLink.getHref())).build(); - - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app1/EmployeeRepository.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app1/EmployeeRepository.java deleted file mode 100644 index 83f117020..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app1/EmployeeRepository.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app1; - -import org.springframework.data.repository.CrudRepository; - -/** - * A simple Spring Data {@link CrudRepository} for storing {@link Employee}s. - * - * @author Greg Turnquist - */ -interface EmployeeRepository extends CrudRepository { -} diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app1/SpringDocApp1Test.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app1/SpringDocApp1Test.java deleted file mode 100644 index 18f22a25c..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app1/SpringDocApp1Test.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app1; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -public class SpringDocApp1Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp {} - -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app10/Dummy.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app10/Dummy.java deleted file mode 100644 index 761794ae2..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app10/Dummy.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * - * * - * * * - * * * * 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.app10; - -import lombok.AllArgsConstructor; -import lombok.Data; - -@Data -@AllArgsConstructor -public class Dummy { - - private T value; - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app10/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app10/HelloController.java deleted file mode 100644 index 00d143fbf..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app10/HelloController.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * - * * - * * * - * * * * 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.app10; - -import java.util.List; - -import org.springframework.data.domain.Page; -import org.springframework.data.domain.PageImpl; -import org.springframework.data.web.PagedModel; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -@SuppressWarnings("rawtypes") -@RestController -public class HelloController { - - @GetMapping("/page-simple") - public Page pageSimple() { - return pageImpl("test"); - } - - @GetMapping("/paged-model-simple") - public PagedModel pagedModelSimple() { - return pagedModel("test"); - } - - @GetMapping("/page-complex") - public Page>> pageComplex() { - return pageImpl(new Dummy<>(List.of("test"))); - } - - @GetMapping("/paged-model-complex") - public PagedModel>> pagedModelComplex() { - return pagedModel(new Dummy<>(List.of("test"))); - } - - @GetMapping("/page-raw") - public Page pageRaw() { - return pageSimple(); - } - - @GetMapping("/paged-model-raw") - public PagedModel pagedModelRaw() { - return pagedModelSimple(); - } - - private PagedModel pagedModel(T value) { - return new PagedModel<>(pageImpl(value)); - } - - private Page pageImpl(T value) { - return new PageImpl<>(List.of(value)); - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app10/SpringDocApp10DirectTest.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app10/SpringDocApp10DirectTest.java deleted file mode 100644 index 3fee1d1e1..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app10/SpringDocApp10DirectTest.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * - * * - * * * - * * * * 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.app10; - -import org.junit.jupiter.api.Test; -import org.springdoc.core.utils.Constants; -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.data.web.config.EnableSpringDataWebSupport; - -import static org.hamcrest.Matchers.is; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; - -public class SpringDocApp10DirectTest extends AbstractSpringDocTest { - - @Override - @Test - protected void testApp() throws Exception { - mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL)) - .andExpect(status().isOk()) - .andExpect(jsonPath("$.openapi", is("3.0.1"))) - .andExpect(content().json(getContent("results/app10-direct.json"), true)); - } - - @SpringBootApplication - @EnableSpringDataWebSupport(pageSerializationMode = EnableSpringDataWebSupport.PageSerializationMode.DIRECT) - public static class SpringDocTestApp { - - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app10/SpringDocApp10NotSpecifiedTest.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app10/SpringDocApp10NotSpecifiedTest.java deleted file mode 100644 index 6b1b457fb..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app10/SpringDocApp10NotSpecifiedTest.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * - * * - * * * - * * * * 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.app10; - -import java.util.Optional; - -import io.swagger.v3.core.converter.ModelConverter; -import io.swagger.v3.core.converter.ModelConverters; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.Test; -import org.springdoc.core.converters.PageOpenAPIConverter; -import org.springdoc.core.utils.Constants; -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -import static org.hamcrest.Matchers.is; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; - -public class SpringDocApp10NotSpecifiedTest extends AbstractSpringDocTest { - - - @BeforeAll - public static void init() { - Optional pageOpenAPIConverter = - ModelConverters.getInstance().getConverters() - .stream().filter(modelConverter -> modelConverter instanceof PageOpenAPIConverter).findAny(); - pageOpenAPIConverter.ifPresent(ModelConverters.getInstance()::removeConverter); - } - - @Override - @Test - protected void testApp() throws Exception { - mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL)) - .andExpect(status().isOk()) - .andExpect(jsonPath("$.openapi", is("3.0.1"))) - .andExpect(content().json(getContent("results/app10-direct.json"), true)); - } - - @SpringBootApplication - public static class SpringDocTestApp { - - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app10/SpringDocApp10ViaDtoTest.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app10/SpringDocApp10ViaDtoTest.java deleted file mode 100644 index ddf6fef87..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app10/SpringDocApp10ViaDtoTest.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * - * * - * * * - * * * * 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.app10; - -import org.junit.jupiter.api.Test; -import org.springdoc.core.utils.Constants; -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.data.web.config.EnableSpringDataWebSupport; - -import static org.hamcrest.Matchers.is; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; - -public class SpringDocApp10ViaDtoTest extends AbstractSpringDocTest { - - @Override - @Test - protected void testApp() throws Exception { - mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL)) - .andExpect(status().isOk()) - .andExpect(jsonPath("$.openapi", is("3.0.1"))) - .andExpect(content().json(getContent("results/app10-via_dto.json"), true)); - } - - @SpringBootApplication - @EnableSpringDataWebSupport(pageSerializationMode = EnableSpringDataWebSupport.PageSerializationMode.VIA_DTO) - public static class SpringDocTestApp { - - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app2/SpringDocApp2Test.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app2/SpringDocApp2Test.java deleted file mode 100644 index 1966d9749..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app2/SpringDocApp2Test.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app2; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.test.context.TestPropertySource; - -@TestPropertySource(properties = "springdoc.model-converters.pageable-converter.enabled=true") -public class SpringDocApp2Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp {} - -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app2/config/DatabaseConfig.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app2/config/DatabaseConfig.java deleted file mode 100644 index ce3c41005..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app2/config/DatabaseConfig.java +++ /dev/null @@ -1,32 +0,0 @@ -package test.org.springdoc.api.app2.config; - -import java.time.LocalDate; - -import jakarta.annotation.PostConstruct; -import lombok.RequiredArgsConstructor; -import test.org.springdoc.api.app2.entities.Post; -import test.org.springdoc.api.app2.repositories.PostRepository; - -import org.springframework.context.annotation.Configuration; - -/** - * @author Davide Pedone - * 2020 - */ -@Configuration -@RequiredArgsConstructor -public class DatabaseConfig { - - private final PostRepository postRepository; - - @PostConstruct - private void postConstruct() { - for (int i = 0; i < 33; i++) { - Post post = new Post(); - post.setAuthor("name" + i); - post.setContent("content" + i); - post.setCreatedAt(LocalDate.now().toEpochDay()); - postRepository.save(post); - } - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app2/controller/PostController.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app2/controller/PostController.java deleted file mode 100644 index d413130fa..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app2/controller/PostController.java +++ /dev/null @@ -1,29 +0,0 @@ -package test.org.springdoc.api.app2.controller; - -import lombok.RequiredArgsConstructor; -import test.org.springdoc.api.app2.entities.Post; -import test.org.springdoc.api.app2.service.PostService; - -import org.springframework.data.domain.Pageable; -import org.springframework.hateoas.EntityModel; -import org.springframework.hateoas.PagedModel; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * @author Davide Pedone - * 2020 - */ -@RestController -@RequiredArgsConstructor -public class PostController { - - private final PostService postService; - - @GetMapping - public ResponseEntity>> getAll(Pageable pageable) { - return new ResponseEntity<>(postService.getAll(pageable), HttpStatus.OK); - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app2/entities/Post.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app2/entities/Post.java deleted file mode 100644 index 64fd0db41..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app2/entities/Post.java +++ /dev/null @@ -1,30 +0,0 @@ -package test.org.springdoc.api.app2.entities; - -import jakarta.persistence.Entity; -import jakarta.persistence.GeneratedValue; -import jakarta.persistence.Id; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -/** - * @author Davide Pedone - * 2020 - */ -@Data -@Entity -@NoArgsConstructor -@AllArgsConstructor -public class Post { - - @Id - @GeneratedValue - private Long id; - - private String author; - - private String content; - - private Long createdAt; - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app2/hateoas/PostResourceAssembler.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app2/hateoas/PostResourceAssembler.java deleted file mode 100644 index 4ab817898..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app2/hateoas/PostResourceAssembler.java +++ /dev/null @@ -1,22 +0,0 @@ -package test.org.springdoc.api.app2.hateoas; - - -import test.org.springdoc.api.app2.entities.Post; - -import org.springframework.hateoas.EntityModel; -import org.springframework.hateoas.server.RepresentationModelAssembler; -import org.springframework.stereotype.Component; - -/** - * @author Davide Pedone - * 2020 - */ -@Component -public class PostResourceAssembler implements RepresentationModelAssembler> { - - - @Override - public EntityModel toModel(Post entity) { - return EntityModel.of(entity); - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app2/repositories/PostRepository.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app2/repositories/PostRepository.java deleted file mode 100644 index e40d48b17..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app2/repositories/PostRepository.java +++ /dev/null @@ -1,14 +0,0 @@ -package test.org.springdoc.api.app2.repositories; - - -import test.org.springdoc.api.app2.entities.Post; - -import org.springframework.data.repository.CrudRepository; -import org.springframework.data.repository.PagingAndSortingRepository; - -/** - * @author Davide Pedone - * 2020 - */ -public interface PostRepository extends PagingAndSortingRepository, CrudRepository { -} diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app2/service/PostService.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app2/service/PostService.java deleted file mode 100644 index 768b3692e..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app2/service/PostService.java +++ /dev/null @@ -1,35 +0,0 @@ -package test.org.springdoc.api.app2.service; - - -import lombok.RequiredArgsConstructor; -import test.org.springdoc.api.app2.entities.Post; -import test.org.springdoc.api.app2.hateoas.PostResourceAssembler; -import test.org.springdoc.api.app2.repositories.PostRepository; - -import org.springframework.data.domain.Page; -import org.springframework.data.domain.Pageable; -import org.springframework.data.web.PagedResourcesAssembler; -import org.springframework.hateoas.EntityModel; -import org.springframework.hateoas.PagedModel; -import org.springframework.stereotype.Service; - -/** - * @author Davide Pedone - * 2020 - */ -@RequiredArgsConstructor -@Service -public class PostService { - - private final PostRepository postRepository; - - private final PagedResourcesAssembler pagedResourcesAssembler; - - private final PostResourceAssembler postResourceAssembler; - - public PagedModel> getAll(Pageable pageable) { - Page postPage = postRepository.findAll(pageable); - return pagedResourcesAssembler.toModel(postPage, postResourceAssembler); - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app3/DatabaseLoader.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app3/DatabaseLoader.java deleted file mode 100644 index e3d107802..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app3/DatabaseLoader.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app3; - -import org.springframework.boot.CommandLineRunner; -import org.springframework.context.annotation.Bean; -import org.springframework.stereotype.Component; - -/** - * Pre-load some data using a Spring Boot {@link CommandLineRunner}. - * - * @author Greg Turnquist - */ -@Component -class DatabaseLoader { - - /** - * Use Spring to inject a {@link EmployeeRepository} that can then load data. Since this will run only after the app - * is operational, the database will be up. - * - * @param repository - */ - @Bean - CommandLineRunner init(EmployeeRepository repository) { - - return args -> { - repository.save(new Employee("Frodo", "Baggins", "ring bearer")); - repository.save(new Employee("Bilbo", "Baggins", "burglar")); - }; - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app3/Employee.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app3/Employee.java deleted file mode 100644 index 19ed66469..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app3/Employee.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app3; - -import jakarta.persistence.Entity; -import jakarta.persistence.GeneratedValue; -import jakarta.persistence.Id; -import lombok.AccessLevel; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -/** - * Domain object representing a company employee. Project Lombok keeps actual code at a minimum. {@code @Data} - - * Generates getters, setters, toString, hash, and equals functions {@code @Entity} - JPA annotation to flag this class - * for DB persistence {@code @NoArgsConstructor} - Create a constructor with no args to support JPA - * {@code @AllArgsConstructor} - Create a constructor with all args to support testing - * {@code @JsonIgnoreProperties(ignoreUnknow=true)} When converting JSON to Java, ignore any unrecognized attributes. - * This is critical for REST because it encourages adding new fields in later versions that won't break. It also allows - * things like _links to be ignore as well, meaning HAL documents can be fetched and later posted to the server without - * adjustment. - * - * @author Greg Turnquist - */ -@Data -@Entity -@NoArgsConstructor(access = AccessLevel.PRIVATE) -@AllArgsConstructor -class Employee { - - @Id - @GeneratedValue - private Long id; - - private String firstName; - - private String lastName; - - private String role; - - /** - * Useful constructor when id is not yet known. - * - * @param firstName - * @param lastName - * @param role - */ - Employee(String firstName, String lastName, String role) { - - this.firstName = firstName; - this.lastName = lastName; - this.role = role; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app3/EmployeeController.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app3/EmployeeController.java deleted file mode 100644 index 209dd8d7c..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app3/EmployeeController.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app3; - -import org.springframework.hateoas.EntityModel; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RestController; - -/** - * Spring Web {@link RestController} used to generate a REST API. - * - * @author Greg Turnquist - */ -@RestController -class EmployeeController { - - /** - * Look up a single {@link Employee} and transform it into a REST resource. Then return it through Spring Web's - * {@link ResponseEntity} fluent API. - * - * @param id - */ - @GetMapping("/employees/{id}") - EntityModel findOne(@PathVariable long id) { - - return null; - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app3/EmployeeRepository.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app3/EmployeeRepository.java deleted file mode 100644 index 1de3d1b4b..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app3/EmployeeRepository.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app3; - -import org.springframework.data.repository.CrudRepository; - -/** - * A simple Spring Data {@link CrudRepository} for storing {@link Employee}s. - * - * @author Greg Turnquist - */ -interface EmployeeRepository extends CrudRepository { -} diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app3/SpringDocApp3Test.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app3/SpringDocApp3Test.java deleted file mode 100644 index ce9055605..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app3/SpringDocApp3Test.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app3; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.test.context.TestPropertySource; - -@TestPropertySource(properties = "springdoc.remove-broken-reference-definitions=false") -public class SpringDocApp3Test extends AbstractSpringDocTest { - - -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app3/SpringDocTestApp.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app3/SpringDocTestApp.java deleted file mode 100644 index a030eeebb..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app3/SpringDocTestApp.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app3; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -@SpringBootApplication -public class SpringDocTestApp { - - public static void main(String[] args) { - SpringApplication.run(SpringDocTestApp.class, args); - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app4/Album.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app4/Album.java deleted file mode 100644 index ed3eb1a2e..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app4/Album.java +++ /dev/null @@ -1,29 +0,0 @@ -package test.org.springdoc.api.app4; - -public class Album { - - private String title; - - private String description; - - private String releaseDate; - - public Album(String title, String description, String releaseDate) { - this.title = title; - this.description = description; - this.releaseDate = releaseDate; - } - - public String getTitle() { - return title; - } - - public String getDescription() { - return description; - } - - public String getReleaseDate() { - return releaseDate; - } - -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app4/AlbumController.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app4/AlbumController.java deleted file mode 100644 index 577864cb8..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app4/AlbumController.java +++ /dev/null @@ -1,32 +0,0 @@ -package test.org.springdoc.api.app4; - -import java.util.Arrays; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.domain.Page; -import org.springframework.data.domain.PageImpl; -import org.springframework.data.web.PagedResourcesAssembler; -import org.springframework.hateoas.PagedModel; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -@RestController -@SuppressWarnings("unchecked") -public class AlbumController { - - @Autowired - private AlbumModelAssembler albumModelAssembler; - - @Autowired - private PagedResourcesAssembler pagedResourcesAssembler; - - @GetMapping("/api/albums") - public PagedModel getAllAlbums() { - Album album1 = new Album("album-title-1", "album-description-1", "album-release-date-1"); - Album album2 = new Album("album-title-2", "album-description-2", "album-release-date-2"); - Page albumPage = new PageImpl<>(Arrays.asList(album1, album2)); - - return pagedResourcesAssembler.toModel(albumPage, albumModelAssembler); - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app4/AlbumModelAssembler.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app4/AlbumModelAssembler.java deleted file mode 100644 index ddbd8d84e..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app4/AlbumModelAssembler.java +++ /dev/null @@ -1,20 +0,0 @@ -package test.org.springdoc.api.app4; - -import java.util.ArrayList; -import java.util.List; - -import org.springframework.hateoas.EntityModel; -import org.springframework.hateoas.Link; -import org.springframework.hateoas.server.RepresentationModelAssembler; -import org.springframework.stereotype.Component; - -@Component -public class AlbumModelAssembler implements RepresentationModelAssembler> { - - @Override - public EntityModel toModel(Album entity) { - List links = new ArrayList<>(); - return EntityModel.of(entity, links); - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app4/SpringDocApp4Test.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app4/SpringDocApp4Test.java deleted file mode 100644 index 6fa3df392..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app4/SpringDocApp4Test.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app4; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -public class SpringDocApp4Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp {} - -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app5/SpringDocApp5Test.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app5/SpringDocApp5Test.java deleted file mode 100644 index 1f9ed011d..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app5/SpringDocApp5Test.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app5; - -import io.swagger.v3.oas.models.Components; -import io.swagger.v3.oas.models.OpenAPI; -import io.swagger.v3.oas.models.media.ObjectSchema; -import io.swagger.v3.oas.models.media.StringSchema; -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.Bean; - -public class SpringDocApp5Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp { - @Bean - public OpenAPI customOpenAPI() { - return new OpenAPI().components(new Components() - .addSchemas("CompanyDtoNew", new ObjectSchema().addProperties("id", new StringSchema().format("uuid" - )).addProperties("name", new StringSchema()))); - } - } - -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app5/controller/CompanyController.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app5/controller/CompanyController.java deleted file mode 100644 index 2b63801d5..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app5/controller/CompanyController.java +++ /dev/null @@ -1,31 +0,0 @@ -package test.org.springdoc.api.app5.controller; - -import io.swagger.v3.oas.annotations.media.Content; -import io.swagger.v3.oas.annotations.media.Schema; -import jakarta.validation.Valid; -import lombok.RequiredArgsConstructor; -import test.org.springdoc.api.app5.entities.CompanyDto; - -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RestController; - -/** - * @author Davide Pedone - * 2020 - */ -@RestController -@RequiredArgsConstructor -public class CompanyController { - - - @PostMapping - @io.swagger.v3.oas.annotations.parameters.RequestBody( - description = "Details of the Item to be created", - content = @Content(schema = @Schema(ref = "#/components/schemas/CompanyDtoNew"))) - public CompanyDto create(@Valid @RequestBody final CompanyDto companyDto) { - - return null; - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app5/entities/Company.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app5/entities/Company.java deleted file mode 100644 index a85e15694..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app5/entities/Company.java +++ /dev/null @@ -1,29 +0,0 @@ -package test.org.springdoc.api.app5.entities; - -import java.util.UUID; - -import com.fasterxml.jackson.annotation.JsonProperty; -import jakarta.validation.constraints.NotNull; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.EqualsAndHashCode; - -import org.springframework.hateoas.RepresentationModel; -import org.springframework.hateoas.server.core.Relation; - -/** - * @author bnasslahsen - */ -@AllArgsConstructor -@Data -@Builder -@EqualsAndHashCode(callSuper = false) -@Relation(collectionRelation = "companies", itemRelation = "company") -public class Company extends RepresentationModel { - @JsonProperty(access = JsonProperty.Access.READ_ONLY) - private UUID id; - - @NotNull - private String name; -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app5/entities/CompanyDto.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app5/entities/CompanyDto.java deleted file mode 100644 index 5a7558c8e..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app5/entities/CompanyDto.java +++ /dev/null @@ -1,29 +0,0 @@ -package test.org.springdoc.api.app5.entities; - -import java.util.UUID; - -import com.fasterxml.jackson.annotation.JsonProperty; -import jakarta.validation.constraints.NotNull; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.EqualsAndHashCode; - -import org.springframework.hateoas.RepresentationModel; -import org.springframework.hateoas.server.core.Relation; - -/** - * @author bnasslahsen - */ -@AllArgsConstructor -@Data -@Builder -@EqualsAndHashCode(callSuper = false) -@Relation(collectionRelation = "companies", itemRelation = "company") -public class CompanyDto extends RepresentationModel { - @JsonProperty(access = JsonProperty.Access.READ_ONLY) - private UUID id; - - @NotNull - private String name; -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app5/hateoas/CompanyModelAssembler.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app5/hateoas/CompanyModelAssembler.java deleted file mode 100644 index c893acbf9..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app5/hateoas/CompanyModelAssembler.java +++ /dev/null @@ -1,29 +0,0 @@ -package test.org.springdoc.api.app5.hateoas; - -import test.org.springdoc.api.app5.controller.CompanyController; -import test.org.springdoc.api.app5.entities.Company; -import test.org.springdoc.api.app5.entities.CompanyDto; - -import org.springframework.hateoas.server.mvc.RepresentationModelAssemblerSupport; -import org.springframework.lang.NonNull; -import org.springframework.stereotype.Component; - -/** - * @author bnasslahsen - */ -@Component -public class CompanyModelAssembler extends RepresentationModelAssemblerSupport { - - public CompanyModelAssembler() { - super(CompanyController.class, CompanyDto.class); - } - - @Override - @NonNull - public CompanyDto toModel(@NonNull final Company company) { - return CompanyDto.builder() - .id(company.getId()) - .name(company.getName()) - .build(); - } -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app6/SpringDocApp6Test.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app6/SpringDocApp6Test.java deleted file mode 100644 index 92f1dfcdd..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app6/SpringDocApp6Test.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * - * * - * * * - * * * * - * * * * * 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.app6; - -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; -import java.util.Map.Entry; - -import com.fasterxml.jackson.databind.introspect.SimpleMixInResolver; -import com.fasterxml.jackson.databind.type.ClassKey; -import org.apache.commons.lang3.reflect.FieldUtils; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeEach; -import org.springdoc.core.providers.ObjectMapperProvider; -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.test.context.TestPropertySource; - -@TestPropertySource(properties = "spring.hateoas.use-hal-as-default-json-media-type= false") -public class SpringDocApp6Test extends AbstractSpringDocTest { - - private final Map> springMixins = new HashMap<>(); - - @Autowired - ObjectMapperProvider objectMapperProvider; - - @BeforeEach - void init() throws IllegalAccessException { - SimpleMixInResolver _mixIns = (SimpleMixInResolver) FieldUtils.readDeclaredField(objectMapperProvider.jsonMapper(),"_mixIns", true); - Map> _localMixIns = (Map>) FieldUtils.readDeclaredField(_mixIns, "_localMixIns", true); - Iterator>> iterator = _localMixIns.entrySet().iterator(); - - while (iterator.hasNext()) { - Entry> entry = iterator.next(); - if (entry.getKey().toString().startsWith("org.springframework")) { - springMixins.put(entry.getKey(), entry.getValue()); - iterator.remove(); - } - } - } - - @AfterEach - void clean() throws IllegalAccessException { - SimpleMixInResolver _mixIns = (SimpleMixInResolver) FieldUtils.readDeclaredField(objectMapperProvider.jsonMapper(), "_mixIns", true); - Map> _localMixIns = (Map>) FieldUtils.readDeclaredField(_mixIns, "_localMixIns", true); - _localMixIns.putAll(springMixins); - } - - @SpringBootApplication - static class SpringDocTestApp { - } - -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app6/controller/ItemController.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app6/controller/ItemController.java deleted file mode 100644 index 8b814f4fd..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app6/controller/ItemController.java +++ /dev/null @@ -1,37 +0,0 @@ -package test.org.springdoc.api.app6.controller; - -import java.util.List; -import java.util.stream.Stream; - -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import test.org.springdoc.api.app6.model.Item; - -import org.springframework.hateoas.CollectionModel; -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.linkTo; -import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.methodOn; - -@RestController -@RequestMapping(value = "/v1/items", produces = MediaType.APPLICATION_JSON_VALUE) -@Tag(name = "Item", description = "The Item API") -public class ItemController { - - List items = Stream.of(new Item("foo"), new Item("bar")).toList(); - - @Operation(summary = "Get all items") - @GetMapping(produces = { MediaType.APPLICATION_JSON_VALUE }) - public ResponseEntity> getAllItems() { - - CollectionModel collection = CollectionModel.of(items); - collection.add(linkTo(methodOn(ItemController.class).getAllItems()).withSelfRel().expand()); - - return new ResponseEntity<>(collection, HttpStatus.OK); - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app6/model/Item.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app6/model/Item.java deleted file mode 100644 index 9e19f22c1..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app6/model/Item.java +++ /dev/null @@ -1,32 +0,0 @@ -package test.org.springdoc.api.app6.model; - -import org.springframework.hateoas.Link; -import org.springframework.hateoas.RepresentationModel; - - -public class Item extends RepresentationModel { - - private String description; - - public Item(String description) { - this.description = description; - } - - public Item(Link initialLink, String description) { - super(initialLink); - this.description = description; - } - - public Item(Iterable initialLinks, String description) { - super(initialLinks); - this.description = description; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app7/FooConfiguration.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app7/FooConfiguration.java deleted file mode 100644 index daa030e9b..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app7/FooConfiguration.java +++ /dev/null @@ -1,16 +0,0 @@ -package test.org.springdoc.api.app7; - -import org.springdoc.core.models.GroupedOpenApi; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -@Configuration -public class FooConfiguration { - @Bean - public GroupedOpenApi userOpenApi() { - String packagesToscan[] = { "test.org.springdoc.api.app7" }; - return GroupedOpenApi.builder().group("foo-service").packagesToScan(packagesToscan) - .build(); - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app7/SpringDocApp7Test.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app7/SpringDocApp7Test.java deleted file mode 100644 index 9166a80a6..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app7/SpringDocApp7Test.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app7; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -public class SpringDocApp7Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp { - } - -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app7/application/Foo.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app7/application/Foo.java deleted file mode 100644 index 4ef52f3ac..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app7/application/Foo.java +++ /dev/null @@ -1,10 +0,0 @@ -package test.org.springdoc.api.app7.application; - -import lombok.AllArgsConstructor; -import lombok.Data; - -@Data -@AllArgsConstructor -public class Foo { - String foo; -} diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app7/application/FooController.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app7/application/FooController.java deleted file mode 100644 index 348e1f11e..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app7/application/FooController.java +++ /dev/null @@ -1,33 +0,0 @@ -package test.org.springdoc.api.app7.application; - -import java.util.UUID; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.hateoas.EntityModel; -import org.springframework.hateoas.MediaTypes; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RestController; - -@RestController -public class FooController { - - private final FooService fooService; - - private final FooResourceAssembler fooResourceAssembler; - - @Autowired - public FooController( - FooService fooService, - FooResourceAssembler fooResourceAssembler) { - this.fooService = fooService; - this.fooResourceAssembler = fooResourceAssembler; - } - - @GetMapping(value = "foo/{id}", produces = MediaTypes.HAL_JSON_VALUE) - public ResponseEntity> getFoo(@PathVariable("id") UUID id) throws Exception { - Foo foo = fooService.getFoo(id).orElseThrow(Exception::new); - return ResponseEntity.ok(fooResourceAssembler.toModel(foo)); - } -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app7/application/FooResourceAssembler.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app7/application/FooResourceAssembler.java deleted file mode 100644 index 6a08e4b23..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app7/application/FooResourceAssembler.java +++ /dev/null @@ -1,35 +0,0 @@ -package test.org.springdoc.api.app7.application; - -import java.util.UUID; - -import org.springframework.hateoas.CollectionModel; -import org.springframework.hateoas.EntityModel; -import org.springframework.hateoas.server.SimpleRepresentationModelAssembler; -import org.springframework.stereotype.Component; - -import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.linkTo; -import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.methodOn; - -@Component -public class FooResourceAssembler - implements SimpleRepresentationModelAssembler { - - @Override - public void addLinks(EntityModel resource) { - Foo foo = resource.getContent(); - if (foo != null) { - try { - resource.add( - linkTo(methodOn(FooController.class).getFoo(UUID.fromString(foo.getFoo()))).withSelfRel()); - } - catch (Exception e) { - throw new RuntimeException(e); - } - } - } - - @Override - public void addLinks(CollectionModel> resources) { - - } -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app7/application/FooService.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app7/application/FooService.java deleted file mode 100644 index 6f861e45d..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app7/application/FooService.java +++ /dev/null @@ -1,13 +0,0 @@ -package test.org.springdoc.api.app7.application; - -import java.util.Optional; -import java.util.UUID; - -import org.springframework.stereotype.Service; - -@Service -public class FooService { - public Optional getFoo(UUID uuid) { - return Optional.of(new Foo(uuid.toString())); - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app8/DatabaseLoader.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app8/DatabaseLoader.java deleted file mode 100644 index 911c519e3..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app8/DatabaseLoader.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app8; - -import org.springframework.boot.CommandLineRunner; -import org.springframework.context.annotation.Bean; -import org.springframework.stereotype.Component; - -/** - * Pre-load some data using a Spring Boot {@link CommandLineRunner}. - * - * @author Greg Turnquist - */ -@Component -class DatabaseLoader { - - /** - * Use Spring to inject a {@link EmployeeRepository} that can then load data. Since this will run only after the app - * is operational, the database will be up. - * - * @param repository - */ - @Bean - CommandLineRunner init(EmployeeRepository repository) { - - return args -> { - repository.save(new Employee("Frodo", "Baggins", "ring bearer")); - repository.save(new Employee("Bilbo", "Baggins", "burglar")); - }; - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app8/Employee.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app8/Employee.java deleted file mode 100644 index 2d7ff5616..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app8/Employee.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app8; - -import jakarta.persistence.Entity; -import jakarta.persistence.GeneratedValue; -import jakarta.persistence.Id; -import lombok.AccessLevel; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -/** - * Domain object representing a company employee. Project Lombok keeps actual code at a minimum. {@code @Data} - - * Generates getters, setters, toString, hash, and equals functions {@code @Entity} - JPA annotation to flag this class - * for DB persistence {@code @NoArgsConstructor} - Create a constructor with no args to support JPA - * {@code @AllArgsConstructor} - Create a constructor with all args to support testing - * {@code @JsonIgnoreProperties(ignoreUnknow=true)} When converting JSON to Java, ignore any unrecognized attributes. - * This is critical for REST because it encourages adding new fields in later versions that won't break. It also allows - * things like _links to be ignore as well, meaning HAL documents can be fetched and later posted to the server without - * adjustment. - * - * @author Greg Turnquist - */ -@Data -@Entity -@NoArgsConstructor(access = AccessLevel.PRIVATE) -@AllArgsConstructor -class Employee { - - @Id - @GeneratedValue - private Long id; - - private String firstName; - - private String lastName; - - private String role; - - /** - * Useful constructor when id is not yet known. - * - * @param firstName - * @param lastName - * @param role - */ - Employee(String firstName, String lastName, String role) { - - this.firstName = firstName; - this.lastName = lastName; - this.role = role; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app8/EmployeeController.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app8/EmployeeController.java deleted file mode 100644 index 8afc7bfa6..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app8/EmployeeController.java +++ /dev/null @@ -1,131 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app8; - -import java.net.URI; -import java.net.URISyntaxException; -import java.util.List; -import java.util.stream.StreamSupport; - -import org.springframework.hateoas.CollectionModel; -import org.springframework.hateoas.EntityModel; -import org.springframework.hateoas.IanaLinkRelations; -import org.springframework.hateoas.Link; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.ResponseStatus; -import org.springframework.web.bind.annotation.RestController; - -import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.linkTo; -import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.methodOn; - -/** - * Spring Web {@link RestController} used to generate a REST API. - * - * @author Greg Turnquist - */ -@RestController -class EmployeeController { - - private final EmployeeRepository repository; - - EmployeeController(EmployeeRepository repository) { - this.repository = repository; - } - - /** - * Look up all employees, and transform them into a REST collection resource. Then return them through Spring Web's - * {@link ResponseEntity} fluent API. - */ - @GetMapping("/employees") - ResponseEntity>> findAll() { - - List> employees = StreamSupport.stream(repository.findAll().spliterator(), false) - .map(employee -> EntityModel.of(employee, // - linkTo(methodOn(EmployeeController.class).findOne(employee.getId())).withSelfRel(), // - linkTo(methodOn(EmployeeController.class).findAll()).withRel("employees"))) // - .toList(); - - return ResponseEntity.ok( // - CollectionModel.of(employees, // - linkTo(methodOn(EmployeeController.class).findAll()).withSelfRel())); - } - - @PostMapping("/employees") - @ResponseStatus(HttpStatus.CREATED) - ResponseEntity> newEmployee(@RequestBody Employee employee) { - - try { - Employee savedEmployee = repository.save(employee); - - EntityModel employeeResource = EntityModel.of(savedEmployee, // - linkTo(methodOn(EmployeeController.class).findOne(savedEmployee.getId())).withSelfRel()); - - return ResponseEntity // - .created(new URI(employeeResource.getRequiredLink(IanaLinkRelations.SELF).getHref())) // - .body(employeeResource); - } - catch (URISyntaxException e) { - return ResponseEntity.badRequest().body(null); - } - } - - /** - * Look up a single {@link Employee} and transform it into a REST resource. Then return it through Spring Web's - * {@link ResponseEntity} fluent API. - * - * @param id - */ - @GetMapping("/employees/{id}") - ResponseEntity> findOne(@PathVariable long id) { - - return repository.findById(id) // - .map(employee -> EntityModel.of(employee, // - linkTo(methodOn(EmployeeController.class).findOne(employee.getId())).withSelfRel(), // - linkTo(methodOn(EmployeeController.class).findAll()).withRel("employees"))) // - .map(ResponseEntity::ok) // - .orElse(ResponseEntity.notFound().build()); - } - - /** - * Update existing employee then return a Location header. - * - * @param employee - * @param id - * @return - */ - @PutMapping("/employees/{id}") - @ResponseStatus(HttpStatus.NO_CONTENT) - ResponseEntity updateEmployee(@RequestBody Employee employee, @PathVariable long id) throws URISyntaxException { - - Employee employeeToUpdate = employee; - employeeToUpdate.setId(id); - repository.save(employeeToUpdate); - - Link newlyCreatedLink = linkTo(methodOn(EmployeeController.class).findOne(id)).withSelfRel(); - - return ResponseEntity.noContent().location(new URI(newlyCreatedLink.getHref())).build(); - - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app8/EmployeeRepository.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app8/EmployeeRepository.java deleted file mode 100644 index 019db4a69..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app8/EmployeeRepository.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app8; - -import org.springframework.data.repository.CrudRepository; - -/** - * A simple Spring Data {@link CrudRepository} for storing {@link Employee}s. - * - * @author Greg Turnquist - */ -interface EmployeeRepository extends CrudRepository { -} diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app8/SpringDocApp8Test.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app8/SpringDocApp8Test.java deleted file mode 100644 index 06a8048d8..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app8/SpringDocApp8Test.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * - * * - * * * - * * * * - * * * * * 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.app8; - -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; -import java.util.Map.Entry; - -import com.fasterxml.jackson.databind.introspect.SimpleMixInResolver; -import com.fasterxml.jackson.databind.type.ClassKey; -import org.apache.commons.lang3.reflect.FieldUtils; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.BeforeEach; -import org.springdoc.core.providers.ObjectMapperProvider; -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.test.context.TestPropertySource; - -@TestPropertySource(properties = "springdoc.enable-hateoas=false") -public class SpringDocApp8Test extends AbstractSpringDocTest { - - private final Map> springMixins = new HashMap<>(); - - @Autowired - ObjectMapperProvider objectMapperProvider; - - @BeforeEach - void init() throws IllegalAccessException { - SimpleMixInResolver _mixIns = (SimpleMixInResolver) FieldUtils.readDeclaredField(objectMapperProvider.jsonMapper(), "_mixIns", true); - Map> _localMixIns = (Map>) FieldUtils.readDeclaredField(_mixIns, "_localMixIns", true); - Iterator>> it = _localMixIns.entrySet().iterator(); - while (it.hasNext()) { - Map.Entry> entry = it.next(); - if (entry.getKey().toString().startsWith("org.springframework")) { - springMixins.put(entry.getKey(), entry.getValue()); - it.remove(); - } - } - - } - - @AfterEach - void clean() throws IllegalAccessException { - SimpleMixInResolver _mixIns = (SimpleMixInResolver) FieldUtils.readDeclaredField(objectMapperProvider.jsonMapper(), "_mixIns", true); - Map> _localMixIns = (Map>) FieldUtils.readDeclaredField(_mixIns, "_localMixIns", true); - _localMixIns.putAll(springMixins); - } - - @SpringBootApplication - static class SpringDocTestApp {} -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app9/FooConfiguration.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app9/FooConfiguration.java deleted file mode 100644 index c5a21f1c1..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app9/FooConfiguration.java +++ /dev/null @@ -1,57 +0,0 @@ -package test.org.springdoc.api.app9; - -import java.util.List; - -import io.swagger.v3.oas.models.Components; -import io.swagger.v3.oas.models.OpenAPI; -import io.swagger.v3.oas.models.info.Contact; -import io.swagger.v3.oas.models.info.Info; -import io.swagger.v3.oas.models.media.ArraySchema; -import io.swagger.v3.oas.models.media.Schema; -import io.swagger.v3.oas.models.security.SecurityScheme; -import io.swagger.v3.oas.models.tags.Tag; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -@Configuration -public class FooConfiguration { - @Bean - OpenAPI customOpenApi() { - return new OpenAPI() - .components(new Components().addSecuritySchemes("bearerScheme", - new SecurityScheme() - .type(SecurityScheme.Type.HTTP) - .scheme("bearer") - .bearerFormat("JWT")) - .addSchemas("FeedResponse", feedResponseSchema())) - .info(new Info() - .title("Response API") - .description("API for some response") - .version("0.0.1") - .contact(new Contact() - .name("EAlf91"))) - .tags(List.of(new Tag() - .name("ResponseTag") - .description("ResponseTag for API"), - new Tag() - .name("ResponseData") - .description("Version 2 ResponseApi"))); - - } - - private Schema feedResponseSchema() { - Schema schema = new Schema<>(); - schema.addProperty("_links", linkSchema()); - schema.addProperty("data", new ArraySchema().items(new Schema<>().$ref("#/components/schemas/ResponseData"))); - return schema; - } - - private Schema linkSchema() { - Schema linkSchema = new Schema<>(); - linkSchema.addProperty("next", new Schema<>().$ref("#/components/schemas/Link").example("http://localhost:8080/some-link")); - linkSchema.addProperty("self", new Schema<>().$ref("#/components/schemas/Link").example("http://localhost:8080/some-other-link")); - return linkSchema; - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app9/SpringDocApp9Test.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app9/SpringDocApp9Test.java deleted file mode 100644 index 2e4cab1b2..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app9/SpringDocApp9Test.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app9; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -public class SpringDocApp9Test extends AbstractSpringDocTest { - - @SpringBootApplication - static class SpringDocTestApp { - } - -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app9/application/FooController.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app9/application/FooController.java deleted file mode 100644 index 8600ded15..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app9/application/FooController.java +++ /dev/null @@ -1,37 +0,0 @@ -package test.org.springdoc.api.app9.application; - -import java.util.List; -import java.util.UUID; - -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import test.org.springdoc.api.app9.application.dto.FeedResponse; -import test.org.springdoc.api.app9.application.dto.ResponseData; - -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.ResponseStatus; -import org.springframework.web.bind.annotation.RestController; -@Tag(name = "ResponseDataController") -@RestController -@RequestMapping(value = "/some-route", produces = MediaType.APPLICATION_JSON_VALUE) -@RequiredArgsConstructor -@Slf4j -public class FooController { - - - - - @Operation(summary = "Get all data", description = "Get all data") - @GetMapping(value = "foo/{id}") - @ResponseStatus(HttpStatus.OK) - public FeedResponse getFoo(@PathVariable("id") UUID id) { - var dataList = List.of(ResponseData.builder().dataId(id).build()); - return FeedResponse.createForResponseData(dataList, UUID.randomUUID()); - } -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app9/application/dto/FeedResponse.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app9/application/dto/FeedResponse.java deleted file mode 100644 index a9819e55d..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app9/application/dto/FeedResponse.java +++ /dev/null @@ -1,39 +0,0 @@ -package test.org.springdoc.api.app9.application.dto; - -import java.util.List; -import java.util.UUID; - -import com.fasterxml.jackson.annotation.JsonProperty; -import jakarta.validation.constraints.NotNull; -import lombok.AccessLevel; -import lombok.Builder; -import lombok.EqualsAndHashCode; -import lombok.Getter; -import lombok.experimental.Accessors; -import test.org.springdoc.api.app9.application.FooController; - -import org.springframework.hateoas.IanaLinkRelations; -import org.springframework.hateoas.RepresentationModel; - -import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.linkTo; -import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.methodOn; - -@Getter -@Accessors(fluent = true) -@Builder(access = AccessLevel.PACKAGE) -@EqualsAndHashCode(callSuper = true) -public class FeedResponse extends RepresentationModel { - @NotNull - @JsonProperty("data") - private final List data; - - public static FeedResponse createForResponseData(@NotNull List responseData, UUID uuid) { - var feedResponse = new FeedResponse(responseData); - feedResponse.add(linkTo(methodOn(FooController.class).getFoo(uuid)).withSelfRel()); - - - feedResponse.add(linkTo(methodOn(FooController.class).getFoo(uuid)).withRel(IanaLinkRelations.NEXT)); - - return feedResponse; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app9/application/dto/ResponseData.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app9/application/dto/ResponseData.java deleted file mode 100644 index 4481194c6..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/app9/application/dto/ResponseData.java +++ /dev/null @@ -1,20 +0,0 @@ -package test.org.springdoc.api.app9.application.dto; - -import java.time.LocalDate; -import java.util.UUID; - -import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.v3.oas.annotations.media.Schema; -import jakarta.validation.constraints.NotNull; -import lombok.Builder; - -@Builder -public record ResponseData( - @JsonProperty(value = "DATA_ID", required = true) - @NotNull - UUID dataId, - @JsonProperty(value = "DATE", required = true) - @NotNull - @Schema(example = "2024-03-27", format = "date") - LocalDate date -) {} diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/AbstractSpringDocTest.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/AbstractSpringDocTest.java new file mode 100644 index 000000000..4f6c2d241 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/AbstractSpringDocTest.java @@ -0,0 +1,85 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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; + +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; + +import org.junit.jupiter.api.Test; +import org.springdoc.core.utils.Constants; + +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.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; + +@ActiveProfiles("test") +@SpringBootTest +@AutoConfigureMockMvc +@TestPropertySource(properties = "springdoc.api-docs.version=openapi_3_0" ) +public abstract class AbstractSpringDocTest { + + public static String className; + + @Autowired + protected MockMvc mockMvc; + + public static String getContent(String fileName) { + try { + Path path = Paths.get(AbstractSpringDocTest.class.getClassLoader().getResource(fileName).toURI()); + byte[] fileBytes = Files.readAllBytes(path); + return new String(fileBytes, StandardCharsets.UTF_8); + } + catch (Exception e) { + throw new RuntimeException("Failed to read file: " + fileName, e); + } + } + + @Test + protected void testApp() throws Exception { + className = getClass().getSimpleName(); + String testNumber = className.replaceAll("[^0-9]", ""); + MvcResult mockMvcResult = mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL)).andExpect(status().isOk()) + .andExpect(jsonPath("$.openapi", is("3.0.1"))).andReturn(); + String result = mockMvcResult.getResponse().getContentAsString(); + Path path = Paths.get(getClass().getClassLoader().getResource("results/3.0.1/app" + testNumber + ".json").toURI()); + byte[] fileBytes = Files.readAllBytes(path); + String expected = new String(fileBytes); + assertEquals(expected, result, true); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app1/DatabaseLoader.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app1/DatabaseLoader.java new file mode 100644 index 000000000..f07681cbd --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app1/DatabaseLoader.java @@ -0,0 +1,55 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app1; + +import org.springframework.boot.CommandLineRunner; +import org.springframework.context.annotation.Bean; +import org.springframework.stereotype.Component; + +/** + * Pre-load some data using a Spring Boot {@link CommandLineRunner}. + * + * @author Greg Turnquist + */ +@Component +class DatabaseLoader { + + /** + * Use Spring to inject a {@link EmployeeRepository} that can then load data. Since this will run only after the app + * is operational, the database will be up. + * + * @param repository + */ + @Bean + CommandLineRunner init(EmployeeRepository repository) { + + return args -> { + repository.save(new Employee("Frodo", "Baggins", "ring bearer")); + repository.save(new Employee("Bilbo", "Baggins", "burglar")); + }; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app1/Employee.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app1/Employee.java new file mode 100644 index 000000000..e491214b7 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app1/Employee.java @@ -0,0 +1,77 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app1; + +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.Id; +import lombok.AccessLevel; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * Domain object representing a company employee. Project Lombok keeps actual code at a minimum. {@code @Data} - + * Generates getters, setters, toString, hash, and equals functions {@code @Entity} - JPA annotation to flag this class + * for DB persistence {@code @NoArgsConstructor} - Create a constructor with no args to support JPA + * {@code @AllArgsConstructor} - Create a constructor with all args to support testing + * {@code @JsonIgnoreProperties(ignoreUnknow=true)} When converting JSON to Java, ignore any unrecognized attributes. + * This is critical for REST because it encourages adding new fields in later versions that won't break. It also allows + * things like _links to be ignore as well, meaning HAL documents can be fetched and later posted to the server without + * adjustment. + * + * @author Greg Turnquist + */ +@Data +@Entity +@NoArgsConstructor(access = AccessLevel.PRIVATE) +@AllArgsConstructor +class Employee { + + @Id + @GeneratedValue + private Long id; + + private String firstName; + + private String lastName; + + private String role; + + /** + * Useful constructor when id is not yet known. + * + * @param firstName + * @param lastName + * @param role + */ + Employee(String firstName, String lastName, String role) { + + this.firstName = firstName; + this.lastName = lastName; + this.role = role; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app1/EmployeeController.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app1/EmployeeController.java new file mode 100644 index 000000000..53ce35d71 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app1/EmployeeController.java @@ -0,0 +1,139 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app1; + +import java.net.URI; +import java.net.URISyntaxException; +import java.util.List; +import java.util.stream.StreamSupport; + +import org.springframework.hateoas.CollectionModel; +import org.springframework.hateoas.EntityModel; +import org.springframework.hateoas.IanaLinkRelations; +import org.springframework.hateoas.Link; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.ResponseStatus; +import org.springframework.web.bind.annotation.RestController; + +import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.linkTo; +import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.methodOn; + +/** + * Spring Web {@link RestController} used to generate a REST API. + * + * @author Greg Turnquist + */ +@RestController +class EmployeeController { + + private final EmployeeRepository repository; + + EmployeeController(EmployeeRepository repository) { + this.repository = repository; + } + + /** + * Look up all employees, and transform them into a REST collection resource. Then return them through Spring Web's + * {@link ResponseEntity} fluent API. + */ + @GetMapping("/employees") + ResponseEntity>> findAll() { + + List> employees = StreamSupport.stream(repository.findAll().spliterator(), false) + .map(employee -> EntityModel.of(employee, // + linkTo(methodOn(EmployeeController.class).findOne(employee.getId())).withSelfRel(), // + linkTo(methodOn(EmployeeController.class).findAll()).withRel("employees"))) // + .toList(); + + return ResponseEntity.ok( // + CollectionModel.of(employees, // + linkTo(methodOn(EmployeeController.class).findAll()).withSelfRel())); + } + + @PostMapping("/employees") + @ResponseStatus(HttpStatus.CREATED) + ResponseEntity> newEmployee(@RequestBody Employee employee) { + + try { + Employee savedEmployee = repository.save(employee); + + EntityModel employeeResource = EntityModel.of(savedEmployee, // + linkTo(methodOn(EmployeeController.class).findOne(savedEmployee.getId())).withSelfRel()); + + return ResponseEntity // + .created(new URI(employeeResource.getRequiredLink(IanaLinkRelations.SELF).getHref())) // + .body(employeeResource); + } + catch (URISyntaxException e) { + return ResponseEntity.badRequest().body(null); + } + } + + /** + * Look up a single {@link Employee} and transform it into a REST resource. Then return it through Spring Web's + * {@link ResponseEntity} fluent API. + * + * @param id + */ + @GetMapping("/employees/{id}") + ResponseEntity> findOne(@PathVariable long id) { + + return repository.findById(id) // + .map(employee -> EntityModel.of(employee, // + linkTo(methodOn(EmployeeController.class).findOne(employee.getId())).withSelfRel(), // + linkTo(methodOn(EmployeeController.class).findAll()).withRel("employees"))) // + .map(ResponseEntity::ok) // + .orElse(ResponseEntity.notFound().build()); + } + + /** + * Update existing employee then return a Location header. + * + * @param employee + * @param id + * @return + */ + @PutMapping("/employees/{id}") + @ResponseStatus(HttpStatus.NO_CONTENT) + ResponseEntity updateEmployee(@RequestBody Employee employee, @PathVariable long id) throws URISyntaxException { + + Employee employeeToUpdate = employee; + employeeToUpdate.setId(id); + repository.save(employeeToUpdate); + + Link newlyCreatedLink = linkTo(methodOn(EmployeeController.class).findOne(id)).withSelfRel(); + + return ResponseEntity.noContent().location(new URI(newlyCreatedLink.getHref())).build(); + + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app1/EmployeeRepository.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app1/EmployeeRepository.java new file mode 100644 index 000000000..0f4a84020 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app1/EmployeeRepository.java @@ -0,0 +1,36 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app1; + +import org.springframework.data.repository.CrudRepository; + +/** + * A simple Spring Data {@link CrudRepository} for storing {@link Employee}s. + * + * @author Greg Turnquist + */ +interface EmployeeRepository extends CrudRepository { +} diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app1/SpringDocApp1Test.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app1/SpringDocApp1Test.java new file mode 100644 index 000000000..0d4ab7109 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app1/SpringDocApp1Test.java @@ -0,0 +1,38 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app1; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp1Test extends AbstractSpringDocTest { + + @SpringBootApplication + static class SpringDocTestApp {} + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app10/Dummy.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app10/Dummy.java new file mode 100644 index 000000000..85baf2822 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app10/Dummy.java @@ -0,0 +1,38 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app10; + +import lombok.AllArgsConstructor; +import lombok.Data; + +@Data +@AllArgsConstructor +public class Dummy { + + private T value; + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app10/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app10/HelloController.java new file mode 100644 index 000000000..ae53b9bcc --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app10/HelloController.java @@ -0,0 +1,79 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app10; + +import java.util.List; + +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageImpl; +import org.springframework.data.web.PagedModel; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +@SuppressWarnings("rawtypes") +@RestController +public class HelloController { + + @GetMapping("/page-simple") + public Page pageSimple() { + return pageImpl("test"); + } + + @GetMapping("/paged-model-simple") + public PagedModel pagedModelSimple() { + return pagedModel("test"); + } + + @GetMapping("/page-complex") + public Page>> pageComplex() { + return pageImpl(new Dummy<>(List.of("test"))); + } + + @GetMapping("/paged-model-complex") + public PagedModel>> pagedModelComplex() { + return pagedModel(new Dummy<>(List.of("test"))); + } + + @GetMapping("/page-raw") + public Page pageRaw() { + return pageSimple(); + } + + @GetMapping("/paged-model-raw") + public PagedModel pagedModelRaw() { + return pagedModelSimple(); + } + + private PagedModel pagedModel(T value) { + return new PagedModel<>(pageImpl(value)); + } + + private Page pageImpl(T value) { + return new PageImpl<>(List.of(value)); + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app10/SpringDocApp10DirectTest.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app10/SpringDocApp10DirectTest.java new file mode 100644 index 000000000..b56e3f542 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app10/SpringDocApp10DirectTest.java @@ -0,0 +1,59 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app10; + +import org.junit.jupiter.api.Test; +import org.springdoc.core.utils.Constants; +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.data.web.config.EnableSpringDataWebSupport; + +import static org.hamcrest.Matchers.is; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + +public class SpringDocApp10DirectTest extends AbstractSpringDocTest { + + @Override + @Test + protected void testApp() throws Exception { + mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL)) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.openapi", is("3.0.1"))) + .andExpect(content().json(getContent("results/3.0.1/app10-direct.json"), true)); + } + + @SpringBootApplication + @EnableSpringDataWebSupport(pageSerializationMode = EnableSpringDataWebSupport.PageSerializationMode.DIRECT) + public static class SpringDocTestApp { + + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app10/SpringDocApp10NotSpecifiedTest.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app10/SpringDocApp10NotSpecifiedTest.java new file mode 100644 index 000000000..de83b58dc --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app10/SpringDocApp10NotSpecifiedTest.java @@ -0,0 +1,72 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app10; + +import java.util.Optional; + +import io.swagger.v3.core.converter.ModelConverter; +import io.swagger.v3.core.converter.ModelConverters; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.springdoc.core.converters.PageOpenAPIConverter; +import org.springdoc.core.utils.Constants; +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +import static org.hamcrest.Matchers.is; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + +public class SpringDocApp10NotSpecifiedTest extends AbstractSpringDocTest { + + + @BeforeAll + public static void init() { + Optional pageOpenAPIConverter = + ModelConverters.getInstance().getConverters() + .stream().filter(modelConverter -> modelConverter instanceof PageOpenAPIConverter).findAny(); + pageOpenAPIConverter.ifPresent(ModelConverters.getInstance()::removeConverter); + } + + @Override + @Test + protected void testApp() throws Exception { + mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL)) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.openapi", is("3.0.1"))) + .andExpect(content().json(getContent("results/3.0.1/app10-direct.json"), true)); + } + + @SpringBootApplication + public static class SpringDocTestApp { + + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app10/SpringDocApp10ViaDtoTest.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app10/SpringDocApp10ViaDtoTest.java new file mode 100644 index 000000000..e8917f8d9 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app10/SpringDocApp10ViaDtoTest.java @@ -0,0 +1,59 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app10; + +import org.junit.jupiter.api.Test; +import org.springdoc.core.utils.Constants; +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.data.web.config.EnableSpringDataWebSupport; + +import static org.hamcrest.Matchers.is; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + +public class SpringDocApp10ViaDtoTest extends AbstractSpringDocTest { + + @Override + @Test + protected void testApp() throws Exception { + mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL)) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.openapi", is("3.0.1"))) + .andExpect(content().json(getContent("results/3.0.1/app10-via_dto.json"), true)); + } + + @SpringBootApplication + @EnableSpringDataWebSupport(pageSerializationMode = EnableSpringDataWebSupport.PageSerializationMode.VIA_DTO) + public static class SpringDocTestApp { + + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app2/SpringDocApp2Test.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app2/SpringDocApp2Test.java new file mode 100644 index 000000000..b89e6019b --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app2/SpringDocApp2Test.java @@ -0,0 +1,40 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app2; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.test.context.TestPropertySource; + +@TestPropertySource(properties = "springdoc.model-converters.pageable-converter.enabled=true") +public class SpringDocApp2Test extends AbstractSpringDocTest { + + @SpringBootApplication + static class SpringDocTestApp {} + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app2/config/DatabaseConfig.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app2/config/DatabaseConfig.java new file mode 100644 index 000000000..facf8d943 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app2/config/DatabaseConfig.java @@ -0,0 +1,58 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app2.config; + +import java.time.LocalDate; + +import jakarta.annotation.PostConstruct; +import lombok.RequiredArgsConstructor; +import test.org.springdoc.api.v30.app2.entities.Post; +import test.org.springdoc.api.v30.app2.repositories.PostRepository; + +import org.springframework.context.annotation.Configuration; + +/** + * @author Davide Pedone + * 2020 + */ +@Configuration +@RequiredArgsConstructor +public class DatabaseConfig { + + private final PostRepository postRepository; + + @PostConstruct + private void postConstruct() { + for (int i = 0; i < 33; i++) { + Post post = new Post(); + post.setAuthor("name" + i); + post.setContent("content" + i); + post.setCreatedAt(LocalDate.now().toEpochDay()); + postRepository.save(post); + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app2/controller/PostController.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app2/controller/PostController.java new file mode 100644 index 000000000..f0745d2ba --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app2/controller/PostController.java @@ -0,0 +1,55 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app2.controller; + +import lombok.RequiredArgsConstructor; +import test.org.springdoc.api.v30.app2.entities.Post; +import test.org.springdoc.api.v30.app2.service.PostService; + +import org.springframework.data.domain.Pageable; +import org.springframework.hateoas.EntityModel; +import org.springframework.hateoas.PagedModel; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * @author Davide Pedone + * 2020 + */ +@RestController +@RequiredArgsConstructor +public class PostController { + + private final PostService postService; + + @GetMapping + public ResponseEntity>> getAll(Pageable pageable) { + return new ResponseEntity<>(postService.getAll(pageable), HttpStatus.OK); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app2/entities/Post.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app2/entities/Post.java new file mode 100644 index 000000000..0a9bad4b0 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app2/entities/Post.java @@ -0,0 +1,56 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app2.entities; + +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.Id; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @author Davide Pedone + * 2020 + */ +@Data +@Entity +@NoArgsConstructor +@AllArgsConstructor +public class Post { + + @Id + @GeneratedValue + private Long id; + + private String author; + + private String content; + + private Long createdAt; + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app2/hateoas/PostResourceAssembler.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app2/hateoas/PostResourceAssembler.java new file mode 100644 index 000000000..66f749466 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app2/hateoas/PostResourceAssembler.java @@ -0,0 +1,48 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app2.hateoas; + + +import test.org.springdoc.api.v30.app2.entities.Post; + +import org.springframework.hateoas.EntityModel; +import org.springframework.hateoas.server.RepresentationModelAssembler; +import org.springframework.stereotype.Component; + +/** + * @author Davide Pedone + * 2020 + */ +@Component +public class PostResourceAssembler implements RepresentationModelAssembler> { + + + @Override + public EntityModel toModel(Post entity) { + return EntityModel.of(entity); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app2/repositories/PostRepository.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app2/repositories/PostRepository.java new file mode 100644 index 000000000..2b98aed8f --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app2/repositories/PostRepository.java @@ -0,0 +1,40 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app2.repositories; + + +import test.org.springdoc.api.v30.app2.entities.Post; + +import org.springframework.data.repository.CrudRepository; +import org.springframework.data.repository.PagingAndSortingRepository; + +/** + * @author Davide Pedone + * 2020 + */ +public interface PostRepository extends PagingAndSortingRepository, CrudRepository { +} diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app2/service/PostService.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app2/service/PostService.java new file mode 100644 index 000000000..9e5bdc6a7 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app2/service/PostService.java @@ -0,0 +1,61 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app2.service; + + +import lombok.RequiredArgsConstructor; +import test.org.springdoc.api.v30.app2.entities.Post; +import test.org.springdoc.api.v30.app2.hateoas.PostResourceAssembler; +import test.org.springdoc.api.v30.app2.repositories.PostRepository; + +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.data.web.PagedResourcesAssembler; +import org.springframework.hateoas.EntityModel; +import org.springframework.hateoas.PagedModel; +import org.springframework.stereotype.Service; + +/** + * @author Davide Pedone + * 2020 + */ +@RequiredArgsConstructor +@Service +public class PostService { + + private final PostRepository postRepository; + + private final PagedResourcesAssembler pagedResourcesAssembler; + + private final PostResourceAssembler postResourceAssembler; + + public PagedModel> getAll(Pageable pageable) { + Page postPage = postRepository.findAll(pageable); + return pagedResourcesAssembler.toModel(postPage, postResourceAssembler); + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app3/DatabaseLoader.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app3/DatabaseLoader.java new file mode 100644 index 000000000..28cc70f30 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app3/DatabaseLoader.java @@ -0,0 +1,55 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app3; + +import org.springframework.boot.CommandLineRunner; +import org.springframework.context.annotation.Bean; +import org.springframework.stereotype.Component; + +/** + * Pre-load some data using a Spring Boot {@link CommandLineRunner}. + * + * @author Greg Turnquist + */ +@Component +class DatabaseLoader { + + /** + * Use Spring to inject a {@link EmployeeRepository} that can then load data. Since this will run only after the app + * is operational, the database will be up. + * + * @param repository + */ + @Bean + CommandLineRunner init(EmployeeRepository repository) { + + return args -> { + repository.save(new Employee("Frodo", "Baggins", "ring bearer")); + repository.save(new Employee("Bilbo", "Baggins", "burglar")); + }; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app3/Employee.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app3/Employee.java new file mode 100644 index 000000000..a3f214c08 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app3/Employee.java @@ -0,0 +1,77 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app3; + +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.Id; +import lombok.AccessLevel; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * Domain object representing a company employee. Project Lombok keeps actual code at a minimum. {@code @Data} - + * Generates getters, setters, toString, hash, and equals functions {@code @Entity} - JPA annotation to flag this class + * for DB persistence {@code @NoArgsConstructor} - Create a constructor with no args to support JPA + * {@code @AllArgsConstructor} - Create a constructor with all args to support testing + * {@code @JsonIgnoreProperties(ignoreUnknow=true)} When converting JSON to Java, ignore any unrecognized attributes. + * This is critical for REST because it encourages adding new fields in later versions that won't break. It also allows + * things like _links to be ignore as well, meaning HAL documents can be fetched and later posted to the server without + * adjustment. + * + * @author Greg Turnquist + */ +@Data +@Entity +@NoArgsConstructor(access = AccessLevel.PRIVATE) +@AllArgsConstructor +class Employee { + + @Id + @GeneratedValue + private Long id; + + private String firstName; + + private String lastName; + + private String role; + + /** + * Useful constructor when id is not yet known. + * + * @param firstName + * @param lastName + * @param role + */ + Employee(String firstName, String lastName, String role) { + + this.firstName = firstName; + this.lastName = lastName; + this.role = role; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app3/EmployeeController.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app3/EmployeeController.java new file mode 100644 index 000000000..7e667c7bb --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app3/EmployeeController.java @@ -0,0 +1,54 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app3; + +import org.springframework.hateoas.EntityModel; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RestController; + +/** + * Spring Web {@link RestController} used to generate a REST API. + * + * @author Greg Turnquist + */ +@RestController +class EmployeeController { + + /** + * Look up a single {@link Employee} and transform it into a REST resource. Then return it through Spring Web's + * {@link ResponseEntity} fluent API. + * + * @param id + */ + @GetMapping("/employees/{id}") + EntityModel findOne(@PathVariable long id) { + + return null; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app3/EmployeeRepository.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app3/EmployeeRepository.java new file mode 100644 index 000000000..f0914e0c7 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app3/EmployeeRepository.java @@ -0,0 +1,36 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app3; + +import org.springframework.data.repository.CrudRepository; + +/** + * A simple Spring Data {@link CrudRepository} for storing {@link Employee}s. + * + * @author Greg Turnquist + */ +interface EmployeeRepository extends CrudRepository { +} diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app3/SpringDocApp3Test.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app3/SpringDocApp3Test.java new file mode 100644 index 000000000..30a8aeb1a --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app3/SpringDocApp3Test.java @@ -0,0 +1,37 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app3; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.test.context.TestPropertySource; + +@TestPropertySource(properties = "springdoc.remove-broken-reference-definitions=false") +public class SpringDocApp3Test extends AbstractSpringDocTest { + + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app3/SpringDocTestApp.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app3/SpringDocTestApp.java new file mode 100644 index 000000000..756719ead --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app3/SpringDocTestApp.java @@ -0,0 +1,39 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app3; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class SpringDocTestApp { + + public static void main(String[] args) { + SpringApplication.run(SpringDocTestApp.class, args); + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app4/Album.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app4/Album.java new file mode 100644 index 000000000..185011185 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app4/Album.java @@ -0,0 +1,55 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app4; + +public class Album { + + private String title; + + private String description; + + private String releaseDate; + + public Album(String title, String description, String releaseDate) { + this.title = title; + this.description = description; + this.releaseDate = releaseDate; + } + + public String getTitle() { + return title; + } + + public String getDescription() { + return description; + } + + public String getReleaseDate() { + return releaseDate; + } + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app4/AlbumController.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app4/AlbumController.java new file mode 100644 index 000000000..87c097c3e --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app4/AlbumController.java @@ -0,0 +1,58 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app4; + +import java.util.Arrays; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageImpl; +import org.springframework.data.web.PagedResourcesAssembler; +import org.springframework.hateoas.PagedModel; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@SuppressWarnings("unchecked") +public class AlbumController { + + @Autowired + private AlbumModelAssembler albumModelAssembler; + + @Autowired + private PagedResourcesAssembler pagedResourcesAssembler; + + @GetMapping("/api/albums") + public PagedModel getAllAlbums() { + Album album1 = new Album("album-title-1", "album-description-1", "album-release-date-1"); + Album album2 = new Album("album-title-2", "album-description-2", "album-release-date-2"); + Page albumPage = new PageImpl<>(Arrays.asList(album1, album2)); + + return pagedResourcesAssembler.toModel(albumPage, albumModelAssembler); + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app4/AlbumModelAssembler.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app4/AlbumModelAssembler.java new file mode 100644 index 000000000..4a90ad1b7 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app4/AlbumModelAssembler.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.app4; + +import java.util.ArrayList; +import java.util.List; + +import org.springframework.hateoas.EntityModel; +import org.springframework.hateoas.Link; +import org.springframework.hateoas.server.RepresentationModelAssembler; +import org.springframework.stereotype.Component; + +@Component +public class AlbumModelAssembler implements RepresentationModelAssembler> { + + @Override + public EntityModel toModel(Album entity) { + List links = new ArrayList<>(); + return EntityModel.of(entity, links); + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app4/SpringDocApp4Test.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app4/SpringDocApp4Test.java new file mode 100644 index 000000000..6a3b81f87 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app4/SpringDocApp4Test.java @@ -0,0 +1,38 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app4; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp4Test extends AbstractSpringDocTest { + + @SpringBootApplication + static class SpringDocTestApp {} + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app5/SpringDocApp5Test.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app5/SpringDocApp5Test.java new file mode 100644 index 000000000..0f558d601 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app5/SpringDocApp5Test.java @@ -0,0 +1,50 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app5; + +import io.swagger.v3.oas.models.Components; +import io.swagger.v3.oas.models.OpenAPI; +import io.swagger.v3.oas.models.media.ObjectSchema; +import io.swagger.v3.oas.models.media.StringSchema; +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; + +public class SpringDocApp5Test extends AbstractSpringDocTest { + + @SpringBootApplication + static class SpringDocTestApp { + @Bean + public OpenAPI customOpenAPI() { + return new OpenAPI().components(new Components() + .addSchemas("CompanyDtoNew", new ObjectSchema().addProperties("id", new StringSchema().format("uuid" + )).addProperties("name", new StringSchema()))); + } + } + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app5/controller/CompanyController.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app5/controller/CompanyController.java new file mode 100644 index 000000000..922a04f29 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app5/controller/CompanyController.java @@ -0,0 +1,57 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app5.controller; + +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.Valid; +import lombok.RequiredArgsConstructor; +import test.org.springdoc.api.v30.app5.entities.CompanyDto; + +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RestController; + +/** + * @author Davide Pedone + * 2020 + */ +@RestController +@RequiredArgsConstructor +public class CompanyController { + + + @PostMapping + @io.swagger.v3.oas.annotations.parameters.RequestBody( + description = "Details of the Item to be created", + content = @Content(schema = @Schema(ref = "#/components/schemas/CompanyDtoNew"))) + public CompanyDto create(@Valid @RequestBody final CompanyDto companyDto) { + + return null; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app5/entities/Company.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app5/entities/Company.java new file mode 100644 index 000000000..6f7384d96 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app5/entities/Company.java @@ -0,0 +1,55 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app5.entities; + +import java.util.UUID; + +import com.fasterxml.jackson.annotation.JsonProperty; +import jakarta.validation.constraints.NotNull; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import org.springframework.hateoas.RepresentationModel; +import org.springframework.hateoas.server.core.Relation; + +/** + * @author bnasslahsen + */ +@AllArgsConstructor +@Data +@Builder +@EqualsAndHashCode(callSuper = false) +@Relation(collectionRelation = "companies", itemRelation = "company") +public class Company extends RepresentationModel { + @JsonProperty(access = JsonProperty.Access.READ_ONLY) + private UUID id; + + @NotNull + private String name; +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app5/entities/CompanyDto.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app5/entities/CompanyDto.java new file mode 100644 index 000000000..45a863a72 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app5/entities/CompanyDto.java @@ -0,0 +1,55 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app5.entities; + +import java.util.UUID; + +import com.fasterxml.jackson.annotation.JsonProperty; +import jakarta.validation.constraints.NotNull; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import org.springframework.hateoas.RepresentationModel; +import org.springframework.hateoas.server.core.Relation; + +/** + * @author bnasslahsen + */ +@AllArgsConstructor +@Data +@Builder +@EqualsAndHashCode(callSuper = false) +@Relation(collectionRelation = "companies", itemRelation = "company") +public class CompanyDto extends RepresentationModel { + @JsonProperty(access = JsonProperty.Access.READ_ONLY) + private UUID id; + + @NotNull + private String name; +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app5/hateoas/CompanyModelAssembler.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app5/hateoas/CompanyModelAssembler.java new file mode 100644 index 000000000..57ecb5013 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app5/hateoas/CompanyModelAssembler.java @@ -0,0 +1,55 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app5.hateoas; + +import test.org.springdoc.api.v30.app5.controller.CompanyController; +import test.org.springdoc.api.v30.app5.entities.Company; +import test.org.springdoc.api.v30.app5.entities.CompanyDto; + +import org.springframework.hateoas.server.mvc.RepresentationModelAssemblerSupport; +import org.springframework.lang.NonNull; +import org.springframework.stereotype.Component; + +/** + * @author bnasslahsen + */ +@Component +public class CompanyModelAssembler extends RepresentationModelAssemblerSupport { + + public CompanyModelAssembler() { + super(CompanyController.class, CompanyDto.class); + } + + @Override + @NonNull + public CompanyDto toModel(@NonNull final Company company) { + return CompanyDto.builder() + .id(company.getId()) + .name(company.getName()) + .build(); + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app6/SpringDocApp6Test.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app6/SpringDocApp6Test.java new file mode 100644 index 000000000..7a238ff74 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app6/SpringDocApp6Test.java @@ -0,0 +1,80 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app6; + +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; +import java.util.Map.Entry; + +import com.fasterxml.jackson.databind.introspect.SimpleMixInResolver; +import com.fasterxml.jackson.databind.type.ClassKey; +import org.apache.commons.lang3.reflect.FieldUtils; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.springdoc.core.providers.ObjectMapperProvider; +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.test.context.TestPropertySource; + +@TestPropertySource(properties = "spring.hateoas.use-hal-as-default-json-media-type= false") +public class SpringDocApp6Test extends AbstractSpringDocTest { + + private final Map> springMixins = new HashMap<>(); + + @Autowired + ObjectMapperProvider objectMapperProvider; + + @BeforeEach + void init() throws IllegalAccessException { + SimpleMixInResolver _mixIns = (SimpleMixInResolver) FieldUtils.readDeclaredField(objectMapperProvider.jsonMapper(),"_mixIns", true); + Map> _localMixIns = (Map>) FieldUtils.readDeclaredField(_mixIns, "_localMixIns", true); + Iterator>> iterator = _localMixIns.entrySet().iterator(); + + while (iterator.hasNext()) { + Entry> entry = iterator.next(); + if (entry.getKey().toString().startsWith("org.springframework")) { + springMixins.put(entry.getKey(), entry.getValue()); + iterator.remove(); + } + } + } + + @AfterEach + void clean() throws IllegalAccessException { + SimpleMixInResolver _mixIns = (SimpleMixInResolver) FieldUtils.readDeclaredField(objectMapperProvider.jsonMapper(), "_mixIns", true); + Map> _localMixIns = (Map>) FieldUtils.readDeclaredField(_mixIns, "_localMixIns", true); + _localMixIns.putAll(springMixins); + } + + @SpringBootApplication + static class SpringDocTestApp { + } + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app6/controller/ItemController.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app6/controller/ItemController.java new file mode 100644 index 000000000..b8fd4d2c2 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app6/controller/ItemController.java @@ -0,0 +1,63 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app6.controller; + +import java.util.List; +import java.util.stream.Stream; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import test.org.springdoc.api.v30.app6.model.Item; + +import org.springframework.hateoas.CollectionModel; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.linkTo; +import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.methodOn; + +@RestController +@RequestMapping(value = "/v1/items", produces = MediaType.APPLICATION_JSON_VALUE) +@Tag(name = "Item", description = "The Item API") +public class ItemController { + + List items = Stream.of(new Item("foo"), new Item("bar")).toList(); + + @Operation(summary = "Get all items") + @GetMapping(produces = { MediaType.APPLICATION_JSON_VALUE }) + public ResponseEntity> getAllItems() { + + CollectionModel collection = CollectionModel.of(items); + collection.add(linkTo(methodOn(ItemController.class).getAllItems()).withSelfRel().expand()); + + return new ResponseEntity<>(collection, HttpStatus.OK); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app6/model/Item.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app6/model/Item.java new file mode 100644 index 000000000..570b2a487 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app6/model/Item.java @@ -0,0 +1,58 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app6.model; + +import org.springframework.hateoas.Link; +import org.springframework.hateoas.RepresentationModel; + + +public class Item extends RepresentationModel { + + private String description; + + public Item(String description) { + this.description = description; + } + + public Item(Link initialLink, String description) { + super(initialLink); + this.description = description; + } + + public Item(Iterable initialLinks, String description) { + super(initialLinks); + this.description = description; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app7/FooConfiguration.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app7/FooConfiguration.java new file mode 100644 index 000000000..4694d8e15 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app7/FooConfiguration.java @@ -0,0 +1,42 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app7; + +import org.springdoc.core.models.GroupedOpenApi; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +public class FooConfiguration { + @Bean + public GroupedOpenApi userOpenApi() { + String packagesToscan[] = { "test.org.springdoc.api.app7" }; + return GroupedOpenApi.builder().group("foo-service").packagesToScan(packagesToscan) + .build(); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app7/SpringDocApp7Test.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app7/SpringDocApp7Test.java new file mode 100644 index 000000000..6c1a11c2f --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app7/SpringDocApp7Test.java @@ -0,0 +1,39 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app7; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp7Test extends AbstractSpringDocTest { + + @SpringBootApplication + static class SpringDocTestApp { + } + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app7/application/Foo.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app7/application/Foo.java new file mode 100644 index 000000000..a724fe4c1 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app7/application/Foo.java @@ -0,0 +1,36 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app7.application; + +import lombok.AllArgsConstructor; +import lombok.Data; + +@Data +@AllArgsConstructor +public class Foo { + String foo; +} diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app7/application/FooController.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app7/application/FooController.java new file mode 100644 index 000000000..2d396aeec --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app7/application/FooController.java @@ -0,0 +1,59 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app7.application; + +import java.util.UUID; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.hateoas.EntityModel; +import org.springframework.hateoas.MediaTypes; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class FooController { + + private final FooService fooService; + + private final FooResourceAssembler fooResourceAssembler; + + @Autowired + public FooController( + FooService fooService, + FooResourceAssembler fooResourceAssembler) { + this.fooService = fooService; + this.fooResourceAssembler = fooResourceAssembler; + } + + @GetMapping(value = "foo/{id}", produces = MediaTypes.HAL_JSON_VALUE) + public ResponseEntity> getFoo(@PathVariable("id") UUID id) throws Exception { + Foo foo = fooService.getFoo(id).orElseThrow(Exception::new); + return ResponseEntity.ok(fooResourceAssembler.toModel(foo)); + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app7/application/FooResourceAssembler.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app7/application/FooResourceAssembler.java new file mode 100644 index 000000000..546bad633 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app7/application/FooResourceAssembler.java @@ -0,0 +1,61 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app7.application; + +import java.util.UUID; + +import org.springframework.hateoas.CollectionModel; +import org.springframework.hateoas.EntityModel; +import org.springframework.hateoas.server.SimpleRepresentationModelAssembler; +import org.springframework.stereotype.Component; + +import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.linkTo; +import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.methodOn; + +@Component +public class FooResourceAssembler + implements SimpleRepresentationModelAssembler { + + @Override + public void addLinks(EntityModel resource) { + Foo foo = resource.getContent(); + if (foo != null) { + try { + resource.add( + linkTo(methodOn(FooController.class).getFoo(UUID.fromString(foo.getFoo()))).withSelfRel()); + } + catch (Exception e) { + throw new RuntimeException(e); + } + } + } + + @Override + public void addLinks(CollectionModel> resources) { + + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app7/application/FooService.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app7/application/FooService.java new file mode 100644 index 000000000..7a290453e --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app7/application/FooService.java @@ -0,0 +1,39 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app7.application; + +import java.util.Optional; +import java.util.UUID; + +import org.springframework.stereotype.Service; + +@Service +public class FooService { + public Optional getFoo(UUID uuid) { + return Optional.of(new Foo(uuid.toString())); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app8/DatabaseLoader.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app8/DatabaseLoader.java new file mode 100644 index 000000000..e362554b2 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app8/DatabaseLoader.java @@ -0,0 +1,55 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app8; + +import org.springframework.boot.CommandLineRunner; +import org.springframework.context.annotation.Bean; +import org.springframework.stereotype.Component; + +/** + * Pre-load some data using a Spring Boot {@link CommandLineRunner}. + * + * @author Greg Turnquist + */ +@Component +class DatabaseLoader { + + /** + * Use Spring to inject a {@link EmployeeRepository} that can then load data. Since this will run only after the app + * is operational, the database will be up. + * + * @param repository + */ + @Bean + CommandLineRunner init(EmployeeRepository repository) { + + return args -> { + repository.save(new Employee("Frodo", "Baggins", "ring bearer")); + repository.save(new Employee("Bilbo", "Baggins", "burglar")); + }; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app8/Employee.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app8/Employee.java new file mode 100644 index 000000000..700df1514 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app8/Employee.java @@ -0,0 +1,77 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app8; + +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.Id; +import lombok.AccessLevel; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * Domain object representing a company employee. Project Lombok keeps actual code at a minimum. {@code @Data} - + * Generates getters, setters, toString, hash, and equals functions {@code @Entity} - JPA annotation to flag this class + * for DB persistence {@code @NoArgsConstructor} - Create a constructor with no args to support JPA + * {@code @AllArgsConstructor} - Create a constructor with all args to support testing + * {@code @JsonIgnoreProperties(ignoreUnknow=true)} When converting JSON to Java, ignore any unrecognized attributes. + * This is critical for REST because it encourages adding new fields in later versions that won't break. It also allows + * things like _links to be ignore as well, meaning HAL documents can be fetched and later posted to the server without + * adjustment. + * + * @author Greg Turnquist + */ +@Data +@Entity +@NoArgsConstructor(access = AccessLevel.PRIVATE) +@AllArgsConstructor +class Employee { + + @Id + @GeneratedValue + private Long id; + + private String firstName; + + private String lastName; + + private String role; + + /** + * Useful constructor when id is not yet known. + * + * @param firstName + * @param lastName + * @param role + */ + Employee(String firstName, String lastName, String role) { + + this.firstName = firstName; + this.lastName = lastName; + this.role = role; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app8/EmployeeController.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app8/EmployeeController.java new file mode 100644 index 000000000..3a21941b4 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app8/EmployeeController.java @@ -0,0 +1,139 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app8; + +import java.net.URI; +import java.net.URISyntaxException; +import java.util.List; +import java.util.stream.StreamSupport; + +import org.springframework.hateoas.CollectionModel; +import org.springframework.hateoas.EntityModel; +import org.springframework.hateoas.IanaLinkRelations; +import org.springframework.hateoas.Link; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.ResponseStatus; +import org.springframework.web.bind.annotation.RestController; + +import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.linkTo; +import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.methodOn; + +/** + * Spring Web {@link RestController} used to generate a REST API. + * + * @author Greg Turnquist + */ +@RestController +class EmployeeController { + + private final EmployeeRepository repository; + + EmployeeController(EmployeeRepository repository) { + this.repository = repository; + } + + /** + * Look up all employees, and transform them into a REST collection resource. Then return them through Spring Web's + * {@link ResponseEntity} fluent API. + */ + @GetMapping("/employees") + ResponseEntity>> findAll() { + + List> employees = StreamSupport.stream(repository.findAll().spliterator(), false) + .map(employee -> EntityModel.of(employee, // + linkTo(methodOn(EmployeeController.class).findOne(employee.getId())).withSelfRel(), // + linkTo(methodOn(EmployeeController.class).findAll()).withRel("employees"))) // + .toList(); + + return ResponseEntity.ok( // + CollectionModel.of(employees, // + linkTo(methodOn(EmployeeController.class).findAll()).withSelfRel())); + } + + @PostMapping("/employees") + @ResponseStatus(HttpStatus.CREATED) + ResponseEntity> newEmployee(@RequestBody Employee employee) { + + try { + Employee savedEmployee = repository.save(employee); + + EntityModel employeeResource = EntityModel.of(savedEmployee, // + linkTo(methodOn(EmployeeController.class).findOne(savedEmployee.getId())).withSelfRel()); + + return ResponseEntity // + .created(new URI(employeeResource.getRequiredLink(IanaLinkRelations.SELF).getHref())) // + .body(employeeResource); + } + catch (URISyntaxException e) { + return ResponseEntity.badRequest().body(null); + } + } + + /** + * Look up a single {@link Employee} and transform it into a REST resource. Then return it through Spring Web's + * {@link ResponseEntity} fluent API. + * + * @param id + */ + @GetMapping("/employees/{id}") + ResponseEntity> findOne(@PathVariable long id) { + + return repository.findById(id) // + .map(employee -> EntityModel.of(employee, // + linkTo(methodOn(EmployeeController.class).findOne(employee.getId())).withSelfRel(), // + linkTo(methodOn(EmployeeController.class).findAll()).withRel("employees"))) // + .map(ResponseEntity::ok) // + .orElse(ResponseEntity.notFound().build()); + } + + /** + * Update existing employee then return a Location header. + * + * @param employee + * @param id + * @return + */ + @PutMapping("/employees/{id}") + @ResponseStatus(HttpStatus.NO_CONTENT) + ResponseEntity updateEmployee(@RequestBody Employee employee, @PathVariable long id) throws URISyntaxException { + + Employee employeeToUpdate = employee; + employeeToUpdate.setId(id); + repository.save(employeeToUpdate); + + Link newlyCreatedLink = linkTo(methodOn(EmployeeController.class).findOne(id)).withSelfRel(); + + return ResponseEntity.noContent().location(new URI(newlyCreatedLink.getHref())).build(); + + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app8/EmployeeRepository.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app8/EmployeeRepository.java new file mode 100644 index 000000000..dfb350e43 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app8/EmployeeRepository.java @@ -0,0 +1,36 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app8; + +import org.springframework.data.repository.CrudRepository; + +/** + * A simple Spring Data {@link CrudRepository} for storing {@link Employee}s. + * + * @author Greg Turnquist + */ +interface EmployeeRepository extends CrudRepository { +} diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app8/SpringDocApp8Test.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app8/SpringDocApp8Test.java new file mode 100644 index 000000000..ee48105ed --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app8/SpringDocApp8Test.java @@ -0,0 +1,78 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app8; + +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; +import java.util.Map.Entry; + +import com.fasterxml.jackson.databind.introspect.SimpleMixInResolver; +import com.fasterxml.jackson.databind.type.ClassKey; +import org.apache.commons.lang3.reflect.FieldUtils; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.springdoc.core.providers.ObjectMapperProvider; +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.test.context.TestPropertySource; + +@TestPropertySource(properties = "springdoc.enable-hateoas=false") +public class SpringDocApp8Test extends AbstractSpringDocTest { + + private final Map> springMixins = new HashMap<>(); + + @Autowired + ObjectMapperProvider objectMapperProvider; + + @BeforeEach + void init() throws IllegalAccessException { + SimpleMixInResolver _mixIns = (SimpleMixInResolver) FieldUtils.readDeclaredField(objectMapperProvider.jsonMapper(), "_mixIns", true); + Map> _localMixIns = (Map>) FieldUtils.readDeclaredField(_mixIns, "_localMixIns", true); + Iterator>> it = _localMixIns.entrySet().iterator(); + while (it.hasNext()) { + Map.Entry> entry = it.next(); + if (entry.getKey().toString().startsWith("org.springframework")) { + springMixins.put(entry.getKey(), entry.getValue()); + it.remove(); + } + } + + } + + @AfterEach + void clean() throws IllegalAccessException { + SimpleMixInResolver _mixIns = (SimpleMixInResolver) FieldUtils.readDeclaredField(objectMapperProvider.jsonMapper(), "_mixIns", true); + Map> _localMixIns = (Map>) FieldUtils.readDeclaredField(_mixIns, "_localMixIns", true); + _localMixIns.putAll(springMixins); + } + + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app9/FooConfiguration.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app9/FooConfiguration.java new file mode 100644 index 000000000..baf92b141 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app9/FooConfiguration.java @@ -0,0 +1,83 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app9; + +import java.util.List; + +import io.swagger.v3.oas.models.Components; +import io.swagger.v3.oas.models.OpenAPI; +import io.swagger.v3.oas.models.info.Contact; +import io.swagger.v3.oas.models.info.Info; +import io.swagger.v3.oas.models.media.ArraySchema; +import io.swagger.v3.oas.models.media.Schema; +import io.swagger.v3.oas.models.security.SecurityScheme; +import io.swagger.v3.oas.models.tags.Tag; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +public class FooConfiguration { + @Bean + OpenAPI customOpenApi() { + return new OpenAPI() + .components(new Components().addSecuritySchemes("bearerScheme", + new SecurityScheme() + .type(SecurityScheme.Type.HTTP) + .scheme("bearer") + .bearerFormat("JWT")) + .addSchemas("FeedResponse", feedResponseSchema())) + .info(new Info() + .title("Response API") + .description("API for some response") + .version("0.0.1") + .contact(new Contact() + .name("EAlf91"))) + .tags(List.of(new Tag() + .name("ResponseTag") + .description("ResponseTag for API"), + new Tag() + .name("ResponseData") + .description("Version 2 ResponseApi"))); + + } + + private Schema feedResponseSchema() { + Schema schema = new Schema<>(); + schema.addProperty("_links", linkSchema()); + schema.addProperty("data", new ArraySchema().items(new Schema<>().$ref("#/components/schemas/ResponseData"))); + return schema; + } + + private Schema linkSchema() { + Schema linkSchema = new Schema<>(); + linkSchema.addProperty("next", new Schema<>().$ref("#/components/schemas/Link").example("http://localhost:8080/some-link")); + linkSchema.addProperty("self", new Schema<>().$ref("#/components/schemas/Link").example("http://localhost:8080/some-other-link")); + return linkSchema; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app9/SpringDocApp9Test.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app9/SpringDocApp9Test.java new file mode 100644 index 000000000..c1557b44f --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app9/SpringDocApp9Test.java @@ -0,0 +1,39 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app9; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp9Test extends AbstractSpringDocTest { + + @SpringBootApplication + static class SpringDocTestApp { + } + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app9/application/FooController.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app9/application/FooController.java new file mode 100644 index 000000000..530c4077b --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app9/application/FooController.java @@ -0,0 +1,63 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app9.application; + +import java.util.List; +import java.util.UUID; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import test.org.springdoc.api.v30.app9.application.dto.FeedResponse; +import test.org.springdoc.api.v30.app9.application.dto.ResponseData; + +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseStatus; +import org.springframework.web.bind.annotation.RestController; +@Tag(name = "ResponseDataController") +@RestController +@RequestMapping(value = "/some-route", produces = MediaType.APPLICATION_JSON_VALUE) +@RequiredArgsConstructor +@Slf4j +public class FooController { + + + + + @Operation(summary = "Get all data", description = "Get all data") + @GetMapping(value = "foo/{id}") + @ResponseStatus(HttpStatus.OK) + public FeedResponse getFoo(@PathVariable("id") UUID id) { + var dataList = List.of(ResponseData.builder().dataId(id).build()); + return FeedResponse.createForResponseData(dataList, UUID.randomUUID()); + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app9/application/dto/FeedResponse.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app9/application/dto/FeedResponse.java new file mode 100644 index 000000000..6a7a435ad --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app9/application/dto/FeedResponse.java @@ -0,0 +1,65 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app9.application.dto; + +import java.util.List; +import java.util.UUID; + +import com.fasterxml.jackson.annotation.JsonProperty; +import jakarta.validation.constraints.NotNull; +import lombok.AccessLevel; +import lombok.Builder; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.experimental.Accessors; +import test.org.springdoc.api.v30.app9.application.FooController; + +import org.springframework.hateoas.IanaLinkRelations; +import org.springframework.hateoas.RepresentationModel; + +import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.linkTo; +import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.methodOn; + +@Getter +@Accessors(fluent = true) +@Builder(access = AccessLevel.PACKAGE) +@EqualsAndHashCode(callSuper = true) +public class FeedResponse extends RepresentationModel { + @NotNull + @JsonProperty("data") + private final List data; + + public static FeedResponse createForResponseData(@NotNull List responseData, UUID uuid) { + var feedResponse = new FeedResponse(responseData); + feedResponse.add(linkTo(methodOn(FooController.class).getFoo(uuid)).withSelfRel()); + + + feedResponse.add(linkTo(methodOn(FooController.class).getFoo(uuid)).withRel(IanaLinkRelations.NEXT)); + + return feedResponse; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app9/application/dto/ResponseData.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app9/application/dto/ResponseData.java new file mode 100644 index 000000000..847a9e465 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v30/app9/application/dto/ResponseData.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.app9.application.dto; + +import java.time.LocalDate; +import java.util.UUID; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotNull; +import lombok.Builder; + +@Builder +public record ResponseData( + @JsonProperty(value = "DATA_ID", required = true) + @NotNull + UUID dataId, + @JsonProperty(value = "DATE", required = true) + @NotNull + @Schema(example = "2024-03-27", format = "date") + LocalDate date +) {} diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/AbstractSpringDocTest.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/AbstractSpringDocTest.java new file mode 100644 index 000000000..a38cc04c9 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/AbstractSpringDocTest.java @@ -0,0 +1,83 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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; + +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; + +import org.junit.jupiter.api.Test; +import org.springdoc.core.utils.Constants; + +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.web.servlet.MockMvc; +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; + +@ActiveProfiles("test") +@SpringBootTest +@AutoConfigureMockMvc +public abstract class AbstractSpringDocTest { + + public static String className; + + @Autowired + protected MockMvc mockMvc; + + public static String getContent(String fileName) { + try { + Path path = Paths.get(AbstractSpringDocTest.class.getClassLoader().getResource(fileName).toURI()); + byte[] fileBytes = Files.readAllBytes(path); + return new String(fileBytes, StandardCharsets.UTF_8); + } + catch (Exception e) { + throw new RuntimeException("Failed to read file: " + fileName, e); + } + } + + @Test + protected void testApp() throws Exception { + className = getClass().getSimpleName(); + String testNumber = className.replaceAll("[^0-9]", ""); + MvcResult mockMvcResult = mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL)).andExpect(status().isOk()) + .andExpect(jsonPath("$.openapi", is("3.1.0"))).andReturn(); + String result = mockMvcResult.getResponse().getContentAsString(); + Path path = Paths.get(getClass().getClassLoader().getResource("results/3.1.0/app" + testNumber + ".json").toURI()); + byte[] fileBytes = Files.readAllBytes(path); + String expected = new String(fileBytes); + assertEquals(expected, result, true); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app1/DatabaseLoader.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app1/DatabaseLoader.java new file mode 100644 index 000000000..3e1eb517a --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app1/DatabaseLoader.java @@ -0,0 +1,55 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app1; + +import org.springframework.boot.CommandLineRunner; +import org.springframework.context.annotation.Bean; +import org.springframework.stereotype.Component; + +/** + * Pre-load some data using a Spring Boot {@link CommandLineRunner}. + * + * @author Greg Turnquist + */ +@Component +class DatabaseLoader { + + /** + * Use Spring to inject a {@link EmployeeRepository} that can then load data. Since this will run only after the app + * is operational, the database will be up. + * + * @param repository + */ + @Bean + CommandLineRunner init(EmployeeRepository repository) { + + return args -> { + repository.save(new Employee("Frodo", "Baggins", "ring bearer")); + repository.save(new Employee("Bilbo", "Baggins", "burglar")); + }; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app1/Employee.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app1/Employee.java new file mode 100644 index 000000000..8692d25c1 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app1/Employee.java @@ -0,0 +1,77 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app1; + +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.Id; +import lombok.AccessLevel; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * Domain object representing a company employee. Project Lombok keeps actual code at a minimum. {@code @Data} - + * Generates getters, setters, toString, hash, and equals functions {@code @Entity} - JPA annotation to flag this class + * for DB persistence {@code @NoArgsConstructor} - Create a constructor with no args to support JPA + * {@code @AllArgsConstructor} - Create a constructor with all args to support testing + * {@code @JsonIgnoreProperties(ignoreUnknow=true)} When converting JSON to Java, ignore any unrecognized attributes. + * This is critical for REST because it encourages adding new fields in later versions that won't break. It also allows + * things like _links to be ignore as well, meaning HAL documents can be fetched and later posted to the server without + * adjustment. + * + * @author Greg Turnquist + */ +@Data +@Entity +@NoArgsConstructor(access = AccessLevel.PRIVATE) +@AllArgsConstructor +class Employee { + + @Id + @GeneratedValue + private Long id; + + private String firstName; + + private String lastName; + + private String role; + + /** + * Useful constructor when id is not yet known. + * + * @param firstName + * @param lastName + * @param role + */ + Employee(String firstName, String lastName, String role) { + + this.firstName = firstName; + this.lastName = lastName; + this.role = role; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app1/EmployeeController.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app1/EmployeeController.java new file mode 100644 index 000000000..323974545 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app1/EmployeeController.java @@ -0,0 +1,139 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app1; + +import java.net.URI; +import java.net.URISyntaxException; +import java.util.List; +import java.util.stream.StreamSupport; + +import org.springframework.hateoas.CollectionModel; +import org.springframework.hateoas.EntityModel; +import org.springframework.hateoas.IanaLinkRelations; +import org.springframework.hateoas.Link; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.ResponseStatus; +import org.springframework.web.bind.annotation.RestController; + +import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.linkTo; +import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.methodOn; + +/** + * Spring Web {@link RestController} used to generate a REST API. + * + * @author Greg Turnquist + */ +@RestController +class EmployeeController { + + private final EmployeeRepository repository; + + EmployeeController(EmployeeRepository repository) { + this.repository = repository; + } + + /** + * Look up all employees, and transform them into a REST collection resource. Then return them through Spring Web's + * {@link ResponseEntity} fluent API. + */ + @GetMapping("/employees") + ResponseEntity>> findAll() { + + List> employees = StreamSupport.stream(repository.findAll().spliterator(), false) + .map(employee -> EntityModel.of(employee, // + linkTo(methodOn(EmployeeController.class).findOne(employee.getId())).withSelfRel(), // + linkTo(methodOn(EmployeeController.class).findAll()).withRel("employees"))) // + .toList(); + + return ResponseEntity.ok( // + CollectionModel.of(employees, // + linkTo(methodOn(EmployeeController.class).findAll()).withSelfRel())); + } + + @PostMapping("/employees") + @ResponseStatus(HttpStatus.CREATED) + ResponseEntity> newEmployee(@RequestBody Employee employee) { + + try { + Employee savedEmployee = repository.save(employee); + + EntityModel employeeResource = EntityModel.of(savedEmployee, // + linkTo(methodOn(EmployeeController.class).findOne(savedEmployee.getId())).withSelfRel()); + + return ResponseEntity // + .created(new URI(employeeResource.getRequiredLink(IanaLinkRelations.SELF).getHref())) // + .body(employeeResource); + } + catch (URISyntaxException e) { + return ResponseEntity.badRequest().body(null); + } + } + + /** + * Look up a single {@link Employee} and transform it into a REST resource. Then return it through Spring Web's + * {@link ResponseEntity} fluent API. + * + * @param id + */ + @GetMapping("/employees/{id}") + ResponseEntity> findOne(@PathVariable long id) { + + return repository.findById(id) // + .map(employee -> EntityModel.of(employee, // + linkTo(methodOn(EmployeeController.class).findOne(employee.getId())).withSelfRel(), // + linkTo(methodOn(EmployeeController.class).findAll()).withRel("employees"))) // + .map(ResponseEntity::ok) // + .orElse(ResponseEntity.notFound().build()); + } + + /** + * Update existing employee then return a Location header. + * + * @param employee + * @param id + * @return + */ + @PutMapping("/employees/{id}") + @ResponseStatus(HttpStatus.NO_CONTENT) + ResponseEntity updateEmployee(@RequestBody Employee employee, @PathVariable long id) throws URISyntaxException { + + Employee employeeToUpdate = employee; + employeeToUpdate.setId(id); + repository.save(employeeToUpdate); + + Link newlyCreatedLink = linkTo(methodOn(EmployeeController.class).findOne(id)).withSelfRel(); + + return ResponseEntity.noContent().location(new URI(newlyCreatedLink.getHref())).build(); + + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app1/EmployeeRepository.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app1/EmployeeRepository.java new file mode 100644 index 000000000..e51dff831 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app1/EmployeeRepository.java @@ -0,0 +1,36 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app1; + +import org.springframework.data.repository.CrudRepository; + +/** + * A simple Spring Data {@link CrudRepository} for storing {@link Employee}s. + * + * @author Greg Turnquist + */ +interface EmployeeRepository extends CrudRepository { +} diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app1/SpringDocApp1Test.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app1/SpringDocApp1Test.java new file mode 100644 index 000000000..76ecc6662 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app1/SpringDocApp1Test.java @@ -0,0 +1,38 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app1; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp1Test extends AbstractSpringDocTest { + + @SpringBootApplication + static class SpringDocTestApp {} + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app10/Dummy.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app10/Dummy.java new file mode 100644 index 000000000..0bf8faf98 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app10/Dummy.java @@ -0,0 +1,38 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app10; + +import lombok.AllArgsConstructor; +import lombok.Data; + +@Data +@AllArgsConstructor +public class Dummy { + + private T value; + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app10/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app10/HelloController.java new file mode 100644 index 000000000..d028d144d --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app10/HelloController.java @@ -0,0 +1,79 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app10; + +import java.util.List; + +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageImpl; +import org.springframework.data.web.PagedModel; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +@SuppressWarnings("rawtypes") +@RestController +public class HelloController { + + @GetMapping("/page-simple") + public Page pageSimple() { + return pageImpl("test"); + } + + @GetMapping("/paged-model-simple") + public PagedModel pagedModelSimple() { + return pagedModel("test"); + } + + @GetMapping("/page-complex") + public Page>> pageComplex() { + return pageImpl(new Dummy<>(List.of("test"))); + } + + @GetMapping("/paged-model-complex") + public PagedModel>> pagedModelComplex() { + return pagedModel(new Dummy<>(List.of("test"))); + } + + @GetMapping("/page-raw") + public Page pageRaw() { + return pageSimple(); + } + + @GetMapping("/paged-model-raw") + public PagedModel pagedModelRaw() { + return pagedModelSimple(); + } + + private PagedModel pagedModel(T value) { + return new PagedModel<>(pageImpl(value)); + } + + private Page pageImpl(T value) { + return new PageImpl<>(List.of(value)); + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app10/SpringDocApp10DirectTest.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app10/SpringDocApp10DirectTest.java new file mode 100644 index 000000000..954dddce3 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app10/SpringDocApp10DirectTest.java @@ -0,0 +1,59 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app10; + +import org.junit.jupiter.api.Test; +import org.springdoc.core.utils.Constants; +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.data.web.config.EnableSpringDataWebSupport; + +import static org.hamcrest.Matchers.is; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + +public class SpringDocApp10DirectTest extends AbstractSpringDocTest { + + @Override + @Test + protected void testApp() throws Exception { + mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL)) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.openapi", is("3.1.0"))) + .andExpect(content().json(getContent("results/3.1.0/app10-direct.json"), true)); + } + + @SpringBootApplication + @EnableSpringDataWebSupport(pageSerializationMode = EnableSpringDataWebSupport.PageSerializationMode.DIRECT) + public static class SpringDocTestApp { + + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app10/SpringDocApp10NotSpecifiedTest.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app10/SpringDocApp10NotSpecifiedTest.java new file mode 100644 index 000000000..fd9f13add --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app10/SpringDocApp10NotSpecifiedTest.java @@ -0,0 +1,72 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app10; + +import java.util.Optional; + +import io.swagger.v3.core.converter.ModelConverter; +import io.swagger.v3.core.converter.ModelConverters; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.springdoc.core.converters.PageOpenAPIConverter; +import org.springdoc.core.utils.Constants; +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +import static org.hamcrest.Matchers.is; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + +public class SpringDocApp10NotSpecifiedTest extends AbstractSpringDocTest { + + + @BeforeAll + public static void init() { + Optional pageOpenAPIConverter = + ModelConverters.getInstance().getConverters() + .stream().filter(modelConverter -> modelConverter instanceof PageOpenAPIConverter).findAny(); + pageOpenAPIConverter.ifPresent(ModelConverters.getInstance()::removeConverter); + } + + @Override + @Test + protected void testApp() throws Exception { + mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL)) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.openapi", is("3.1.0"))) + .andExpect(content().json(getContent("results/3.1.0/app10-direct.json"), true)); + } + + @SpringBootApplication + public static class SpringDocTestApp { + + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app10/SpringDocApp10ViaDtoTest.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app10/SpringDocApp10ViaDtoTest.java new file mode 100644 index 000000000..4b3253cca --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app10/SpringDocApp10ViaDtoTest.java @@ -0,0 +1,59 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app10; + +import org.junit.jupiter.api.Test; +import org.springdoc.core.utils.Constants; +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.data.web.config.EnableSpringDataWebSupport; + +import static org.hamcrest.Matchers.is; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + +public class SpringDocApp10ViaDtoTest extends AbstractSpringDocTest { + + @Override + @Test + protected void testApp() throws Exception { + mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL)) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.openapi", is("3.1.0"))) + .andExpect(content().json(getContent("results/3.1.0/app10-via_dto.json"), true)); + } + + @SpringBootApplication + @EnableSpringDataWebSupport(pageSerializationMode = EnableSpringDataWebSupport.PageSerializationMode.VIA_DTO) + public static class SpringDocTestApp { + + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app2/SpringDocApp2Test.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app2/SpringDocApp2Test.java new file mode 100644 index 000000000..9f4d7f515 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app2/SpringDocApp2Test.java @@ -0,0 +1,40 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app2; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.test.context.TestPropertySource; + +@TestPropertySource(properties = "springdoc.model-converters.pageable-converter.enabled=true") +public class SpringDocApp2Test extends AbstractSpringDocTest { + + @SpringBootApplication + static class SpringDocTestApp {} + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app2/config/DatabaseConfig.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app2/config/DatabaseConfig.java new file mode 100644 index 000000000..8ef2464c6 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app2/config/DatabaseConfig.java @@ -0,0 +1,58 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app2.config; + +import java.time.LocalDate; + +import jakarta.annotation.PostConstruct; +import lombok.RequiredArgsConstructor; +import test.org.springdoc.api.v31.app2.entities.Post; +import test.org.springdoc.api.v31.app2.repositories.PostRepository; + +import org.springframework.context.annotation.Configuration; + +/** + * @author Davide Pedone + * 2020 + */ +@Configuration +@RequiredArgsConstructor +public class DatabaseConfig { + + private final PostRepository postRepository; + + @PostConstruct + private void postConstruct() { + for (int i = 0; i < 33; i++) { + Post post = new Post(); + post.setAuthor("name" + i); + post.setContent("content" + i); + post.setCreatedAt(LocalDate.now().toEpochDay()); + postRepository.save(post); + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app2/controller/PostController.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app2/controller/PostController.java new file mode 100644 index 000000000..8a96491e4 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app2/controller/PostController.java @@ -0,0 +1,55 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app2.controller; + +import lombok.RequiredArgsConstructor; +import test.org.springdoc.api.v31.app2.entities.Post; +import test.org.springdoc.api.v31.app2.service.PostService; + +import org.springframework.data.domain.Pageable; +import org.springframework.hateoas.EntityModel; +import org.springframework.hateoas.PagedModel; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * @author Davide Pedone + * 2020 + */ +@RestController +@RequiredArgsConstructor +public class PostController { + + private final PostService postService; + + @GetMapping + public ResponseEntity>> getAll(Pageable pageable) { + return new ResponseEntity<>(postService.getAll(pageable), HttpStatus.OK); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app2/entities/Post.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app2/entities/Post.java new file mode 100644 index 000000000..6ac6f1328 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app2/entities/Post.java @@ -0,0 +1,56 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app2.entities; + +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.Id; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @author Davide Pedone + * 2020 + */ +@Data +@Entity +@NoArgsConstructor +@AllArgsConstructor +public class Post { + + @Id + @GeneratedValue + private Long id; + + private String author; + + private String content; + + private Long createdAt; + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app2/hateoas/PostResourceAssembler.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app2/hateoas/PostResourceAssembler.java new file mode 100644 index 000000000..2f64e515f --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app2/hateoas/PostResourceAssembler.java @@ -0,0 +1,48 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app2.hateoas; + + +import test.org.springdoc.api.v31.app2.entities.Post; + +import org.springframework.hateoas.EntityModel; +import org.springframework.hateoas.server.RepresentationModelAssembler; +import org.springframework.stereotype.Component; + +/** + * @author Davide Pedone + * 2020 + */ +@Component +public class PostResourceAssembler implements RepresentationModelAssembler> { + + + @Override + public EntityModel toModel(Post entity) { + return EntityModel.of(entity); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app2/repositories/PostRepository.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app2/repositories/PostRepository.java new file mode 100644 index 000000000..93bb46767 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app2/repositories/PostRepository.java @@ -0,0 +1,40 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app2.repositories; + + +import test.org.springdoc.api.v31.app2.entities.Post; + +import org.springframework.data.repository.CrudRepository; +import org.springframework.data.repository.PagingAndSortingRepository; + +/** + * @author Davide Pedone + * 2020 + */ +public interface PostRepository extends PagingAndSortingRepository, CrudRepository { +} diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app2/service/PostService.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app2/service/PostService.java new file mode 100644 index 000000000..55899bebe --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app2/service/PostService.java @@ -0,0 +1,61 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app2.service; + + +import lombok.RequiredArgsConstructor; +import test.org.springdoc.api.v31.app2.entities.Post; +import test.org.springdoc.api.v31.app2.hateoas.PostResourceAssembler; +import test.org.springdoc.api.v31.app2.repositories.PostRepository; + +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.data.web.PagedResourcesAssembler; +import org.springframework.hateoas.EntityModel; +import org.springframework.hateoas.PagedModel; +import org.springframework.stereotype.Service; + +/** + * @author Davide Pedone + * 2020 + */ +@RequiredArgsConstructor +@Service +public class PostService { + + private final PostRepository postRepository; + + private final PagedResourcesAssembler pagedResourcesAssembler; + + private final PostResourceAssembler postResourceAssembler; + + public PagedModel> getAll(Pageable pageable) { + Page postPage = postRepository.findAll(pageable); + return pagedResourcesAssembler.toModel(postPage, postResourceAssembler); + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app3/DatabaseLoader.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app3/DatabaseLoader.java new file mode 100644 index 000000000..77e094e5f --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app3/DatabaseLoader.java @@ -0,0 +1,55 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app3; + +import org.springframework.boot.CommandLineRunner; +import org.springframework.context.annotation.Bean; +import org.springframework.stereotype.Component; + +/** + * Pre-load some data using a Spring Boot {@link CommandLineRunner}. + * + * @author Greg Turnquist + */ +@Component +class DatabaseLoader { + + /** + * Use Spring to inject a {@link EmployeeRepository} that can then load data. Since this will run only after the app + * is operational, the database will be up. + * + * @param repository + */ + @Bean + CommandLineRunner init(EmployeeRepository repository) { + + return args -> { + repository.save(new Employee("Frodo", "Baggins", "ring bearer")); + repository.save(new Employee("Bilbo", "Baggins", "burglar")); + }; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app3/Employee.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app3/Employee.java new file mode 100644 index 000000000..4d7df1a7e --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app3/Employee.java @@ -0,0 +1,77 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app3; + +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.Id; +import lombok.AccessLevel; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * Domain object representing a company employee. Project Lombok keeps actual code at a minimum. {@code @Data} - + * Generates getters, setters, toString, hash, and equals functions {@code @Entity} - JPA annotation to flag this class + * for DB persistence {@code @NoArgsConstructor} - Create a constructor with no args to support JPA + * {@code @AllArgsConstructor} - Create a constructor with all args to support testing + * {@code @JsonIgnoreProperties(ignoreUnknow=true)} When converting JSON to Java, ignore any unrecognized attributes. + * This is critical for REST because it encourages adding new fields in later versions that won't break. It also allows + * things like _links to be ignore as well, meaning HAL documents can be fetched and later posted to the server without + * adjustment. + * + * @author Greg Turnquist + */ +@Data +@Entity +@NoArgsConstructor(access = AccessLevel.PRIVATE) +@AllArgsConstructor +class Employee { + + @Id + @GeneratedValue + private Long id; + + private String firstName; + + private String lastName; + + private String role; + + /** + * Useful constructor when id is not yet known. + * + * @param firstName + * @param lastName + * @param role + */ + Employee(String firstName, String lastName, String role) { + + this.firstName = firstName; + this.lastName = lastName; + this.role = role; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app3/EmployeeController.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app3/EmployeeController.java new file mode 100644 index 000000000..3bbc31e5d --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app3/EmployeeController.java @@ -0,0 +1,54 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app3; + +import org.springframework.hateoas.EntityModel; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RestController; + +/** + * Spring Web {@link RestController} used to generate a REST API. + * + * @author Greg Turnquist + */ +@RestController +class EmployeeController { + + /** + * Look up a single {@link Employee} and transform it into a REST resource. Then return it through Spring Web's + * {@link ResponseEntity} fluent API. + * + * @param id + */ + @GetMapping("/employees/{id}") + EntityModel findOne(@PathVariable long id) { + + return null; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app3/EmployeeRepository.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app3/EmployeeRepository.java new file mode 100644 index 000000000..0915f1e19 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app3/EmployeeRepository.java @@ -0,0 +1,36 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app3; + +import org.springframework.data.repository.CrudRepository; + +/** + * A simple Spring Data {@link CrudRepository} for storing {@link Employee}s. + * + * @author Greg Turnquist + */ +interface EmployeeRepository extends CrudRepository { +} diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app3/SpringDocApp3Test.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app3/SpringDocApp3Test.java new file mode 100644 index 000000000..fdaddc056 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app3/SpringDocApp3Test.java @@ -0,0 +1,37 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app3; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.test.context.TestPropertySource; + +@TestPropertySource(properties = "springdoc.remove-broken-reference-definitions=false") +public class SpringDocApp3Test extends AbstractSpringDocTest { + + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app3/SpringDocTestApp.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app3/SpringDocTestApp.java new file mode 100644 index 000000000..b69b2599c --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app3/SpringDocTestApp.java @@ -0,0 +1,39 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app3; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class SpringDocTestApp { + + public static void main(String[] args) { + SpringApplication.run(SpringDocTestApp.class, args); + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app4/Album.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app4/Album.java new file mode 100644 index 000000000..8cc5876af --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app4/Album.java @@ -0,0 +1,55 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app4; + +public class Album { + + private String title; + + private String description; + + private String releaseDate; + + public Album(String title, String description, String releaseDate) { + this.title = title; + this.description = description; + this.releaseDate = releaseDate; + } + + public String getTitle() { + return title; + } + + public String getDescription() { + return description; + } + + public String getReleaseDate() { + return releaseDate; + } + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app4/AlbumController.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app4/AlbumController.java new file mode 100644 index 000000000..e85fc6e73 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app4/AlbumController.java @@ -0,0 +1,58 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app4; + +import java.util.Arrays; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageImpl; +import org.springframework.data.web.PagedResourcesAssembler; +import org.springframework.hateoas.PagedModel; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@SuppressWarnings("unchecked") +public class AlbumController { + + @Autowired + private AlbumModelAssembler albumModelAssembler; + + @Autowired + private PagedResourcesAssembler pagedResourcesAssembler; + + @GetMapping("/api/albums") + public PagedModel getAllAlbums() { + Album album1 = new Album("album-title-1", "album-description-1", "album-release-date-1"); + Album album2 = new Album("album-title-2", "album-description-2", "album-release-date-2"); + Page albumPage = new PageImpl<>(Arrays.asList(album1, album2)); + + return pagedResourcesAssembler.toModel(albumPage, albumModelAssembler); + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app4/AlbumModelAssembler.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app4/AlbumModelAssembler.java new file mode 100644 index 000000000..a22e1aaea --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app4/AlbumModelAssembler.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.app4; + +import java.util.ArrayList; +import java.util.List; + +import org.springframework.hateoas.EntityModel; +import org.springframework.hateoas.Link; +import org.springframework.hateoas.server.RepresentationModelAssembler; +import org.springframework.stereotype.Component; + +@Component +public class AlbumModelAssembler implements RepresentationModelAssembler> { + + @Override + public EntityModel toModel(Album entity) { + List links = new ArrayList<>(); + return EntityModel.of(entity, links); + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app4/SpringDocApp4Test.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app4/SpringDocApp4Test.java new file mode 100644 index 000000000..c017a86a5 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app4/SpringDocApp4Test.java @@ -0,0 +1,38 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app4; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp4Test extends AbstractSpringDocTest { + + @SpringBootApplication + static class SpringDocTestApp {} + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app5/SpringDocApp5Test.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app5/SpringDocApp5Test.java new file mode 100644 index 000000000..dc93acbf7 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app5/SpringDocApp5Test.java @@ -0,0 +1,50 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app5; + +import io.swagger.v3.oas.models.Components; +import io.swagger.v3.oas.models.OpenAPI; +import io.swagger.v3.oas.models.media.ObjectSchema; +import io.swagger.v3.oas.models.media.StringSchema; +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; + +public class SpringDocApp5Test extends AbstractSpringDocTest { + + @SpringBootApplication + static class SpringDocTestApp { + @Bean + public OpenAPI customOpenAPI() { + return new OpenAPI().components(new Components() + .addSchemas("CompanyDtoNew", new ObjectSchema().addProperties("id", new StringSchema().format("uuid" + )).addProperties("name", new StringSchema()))); + } + } + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app5/controller/CompanyController.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app5/controller/CompanyController.java new file mode 100644 index 000000000..ad955f062 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app5/controller/CompanyController.java @@ -0,0 +1,57 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app5.controller; + +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.Valid; +import lombok.RequiredArgsConstructor; +import test.org.springdoc.api.v31.app5.entities.CompanyDto; + +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RestController; + +/** + * @author Davide Pedone + * 2020 + */ +@RestController +@RequiredArgsConstructor +public class CompanyController { + + + @PostMapping + @io.swagger.v3.oas.annotations.parameters.RequestBody( + description = "Details of the Item to be created", + content = @Content(schema = @Schema(ref = "#/components/schemas/CompanyDtoNew"))) + public CompanyDto create(@Valid @RequestBody final CompanyDto companyDto) { + + return null; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app5/entities/Company.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app5/entities/Company.java new file mode 100644 index 000000000..74f2a0402 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app5/entities/Company.java @@ -0,0 +1,55 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app5.entities; + +import java.util.UUID; + +import com.fasterxml.jackson.annotation.JsonProperty; +import jakarta.validation.constraints.NotNull; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import org.springframework.hateoas.RepresentationModel; +import org.springframework.hateoas.server.core.Relation; + +/** + * @author bnasslahsen + */ +@AllArgsConstructor +@Data +@Builder +@EqualsAndHashCode(callSuper = false) +@Relation(collectionRelation = "companies", itemRelation = "company") +public class Company extends RepresentationModel { + @JsonProperty(access = JsonProperty.Access.READ_ONLY) + private UUID id; + + @NotNull + private String name; +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app5/entities/CompanyDto.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app5/entities/CompanyDto.java new file mode 100644 index 000000000..62fd1d84c --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app5/entities/CompanyDto.java @@ -0,0 +1,55 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app5.entities; + +import java.util.UUID; + +import com.fasterxml.jackson.annotation.JsonProperty; +import jakarta.validation.constraints.NotNull; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import org.springframework.hateoas.RepresentationModel; +import org.springframework.hateoas.server.core.Relation; + +/** + * @author bnasslahsen + */ +@AllArgsConstructor +@Data +@Builder +@EqualsAndHashCode(callSuper = false) +@Relation(collectionRelation = "companies", itemRelation = "company") +public class CompanyDto extends RepresentationModel { + @JsonProperty(access = JsonProperty.Access.READ_ONLY) + private UUID id; + + @NotNull + private String name; +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app5/hateoas/CompanyModelAssembler.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app5/hateoas/CompanyModelAssembler.java new file mode 100644 index 000000000..ffb87b28b --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app5/hateoas/CompanyModelAssembler.java @@ -0,0 +1,55 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app5.hateoas; + +import test.org.springdoc.api.v31.app5.controller.CompanyController; +import test.org.springdoc.api.v31.app5.entities.Company; +import test.org.springdoc.api.v31.app5.entities.CompanyDto; + +import org.springframework.hateoas.server.mvc.RepresentationModelAssemblerSupport; +import org.springframework.lang.NonNull; +import org.springframework.stereotype.Component; + +/** + * @author bnasslahsen + */ +@Component +public class CompanyModelAssembler extends RepresentationModelAssemblerSupport { + + public CompanyModelAssembler() { + super(CompanyController.class, CompanyDto.class); + } + + @Override + @NonNull + public CompanyDto toModel(@NonNull final Company company) { + return CompanyDto.builder() + .id(company.getId()) + .name(company.getName()) + .build(); + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app6/SpringDocApp6Test.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app6/SpringDocApp6Test.java new file mode 100644 index 000000000..dc0f8a0f2 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app6/SpringDocApp6Test.java @@ -0,0 +1,80 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app6; + +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; +import java.util.Map.Entry; + +import com.fasterxml.jackson.databind.introspect.SimpleMixInResolver; +import com.fasterxml.jackson.databind.type.ClassKey; +import org.apache.commons.lang3.reflect.FieldUtils; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.springdoc.core.providers.ObjectMapperProvider; +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.test.context.TestPropertySource; + +@TestPropertySource(properties = "spring.hateoas.use-hal-as-default-json-media-type= false") +public class SpringDocApp6Test extends AbstractSpringDocTest { + + private final Map> springMixins = new HashMap<>(); + + @Autowired + ObjectMapperProvider objectMapperProvider; + + @BeforeEach + void init() throws IllegalAccessException { + SimpleMixInResolver _mixIns = (SimpleMixInResolver) FieldUtils.readDeclaredField(objectMapperProvider.jsonMapper(),"_mixIns", true); + Map> _localMixIns = (Map>) FieldUtils.readDeclaredField(_mixIns, "_localMixIns", true); + Iterator>> iterator = _localMixIns.entrySet().iterator(); + + while (iterator.hasNext()) { + Entry> entry = iterator.next(); + if (entry.getKey().toString().startsWith("org.springframework")) { + springMixins.put(entry.getKey(), entry.getValue()); + iterator.remove(); + } + } + } + + @AfterEach + void clean() throws IllegalAccessException { + SimpleMixInResolver _mixIns = (SimpleMixInResolver) FieldUtils.readDeclaredField(objectMapperProvider.jsonMapper(), "_mixIns", true); + Map> _localMixIns = (Map>) FieldUtils.readDeclaredField(_mixIns, "_localMixIns", true); + _localMixIns.putAll(springMixins); + } + + @SpringBootApplication + static class SpringDocTestApp { + } + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app6/controller/ItemController.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app6/controller/ItemController.java new file mode 100644 index 000000000..cbe732945 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app6/controller/ItemController.java @@ -0,0 +1,63 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app6.controller; + +import java.util.List; +import java.util.stream.Stream; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import test.org.springdoc.api.v31.app6.model.Item; + +import org.springframework.hateoas.CollectionModel; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.linkTo; +import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.methodOn; + +@RestController +@RequestMapping(value = "/v1/items", produces = MediaType.APPLICATION_JSON_VALUE) +@Tag(name = "Item", description = "The Item API") +public class ItemController { + + List items = Stream.of(new Item("foo"), new Item("bar")).toList(); + + @Operation(summary = "Get all items") + @GetMapping(produces = { MediaType.APPLICATION_JSON_VALUE }) + public ResponseEntity> getAllItems() { + + CollectionModel collection = CollectionModel.of(items); + collection.add(linkTo(methodOn(ItemController.class).getAllItems()).withSelfRel().expand()); + + return new ResponseEntity<>(collection, HttpStatus.OK); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app6/model/Item.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app6/model/Item.java new file mode 100644 index 000000000..f78545b0f --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app6/model/Item.java @@ -0,0 +1,58 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app6.model; + +import org.springframework.hateoas.Link; +import org.springframework.hateoas.RepresentationModel; + + +public class Item extends RepresentationModel { + + private String description; + + public Item(String description) { + this.description = description; + } + + public Item(Link initialLink, String description) { + super(initialLink); + this.description = description; + } + + public Item(Iterable initialLinks, String description) { + super(initialLinks); + this.description = description; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app7/FooConfiguration.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app7/FooConfiguration.java new file mode 100644 index 000000000..31b684e72 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app7/FooConfiguration.java @@ -0,0 +1,42 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app7; + +import org.springdoc.core.models.GroupedOpenApi; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +public class FooConfiguration { + @Bean + public GroupedOpenApi userOpenApi() { + String packagesToscan[] = { "test.org.springdoc.api.app7" }; + return GroupedOpenApi.builder().group("foo-service").packagesToScan(packagesToscan) + .build(); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app7/SpringDocApp7Test.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app7/SpringDocApp7Test.java new file mode 100644 index 000000000..838a6bfc1 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app7/SpringDocApp7Test.java @@ -0,0 +1,39 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app7; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp7Test extends AbstractSpringDocTest { + + @SpringBootApplication + static class SpringDocTestApp { + } + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app7/application/Foo.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app7/application/Foo.java new file mode 100644 index 000000000..fda9ae798 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app7/application/Foo.java @@ -0,0 +1,36 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app7.application; + +import lombok.AllArgsConstructor; +import lombok.Data; + +@Data +@AllArgsConstructor +public class Foo { + String foo; +} diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app7/application/FooController.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app7/application/FooController.java new file mode 100644 index 000000000..49bb8c5d2 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app7/application/FooController.java @@ -0,0 +1,59 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app7.application; + +import java.util.UUID; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.hateoas.EntityModel; +import org.springframework.hateoas.MediaTypes; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class FooController { + + private final FooService fooService; + + private final FooResourceAssembler fooResourceAssembler; + + @Autowired + public FooController( + FooService fooService, + FooResourceAssembler fooResourceAssembler) { + this.fooService = fooService; + this.fooResourceAssembler = fooResourceAssembler; + } + + @GetMapping(value = "foo/{id}", produces = MediaTypes.HAL_JSON_VALUE) + public ResponseEntity> getFoo(@PathVariable("id") UUID id) throws Exception { + Foo foo = fooService.getFoo(id).orElseThrow(Exception::new); + return ResponseEntity.ok(fooResourceAssembler.toModel(foo)); + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app7/application/FooResourceAssembler.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app7/application/FooResourceAssembler.java new file mode 100644 index 000000000..89ed69013 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app7/application/FooResourceAssembler.java @@ -0,0 +1,61 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app7.application; + +import java.util.UUID; + +import org.springframework.hateoas.CollectionModel; +import org.springframework.hateoas.EntityModel; +import org.springframework.hateoas.server.SimpleRepresentationModelAssembler; +import org.springframework.stereotype.Component; + +import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.linkTo; +import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.methodOn; + +@Component +public class FooResourceAssembler + implements SimpleRepresentationModelAssembler { + + @Override + public void addLinks(EntityModel resource) { + Foo foo = resource.getContent(); + if (foo != null) { + try { + resource.add( + linkTo(methodOn(FooController.class).getFoo(UUID.fromString(foo.getFoo()))).withSelfRel()); + } + catch (Exception e) { + throw new RuntimeException(e); + } + } + } + + @Override + public void addLinks(CollectionModel> resources) { + + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app7/application/FooService.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app7/application/FooService.java new file mode 100644 index 000000000..054b495e9 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app7/application/FooService.java @@ -0,0 +1,39 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app7.application; + +import java.util.Optional; +import java.util.UUID; + +import org.springframework.stereotype.Service; + +@Service +public class FooService { + public Optional getFoo(UUID uuid) { + return Optional.of(new Foo(uuid.toString())); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app8/DatabaseLoader.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app8/DatabaseLoader.java new file mode 100644 index 000000000..fe79f0adb --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app8/DatabaseLoader.java @@ -0,0 +1,55 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app8; + +import org.springframework.boot.CommandLineRunner; +import org.springframework.context.annotation.Bean; +import org.springframework.stereotype.Component; + +/** + * Pre-load some data using a Spring Boot {@link CommandLineRunner}. + * + * @author Greg Turnquist + */ +@Component +class DatabaseLoader { + + /** + * Use Spring to inject a {@link EmployeeRepository} that can then load data. Since this will run only after the app + * is operational, the database will be up. + * + * @param repository + */ + @Bean + CommandLineRunner init(EmployeeRepository repository) { + + return args -> { + repository.save(new Employee("Frodo", "Baggins", "ring bearer")); + repository.save(new Employee("Bilbo", "Baggins", "burglar")); + }; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app8/Employee.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app8/Employee.java new file mode 100644 index 000000000..2f16d3d6d --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app8/Employee.java @@ -0,0 +1,77 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app8; + +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.Id; +import lombok.AccessLevel; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * Domain object representing a company employee. Project Lombok keeps actual code at a minimum. {@code @Data} - + * Generates getters, setters, toString, hash, and equals functions {@code @Entity} - JPA annotation to flag this class + * for DB persistence {@code @NoArgsConstructor} - Create a constructor with no args to support JPA + * {@code @AllArgsConstructor} - Create a constructor with all args to support testing + * {@code @JsonIgnoreProperties(ignoreUnknow=true)} When converting JSON to Java, ignore any unrecognized attributes. + * This is critical for REST because it encourages adding new fields in later versions that won't break. It also allows + * things like _links to be ignore as well, meaning HAL documents can be fetched and later posted to the server without + * adjustment. + * + * @author Greg Turnquist + */ +@Data +@Entity +@NoArgsConstructor(access = AccessLevel.PRIVATE) +@AllArgsConstructor +class Employee { + + @Id + @GeneratedValue + private Long id; + + private String firstName; + + private String lastName; + + private String role; + + /** + * Useful constructor when id is not yet known. + * + * @param firstName + * @param lastName + * @param role + */ + Employee(String firstName, String lastName, String role) { + + this.firstName = firstName; + this.lastName = lastName; + this.role = role; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app8/EmployeeController.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app8/EmployeeController.java new file mode 100644 index 000000000..6399f78f7 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app8/EmployeeController.java @@ -0,0 +1,139 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app8; + +import java.net.URI; +import java.net.URISyntaxException; +import java.util.List; +import java.util.stream.StreamSupport; + +import org.springframework.hateoas.CollectionModel; +import org.springframework.hateoas.EntityModel; +import org.springframework.hateoas.IanaLinkRelations; +import org.springframework.hateoas.Link; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.ResponseStatus; +import org.springframework.web.bind.annotation.RestController; + +import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.linkTo; +import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.methodOn; + +/** + * Spring Web {@link RestController} used to generate a REST API. + * + * @author Greg Turnquist + */ +@RestController +class EmployeeController { + + private final EmployeeRepository repository; + + EmployeeController(EmployeeRepository repository) { + this.repository = repository; + } + + /** + * Look up all employees, and transform them into a REST collection resource. Then return them through Spring Web's + * {@link ResponseEntity} fluent API. + */ + @GetMapping("/employees") + ResponseEntity>> findAll() { + + List> employees = StreamSupport.stream(repository.findAll().spliterator(), false) + .map(employee -> EntityModel.of(employee, // + linkTo(methodOn(EmployeeController.class).findOne(employee.getId())).withSelfRel(), // + linkTo(methodOn(EmployeeController.class).findAll()).withRel("employees"))) // + .toList(); + + return ResponseEntity.ok( // + CollectionModel.of(employees, // + linkTo(methodOn(EmployeeController.class).findAll()).withSelfRel())); + } + + @PostMapping("/employees") + @ResponseStatus(HttpStatus.CREATED) + ResponseEntity> newEmployee(@RequestBody Employee employee) { + + try { + Employee savedEmployee = repository.save(employee); + + EntityModel employeeResource = EntityModel.of(savedEmployee, // + linkTo(methodOn(EmployeeController.class).findOne(savedEmployee.getId())).withSelfRel()); + + return ResponseEntity // + .created(new URI(employeeResource.getRequiredLink(IanaLinkRelations.SELF).getHref())) // + .body(employeeResource); + } + catch (URISyntaxException e) { + return ResponseEntity.badRequest().body(null); + } + } + + /** + * Look up a single {@link Employee} and transform it into a REST resource. Then return it through Spring Web's + * {@link ResponseEntity} fluent API. + * + * @param id + */ + @GetMapping("/employees/{id}") + ResponseEntity> findOne(@PathVariable long id) { + + return repository.findById(id) // + .map(employee -> EntityModel.of(employee, // + linkTo(methodOn(EmployeeController.class).findOne(employee.getId())).withSelfRel(), // + linkTo(methodOn(EmployeeController.class).findAll()).withRel("employees"))) // + .map(ResponseEntity::ok) // + .orElse(ResponseEntity.notFound().build()); + } + + /** + * Update existing employee then return a Location header. + * + * @param employee + * @param id + * @return + */ + @PutMapping("/employees/{id}") + @ResponseStatus(HttpStatus.NO_CONTENT) + ResponseEntity updateEmployee(@RequestBody Employee employee, @PathVariable long id) throws URISyntaxException { + + Employee employeeToUpdate = employee; + employeeToUpdate.setId(id); + repository.save(employeeToUpdate); + + Link newlyCreatedLink = linkTo(methodOn(EmployeeController.class).findOne(id)).withSelfRel(); + + return ResponseEntity.noContent().location(new URI(newlyCreatedLink.getHref())).build(); + + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app8/EmployeeRepository.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app8/EmployeeRepository.java new file mode 100644 index 000000000..686499af5 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app8/EmployeeRepository.java @@ -0,0 +1,36 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app8; + +import org.springframework.data.repository.CrudRepository; + +/** + * A simple Spring Data {@link CrudRepository} for storing {@link Employee}s. + * + * @author Greg Turnquist + */ +interface EmployeeRepository extends CrudRepository { +} diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app8/SpringDocApp8Test.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app8/SpringDocApp8Test.java new file mode 100644 index 000000000..f0f293ebe --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app8/SpringDocApp8Test.java @@ -0,0 +1,78 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app8; + +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; +import java.util.Map.Entry; + +import com.fasterxml.jackson.databind.introspect.SimpleMixInResolver; +import com.fasterxml.jackson.databind.type.ClassKey; +import org.apache.commons.lang3.reflect.FieldUtils; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.springdoc.core.providers.ObjectMapperProvider; +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.test.context.TestPropertySource; + +@TestPropertySource(properties = "springdoc.enable-hateoas=false") +public class SpringDocApp8Test extends AbstractSpringDocTest { + + private final Map> springMixins = new HashMap<>(); + + @Autowired + ObjectMapperProvider objectMapperProvider; + + @BeforeEach + void init() throws IllegalAccessException { + SimpleMixInResolver _mixIns = (SimpleMixInResolver) FieldUtils.readDeclaredField(objectMapperProvider.jsonMapper(), "_mixIns", true); + Map> _localMixIns = (Map>) FieldUtils.readDeclaredField(_mixIns, "_localMixIns", true); + Iterator>> it = _localMixIns.entrySet().iterator(); + while (it.hasNext()) { + Entry> entry = it.next(); + if (entry.getKey().toString().startsWith("org.springframework")) { + springMixins.put(entry.getKey(), entry.getValue()); + it.remove(); + } + } + + } + + @AfterEach + void clean() throws IllegalAccessException { + SimpleMixInResolver _mixIns = (SimpleMixInResolver) FieldUtils.readDeclaredField(objectMapperProvider.jsonMapper(), "_mixIns", true); + Map> _localMixIns = (Map>) FieldUtils.readDeclaredField(_mixIns, "_localMixIns", true); + _localMixIns.putAll(springMixins); + } + + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app9/FooConfiguration.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app9/FooConfiguration.java new file mode 100644 index 000000000..75bb7d166 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app9/FooConfiguration.java @@ -0,0 +1,83 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app9; + +import java.util.List; + +import io.swagger.v3.oas.models.Components; +import io.swagger.v3.oas.models.OpenAPI; +import io.swagger.v3.oas.models.info.Contact; +import io.swagger.v3.oas.models.info.Info; +import io.swagger.v3.oas.models.media.ArraySchema; +import io.swagger.v3.oas.models.media.Schema; +import io.swagger.v3.oas.models.security.SecurityScheme; +import io.swagger.v3.oas.models.tags.Tag; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +public class FooConfiguration { + @Bean + OpenAPI customOpenApi() { + return new OpenAPI() + .components(new Components().addSecuritySchemes("bearerScheme", + new SecurityScheme() + .type(SecurityScheme.Type.HTTP) + .scheme("bearer") + .bearerFormat("JWT")) + .addSchemas("FeedResponse", feedResponseSchema())) + .info(new Info() + .title("Response API") + .description("API for some response") + .version("0.0.1") + .contact(new Contact() + .name("EAlf91"))) + .tags(List.of(new Tag() + .name("ResponseTag") + .description("ResponseTag for API"), + new Tag() + .name("ResponseData") + .description("Version 2 ResponseApi"))); + + } + + private Schema feedResponseSchema() { + Schema schema = new Schema<>(); + schema.addProperty("_links", linkSchema()); + schema.addProperty("data", new ArraySchema().items(new Schema<>().$ref("#/components/schemas/ResponseData"))); + return schema; + } + + private Schema linkSchema() { + Schema linkSchema = new Schema<>(); + linkSchema.addProperty("next", new Schema<>().$ref("#/components/schemas/Link").example("http://localhost:8080/some-link")); + linkSchema.addProperty("self", new Schema<>().$ref("#/components/schemas/Link").example("http://localhost:8080/some-other-link")); + return linkSchema; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app9/SpringDocApp9Test.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app9/SpringDocApp9Test.java new file mode 100644 index 000000000..c0bf9885b --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app9/SpringDocApp9Test.java @@ -0,0 +1,39 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app9; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp9Test extends AbstractSpringDocTest { + + @SpringBootApplication + static class SpringDocTestApp { + } + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app9/application/FooController.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app9/application/FooController.java new file mode 100644 index 000000000..b8fe61384 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app9/application/FooController.java @@ -0,0 +1,63 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app9.application; + +import java.util.List; +import java.util.UUID; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import test.org.springdoc.api.v31.app9.application.dto.FeedResponse; +import test.org.springdoc.api.v31.app9.application.dto.ResponseData; + +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseStatus; +import org.springframework.web.bind.annotation.RestController; +@Tag(name = "ResponseDataController") +@RestController +@RequestMapping(value = "/some-route", produces = MediaType.APPLICATION_JSON_VALUE) +@RequiredArgsConstructor +@Slf4j +public class FooController { + + + + + @Operation(summary = "Get all data", description = "Get all data") + @GetMapping(value = "foo/{id}") + @ResponseStatus(HttpStatus.OK) + public FeedResponse getFoo(@PathVariable("id") UUID id) { + var dataList = List.of(ResponseData.builder().dataId(id).build()); + return FeedResponse.createForResponseData(dataList, UUID.randomUUID()); + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app9/application/dto/FeedResponse.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app9/application/dto/FeedResponse.java new file mode 100644 index 000000000..dafa1dfa8 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app9/application/dto/FeedResponse.java @@ -0,0 +1,65 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app9.application.dto; + +import java.util.List; +import java.util.UUID; + +import com.fasterxml.jackson.annotation.JsonProperty; +import jakarta.validation.constraints.NotNull; +import lombok.AccessLevel; +import lombok.Builder; +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.experimental.Accessors; +import test.org.springdoc.api.v31.app9.application.FooController; + +import org.springframework.hateoas.IanaLinkRelations; +import org.springframework.hateoas.RepresentationModel; + +import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.linkTo; +import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.methodOn; + +@Getter +@Accessors(fluent = true) +@Builder(access = AccessLevel.PACKAGE) +@EqualsAndHashCode(callSuper = true) +public class FeedResponse extends RepresentationModel { + @NotNull + @JsonProperty("data") + private final List data; + + public static FeedResponse createForResponseData(@NotNull List responseData, UUID uuid) { + var feedResponse = new FeedResponse(responseData); + feedResponse.add(linkTo(methodOn(FooController.class).getFoo(uuid)).withSelfRel()); + + + feedResponse.add(linkTo(methodOn(FooController.class).getFoo(uuid)).withRel(IanaLinkRelations.NEXT)); + + return feedResponse; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app9/application/dto/ResponseData.java b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app9/application/dto/ResponseData.java new file mode 100644 index 000000000..2210e7c64 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/java/test/org/springdoc/api/v31/app9/application/dto/ResponseData.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.app9.application.dto; + +import java.time.LocalDate; +import java.util.UUID; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotNull; +import lombok.Builder; + +@Builder +public record ResponseData( + @JsonProperty(value = "DATA_ID", required = true) + @NotNull + UUID dataId, + @JsonProperty(value = "DATE", required = true) + @NotNull + @Schema(example = "2024-03-27", format = "date") + LocalDate date +) {} diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/resources/results/app1.json b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/resources/results/3.0.1/app1.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/resources/results/app1.json rename to springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/resources/results/3.0.1/app1.json diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/resources/results/app10-direct.json b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/resources/results/3.0.1/app10-direct.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/resources/results/app10-direct.json rename to springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/resources/results/3.0.1/app10-direct.json diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/resources/results/app10-via_dto.json b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/resources/results/3.0.1/app10-via_dto.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/resources/results/app10-via_dto.json rename to springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/resources/results/3.0.1/app10-via_dto.json diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/resources/results/app2.json b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/resources/results/3.0.1/app2.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/resources/results/app2.json rename to springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/resources/results/3.0.1/app2.json diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/resources/results/app3.json b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/resources/results/3.0.1/app3.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/resources/results/app3.json rename to springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/resources/results/3.0.1/app3.json diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/resources/results/app4.json b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/resources/results/3.0.1/app4.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/resources/results/app4.json rename to springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/resources/results/3.0.1/app4.json diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/resources/results/app5.json b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/resources/results/3.0.1/app5.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/resources/results/app5.json rename to springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/resources/results/3.0.1/app5.json diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/resources/results/app6.json b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/resources/results/3.0.1/app6.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/resources/results/app6.json rename to springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/resources/results/3.0.1/app6.json diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/resources/results/app7.json b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/resources/results/3.0.1/app7.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/resources/results/app7.json rename to springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/resources/results/3.0.1/app7.json diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/resources/results/app8.json b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/resources/results/3.0.1/app8.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/resources/results/app8.json rename to springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/resources/results/3.0.1/app8.json diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/resources/results/app9.json b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/resources/results/3.0.1/app9.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/resources/results/app9.json rename to springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/resources/results/3.0.1/app9.json diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/resources/results/app9wrong.json b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/resources/results/3.0.1/app9wrong.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/resources/results/app9wrong.json rename to springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/resources/results/3.0.1/app9wrong.json diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/resources/results/3.1.0/app1.json b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/resources/results/3.1.0/app1.json new file mode 100644 index 000000000..60e2a1866 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/resources/results/3.1.0/app1.json @@ -0,0 +1,223 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/employees": { + "get": { + "tags": [ + "employee-controller" + ], + "operationId": "findAll", + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/CollectionModelEntityModelEmployee" + } + } + } + } + } + }, + "post": { + "tags": [ + "employee-controller" + ], + "operationId": "newEmployee", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Employee" + } + } + }, + "required": true + }, + "responses": { + "201": { + "description": "Created", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/EntityModelEmployee" + } + } + } + } + } + } + }, + "/employees/{id}": { + "get": { + "tags": [ + "employee-controller" + ], + "operationId": "findOne", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "integer", + "format": "int64" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/EntityModelEmployee" + } + } + } + } + } + }, + "put": { + "tags": [ + "employee-controller" + ], + "operationId": "updateEmployee", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "integer", + "format": "int64" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Employee" + } + } + }, + "required": true + }, + "responses": { + "204": { + "description": "No Content" + } + } + } + } + }, + "components": { + "schemas": { + "CollectionModelEntityModelEmployee": { + "type": "object", + "properties": { + "_embedded": { + "type": "object", + "properties": { + "employeeList": { + "type": "array", + "items": { + "$ref": "#/components/schemas/EntityModelEmployee" + } + } + } + }, + "_links": { + "$ref": "#/components/schemas/Links" + } + } + }, + "Employee": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "firstName": { + "type": "string" + }, + "lastName": { + "type": "string" + }, + "role": { + "type": "string" + } + } + }, + "EntityModelEmployee": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "firstName": { + "type": "string" + }, + "lastName": { + "type": "string" + }, + "role": { + "type": "string" + }, + "_links": { + "$ref": "#/components/schemas/Links" + } + } + }, + "Links": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/Link" + } + }, + "Link": { + "type": "object", + "properties": { + "href": { + "type": "string" + }, + "hreflang": { + "type": "string" + }, + "title": { + "type": "string" + }, + "type": { + "type": "string" + }, + "deprecation": { + "type": "string" + }, + "profile": { + "type": "string" + }, + "name": { + "type": "string" + }, + "templated": { + "type": "boolean" + } + } + } + } + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/resources/results/3.1.0/app10-direct.json b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/resources/results/3.1.0/app10-direct.json new file mode 100644 index 000000000..a6b7e6b7c --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/resources/results/3.1.0/app10-direct.json @@ -0,0 +1,391 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/paged-model-simple": { + "get": { + "tags": [ + "hello-controller" + ], + "operationId": "pagedModelSimple", + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/PagedModelString" + } + } + } + } + } + } + }, + "/paged-model-raw": { + "get": { + "tags": [ + "hello-controller" + ], + "operationId": "pagedModelRaw", + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/PagedModel" + } + } + } + } + } + } + }, + "/paged-model-complex": { + "get": { + "tags": [ + "hello-controller" + ], + "operationId": "pagedModelComplex", + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/PagedModelDummyListString" + } + } + } + } + } + } + }, + "/page-simple": { + "get": { + "tags": [ + "hello-controller" + ], + "operationId": "pageSimple", + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/PageString" + } + } + } + } + } + } + }, + "/page-raw": { + "get": { + "tags": [ + "hello-controller" + ], + "operationId": "pageRaw", + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/Page" + } + } + } + } + } + } + }, + "/page-complex": { + "get": { + "tags": [ + "hello-controller" + ], + "operationId": "pageComplex", + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/PageDummyListString" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "PageMetadata": { + "type": "object", + "properties": { + "size": { + "type": "integer", + "format": "int64" + }, + "number": { + "type": "integer", + "format": "int64" + }, + "totalElements": { + "type": "integer", + "format": "int64" + }, + "totalPages": { + "type": "integer", + "format": "int64" + } + } + }, + "PagedModelString": { + "type": "object", + "properties": { + "content": { + "type": "array", + "items": { + "type": "string" + } + }, + "page": { + "$ref": "#/components/schemas/PageMetadata" + } + } + }, + "PagedModel": { + "type": "object", + "properties": { + "content": { + "type": "array", + "items": { + "type": "object" + } + }, + "page": { + "$ref": "#/components/schemas/PageMetadata" + } + } + }, + "DummyListString": { + "type": "object", + "properties": { + "value": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "PagedModelDummyListString": { + "type": "object", + "properties": { + "content": { + "type": "array", + "items": { + "$ref": "#/components/schemas/DummyListString" + } + }, + "page": { + "$ref": "#/components/schemas/PageMetadata" + } + } + }, + "PageString": { + "type": "object", + "properties": { + "totalPages": { + "type": "integer", + "format": "int32" + }, + "totalElements": { + "type": "integer", + "format": "int64" + }, + "size": { + "type": "integer", + "format": "int32" + }, + "content": { + "type": "array", + "items": { + "type": "string" + } + }, + "number": { + "type": "integer", + "format": "int32" + }, + "sort": { + "$ref": "#/components/schemas/SortObject" + }, + "pageable": { + "$ref": "#/components/schemas/PageableObject" + }, + "first": { + "type": "boolean" + }, + "last": { + "type": "boolean" + }, + "numberOfElements": { + "type": "integer", + "format": "int32" + }, + "empty": { + "type": "boolean" + } + } + }, + "PageableObject": { + "type": "object", + "properties": { + "offset": { + "type": "integer", + "format": "int64" + }, + "sort": { + "$ref": "#/components/schemas/SortObject" + }, + "paged": { + "type": "boolean" + }, + "unpaged": { + "type": "boolean" + }, + "pageSize": { + "type": "integer", + "format": "int32" + }, + "pageNumber": { + "type": "integer", + "format": "int32" + } + } + }, + "SortObject": { + "type": "object", + "properties": { + "empty": { + "type": "boolean" + }, + "unsorted": { + "type": "boolean" + }, + "sorted": { + "type": "boolean" + } + } + }, + "Page": { + "type": "object", + "properties": { + "totalPages": { + "type": "integer", + "format": "int32" + }, + "totalElements": { + "type": "integer", + "format": "int64" + }, + "size": { + "type": "integer", + "format": "int32" + }, + "content": { + "type": "array", + "items": { + "type": "object" + } + }, + "number": { + "type": "integer", + "format": "int32" + }, + "sort": { + "$ref": "#/components/schemas/SortObject" + }, + "pageable": { + "$ref": "#/components/schemas/PageableObject" + }, + "first": { + "type": "boolean" + }, + "last": { + "type": "boolean" + }, + "numberOfElements": { + "type": "integer", + "format": "int32" + }, + "empty": { + "type": "boolean" + } + } + }, + "PageDummyListString": { + "type": "object", + "properties": { + "totalPages": { + "type": "integer", + "format": "int32" + }, + "totalElements": { + "type": "integer", + "format": "int64" + }, + "size": { + "type": "integer", + "format": "int32" + }, + "content": { + "type": "array", + "items": { + "$ref": "#/components/schemas/DummyListString" + } + }, + "number": { + "type": "integer", + "format": "int32" + }, + "sort": { + "$ref": "#/components/schemas/SortObject" + }, + "pageable": { + "$ref": "#/components/schemas/PageableObject" + }, + "first": { + "type": "boolean" + }, + "last": { + "type": "boolean" + }, + "numberOfElements": { + "type": "integer", + "format": "int32" + }, + "empty": { + "type": "boolean" + } + } + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/resources/results/3.1.0/app10-via_dto.json b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/resources/results/3.1.0/app10-via_dto.json new file mode 100644 index 000000000..3434e8fe1 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/resources/results/3.1.0/app10-via_dto.json @@ -0,0 +1,213 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/paged-model-simple": { + "get": { + "tags": [ + "hello-controller" + ], + "operationId": "pagedModelSimple", + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/PagedModelString" + } + } + } + } + } + } + }, + "/paged-model-raw": { + "get": { + "tags": [ + "hello-controller" + ], + "operationId": "pagedModelRaw", + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/PagedModel" + } + } + } + } + } + } + }, + "/paged-model-complex": { + "get": { + "tags": [ + "hello-controller" + ], + "operationId": "pagedModelComplex", + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/PagedModelDummyListString" + } + } + } + } + } + } + }, + "/page-simple": { + "get": { + "tags": [ + "hello-controller" + ], + "operationId": "pageSimple", + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/PagedModelString" + } + } + } + } + } + } + }, + "/page-raw": { + "get": { + "tags": [ + "hello-controller" + ], + "operationId": "pageRaw", + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/PagedModel" + } + } + } + } + } + } + }, + "/page-complex": { + "get": { + "tags": [ + "hello-controller" + ], + "operationId": "pageComplex", + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/PagedModelDummyListString" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "PageMetadata": { + "type": "object", + "properties": { + "size": { + "type": "integer", + "format": "int64" + }, + "number": { + "type": "integer", + "format": "int64" + }, + "totalElements": { + "type": "integer", + "format": "int64" + }, + "totalPages": { + "type": "integer", + "format": "int64" + } + } + }, + "PagedModelString": { + "type": "object", + "properties": { + "content": { + "type": "array", + "items": { + "type": "string" + } + }, + "page": { + "$ref": "#/components/schemas/PageMetadata" + } + } + }, + "PagedModel": { + "type": "object", + "properties": { + "content": { + "type": "array", + "items": { + "type": "object" + } + }, + "page": { + "$ref": "#/components/schemas/PageMetadata" + } + } + }, + "DummyListString": { + "type": "object", + "properties": { + "value": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "PagedModelDummyListString": { + "type": "object", + "properties": { + "content": { + "type": "array", + "items": { + "$ref": "#/components/schemas/DummyListString" + } + }, + "page": { + "$ref": "#/components/schemas/PageMetadata" + } + } + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/resources/results/3.1.0/app2.json b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/resources/results/3.1.0/app2.json new file mode 100644 index 000000000..4f43b9a0e --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/resources/results/3.1.0/app2.json @@ -0,0 +1,170 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/": { + "get": { + "tags": [ + "post-controller" + ], + "operationId": "getAll", + "parameters": [ + { + "name": "pageable", + "in": "query", + "required": true, + "schema": { + "$ref": "#/components/schemas/Pageable" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/PagedModelEntityModelPost" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "Pageable": { + "type": "object", + "properties": { + "page": { + "minimum": 0, + "type": "integer", + "format": "int32" + }, + "size": { + "minimum": 1, + "type": "integer", + "format": "int32" + }, + "sort": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "EntityModelPost": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "author": { + "type": "string" + }, + "content": { + "type": "string" + }, + "createdAt": { + "type": "integer", + "format": "int64" + }, + "_links": { + "$ref": "#/components/schemas/Links" + } + } + }, + "Links": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/Link" + } + }, + "PageMetadata": { + "type": "object", + "properties": { + "size": { + "type": "integer", + "format": "int64" + }, + "totalElements": { + "type": "integer", + "format": "int64" + }, + "totalPages": { + "type": "integer", + "format": "int64" + }, + "number": { + "type": "integer", + "format": "int64" + } + } + }, + "PagedModelEntityModelPost": { + "type": "object", + "properties": { + "_embedded": { + "type": "object", + "properties": { + "postList": { + "type": "array", + "items": { + "$ref": "#/components/schemas/EntityModelPost" + } + } + } + }, + "_links": { + "$ref": "#/components/schemas/Links" + }, + "page": { + "$ref": "#/components/schemas/PageMetadata" + } + } + }, + "Link": { + "type": "object", + "properties": { + "href": { + "type": "string" + }, + "hreflang": { + "type": "string" + }, + "title": { + "type": "string" + }, + "type": { + "type": "string" + }, + "deprecation": { + "type": "string" + }, + "profile": { + "type": "string" + }, + "name": { + "type": "string" + }, + "templated": { + "type": "boolean" + } + } + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/resources/results/3.1.0/app3.json b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/resources/results/3.1.0/app3.json new file mode 100644 index 000000000..d9630c227 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/resources/results/3.1.0/app3.json @@ -0,0 +1,124 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/employees/{id}": { + "get": { + "tags": [ + "employee-controller" + ], + "operationId": "findOne", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "integer", + "format": "int64" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/EntityModelEmployee" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "Employee": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "firstName": { + "type": "string" + }, + "lastName": { + "type": "string" + }, + "role": { + "type": "string" + } + } + }, + "EntityModelEmployee": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "firstName": { + "type": "string" + }, + "lastName": { + "type": "string" + }, + "role": { + "type": "string" + }, + "_links": { + "$ref": "#/components/schemas/Links" + } + } + }, + "Links": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/Link" + } + }, + "Link": { + "type": "object", + "properties": { + "href": { + "type": "string" + }, + "hreflang": { + "type": "string" + }, + "title": { + "type": "string" + }, + "type": { + "type": "string" + }, + "deprecation": { + "type": "string" + }, + "profile": { + "type": "string" + }, + "name": { + "type": "string" + }, + "templated": { + "type": "boolean" + } + } + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/resources/results/3.1.0/app4.json b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/resources/results/3.1.0/app4.json new file mode 100644 index 000000000..4c29ecf08 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/resources/results/3.1.0/app4.json @@ -0,0 +1,131 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/api/albums": { + "get": { + "tags": [ + "album-controller" + ], + "operationId": "getAllAlbums", + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/PagedModelAlbum" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "Album": { + "type": "object", + "properties": { + "title": { + "type": "string" + }, + "description": { + "type": "string" + }, + "releaseDate": { + "type": "string" + } + } + }, + "Links": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/Link" + } + }, + "PageMetadata": { + "type": "object", + "properties": { + "size": { + "type": "integer", + "format": "int64" + }, + "totalElements": { + "type": "integer", + "format": "int64" + }, + "totalPages": { + "type": "integer", + "format": "int64" + }, + "number": { + "type": "integer", + "format": "int64" + } + } + }, + "PagedModelAlbum": { + "type": "object", + "properties": { + "_embedded": { + "type": "object", + "properties": { + "albumList": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Album" + } + } + } + }, + "_links": { + "$ref": "#/components/schemas/Links" + }, + "page": { + "$ref": "#/components/schemas/PageMetadata" + } + } + }, + "Link": { + "type": "object", + "properties": { + "href": { + "type": "string" + }, + "hreflang": { + "type": "string" + }, + "title": { + "type": "string" + }, + "type": { + "type": "string" + }, + "deprecation": { + "type": "string" + }, + "profile": { + "type": "string" + }, + "name": { + "type": "string" + }, + "templated": { + "type": "boolean" + } + } + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/resources/results/3.1.0/app5.json b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/resources/results/3.1.0/app5.json new file mode 100644 index 000000000..badd1f750 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/resources/results/3.1.0/app5.json @@ -0,0 +1,116 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/": { + "post": { + "tags": [ + "company-controller" + ], + "operationId": "create", + "requestBody": { + "description": "Details of the Item to be created", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CompanyDtoNew" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/CompanyDto" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "CompanyDtoNew": { + "type": "object", + "properties": { + "id": { + "type": "string", + "format": "uuid" + }, + "name": { + "type": "string" + } + } + }, + "CompanyDto": { + "required": [ + "name" + ], + "type": "object", + "properties": { + "id": { + "type": "string", + "format": "uuid", + "readOnly": true + }, + "name": { + "type": "string" + }, + "_links": { + "$ref": "#/components/schemas/Links" + } + } + }, + "Links": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/Link" + } + }, + "Link": { + "type": "object", + "properties": { + "href": { + "type": "string" + }, + "hreflang": { + "type": "string" + }, + "title": { + "type": "string" + }, + "type": { + "type": "string" + }, + "deprecation": { + "type": "string" + }, + "profile": { + "type": "string" + }, + "name": { + "type": "string" + }, + "templated": { + "type": "boolean" + } + } + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/resources/results/3.1.0/app6.json b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/resources/results/3.1.0/app6.json new file mode 100644 index 000000000..9cc16a738 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/resources/results/3.1.0/app6.json @@ -0,0 +1,109 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "Item", + "description": "The Item API" + } + ], + "paths": { + "/v1/items": { + "get": { + "tags": [ + "Item" + ], + "summary": "Get all items", + "operationId": "getAllItems", + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CollectionModelItem" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "CollectionModelItem": { + "type": "object", + "properties": { + "links": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Link" + } + }, + "content": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Item" + } + } + } + }, + "Item": { + "type": "object", + "properties": { + "description": { + "type": "string" + }, + "links": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Link" + } + } + } + }, + "Link": { + "type": "object", + "properties": { + "rel": { + "type": "string" + }, + "href": { + "type": "string" + }, + "hreflang": { + "type": "string" + }, + "media": { + "type": "string" + }, + "title": { + "type": "string" + }, + "type": { + "type": "string" + }, + "deprecation": { + "type": "string" + }, + "profile": { + "type": "string" + }, + "name": { + "type": "string" + } + } + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/resources/results/3.1.0/app7.json b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/resources/results/3.1.0/app7.json new file mode 100644 index 000000000..e5652df4e --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/resources/results/3.1.0/app7.json @@ -0,0 +1,96 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/foo/{id}": { + "get": { + "tags": [ + "foo-controller" + ], + "operationId": "getFoo", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string", + "format": "uuid" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/hal+json": { + "schema": { + "$ref": "#/components/schemas/EntityModelFoo" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "EntityModelFoo": { + "type": "object", + "properties": { + "foo": { + "type": "string" + }, + "_links": { + "$ref": "#/components/schemas/Links" + } + } + }, + "Links": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/Link" + } + }, + "Link": { + "type": "object", + "properties": { + "href": { + "type": "string" + }, + "hreflang": { + "type": "string" + }, + "title": { + "type": "string" + }, + "type": { + "type": "string" + }, + "deprecation": { + "type": "string" + }, + "profile": { + "type": "string" + }, + "name": { + "type": "string" + }, + "templated": { + "type": "boolean" + } + } + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/resources/results/3.1.0/app8.json b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/resources/results/3.1.0/app8.json new file mode 100644 index 000000000..f345d8420 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/resources/results/3.1.0/app8.json @@ -0,0 +1,221 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/employees/{id}": { + "get": { + "tags": [ + "employee-controller" + ], + "operationId": "findOne", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "integer", + "format": "int64" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/EntityModelEmployee" + } + } + } + } + } + }, + "put": { + "tags": [ + "employee-controller" + ], + "operationId": "updateEmployee", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "integer", + "format": "int64" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Employee" + } + } + }, + "required": true + }, + "responses": { + "204": { + "description": "No Content" + } + } + } + }, + "/employees": { + "get": { + "tags": [ + "employee-controller" + ], + "operationId": "findAll", + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/CollectionModelEntityModelEmployee" + } + } + } + } + } + }, + "post": { + "tags": [ + "employee-controller" + ], + "operationId": "newEmployee", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Employee" + } + } + }, + "required": true + }, + "responses": { + "201": { + "description": "Created", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/EntityModelEmployee" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "Employee": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "firstName": { + "type": "string" + }, + "lastName": { + "type": "string" + }, + "role": { + "type": "string" + } + } + }, + "EntityModelEmployee": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "firstName": { + "type": "string" + }, + "lastName": { + "type": "string" + }, + "role": { + "type": "string" + }, + "links": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Link" + } + } + } + }, + "Link": { + "type": "object", + "properties": { + "rel": { + "type": "string" + }, + "href": { + "type": "string" + }, + "hreflang": { + "type": "string" + }, + "media": { + "type": "string" + }, + "title": { + "type": "string" + }, + "type": { + "type": "string" + }, + "deprecation": { + "type": "string" + }, + "profile": { + "type": "string" + }, + "name": { + "type": "string" + } + } + }, + "CollectionModelEntityModelEmployee": { + "type": "object", + "properties": { + "links": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Link" + } + }, + "content": { + "type": "array", + "items": { + "$ref": "#/components/schemas/EntityModelEmployee" + } + } + } + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/resources/results/3.1.0/app9.json b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/resources/results/3.1.0/app9.json new file mode 100644 index 000000000..b165286a7 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/resources/results/3.1.0/app9.json @@ -0,0 +1,142 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "Response API", + "description": "API for some response", + "contact": { + "name": "EAlf91" + }, + "version": "0.0.1" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "ResponseTag", + "description": "ResponseTag for API" + }, + { + "name": "ResponseData", + "description": "Version 2 ResponseApi" + } + ], + "paths": { + "/some-route/foo/{id}": { + "get": { + "tags": [ + "ResponseDataController" + ], + "summary": "Get all data", + "description": "Get all data", + "operationId": "getFoo", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string", + "format": "uuid" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/FeedResponse" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "FeedResponse": { + "properties": { + "_links": { + "properties": { + "next": { + "$ref": "#/components/schemas/Link", + "example": "http://localhost:8080/some-link" + }, + "self": { + "$ref": "#/components/schemas/Link", + "example": "http://localhost:8080/some-other-link" + } + } + }, + "data": { + "type": "array", + "items": { + "$ref": "#/components/schemas/ResponseData" + } + } + } + }, + "Link": { + "type": "object", + "properties": { + "href": { + "type": "string" + }, + "hreflang": { + "type": "string" + }, + "title": { + "type": "string" + }, + "type": { + "type": "string" + }, + "deprecation": { + "type": "string" + }, + "profile": { + "type": "string" + }, + "name": { + "type": "string" + }, + "templated": { + "type": "boolean" + } + } + }, + "ResponseData": { + "type": "object", + "properties": { + "DATA_ID": { + "type": "string", + "format": "uuid" + }, + "DATE": { + "type": "string", + "format": "date", + "example": "2024-03-27" + } + }, + "required": [ + "DATA_ID", + "DATE" + ] + } + }, + "securitySchemes": { + "bearerScheme": { + "type": "http", + "scheme": "bearer", + "bearerFormat": "JWT" + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/resources/results/3.1.0/app9wrong.json b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/resources/results/3.1.0/app9wrong.json new file mode 100644 index 000000000..6e8c200a3 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-hateoas-tests/src/test/resources/results/3.1.0/app9wrong.json @@ -0,0 +1,122 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "Response API", + "description": "API for some response", + "contact": { + "name": "EAlf91" + }, + "version": "0.0.1" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "ResponseTag", + "description": "ResponseTag for API" + }, + { + "name": "ResponseData", + "description": "Version 2 ResponseApi" + } + ], + "paths": { + "/some-route/foo/{id}": { + "get": { + "tags": [ + "ResponseDataController" + ], + "summary": "Get all data", + "description": "Get all data", + "operationId": "getFoo", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string", + "format": "uuid" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/FeedResponse" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "FeedResponse": { + "properties": { + "_links": { + "properties": { + "next": { + "$ref": "#/components/schemas/Link" + }, + "self": { + "$ref": "#/components/schemas/Link" + } + } + }, + "data": { + "type": "array", + "items": { + "$ref": "#/components/schemas/ResponseData" + } + } + } + }, + "Link": { + "type": "object", + "properties": { + "href": { + "type": "string" + }, + "hreflang": { + "type": "string" + }, + "title": { + "type": "string" + }, + "type": { + "type": "string" + }, + "deprecation": { + "type": "string" + }, + "profile": { + "type": "string" + }, + "name": { + "type": "string" + }, + "templated": { + "type": "boolean" + } + } + } + }, + "securitySchemes": { + "bearerScheme": { + "type": "http", + "scheme": "bearer", + "bearerFormat": "JWT" + } + } + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/pom.xml b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/pom.xml index d78f4a391..f39da3113 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.1 + 2.8.2 4.0.0 diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/AbstractSpringDocTest.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/AbstractSpringDocTest.java deleted file mode 100644 index d09755609..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/AbstractSpringDocTest.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * - * * Copyright 2019-2020 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; - -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; - -import org.junit.jupiter.api.Test; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springdoc.core.utils.Constants; - -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.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; - -/** - * The type Abstract spring doc test. - */ -@ActiveProfiles("test") -@SpringBootTest -@AutoConfigureMockMvc -@TestPropertySource(properties = "springdoc.api-docs.version=openapi_3_0" ) -public abstract class AbstractSpringDocTest { - - /** - * The constant LOGGER. - */ - protected static final Logger LOGGER = LoggerFactory.getLogger(AbstractSpringDocTest.class); - - /** - * The constant className. - */ - public static String className; - - /** - * The Mock mvc. - */ - @Autowired - protected MockMvc mockMvc; - - /** - * Gets content. - * - * @param fileName the file name - * @return the content - * @throws Exception the exception - */ - public static String getContent(String fileName) throws Exception { - try { - Path path = Paths.get(AbstractSpringDocTest.class.getClassLoader().getResource(fileName).toURI()); - byte[] fileBytes = Files.readAllBytes(path); - return new String(fileBytes, StandardCharsets.UTF_8); - } - catch (Exception e) { - throw new RuntimeException("Failed to read file: " + fileName, e); - } - } - - /** - * Test app. - * - * @throws Exception the exception - */ - @Test - protected void testApp() throws Exception { - className = getClass().getSimpleName(); - String testNumber = className.replaceAll("[^0-9]", ""); - MvcResult mockMvcResult = mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL)).andExpect(status().isOk()) - .andExpect(jsonPath("$.openapi", is("3.0.1"))).andReturn(); - String result = mockMvcResult.getResponse().getContentAsString(); - String expected = getContent("results/app" + testNumber + ".json"); - assertEquals(expected, result, true); - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app1/ApiException.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app1/ApiException.java deleted file mode 100644 index a6bb8f5f4..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app1/ApiException.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app1; - -/** - * The type Api exception. - */ -public final class ApiException extends Exception { - - /** - * The constant serialVersionUID. - */ - private static final long serialVersionUID = 1L; - - /** - * The Code. - */ - @SuppressWarnings("unused") - - private final int code; - - /** - * Instantiates a new Api exception. - * - * @param code the code - * @param msg the msg - */ - public ApiException(int code, String msg) { - super(msg); - this.code = code; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app1/ApiOriginFilter.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app1/ApiOriginFilter.java deleted file mode 100644 index 87e872c4a..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app1/ApiOriginFilter.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app1; - -import java.io.IOException; - -import jakarta.servlet.FilterChain; -import jakarta.servlet.FilterConfig; -import jakarta.servlet.ServletException; -import jakarta.servlet.ServletRequest; -import jakarta.servlet.ServletResponse; -import jakarta.servlet.http.HttpServletResponse; - -/** - * The type Api origin filter. - */ -class ApiOriginFilter implements jakarta.servlet.Filter { - /** - * Do filter. - * - * @param request the request - * @param response the response - * @param chain the chain - * @throws IOException the io exception - * @throws ServletException the servlet exception - */ - @Override - public void doFilter(ServletRequest request, ServletResponse response, - FilterChain chain) throws IOException, ServletException { - HttpServletResponse res = (HttpServletResponse) response; - res.addHeader("Access-Control-Allow-Origin", "*"); - res.addHeader("Access-Control-Allow-Methods", "GET, POST, DELETE, PUT"); - res.addHeader("Access-Control-Allow-Headers", "Content-Type"); - chain.doFilter(request, response); - } - - /** - * Destroy. - */ - @Override - public void destroy() { - } - - /** - * Init. - * - * @param filterConfig the filter config - * @throws ServletException the servlet exception - */ - @Override - public void init(FilterConfig filterConfig) throws ServletException { - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app1/ApiResponseMessage.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app1/ApiResponseMessage.java deleted file mode 100644 index e161afb2a..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app1/ApiResponseMessage.java +++ /dev/null @@ -1,160 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app1; - -import jakarta.xml.bind.annotation.XmlTransient; - -/** - * The type Api response message. - */ -@jakarta.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2019-07-08T09:37:36.546Z[GMT]") -@jakarta.xml.bind.annotation.XmlRootElement -class ApiResponseMessage { - /** - * The constant ERROR. - */ - public static final int ERROR = 1; - - /** - * The constant WARNING. - */ - public static final int WARNING = 2; - - /** - * The constant INFO. - */ - public static final int INFO = 3; - - /** - * The constant OK. - */ - public static final int OK = 4; - - /** - * The constant TOO_BUSY. - */ - public static final int TOO_BUSY = 5; - - /** - * The Code. - */ - int code; - - /** - * The Type. - */ - String type; - - /** - * The Message. - */ - String message; - - /** - * Instantiates a new Api response message. - */ - public ApiResponseMessage() { - } - - /** - * Instantiates a new Api response message. - * - * @param code the code - * @param message the message - */ - public ApiResponseMessage(int code, String message) { - this.code = code; - switch (code) { - case ERROR: - setType("error"); - break; - case WARNING: - setType("warning"); - break; - case INFO: - setType("info"); - break; - case OK: - setType("ok"); - break; - case TOO_BUSY: - setType("too busy"); - break; - default: - setType("unknown"); - break; - } - this.message = message; - } - - /** - * Gets code. - * - * @return the code - */ - @XmlTransient - public int getCode() { - return code; - } - - /** - * Sets code. - * - * @param code the code - */ - public void setCode(int code) { - this.code = code; - } - - /** - * Gets type. - * - * @return the type - */ - public String getType() { - return type; - } - - /** - * Sets type. - * - * @param type the type - */ - public void setType(String type) { - this.type = type; - } - - /** - * Gets message. - * - * @return the message - */ - public String getMessage() { - return message; - } - - /** - * Sets message. - * - * @param message the message - */ - public void setMessage(String message) { - this.message = message; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app1/ErrorMessage.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app1/ErrorMessage.java deleted file mode 100644 index 7eb1c3f7b..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app1/ErrorMessage.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app1; - -/** - * The type Error message. - */ -class ErrorMessage { - - /** - * The Id. - */ - private String id; - - /** - * The Message. - */ - private String message; - - /** - * Instantiates a new Error message. - * - * @param id the id - * @param message2 the message 2 - */ - public ErrorMessage(String id, String message2) { - this.id = id; - this.message = message2; - } - - /** - * Gets id. - * - * @return the id - */ - public String getId() { - return id; - } - - /** - * Sets id. - * - * @param id the id - */ - public void setId(String id) { - this.id = id; - } - - /** - * Gets message. - * - * @return the message - */ - public String getMessage() { - return message; - } - - /** - * Sets message. - * - * @param message the message - */ - public void setMessage(String message) { - this.message = message; - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app1/ExceptionTranslator.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app1/ExceptionTranslator.java deleted file mode 100644 index 56b2a89e9..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app1/ExceptionTranslator.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app1; - -import java.util.UUID; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.ControllerAdvice; -import org.springframework.web.bind.annotation.ExceptionHandler; -import org.springframework.web.bind.annotation.ResponseStatus; - -/** - * The type Exception translator. - */ -@ControllerAdvice -class ExceptionTranslator { - - /** - * The constant LOGGER. - */ - private static final Logger LOGGER = LoggerFactory.getLogger(ExceptionTranslator.class); - - /** - * Handle run time exception response entity. - * - * @param e the e - * @return the response entity - */ - @ExceptionHandler({ RuntimeException.class }) - @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR) - public ResponseEntity handleRunTimeException(RuntimeException e) { - return error(HttpStatus.INTERNAL_SERVER_ERROR, e); - } - - - /** - * Error response entity. - * - * @param status the status - * @param e the e - * @return the response entity - */ - private ResponseEntity error(HttpStatus status, Exception e) { - LOGGER.error("Exception : ", e); - return ResponseEntity.status(status).body(new ErrorMessage(UUID.randomUUID().toString(), e.getMessage())); - } -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app1/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app1/HelloController.java deleted file mode 100644 index 1ef1f9b75..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app1/HelloController.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app1; - - -import io.swagger.v3.oas.annotations.tags.Tag; - -import org.springframework.http.HttpStatus; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.ResponseStatus; -import org.springframework.web.bind.annotation.RestController; - -/** - * The type Hello controller. - */ -@RestController -class HelloController { - - /** - * Index string. - * - * @param numTel the num tel - * @param adresse the adresse - * @return the string - */ - @GetMapping(value = "/hello/{numTelco}") - @ResponseStatus(HttpStatus.I_AM_A_TEAPOT) - @Tag(name = "tea") - public String index(@PathVariable("numTelco") String numTel, String adresse) { - return "Greetings from Spring Boot!"; - } - -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app1/HomeController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app1/HomeController.java deleted file mode 100644 index d11d30441..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app1/HomeController.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app1; - -import org.springframework.beans.factory.annotation.Value; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.GetMapping; - -import static org.springdoc.core.utils.Constants.SWAGGER_UI_PATH; -import static org.springframework.util.AntPathMatcher.DEFAULT_PATH_SEPARATOR; -import static org.springframework.web.servlet.view.UrlBasedViewResolver.REDIRECT_URL_PREFIX; - -/** - * Home redirection to swagger api documentation - */ -@Controller -class HomeController { - - /** - * The Swagger ui path. - */ - @Value(SWAGGER_UI_PATH) - private String swaggerUiPath; - - /** - * Index string. - * - * @return the string - */ - @GetMapping(DEFAULT_PATH_SEPARATOR) - public String index() { - return REDIRECT_URL_PREFIX + swaggerUiPath; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app1/InventoryApi.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app1/InventoryApi.java deleted file mode 100644 index 129204198..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app1/InventoryApi.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * - * * Copyright 2019-2020 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. - * - */ - -/** - * NOTE: This class is auto generated by the swagger code generator program (3.0.8). - * https://github.com/swagger-api/swagger-codegen - * Do not edit the class manually. - */ -package test.org.springdoc.api.app1; - -import java.util.List; - -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.responses.ApiResponse; -import io.swagger.v3.oas.annotations.responses.ApiResponses; -import io.swagger.v3.oas.annotations.tags.Tag; -import jakarta.validation.Valid; -import jakarta.validation.constraints.Max; -import jakarta.validation.constraints.Min; - -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestParam; - -/** - * The interface Inventory api. - */ -@jakarta.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2019-07-08T09:37:36.546Z[GMT]") -@Tag(name = "inventory") -public interface InventoryApi { - - /** - * Add inventory response entity. - * - * @param body the body - * @return the response entity - */ - @Operation(description = "adds an inventory item", operationId = "addInventory", summary = "Adds an item to the system", tags = { - "admins", }) - @ApiResponses(value = { @ApiResponse(responseCode = "201", description = "item created"), - @ApiResponse(responseCode = "400", description = "invalid input, object invalid"), - @ApiResponse(responseCode = "409", description = "an existing item already exists") }) - @PostMapping(value = "/inventory", consumes = { "application/json" }) - ResponseEntity addInventory( - @io.swagger.v3.oas.annotations.parameters.RequestBody(description = "Inventory item to do") @Valid @RequestBody InventoryItem body); - - /** - * Search inventory response entity. - * - * @param searchString the search string - * @param skip the skip - * @param limit the limit - * @return the response entity - */ - @Operation(description = "searches inventory", operationId = "searchInventory", summary = "By passing in the appropriate options, you can search for available inventory in the system ", tags = { - "developers", }, parameters = { - @Parameter(description = "pass an optional search string for looking up inventory", name = "searchString") }) - @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "search results matching criteria"), - @ApiResponse(responseCode = "400", description = "bad input parameter") }) - @GetMapping(value = "/inventory", produces = { "application/json" }) - ResponseEntity> searchInventory( - @Valid @RequestParam(value = "searchString", required = false) String searchString, - @Min(0) @Parameter(description = "number of records to skip for pagination") @Valid @RequestParam(value = "skip", required = true) Integer skip, - @Min(0) @Max(50) @Parameter(description = "maximum number of records to return") @Valid @RequestParam(value = "limit", required = true) Integer limit); - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app1/InventoryApiController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app1/InventoryApiController.java deleted file mode 100644 index 8969acf11..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app1/InventoryApiController.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app1; - -import java.util.List; - -import com.fasterxml.jackson.databind.ObjectMapper; -import io.swagger.v3.oas.annotations.Parameter; -import jakarta.servlet.http.HttpServletRequest; -import jakarta.validation.Valid; -import jakarta.validation.constraints.Max; -import jakarta.validation.constraints.Min; - -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -/** - * The type Inventory api controller. - */ -@jakarta.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2019-07-08T09:37:36.546Z[GMT]") -@RestController -class InventoryApiController implements InventoryApi { - - - /** - * The Object mapper. - */ - @SuppressWarnings("unused") - private final ObjectMapper objectMapper; - - /** - * The Request. - */ - private final HttpServletRequest request; - - /** - * Instantiates a new Inventory api controller. - * - * @param objectMapper the object mapper - * @param request the request - */ - @org.springframework.beans.factory.annotation.Autowired - public InventoryApiController(ObjectMapper objectMapper, HttpServletRequest request) { - this.objectMapper = objectMapper; - this.request = request; - } - - /** - * Add inventory response entity. - * - * @param body the body - * @return the response entity - */ - public ResponseEntity addInventory( - @io.swagger.v3.oas.annotations.parameters.RequestBody(description = "Inventory item to add") @Valid @RequestBody InventoryItem body) { - @SuppressWarnings("unused") - String accept = request.getHeader("Accept"); - return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); - } - - /** - * Search inventory response entity. - * - * @param searchString the search string - * @param skip the skip - * @param limit the limit - * @return the response entity - */ - public ResponseEntity> searchInventory( - @Parameter(description = "pass an optional search string for looking up inventory") @Valid @RequestParam(value = "searchString", required = false) String searchString, - @Min(0) @Parameter(description = "number of records to skip for pagination") @Valid @RequestParam(value = "skip", required = true) Integer skip, - @Min(0) @Max(50) @Parameter(description = "maximum number of records to return") @Valid @RequestParam(value = "limit", required = true) Integer limit) { - @SuppressWarnings("unused") - String accept = request.getHeader("Accept"); - return new ResponseEntity>(HttpStatus.NOT_IMPLEMENTED); - } - - /** - * Gets . - * - * @param language the language - * @return the - */ - public String getme(String language) { - return language; - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app1/InventoryItem.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app1/InventoryItem.java deleted file mode 100644 index bd8a96720..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app1/InventoryItem.java +++ /dev/null @@ -1,253 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app1; - -import java.util.Objects; -import java.util.UUID; - -import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.v3.oas.annotations.media.Schema; -import jakarta.validation.Valid; -import jakarta.validation.constraints.NotNull; - -import org.springframework.validation.annotation.Validated; - -/** - * InventoryItem - */ -@Validated -@jakarta.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2019-07-08T09:37:36.546Z[GMT]") -class InventoryItem { - /** - * The Id. - */ - @JsonProperty("id") - private UUID id = null; - - /** - * The Name. - */ - @JsonProperty("name") - private String name = null; - - /** - * The Release date. - */ - @JsonProperty("releaseDate") - private String releaseDate = null; - - /** - * The Manufacturer. - */ - @JsonProperty("manufacturer") - private Manufacturer manufacturer = null; - - /** - * Id inventory item. - * - * @param id the id - * @return the inventory item - */ - public InventoryItem id(UUID id) { - this.id = id; - return this; - } - - /** - * Get id - * - * @return id id - */ - @Schema(example = "d290f1ee-6c54-4b01-90e6-d701748f0851", required = true) - @NotNull - - @Valid - public UUID getId() { - return id; - } - - /** - * Sets id. - * - * @param id the id - */ - public void setId(UUID id) { - this.id = id; - } - - /** - * Name inventory item. - * - * @param name the name - * @return the inventory item - */ - public InventoryItem name(String name) { - this.name = name; - return this; - } - - /** - * Get name - * - * @return name name - */ - @Schema(example = "Widget Adapter", required = true) - @NotNull - - public String getName() { - return name; - } - - /** - * Sets name. - * - * @param name the name - */ - public void setName(String name) { - this.name = name; - } - - /** - * Release date inventory item. - * - * @param releaseDate the release date - * @return the inventory item - */ - public InventoryItem releaseDate(String releaseDate) { - this.releaseDate = releaseDate; - return this; - } - - /** - * Get releaseDate - * - * @return releaseDate release date - */ - @Schema(example = "2016-08-29T09:12:33.001Z", required = true) - @NotNull - - public String getReleaseDate() { - return releaseDate; - } - - /** - * Sets release date. - * - * @param releaseDate the release date - */ - public void setReleaseDate(String releaseDate) { - this.releaseDate = releaseDate; - } - - /** - * Manufacturer inventory item. - * - * @param manufacturer the manufacturer - * @return the inventory item - */ - public InventoryItem manufacturer(Manufacturer manufacturer) { - this.manufacturer = manufacturer; - return this; - } - - /** - * Get manufacturer - * - * @return manufacturer manufacturer - */ - @Schema(required = true) - @NotNull - - @Valid - public Manufacturer getManufacturer() { - return manufacturer; - } - - /** - * Sets manufacturer. - * - * @param manufacturer the manufacturer - */ - public void setManufacturer(Manufacturer manufacturer) { - this.manufacturer = manufacturer; - } - - - /** - * Equals boolean. - * - * @param o the o - * @return the boolean - */ - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - InventoryItem inventoryItem = (InventoryItem) o; - return Objects.equals(this.id, inventoryItem.id) && - Objects.equals(this.name, inventoryItem.name) && - Objects.equals(this.releaseDate, inventoryItem.releaseDate) && - Objects.equals(this.manufacturer, inventoryItem.manufacturer); - } - - /** - * Hash code int. - * - * @return the int - */ - @Override - public int hashCode() { - return Objects.hash(id, name, releaseDate, manufacturer); - } - - /** - * To string string. - * - * @return the string - */ - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class InventoryItem {\n"); - - sb.append(" id: ").append(toIndentedString(id)).append("\n"); - sb.append(" name: ").append(toIndentedString(name)).append("\n"); - sb.append(" releaseDate: ").append(toIndentedString(releaseDate)).append("\n"); - sb.append(" manufacturer: ").append(toIndentedString(manufacturer)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - * @param o the o - * @return the string - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app1/ItemController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app1/ItemController.java deleted file mode 100644 index ff5a2b887..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app1/ItemController.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app1; - -import java.net.URI; -import java.time.Instant; -import java.util.ArrayList; -import java.util.List; -import java.util.UUID; - -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.enums.Explode; -import io.swagger.v3.oas.annotations.enums.ParameterIn; -import io.swagger.v3.oas.annotations.media.ArraySchema; -import io.swagger.v3.oas.annotations.media.Schema; -import io.swagger.v3.oas.annotations.tags.Tag; -import jakarta.validation.Valid; -import jakarta.validation.constraints.Size; - -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; -import org.springframework.web.servlet.support.ServletUriComponentsBuilder; - -/** - * The type Item controller. - */ -@RestController -@Tag(name = "items") -class ItemController { - - /** - * Show items list. - * - * @param customerID the customer id - * @param toto the toto - * @param startDate the start date - * @param filterIds the filter ids - * @return the list - */ - @GetMapping("/items") - public List showItems(@RequestParam("cusID") @Size(min = 4, max = 6) final String customerID, - @Size(min = 4, max = 6) int toto, - @Parameter(name = "start", in = ParameterIn.QUERY, required = false, schema = @Schema(type = "string", format = "date-time", required = false, example = "1970-01-01T00:00:00.000Z")) @RequestParam(value = "start", required = false) Instant startDate, - @Parameter(name = "filterIds", in = ParameterIn.QUERY, array = @ArraySchema(schema = @Schema(type = "string")), explode = Explode.FALSE) @RequestParam(required = false) List filterIds) { - return new ArrayList(); - } - - /** - * Add item response entity. - * - * @param itemDTO the item dto - * @return the response entity - */ - @PostMapping("/items") - public ResponseEntity addItem(@Valid @RequestBody final ItemLightDTO itemDTO) { - final URI location = ServletUriComponentsBuilder.fromCurrentRequest().path("/{id}") - .buildAndExpand(UUID.randomUUID()).toUri(); - return ResponseEntity.created(location).build(); - } - -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app1/ItemDTO.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app1/ItemDTO.java deleted file mode 100644 index 7f8b0aa02..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app1/ItemDTO.java +++ /dev/null @@ -1,156 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app1; - -import java.io.Serializable; - -/** - * The type Item dto. - * @author bnasslahsen - */ -class ItemDTO implements Serializable { - - /** - * serialVersionUID of type long - */ - private static final long serialVersionUID = 1L; - - /** - * itemID of type String - */ - private String itemID; - - /** - * description of type String - */ - private String description; - - /** - * price of type int - */ - private int price; - - /** - * The Deprecated price. - */ - @Deprecated - private int deprecatedPrice; - - /** - * Instantiates a new Item dto. - */ - public ItemDTO() { - } - - /** - * Instantiates a new Item dto. - * - * @param description description - * @param price price - */ - public ItemDTO(final String description, final int price) { - this.description = description; - this.price = price; - } - - /** - * Instantiates a new Item dto. - * - * @param itemID itemID - * @param description description - * @param price price - */ - public ItemDTO(final String itemID, final String description, final int price) { - this.itemID = itemID; - this.description = description; - this.price = price; - } - - /** - * Gets description. - * - * @return description description - */ - public String getDescription() { - return description; - } - - /** - * Sets description. - * - * @param description description - */ - public void setDescription(final String description) { - this.description = description; - } - - /** - * Gets item id. - * - * @return item id - */ - public String getItemID() { - return itemID; - } - - /** - * Sets item id. - * - * @param itemID itemID - */ - public void setItemID(final String itemID) { - this.itemID = itemID; - } - - /** - * Gets price. - * - * @return price price - */ - public int getPrice() { - return price; - } - - /** - * Sets price. - * - * @param price price - */ - public void setPrice(final int price) { - this.price = price; - } - - /** - * Gets deprecated price. - * - * @return the deprecated price - */ - public int getDeprecatedPrice() { - return deprecatedPrice; - } - - /** - * Sets deprecated price. - * - * @param deprecatedPrice the deprecated price - */ - public void setDeprecatedPrice(int deprecatedPrice) { - this.deprecatedPrice = deprecatedPrice; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app1/ItemLightDTO.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app1/ItemLightDTO.java deleted file mode 100644 index 366cfa21d..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app1/ItemLightDTO.java +++ /dev/null @@ -1,121 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app1; - -import java.io.Serializable; - -/** - * The type Item light dto. - * @author bnasslahsen - */ -class ItemLightDTO implements Serializable { - - /** - * serialVersionUID of type long - */ - private static final long serialVersionUID = 1L; - - /** - * description of type String - */ - private String description; - - /** - * price of type int - */ - private int price; - - /** - * The Deprecated price. - */ - @Deprecated - private int deprecatedPrice; - - /** - * Instantiates a new Item light dto. - */ - public ItemLightDTO() { - } - - /** - * Instantiates a new Item light dto. - * - * @param description the description - * @param price the price - */ - public ItemLightDTO(String description, int price) { - super(); - this.description = description; - this.price = price; - } - - /** - * Gets description. - * - * @return description description - */ - public String getDescription() { - return description; - } - - /** - * Sets description. - * - * @param description description - */ - public void setDescription(final String description) { - this.description = description; - } - - /** - * Gets price. - * - * @return price price - */ - public int getPrice() { - return price; - } - - /** - * Sets price. - * - * @param price price - */ - public void setPrice(final int price) { - this.price = price; - } - - /** - * Gets deprecated price. - * - * @return the deprecated price - */ - public int getDeprecatedPrice() { - return deprecatedPrice; - } - - /** - * Sets deprecated price. - * - * @param deprecatedPrice the deprecated price - */ - public void setDeprecatedPrice(int deprecatedPrice) { - this.deprecatedPrice = deprecatedPrice; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app1/Manufacturer.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app1/Manufacturer.java deleted file mode 100644 index d995b98d5..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app1/Manufacturer.java +++ /dev/null @@ -1,207 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app1; - -import java.util.Objects; - -import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.v3.oas.annotations.media.Schema; -import jakarta.validation.constraints.NotNull; - -import org.springframework.validation.annotation.Validated; - - -/** - * Manufacturer - */ -@Validated -@jakarta.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2019-07-08T09:37:36.546Z[GMT]") -class Manufacturer { - /** - * The Name. - */ - @JsonProperty("name") - private String name = null; - - /** - * The Home page. - */ - @JsonProperty("homePage") - private String homePage = null; - - /** - * The Phone. - */ - @JsonProperty("phone") - private String phone = null; - - /** - * Name manufacturer. - * - * @param name the name - * @return the manufacturer - */ - public Manufacturer name(String name) { - this.name = name; - return this; - } - - /** - * Get name - * - * @return name name - */ - @Schema(example = "ACME Corporation", required = true) - @NotNull - - public String getName() { - return name; - } - - /** - * Sets name. - * - * @param name the name - */ - public void setName(String name) { - this.name = name; - } - - /** - * Home page manufacturer. - * - * @param homePage the home page - * @return the manufacturer - */ - public Manufacturer homePage(String homePage) { - this.homePage = homePage; - return this; - } - - /** - * Get homePage - * - * @return homePage home page - */ - @Schema(example = "https://www.acme-corp.com") - - public String getHomePage() { - return homePage; - } - - /** - * Sets home page. - * - * @param homePage the home page - */ - public void setHomePage(String homePage) { - this.homePage = homePage; - } - - /** - * Phone manufacturer. - * - * @param phone the phone - * @return the manufacturer - */ - public Manufacturer phone(String phone) { - this.phone = phone; - return this; - } - - /** - * Get phone - * - * @return phone phone - */ - @Schema(example = "408-867-5309") - public String getPhone() { - return phone; - } - - /** - * Sets phone. - * - * @param phone the phone - */ - public void setPhone(String phone) { - this.phone = phone; - } - - - /** - * Equals boolean. - * - * @param o the o - * @return the boolean - */ - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - Manufacturer manufacturer = (Manufacturer) o; - return Objects.equals(this.name, manufacturer.name) && - Objects.equals(this.homePage, manufacturer.homePage) && - Objects.equals(this.phone, manufacturer.phone); - } - - /** - * Hash code int. - * - * @return the int - */ - @Override - public int hashCode() { - return Objects.hash(name, homePage, phone); - } - - /** - * To string string. - * - * @return the string - */ - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class Manufacturer {\n"); - - sb.append(" name: ").append(toIndentedString(name)).append("\n"); - sb.append(" homePage: ").append(toIndentedString(homePage)).append("\n"); - sb.append(" phone: ").append(toIndentedString(phone)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - * @param o the o - * @return the string - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app1/PeopleRestService.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app1/PeopleRestService.java deleted file mode 100644 index 803b88779..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app1/PeopleRestService.java +++ /dev/null @@ -1,138 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app1; - -import java.net.URI; -import java.util.Collection; -import java.util.Map; -import java.util.UUID; -import java.util.concurrent.ConcurrentHashMap; - -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.headers.Header; -import io.swagger.v3.oas.annotations.media.ArraySchema; -import io.swagger.v3.oas.annotations.media.Content; -import io.swagger.v3.oas.annotations.media.Schema; -import io.swagger.v3.oas.annotations.responses.ApiResponse; -import io.swagger.v3.oas.annotations.tags.Tag; - -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.DeleteMapping; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; -import org.springframework.web.servlet.support.ServletUriComponentsBuilder; - -/** - * The type People rest service. - */ -@RestController -@Tag(name = "people") -class PeopleRestService { - /** - * The People. - */ - private Map people = new ConcurrentHashMap<>(); - - /** - * Gets people. - * - * @return the people - */ - @GetMapping(value = "/people", produces = MediaType.APPLICATION_JSON_VALUE) - @Operation(description = "List all people", responses = { - @ApiResponse(content = @Content(array = @ArraySchema(schema = @Schema(implementation = PersonDTO.class))), responseCode = "200") }) - public Collection getPeople() { - return people.values(); - } - - /** - * Find person person dto. - * - * @param email the email - * @return the person dto - */ - @Operation(description = "Find person by e-mail", responses = { - @ApiResponse(content = @Content(schema = @Schema(implementation = PersonDTO.class)), responseCode = "200"), - @ApiResponse(responseCode = "404", description = "Person with such e-mail doesn't exists") }) - @GetMapping(value = "/{email}", produces = MediaType.APPLICATION_JSON_VALUE) - public PersonDTO findPerson( - @Parameter(description = "E-Mail address to lookup for", required = true) @PathVariable("email") final String email) { - - final PersonDTO person = people.get(email); - - if (person == null) { - throw new RuntimeException("Person with such e-mail doesn't exists"); - } - - return person; - } - - /** - * Add person response entity. - * - * @param email the email - * @param firstName the first name - * @param lastName the last name - * @return the response entity - */ - @PostMapping(value = "/{email}", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) - @Operation(description = "Create new person", responses = { - @ApiResponse(content = @Content(schema = @Schema(implementation = PersonDTO.class), mediaType = MediaType.APPLICATION_JSON_VALUE), headers = @Header(name = "Location"), responseCode = "201"), - @ApiResponse(responseCode = "409", description = "Person with such e-mail already exists") }) - public ResponseEntity addPerson( - @Parameter(description = "E-Mail", required = true) @PathVariable("email") final String email, - @Parameter(description = "First Name", required = true) @RequestParam("firstName") final String firstName, - @Parameter(description = "Last Name", required = true) @RequestParam("lastName") final String lastName) { - - final PersonDTO person = people.get(email); - - if (person != null) { - return ResponseEntity.status(HttpStatus.CONFLICT).body("Person with such e-mail already exists"); - } - - people.put(email, new PersonDTO(email, firstName, lastName)); - final URI location = ServletUriComponentsBuilder.fromCurrentRequest().path("/{id}") - .buildAndExpand(UUID.randomUUID()).toUri(); - return ResponseEntity.created(location).build(); - } - - /** - * Delete person response entity. - * - * @param email the email - * @return the response entity - */ - @DeleteMapping(value = "/{email}") - @Operation(description = "Delete existing person", responses = { - @ApiResponse(responseCode = "204", description = "Person has been deleted"), - @ApiResponse(responseCode = "404", description = "Person with such e-mail doesn't exists") }) - public ResponseEntity deletePerson( - @Parameter(description = "E-Mail address to lookup for", required = true) @PathVariable("email") final String email) { - if (people.remove(email) == null) { - throw new RuntimeException("Person with such e-mail doesn't exists"); - } - return ResponseEntity.noContent().build(); - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app1/PersonDTO.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app1/PersonDTO.java deleted file mode 100644 index cd8dd27bc..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app1/PersonDTO.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app1; - -/** - * The type Person dto. - */ -class PersonDTO { - /** - * The Email. - */ - private String email; - - /** - * The First name. - */ - private String firstName; - - /** - * The Last name. - */ - private String lastName; - - /** - * Instantiates a new Person dto. - */ - public PersonDTO() { - } - - /** - * Instantiates a new Person dto. - * - * @param email the email - * @param firstName the first name - * @param lastName the last name - */ - public PersonDTO(final String email, final String firstName, final String lastName) { - this.email = email; - this.firstName = firstName; - this.lastName = lastName; - } - - /** - * Gets email. - * - * @return the email - */ - public String getEmail() { - return email; - } - - /** - * Sets email. - * - * @param email the email - */ - public void setEmail(final String email) { - this.email = email; - } - - /** - * Gets first name. - * - * @return the first name - */ - public String getFirstName() { - return firstName; - } - - /** - * Sets first name. - * - * @param firstName the first name - */ - public void setFirstName(final String firstName) { - this.firstName = firstName; - } - - /** - * Gets last name. - * - * @return the last name - */ - public String getLastName() { - return lastName; - } - - /** - * Sets last name. - * - * @param lastName the last name - */ - public void setLastName(final String lastName) { - this.lastName = lastName; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app1/SpringDocApp1Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app1/SpringDocApp1Test.java deleted file mode 100644 index cf33498bc..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app1/SpringDocApp1Test.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app1; - -import io.swagger.v3.oas.models.Components; -import io.swagger.v3.oas.models.OpenAPI; -import io.swagger.v3.oas.models.info.Info; -import io.swagger.v3.oas.models.info.License; -import io.swagger.v3.oas.models.security.SecurityScheme; -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.Bean; -import org.springframework.test.context.TestPropertySource; - -/** - * The type Spring doc app 1 test. - */ -@TestPropertySource(properties = "springdoc.default-produces-media-type=application/json") -class SpringDocApp1Test extends AbstractSpringDocTest { - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp { - /** - * Custom open api open api. - * - * @return the open api - */ - @Bean - public OpenAPI customOpenAPI() { - return new OpenAPI() - .components(new Components().addSecuritySchemes("basicScheme", - new SecurityScheme().type(SecurityScheme.Type.HTTP).scheme("basic"))) - .info(new Info().title("SpringShop API").version("v0") - .license(new License().name("Apache 2.0").url("http://springdoc.org"))); - } - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app10/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app10/HelloController.java deleted file mode 100644 index 72f87433b..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app10/HelloController.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app10; - -import java.util.Locale; - -import jakarta.servlet.http.HttpServletRequest; -import jakarta.servlet.http.HttpServletResponse; -import jakarta.servlet.http.HttpSession; - -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestAttribute; -import org.springframework.web.bind.annotation.RestController; - -/** - * The type Hello controller. - */ -@RestController -class HelloController { - - /** - * Test. - * - * @param header the header - * @param request the request - * @param response the response - * @param locale the locale - * @param hello the hello - */ - @GetMapping("/test") - public void test(HttpSession header, HttpServletRequest request, HttpServletResponse response, Locale locale, - String hello) { - } - - /** - * Test request attribute. - * - * @param sample the sample - * @param s the s - */ - @GetMapping("/testreq") - public void testRequestAttribute(@RequestAttribute String sample, String s) { - - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app10/SpringDocApp10Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app10/SpringDocApp10Test.java deleted file mode 100644 index 3af79d360..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app10/SpringDocApp10Test.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app10; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * The type Spring doc app 10 test. - */ -class SpringDocApp10Test extends AbstractSpringDocTest { - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app100/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app100/HelloController.java deleted file mode 100644 index 519ecc56d..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app100/HelloController.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app100; - -import io.swagger.v3.oas.annotations.tags.Tag; -import io.swagger.v3.oas.annotations.tags.Tags; -import jakarta.validation.constraints.NotNull; - -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * The type Hello controller. - */ -@RestController -@Tags(value = @Tag(name = "hello-ap1")) -class HelloController { - - /** - * Gets all pets. - * - * @param toto the toto - * @return the all pets - */ - @GetMapping(value = "/search", produces = { "application/xml", "application/json" }) - @Tags(value = @Tag(name = "hello-ap2")) - public PersonDTO getAllPets(@NotNull String toto) { - return null; - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app100/PersonDTO.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app100/PersonDTO.java deleted file mode 100644 index 1166d5b3e..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app100/PersonDTO.java +++ /dev/null @@ -1,115 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app100; - -import io.swagger.v3.oas.annotations.media.Schema; - -/** - * The type Person dto. - */ -@Schema -class PersonDTO { - /** - * The Email. - */ - private String email; - - /** - * The First name. - */ - private String firstName; - - /** - * The Last name. - */ - private String lastName; - - /** - * Instantiates a new Person dto. - */ - public PersonDTO() { - } - - /** - * Instantiates a new Person dto. - * - * @param email the email - * @param firstName the first name - * @param lastName the last name - */ - public PersonDTO(final String email, final String firstName, final String lastName) { - this.email = email; - this.firstName = firstName; - this.lastName = lastName; - } - - /** - * Gets email. - * - * @return the email - */ - public String getEmail() { - return email; - } - - /** - * Sets email. - * - * @param email the email - */ - public void setEmail(final String email) { - this.email = email; - } - - /** - * Gets first name. - * - * @return the first name - */ - public String getFirstName() { - return firstName; - } - - /** - * Sets first name. - * - * @param firstName the first name - */ - public void setFirstName(final String firstName) { - this.firstName = firstName; - } - - /** - * Gets last name. - * - * @return the last name - */ - public String getLastName() { - return lastName; - } - - /** - * Sets last name. - * - * @param lastName the last name - */ - public void setLastName(final String lastName) { - this.lastName = lastName; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app100/SpringDocApp100Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app100/SpringDocApp100Test.java deleted file mode 100644 index 53e24d5ef..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app100/SpringDocApp100Test.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app100; - - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * The type Spring doc app 100 test. - */ -class SpringDocApp100Test extends AbstractSpringDocTest { - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} - -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app101/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app101/HelloController.java deleted file mode 100644 index 82f650bc8..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app101/HelloController.java +++ /dev/null @@ -1,31 +0,0 @@ -package test.org.springdoc.api.app101; - -import io.swagger.v3.oas.annotations.media.Content; -import io.swagger.v3.oas.annotations.media.Schema; -import io.swagger.v3.oas.annotations.responses.ApiResponse; - -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * The type Hello controller. - */ -@RestController -@RequestMapping("/hello") -class HelloController { - - /** - * Hello hello dto. - * - * @return the hello dto - */ - @GetMapping - @ApiResponse(content = @Content(schema = @Schema( - description = "${test.app101.operation.hello.response.schema.description}", - implementation = HelloDTO.class))) - public HelloDTO hello() { - return new HelloDTO(); - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app101/HelloDTO.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app101/HelloDTO.java deleted file mode 100644 index fe4847ff6..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app101/HelloDTO.java +++ /dev/null @@ -1,37 +0,0 @@ -package test.org.springdoc.api.app101; - -import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.v3.oas.annotations.media.Schema; - -/** - * The type Hello dto. - */ -@Schema(description = "${test.app101.schema.hello.description}") -class HelloDTO { - - /** - * The Id. - */ - @Schema(description = "${test.app101.schema.hello.param.id.description}") - private String id; - - /** - * Gets id. - * - * @return the id - */ - @JsonProperty("id") - public String getId() { - return id; - } - - /** - * Sets id. - * - * @param id the id - */ - public void setId(String id) { - this.id = id; - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app101/SpringDocApp101Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app101/SpringDocApp101Test.java deleted file mode 100644 index 7a0368db9..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app101/SpringDocApp101Test.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app101; - - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.test.context.ActiveProfiles; - -/** - * The type Spring doc app 101 test. - */ -@ActiveProfiles("101") -class SpringDocApp101Test extends AbstractSpringDocTest { - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} - -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app102/InheritedRequestParams.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app102/InheritedRequestParams.java deleted file mode 100644 index 13fbe8bbb..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app102/InheritedRequestParams.java +++ /dev/null @@ -1,34 +0,0 @@ -package test.org.springdoc.api.app102; - -import io.swagger.v3.oas.annotations.Parameter; -import jakarta.validation.constraints.NotBlank; - -/** - * The type Inherited request params. - */ -class InheritedRequestParams extends RequestParams { - /** - * The Child param. - */ - @Parameter(description = "parameter from child of RequestParams") - @NotBlank - private String childParam; - - /** - * Gets child param. - * - * @return the child param - */ - public String getChildParam() { - return childParam; - } - - /** - * Sets child param. - * - * @param childParam the child param - */ - public void setChildParam(String childParam) { - this.childParam = childParam; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app102/RequestParams.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app102/RequestParams.java deleted file mode 100644 index e8d2b6839..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app102/RequestParams.java +++ /dev/null @@ -1,258 +0,0 @@ -package test.org.springdoc.api.app102; - -import java.math.BigInteger; -import java.util.List; -import java.util.Optional; - -import io.swagger.v3.oas.annotations.Parameter; - -import org.springframework.lang.Nullable; - -/** - * The type Request params. - */ -class RequestParams { - - /** - * The String param. - */ - @Parameter(description = "string parameter") - private String stringParam; - - /** - * The String param 1. - */ - @Deprecated - private String stringParam1; - - /** - * The String param 2. - */ - @Parameter(description = "string parameter2", required = true) - private String stringParam2; - - /** - * The Int param. - */ - @Parameter(description = "int parameter") - private int intParam; - - /** - * The Int param 2. - */ - private Optional intParam2; - - /** - * The Int param 3. - */ - @Nullable - private String intParam3; - - /** - * The Nested. - */ - private Nested nested; - - /** - * The Nested list. - */ - private List nestedList; - - /** - * Gets string param. - * - * @return the string param - */ - public String getStringParam() { - return stringParam; - } - - /** - * Sets string param. - * - * @param stringParam the string param - */ - public void setStringParam(String stringParam) { - this.stringParam = stringParam; - } - - /** - * Gets int param. - * - * @return the int param - */ - public int getIntParam() { - return intParam; - } - - /** - * Sets int param. - * - * @param intParam the int param - */ - public void setIntParam(int intParam) { - this.intParam = intParam; - } - - /** - * Gets int param 2. - * - * @return the int param 2 - */ - public Optional getIntParam2() { - return intParam2; - } - - /** - * Sets int param 2. - * - * @param intParam2 the int param 2 - */ - public void setIntParam2(Optional intParam2) { - this.intParam2 = intParam2; - } - - /** - * Gets int param 3. - * - * @return the int param 3 - */ - @Nullable - public String getIntParam3() { - return intParam3; - } - - /** - * Sets int param 3. - * - * @param intParam3 the int param 3 - */ - public void setIntParam3(@Nullable String intParam3) { - this.intParam3 = intParam3; - } - - /** - * Gets string param 1. - * - * @return the string param 1 - */ - public String getStringParam1() { - return stringParam1; - } - - /** - * Sets string param 1. - * - * @param stringParam1 the string param 1 - */ - public void setStringParam1(String stringParam1) { - this.stringParam1 = stringParam1; - } - - /** - * Gets string param 2. - * - * @return the string param 2 - */ - public String getStringParam2() { - return stringParam2; - } - - /** - * Sets string param 2. - * - * @param stringParam2 the string param 2 - */ - public void setStringParam2(String stringParam2) { - this.stringParam2 = stringParam2; - } - - /** - * Gets nested. - * - * @return the nested - */ - public Nested getNested() { - return nested; - } - - /** - * Sets nested. - * - * @param nested the nested - */ - public void setNested(Nested nested) { - this.nested = nested; - } - - /** - * Gets nested list. - * - * @return the nested list - */ - public List getNestedList() { - return nestedList; - } - - /** - * Sets nested list. - * - * @param nestedList the nested list - */ - public void setNestedList(List nestedList) { - this.nestedList = nestedList; - } - - /** - * The type Nested. - */ - public static class Nested { - /** - * The Param 1. - */ - private String param1; - - /** - * The Param 2. - */ - private BigInteger param2; - - /** - * Gets param 1. - * - * @return the param 1 - */ - @Parameter(description = "nested string parameter") - public String getParam1() { - return param1; - } - - /** - * Sets param 1. - * - * @param param1 the param 1 - */ - public void setParam1(String param1) { - this.param1 = param1; - } - - /** - * Gets param 2. - * - * @return the param 2 - */ - @Parameter(description = "nested BigInteger parameter") - public BigInteger getParam2() { - return param2; - } - - /** - * Sets param 2. - * - * @param param2 the param 2 - */ - public void setParam2(BigInteger param2) { - this.param2 = param2; - } - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app102/SpringDocApp102Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app102/SpringDocApp102Test.java deleted file mode 100644 index fe1770c24..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app102/SpringDocApp102Test.java +++ /dev/null @@ -1,16 +0,0 @@ -package test.org.springdoc.api.app102; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * The type Spring doc app 102 test. - */ -class SpringDocApp102Test extends AbstractSpringDocTest { - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app102/TestController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app102/TestController.java deleted file mode 100644 index 7ddae72c8..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app102/TestController.java +++ /dev/null @@ -1,24 +0,0 @@ -package test.org.springdoc.api.app102; - -import org.springdoc.core.annotations.ParameterObject; - -import org.springframework.lang.Nullable; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -/** - * The type Test controller. - */ -@RestController -class TestController { - /** - * Gets test. - * - * @param param the param - * @param requestParams the request params - */ - @GetMapping("test") - public void getTest(@RequestParam @Nullable String param, @ParameterObject InheritedRequestParams requestParams) { - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app103/ExampleBody.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app103/ExampleBody.java deleted file mode 100644 index e6b831c7c..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app103/ExampleBody.java +++ /dev/null @@ -1,52 +0,0 @@ -package test.org.springdoc.api.app103; - -/** - * The type Example body. - */ -class ExampleBody { - /** - * The String param. - */ - private String stringParam; - - /** - * The Int param. - */ - private int intParam; - - /** - * Gets string param. - * - * @return the string param - */ - public String getStringParam() { - return stringParam; - } - - /** - * Sets string param. - * - * @param stringParam the string param - */ - public void setStringParam(String stringParam) { - this.stringParam = stringParam; - } - - /** - * Gets int param. - * - * @return the int param - */ - public int getIntParam() { - return intParam; - } - - /** - * Sets int param. - * - * @param intParam the int param - */ - public void setIntParam(int intParam) { - this.intParam = intParam; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app103/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app103/HelloController.java deleted file mode 100644 index 9f4af3c26..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app103/HelloController.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app103; - -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.media.Content; -import io.swagger.v3.oas.annotations.media.Encoding; -import io.swagger.v3.oas.annotations.parameters.RequestBody; - -import org.springframework.http.MediaType; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; -import org.springframework.web.bind.annotation.RestController; -import org.springframework.web.multipart.MultipartFile; - -/** - * The type Hello controller. - */ -@RestController -class HelloController { - - /** - * Post my request body string. - * - * @param body the body - * @param file the file - * @return the string - */ - @PostMapping(value = "/test/103", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) - @Operation( - requestBody = @RequestBody( - content = @Content( - encoding = @Encoding(name = "body", contentType = "application/json") - ) - ) - ) - public String postMyRequestBody( - @RequestPart("body") ExampleBody body, - @RequestParam("file") MultipartFile file - ) { - return null; - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app103/SpringDocApp103Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app103/SpringDocApp103Test.java deleted file mode 100644 index cbb84e91d..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app103/SpringDocApp103Test.java +++ /dev/null @@ -1,16 +0,0 @@ -package test.org.springdoc.api.app103; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * The type Spring doc app 103 test. - */ -class SpringDocApp103Test extends AbstractSpringDocTest { - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app104/CrudController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app104/CrudController.java deleted file mode 100644 index e575d7123..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app104/CrudController.java +++ /dev/null @@ -1,47 +0,0 @@ -package test.org.springdoc.api.app104; - -import java.util.List; - -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; - -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.ResponseBody; - -/** - * The type Crud controller. - * - * @param the type parameter - */ -@Controller -@SuppressWarnings("rawtypes") -public abstract class CrudController { - - /** - * Get t. - * - * @param id the id - * @return the t - */ - @GetMapping(path = "{id}") - @ResponseBody - @Operation(description = "Get single object") - public T get( // - @Parameter(description = "The id to get.", required = true) @PathVariable("id") int id) { - return null; - } - - /** - * List list. - * - * @return the list - */ - @GetMapping(path = "") - @ResponseBody - @Operation(description = "Receive a list of objects") - public List list() { - return null; - } -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app104/Design.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app104/Design.java deleted file mode 100644 index 5c9878a01..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app104/Design.java +++ /dev/null @@ -1,7 +0,0 @@ -package test.org.springdoc.api.app104; - -/** - * The type Design. - */ -class Design extends HavingPK { -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app104/DesignController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app104/DesignController.java deleted file mode 100644 index b4e314246..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app104/DesignController.java +++ /dev/null @@ -1,17 +0,0 @@ -package test.org.springdoc.api.app104; - -import io.swagger.v3.oas.annotations.tags.Tag; - -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; - -/** - * The type Design controller. - */ -@Tag(name = "design") -@Controller -@RequestMapping("/design") -class DesignController extends CrudController { - - -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app104/HavingPK.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app104/HavingPK.java deleted file mode 100644 index ac3d20aa1..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app104/HavingPK.java +++ /dev/null @@ -1,7 +0,0 @@ -package test.org.springdoc.api.app104; - -/** - * The type Having pk. - */ -class HavingPK { -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app104/SpringDocApp104Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app104/SpringDocApp104Test.java deleted file mode 100644 index 2b1d35afd..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app104/SpringDocApp104Test.java +++ /dev/null @@ -1,16 +0,0 @@ -package test.org.springdoc.api.app104; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * The type Spring doc app 104 test. - */ -class SpringDocApp104Test extends AbstractSpringDocTest { - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app105/SpringDocApp105Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app105/SpringDocApp105Test.java deleted file mode 100644 index 3f91b44c9..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app105/SpringDocApp105Test.java +++ /dev/null @@ -1,136 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app105; - -import io.swagger.v3.oas.models.Components; -import io.swagger.v3.oas.models.OpenAPI; -import io.swagger.v3.oas.models.info.Info; -import io.swagger.v3.oas.models.info.License; -import io.swagger.v3.oas.models.security.SecurityScheme; -import org.junit.jupiter.api.Test; -import org.springdoc.core.utils.Constants; -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.Bean; -import org.springframework.test.context.TestPropertySource; - -import static org.hamcrest.Matchers.is; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; - -/** - * The type Spring doc app 105 test. - */ -@TestPropertySource(properties = { - "springdoc.group-configs[0].group=stores", - "springdoc.group-configs[0].paths-to-match=/store/**", - "springdoc.group-configs[1].group=users", - "springdoc.group-configs[1].packages-to-scan=test.org.springdoc.api.app105.api.user", - "springdoc.group-configs[2].group=pets", - "springdoc.group-configs[2].paths-to-match=/pet/**", - "springdoc.group-configs[3].group=groups test", - "springdoc.group-configs[3].paths-to-match=/v1/**", - "springdoc.group-configs[3].paths-to-exclude=/v1/users", - "springdoc.group-configs[3].packages-to-scan=test.org.springdoc.api.app105.api.user,test.org.springdoc.api.app105.api.store", -}) -class SpringDocApp105Test extends AbstractSpringDocTest { - - /** - * The constant className. - */ - public static String className; - - /** - * Test app. - * - * @throws Exception the exception - */ - @Test - protected void testApp() throws Exception { - mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL + "/stores")) - .andExpect(status().isOk()) - .andExpect(jsonPath("$.openapi", is("3.0.1"))) - .andExpect(content().json(getContent("results/app105-1.json"), true)); - } - - /** - * Test app 2. - * - * @throws Exception the exception - */ - @Test - void testApp2() throws Exception { - mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL + "/users")) - .andExpect(status().isOk()) - .andExpect(jsonPath("$.openapi", is("3.0.1"))) - .andExpect(content().json(getContent("results/app105-2.json"), true)); - } - - /** - * Test app 3. - * - * @throws Exception the exception - */ - @Test - void testApp3() throws Exception { - mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL + "/pets")) - .andExpect(status().isOk()) - .andExpect(jsonPath("$.openapi", is("3.0.1"))) - .andExpect(content().json(getContent("results/app105-3.json"), true)); - } - - /** - * Test app 4. - * - * @throws Exception the exception - */ - @Test - void testApp4() throws Exception { - mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL + "/groups test")) - .andExpect(status().isOk()) - .andExpect(jsonPath("$.openapi", is("3.0.1"))) - .andExpect(content().json(getContent("results/app105-4.json"), true)); - } - - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp { - /** - * Custom open api open api. - * - * @return the open api - */ - @Bean - public OpenAPI customOpenAPI() { - return new OpenAPI() - .components(new Components().addSecuritySchemes("basicScheme", - new SecurityScheme().type(SecurityScheme.Type.HTTP).scheme("basic"))) - .info(new Info().title("Petstore API").version("v0").description( - "This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.") - .termsOfService("http://swagger.io/terms/") - .license(new License().name("Apache 2.0").url("http://springdoc.org"))); - } - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app105/api/ApiUtil.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app105/api/ApiUtil.java deleted file mode 100644 index cd5cde760..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app105/api/ApiUtil.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app105.api; - -import java.io.IOException; - -import jakarta.servlet.http.HttpServletResponse; - -import org.springframework.http.HttpStatus; -import org.springframework.web.context.request.NativeWebRequest; -import org.springframework.web.server.ResponseStatusException; - -/** - * The type Api util. - */ -public class ApiUtil { - - /** - * Sets example response. - * - * @param req the req - * @param contentType the content type - * @param example the example - */ - public static void setExampleResponse(NativeWebRequest req, String contentType, String example) { - try { - req.getNativeResponse(HttpServletResponse.class).addHeader("Content-Type", contentType); - req.getNativeResponse(HttpServletResponse.class).getOutputStream().print(example); - } - catch (IOException e) { - throw new RuntimeException(e); - } - } - - /** - * Check api key. - * - * @param req the req - */ - public static void checkApiKey(NativeWebRequest req) { - if (!"1".equals(System.getenv("DISABLE_API_KEY")) && !"special-key".equals(req.getHeader("api_key"))) { - throw new ResponseStatusException(HttpStatus.UNAUTHORIZED, "Missing API key!"); - } - } -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app105/api/ExceptionTranslator.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app105/api/ExceptionTranslator.java deleted file mode 100644 index b743c8622..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app105/api/ExceptionTranslator.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app105.api; - -import java.util.Map; - -import jakarta.validation.ConstraintViolationException; - -import org.springframework.boot.web.error.ErrorAttributeOptions; -import org.springframework.boot.web.servlet.error.ErrorAttributes; -import org.springframework.http.HttpStatus; -import org.springframework.web.bind.annotation.ExceptionHandler; -import org.springframework.web.bind.annotation.ResponseStatus; -import org.springframework.web.bind.annotation.RestControllerAdvice; -import org.springframework.web.context.request.RequestAttributes; -import org.springframework.web.context.request.WebRequest; - -/** - * The type Exception translator. - */ -@RestControllerAdvice -class ExceptionTranslator { - - /** - * The Error attributes. - */ - private final ErrorAttributes errorAttributes; - - /** - * Instantiates a new Exception translator. - * - * @param errorAttributes the error attributes - */ - public ExceptionTranslator(ErrorAttributes errorAttributes) { - this.errorAttributes = errorAttributes; - } - - /** - * Process constraint violation exception map. - * - * @param request the request - * @return the map - */ - @ExceptionHandler(ConstraintViolationException.class) - @ResponseStatus(HttpStatus.BAD_REQUEST) - public Map processConstraintViolationException(WebRequest request) { - request.setAttribute("jakarta.servlet.error.status_code", HttpStatus.BAD_REQUEST.value(), RequestAttributes.SCOPE_REQUEST); - return errorAttributes.getErrorAttributes(request, ErrorAttributeOptions.defaults()); - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app105/api/HomeController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app105/api/HomeController.java deleted file mode 100644 index bb86b3787..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app105/api/HomeController.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app105.api; - -import org.springframework.beans.factory.annotation.Value; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.GetMapping; - -import static org.springdoc.core.utils.Constants.SWAGGER_UI_PATH; -import static org.springframework.util.AntPathMatcher.DEFAULT_PATH_SEPARATOR; -import static org.springframework.web.servlet.view.UrlBasedViewResolver.REDIRECT_URL_PREFIX; - -/** - * Home redirection to swagger api documentation - */ -@Controller -class HomeController { - - /** - * The Swagger ui path. - */ - @Value(SWAGGER_UI_PATH) - private String swaggerUiPath; - - /** - * Index string. - * - * @return the string - */ - @GetMapping(DEFAULT_PATH_SEPARATOR) - public String index() { - return REDIRECT_URL_PREFIX + swaggerUiPath; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app105/api/pet/PetApi.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app105/api/pet/PetApi.java deleted file mode 100644 index 098ebb480..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app105/api/pet/PetApi.java +++ /dev/null @@ -1,219 +0,0 @@ -/* - * - * * Copyright 2019-2020 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. - * - */ - -/** - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (3.0.0). - * https://openapi-generator.tech - * Do not edit the class manually. - */ -package test.org.springdoc.api.app105.api.pet; - -import java.util.List; - -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.enums.SecuritySchemeType; -import io.swagger.v3.oas.annotations.media.ArraySchema; -import io.swagger.v3.oas.annotations.media.Content; -import io.swagger.v3.oas.annotations.media.Schema; -import io.swagger.v3.oas.annotations.responses.ApiResponse; -import io.swagger.v3.oas.annotations.responses.ApiResponses; -import io.swagger.v3.oas.annotations.security.OAuthFlow; -import io.swagger.v3.oas.annotations.security.OAuthFlows; -import io.swagger.v3.oas.annotations.security.OAuthScope; -import io.swagger.v3.oas.annotations.security.SecurityRequirement; -import io.swagger.v3.oas.annotations.security.SecurityScheme; -import io.swagger.v3.oas.annotations.tags.Tag; -import jakarta.validation.Valid; -import jakarta.validation.constraints.NotNull; -import test.org.springdoc.api.app105.model.ModelApiResponse; -import test.org.springdoc.api.app105.model.Pet; - -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.DeleteMapping; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; -import org.springframework.web.multipart.MultipartFile; - -/** - * The interface Pet api. - */ -@SecurityScheme(name = "petstore_auth", type = SecuritySchemeType.OAUTH2, flows = @OAuthFlows(implicit = @OAuthFlow(authorizationUrl = "http://petstore.swagger.io/oauth/dialog", scopes = { - @OAuthScope(name = "write:pets", description = "modify pets in your account"), - @OAuthScope(name = "read:pets", description = "read your pets") }))) -@Tag(name = "pet", description = "the pet API") -public interface PetApi { - - /** - * Gets delegate. - * - * @return the delegate - */ - default PetApiDelegate getDelegate() { - return new PetApiDelegate() { - }; - } - - /** - * Add pet. - * - * @param pet the pet - */ - @Operation(summary = "Add a new pet to the store", description = "", security = { - @SecurityRequirement(name = "petstore_auth", scopes = { "write:pets", "read:pets" }) }, tags = { "pet" }) - @ApiResponses(value = { @ApiResponse(responseCode = "405", description = "Invalid input") }) - @PostMapping(value = "/pet", consumes = { "application/json", "application/xml" }) - default void addPet( - @io.swagger.v3.oas.annotations.parameters.RequestBody(description = "Pet object that needs to be added to the store", required = true) @Valid @RequestBody Pet pet) { - // return getDelegate().addPet(pet); - } - - /** - * Delete pet response entity. - * - * @param petId the pet id - * @param apiKey the api key - * @return the response entity - */ - @Operation(summary = "Deletes a pet", description = "", security = { - @SecurityRequirement(name = "petstore_auth", scopes = { "write:pets", "read:pets" }) }, tags = { "pet" }) - @ApiResponses(value = { @ApiResponse(responseCode = "400", description = "Invalid ID supplied"), - @ApiResponse(responseCode = "404", description = "Pet not found") }) - @DeleteMapping(value = "/pet/{petId}") - default ResponseEntity deletePet( - @Parameter(description = "Pet id to delete", required = true) @PathVariable("petId") Long petId, - @Parameter(description = "") @RequestHeader(value = "api_key", required = false) String apiKey) { - return getDelegate().deletePet(petId, apiKey); - } - - /** - * Find pets by status response entity. - * - * @param status the status - * @return the response entity - */ - @Operation(summary = "Finds Pets by status", description = "Multiple status values can be provided with comma separated strings", security = { - @SecurityRequirement(name = "petstore_auth", scopes = { "write:pets", "read:pets" }) }, tags = { "pet" }) - @ApiResponses(value = { - @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(array = @ArraySchema(schema = @Schema(implementation = Pet.class)))), - @ApiResponse(responseCode = "400", description = "Invalid status value") }) - @GetMapping(value = "/pet/findByStatus", produces = { "application/xml", "application/json" }) - default ResponseEntity> findPetsByStatus( - @NotNull @Parameter(description = "Status values that need to be considered for filter", required = true) @Valid @RequestParam(value = "status", required = true) List status) { - return getDelegate().findPetsByStatus(status); - } - - /** - * Find pets by tags response entity. - * - * @param tags the tags - * @return the response entity - */ - @Operation(summary = "Finds Pets by tags", description = "Muliple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.", security = { - @SecurityRequirement(name = "petstore_auth", scopes = { "write:pets", "read:pets" }) }, tags = { "pet" }) - @ApiResponses(value = { - @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(array = @ArraySchema(schema = @Schema(implementation = Pet.class)))), - @ApiResponse(responseCode = "400", description = "Invalid tag value") }) - @GetMapping(value = "/pet/findByTags", produces = { "application/xml", "application/json" }) - default ResponseEntity> findPetsByTags( - @NotNull @Parameter(description = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) List tags) { - return getDelegate().findPetsByTags(tags); - } - - /** - * Gets pet by id. - * - * @param petId the pet id - * @return the pet by id - */ - @Operation(summary = "Find pet by ID", description = "Returns a single pet", security = { - @SecurityRequirement(name = "api_key") }, tags = { "pet" }) - @ApiResponses(value = { - @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(schema = @Schema(implementation = Pet.class))), - @ApiResponse(responseCode = "400", description = "Invalid ID supplied"), - @ApiResponse(responseCode = "404", description = "Pet not found") }) - @GetMapping(value = "/pet/{petId}", produces = { "application/xml", "application/json" }) - default ResponseEntity getPetById( - @Parameter(description = "ID of pet to return", required = true) @PathVariable("petId") Long petId) { - return getDelegate().getPetById(petId); - } - - /** - * Update pet response entity. - * - * @param pet the pet - * @return the response entity - */ - @Operation(summary = "Update an existing pet", description = "", security = { - @SecurityRequirement(name = "petstore_auth", scopes = { "write:pets", "read:pets" }) }, tags = { "pet" }) - @ApiResponses(value = { @ApiResponse(responseCode = "400", description = "Invalid ID supplied"), - @ApiResponse(responseCode = "404", description = "Pet not found"), - @ApiResponse(responseCode = "405", description = "Validation exception") }) - @PutMapping(value = "/pet", consumes = { "application/json", "application/xml" }) - default ResponseEntity updatePet( - @io.swagger.v3.oas.annotations.parameters.RequestBody(description = "Pet object that needs to be added to the store", required = true) @Valid @RequestBody Pet pet) { - return getDelegate().updatePet(pet); - } - - /** - * Update pet with form response entity. - * - * @param petId the pet id - * @param name the name - * @param status the status - * @return the response entity - */ - @Operation(summary = "Updates a pet in the store with form data", description = "", security = { - @SecurityRequirement(name = "petstore_auth", scopes = { "write:pets", "read:pets" }) }, tags = { "pet" }) - @ApiResponses(value = { @ApiResponse(responseCode = "405", description = "Invalid input") }) - @PostMapping(value = "/pet/{petId}", consumes = { "application/x-www-form-urlencoded" }) - default ResponseEntity updatePetWithForm( - @Parameter(description = "ID of pet that needs to be updated", required = true) @PathVariable("petId") Long petId, - @Parameter(description = "Updated name of the pet") @RequestParam(value = "name", required = false) String name, - @Parameter(description = "Updated status of the pet") @RequestParam(value = "status", required = false) String status) { - return getDelegate().updatePetWithForm(petId, name, status); - } - - /** - * Upload file response entity. - * - * @param petId the pet id - * @param additionalMetadata the additional metadata - * @param file the file - * @return the response entity - */ - @Operation(summary = "uploads an image", description = "", security = { - @SecurityRequirement(name = "petstore_auth", scopes = { "write:pets", "read:pets" }) }, tags = { "pet" }) - @ApiResponses(value = { - @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(schema = @Schema(implementation = ModelApiResponse.class))) }) - @PostMapping(value = "/pet/{petId}/uploadImage", produces = { "application/json" }, consumes = { - "multipart/form-data" }) - default ResponseEntity uploadFile( - @Parameter(description = "ID of pet to update", required = true) @PathVariable("petId") Long petId, - @Parameter(description = "Additional data to pass to server") @RequestParam(value = "additionalMetadata", required = false) String additionalMetadata, - @Parameter(description = "file detail") @Valid @RequestPart("file") MultipartFile file) { - return getDelegate().uploadFile(petId, additionalMetadata, file); - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app105/api/pet/PetApiController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app105/api/pet/PetApiController.java deleted file mode 100644 index 65efc6309..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app105/api/pet/PetApiController.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app105.api.pet; - -import java.util.Optional; - -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * The type Pet api controller. - */ -@jakarta.annotation.Generated(value = "org.springdoc.demo.app2.codegen.languages.SpringCodegen", date = "2019-07-11T00:09:29.839+02:00[Europe/Paris]") - -@RestController -@RequestMapping("${openapi.openAPIPetstore.base-path:/}") -class PetApiController implements PetApi { - - /** - * The Delegate. - */ - private final PetApiDelegate delegate; - - /** - * Instantiates a new Pet api controller. - * - * @param delegate the delegate - */ - public PetApiController(@org.springframework.beans.factory.annotation.Autowired(required = false) PetApiDelegate delegate) { - this.delegate = Optional.ofNullable(delegate).orElse(new PetApiDelegate() { - }); - } - - /** - * Gets delegate. - * - * @return the delegate - */ - @Override - public PetApiDelegate getDelegate() { - return delegate; - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app105/api/pet/PetApiDelegate.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app105/api/pet/PetApiDelegate.java deleted file mode 100644 index 3aefe9b6e..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app105/api/pet/PetApiDelegate.java +++ /dev/null @@ -1,185 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app105.api.pet; - -import java.util.List; -import java.util.Optional; - -import jakarta.validation.Valid; -import test.org.springdoc.api.app105.api.ApiUtil; -import test.org.springdoc.api.app105.model.ModelApiResponse; -import test.org.springdoc.api.app105.model.Pet; - -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; -import org.springframework.web.context.request.NativeWebRequest; -import org.springframework.web.multipart.MultipartFile; - -/** - * A delegate to be called by the {@link PetApiController}}. - * Implement this interface with a {@link org.springframework.stereotype.Service} annotated class. - */ -@jakarta.annotation.Generated(value = "org.springdoc.demo.app2.codegen.languages.SpringCodegen", date = "2019-07-11T00:09:29.839+02:00[Europe/Paris]") - -public interface PetApiDelegate { - - /** - * Gets request. - * - * @return the request - */ - default Optional getRequest() { - return Optional.empty(); - } - - /** - * Add pet. - * - * @param pet the pet - * @see PetApi#addPet PetApi#addPet - */ - default void addPet(Pet pet) { - - } - - /** - * Delete pet response entity. - * - * @param petId the pet id - * @param apiKey the api key - * @return the response entity - * @see PetApi#deletePet PetApi#deletePet - */ - default ResponseEntity deletePet(Long petId, - String apiKey) { - return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); - - } - - /** - * Find pets by status response entity. - * - * @param status the status - * @return the response entity - * @see PetApi#findPetsByStatus PetApi#findPetsByStatus - */ - default ResponseEntity> findPetsByStatus(List status) { - extract(); - return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); - - } - - /** - * Extract. - */ - default void extract() { - getRequest().ifPresent(request -> { - for (MediaType mediaType : MediaType.parseMediaTypes(request.getHeader("Accept"))) { - if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { - ApiUtil.setExampleResponse(request, "application/json", "{ \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\"}"); - break; - } - if (mediaType.isCompatibleWith(MediaType.valueOf("application/xml"))) { - ApiUtil.setExampleResponse(request, "application/xml", " 123456789 doggie aeiou aeiou"); - break; - } - } - }); - } - - /** - * Find pets by tags response entity. - * - * @param tags the tags - * @return the response entity - * @see PetApi#findPetsByTags PetApi#findPetsByTags - */ - default ResponseEntity> findPetsByTags(List tags) { - extract(); - return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); - - } - - /** - * Gets pet by id. - * - * @param petId the pet id - * @return the pet by id - * @see PetApi#getPetById PetApi#getPetById - */ - default ResponseEntity getPetById(Long petId) { - extract(); - return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); - - } - - /** - * Update pet response entity. - * - * @param pet the pet - * @return the response entity - * @see PetApi#updatePet PetApi#updatePet - */ - default ResponseEntity updatePet(Pet pet) { - return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); - - } - - /** - * Update pet with form response entity. - * - * @param petId the pet id - * @param name the name - * @param status the status - * @return the response entity - * @see PetApi#updatePetWithForm PetApi#updatePetWithForm - */ - default ResponseEntity updatePetWithForm(Long petId, - String name, - String status) { - return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); - - } - - /** - * Upload file response entity. - * - * @param petId the pet id - * @param additionalMetadata the additional metadata - * @param file the file - * @return the response entity - * @see PetApi#uploadFile PetApi#uploadFile - */ - default ResponseEntity uploadFile(Long petId, - String additionalMetadata, - @Valid MultipartFile file) { - getRequest().ifPresent(request -> { - for (MediaType mediaType : MediaType.parseMediaTypes(request.getHeader("Accept"))) { - if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { - ApiUtil.setExampleResponse(request, "application/json", "{ \"code\" : 0, \"type\" : \"type\", \"message\" : \"message\"}"); - break; - } - } - }); - return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); - - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app105/api/pet/PetApiDelegateImpl.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app105/api/pet/PetApiDelegateImpl.java deleted file mode 100644 index feb72bed7..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app105/api/pet/PetApiDelegateImpl.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app105.api.pet; - -import org.springframework.stereotype.Service; - -/** - * The type Pet api delegate. - */ -@Service -class PetApiDelegateImpl implements PetApiDelegate { - - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app105/api/store/StoreApi.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app105/api/store/StoreApi.java deleted file mode 100644 index 8f4ff87e9..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app105/api/store/StoreApi.java +++ /dev/null @@ -1,140 +0,0 @@ -/* - * - * * Copyright 2019-2020 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. - * - */ - -/** - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (3.0.0). - * https://openapi-generator.tech - * Do not edit the class manually. - */ -package test.org.springdoc.api.app105.api.store; - -import java.util.Map; - -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.media.ArraySchema; -import io.swagger.v3.oas.annotations.media.Content; -import io.swagger.v3.oas.annotations.media.Schema; -import io.swagger.v3.oas.annotations.responses.ApiResponse; -import io.swagger.v3.oas.annotations.responses.ApiResponses; -import io.swagger.v3.oas.annotations.security.SecurityRequirement; -import io.swagger.v3.oas.annotations.tags.Tag; -import jakarta.validation.Valid; -import jakarta.validation.constraints.Max; -import jakarta.validation.constraints.Min; -import jakarta.validation.constraints.NotBlank; -import test.org.springdoc.api.app105.model.Order; - -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.DeleteMapping; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; - -/** - * The interface Store api. - */ -@jakarta.annotation.Generated(value = "org.springdoc.demo.app2.codegen.languages.SpringCodegen", date = "2019-07-11T00:09:29.839+02:00[Europe/Paris]") - -@Tag(name = "store", description = "the store API") -public interface StoreApi { - - /** - * Gets delegate. - * - * @return the delegate - */ - default StoreApiDelegate getDelegate() { - return new StoreApiDelegate() { - }; - } - - /** - * Delete order response entity. - * - * @param orderId the order id - * @return the response entity - */ - @Operation(summary = "Delete purchase order by ID", tags = { "store" }) - @ApiResponses(value = { @ApiResponse(responseCode = "400", description = "Invalid ID supplied"), - @ApiResponse(responseCode = "404", description = "Order not found") }) - @DeleteMapping(value = "/store/order/{orderId}") - default ResponseEntity deleteOrder( - @Parameter(description = "ID of the order that needs to be deleted", required = true) @PathVariable("orderId") String orderId) { - return getDelegate().deleteOrder(orderId); - } - - /** - * Gets inventory. - * - * @return the inventory - */ - @Operation(summary = "Returns pet inventories by status", description = "Returns a map of status codes to quantities", security = { - @SecurityRequirement(name = "api_key") }, tags = { "store" }) - @ApiResponses(value = { - @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(array = @ArraySchema(schema = @Schema(implementation = Map.class)))) }) - @GetMapping(value = "/store/inventory", produces = { "application/json" }) - default ResponseEntity> getInventory() { - return getDelegate().getInventory(); - } - - /** - * Gets order by id. - * - * @param orderId the order id - * @return the order by id - */ - @Operation(summary = "Find purchase order by ID", tags = { "store" }) - @ApiResponses(value = { - @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(schema = @Schema(implementation = Order.class))), - @ApiResponse(responseCode = "400", description = "Invalid ID supplied"), - @ApiResponse(responseCode = "404", description = "Order not found") }) - @GetMapping(value = "/store/order/{orderId}", produces = { "application/xml", "application/json" }) - default ResponseEntity getOrderById( - @Min(1L) @Max(5L) @Parameter(description = "ID of pet that needs to be fetched", required = true) @PathVariable("orderId") Long orderId) { - return getDelegate().getOrderById(orderId); - } - - /** - * Place order response entity. - * - * @param order the order - * @return the response entity - */ - @Operation(summary = "Place an order for a pet", tags = { "store" }) - @ApiResponses(value = { - @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(schema = @Schema(implementation = Order.class))), - @ApiResponse(responseCode = "400", description = "Invalid Order") }) - @PostMapping(value = "/store/order", produces = { "application/xml", "application/json" }, consumes = { - "application/json" }) - default ResponseEntity placeOrder( - @Parameter(description = "order placed for purchasing the pet", required = true) @Valid @RequestBody Order order) { - return getDelegate().placeOrder(order); - } - - /** - * Stores. - * - * @param name the name - */ - @GetMapping(value = "/v1/stores") - default void stores(@Valid @NotBlank String name) { - - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app105/api/store/StoreApiController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app105/api/store/StoreApiController.java deleted file mode 100644 index 7ce9e3984..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app105/api/store/StoreApiController.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app105.api.store; - -import java.util.Optional; - -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * The type Store api controller. - */ -@jakarta.annotation.Generated(value = "org.springdoc.demo.app2.codegen.languages.SpringCodegen", date = "2019-07-11T00:09:29.839+02:00[Europe/Paris]") - -@RestController -@RequestMapping("${openapi.openAPIPetstore.base-path:/}") -class StoreApiController implements StoreApi { - - /** - * The Delegate. - */ - private final StoreApiDelegate delegate; - - /** - * Instantiates a new Store api controller. - * - * @param delegate the delegate - */ - public StoreApiController(@org.springframework.beans.factory.annotation.Autowired(required = false) StoreApiDelegate delegate) { - this.delegate = Optional.ofNullable(delegate).orElse(new StoreApiDelegate() { - }); - } - - /** - * Gets delegate. - * - * @return the delegate - */ - @Override - public StoreApiDelegate getDelegate() { - return delegate; - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app105/api/store/StoreApiDelegate.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app105/api/store/StoreApiDelegate.java deleted file mode 100644 index 73909fcf3..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app105/api/store/StoreApiDelegate.java +++ /dev/null @@ -1,116 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app105.api.store; - -import java.util.Map; -import java.util.Optional; - -import test.org.springdoc.api.app105.api.ApiUtil; -import test.org.springdoc.api.app105.model.Order; - -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; -import org.springframework.web.context.request.NativeWebRequest; - -/** - * A delegate to be called by the {@link StoreApiController}}. - * Implement this interface with a {@link org.springframework.stereotype.Service} annotated class. - */ -@jakarta.annotation.Generated(value = "org.springdoc.demo.app2.codegen.languages.SpringCodegen", date = "2019-07-11T00:09:29.839+02:00[Europe/Paris]") - -public interface StoreApiDelegate { - - /** - * Gets request. - * - * @return the request - */ - default Optional getRequest() { - return Optional.empty(); - } - - /** - * Delete order response entity. - * - * @param orderId the order id - * @return the response entity - * @see StoreApi#deleteOrder StoreApi#deleteOrder - */ - default ResponseEntity deleteOrder(String orderId) { - return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); - - } - - /** - * Gets inventory. - * - * @return the inventory - * @see StoreApi#getInventory StoreApi#getInventory - */ - default ResponseEntity> getInventory() { - return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); - - } - - /** - * Gets order by id. - * - * @param orderId the order id - * @return the order by id - * @see StoreApi#getOrderById StoreApi#getOrderById - */ - default ResponseEntity getOrderById(Long orderId) { - extract(); - return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); - - } - - /** - * Extract. - */ - default void extract() { - getRequest().ifPresent(request -> { - for (MediaType mediaType : MediaType.parseMediaTypes(request.getHeader("Accept"))) { - if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { - ApiUtil.setExampleResponse(request, "application/json", "{ \"petId\" : 6, \"quantity\" : 1, \"id\" : 0, \"shipDate\" : \"2000-01-23T04:56:07.000+00:00\", \"complete\" : false, \"status\" : \"placed\"}"); - break; - } - if (mediaType.isCompatibleWith(MediaType.valueOf("application/xml"))) { - ApiUtil.setExampleResponse(request, "application/xml", " 123456789 123456789 123 2000-01-23T04:56:07.000Z aeiou true"); - break; - } - } - }); - } - - /** - * Place order response entity. - * - * @param order the order - * @return the response entity - * @see StoreApi#placeOrder StoreApi#placeOrder - */ - default ResponseEntity placeOrder(Order order) { - extract(); - return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); - - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app105/api/store/StoreApiDelegateImpl.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app105/api/store/StoreApiDelegateImpl.java deleted file mode 100644 index cd3051772..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app105/api/store/StoreApiDelegateImpl.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app105.api.store; - -import org.springframework.stereotype.Service; - -/** - * The type Store api delegate. - */ -@Service -class StoreApiDelegateImpl implements StoreApiDelegate { - - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app105/api/user/UserApi.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app105/api/user/UserApi.java deleted file mode 100644 index 70f642c76..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app105/api/user/UserApi.java +++ /dev/null @@ -1,189 +0,0 @@ -/* - * - * * Copyright 2019-2020 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. - * - */ - -/** - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (3.0.0). - * https://openapi-generator.tech - * Do not edit the class manually. - */ -package test.org.springdoc.api.app105.api.user; - -import java.util.List; - -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.media.Content; -import io.swagger.v3.oas.annotations.media.Schema; -import io.swagger.v3.oas.annotations.responses.ApiResponse; -import io.swagger.v3.oas.annotations.responses.ApiResponses; -import io.swagger.v3.oas.annotations.tags.Tag; -import jakarta.validation.Valid; -import jakarta.validation.constraints.NotNull; -import test.org.springdoc.api.app105.model.User; - -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.DeleteMapping; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestParam; - -/** - * The interface User api. - */ -@jakarta.annotation.Generated(value = "org.springdoc.demo.app2.codegen.languages.SpringCodegen", date = "2019-07-11T00:09:29.839+02:00[Europe/Paris]") - -@Tag(name = "user", description = "the user API") -public interface UserApi { - - /** - * Gets delegate. - * - * @return the delegate - */ - default UserApiDelegate getDelegate() { - return new UserApiDelegate() { - }; - } - - /** - * Create user response entity. - * - * @param user the user - * @return the response entity - */ - @Operation(summary = "Create user", tags = { "user" }) - @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "successful operation") }) - @PostMapping(value = "/user", consumes = { "application/json" }) - default ResponseEntity createUser( - @io.swagger.v3.oas.annotations.parameters.RequestBody(description = "Created user object", required = true) @Valid @RequestBody User user) { - return getDelegate().createUser(user); - } - - /** - * Create users with array input response entity. - * - * @param user the user - * @return the response entity - */ - @Operation(summary = "Creates list of users with given input array", tags = { "user" }) - @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "successful operation") }) - - @PostMapping(value = "/user/createWithArray", consumes = { "application/json" }) - default ResponseEntity createUsersWithArrayInput( - @io.swagger.v3.oas.annotations.parameters.RequestBody(description = "List of user object", required = true) @Valid @RequestBody List user) { - return getDelegate().createUsersWithArrayInput(user); - } - - /** - * Create users with list input response entity. - * - * @param user the user - * @return the response entity - */ - @Operation(summary = "Creates list of users with given input array", tags = { "user" }) - @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "successful operation") }) - @PostMapping(value = "/user/createWithList", consumes = { "application/json" }) - default ResponseEntity createUsersWithListInput( - @io.swagger.v3.oas.annotations.parameters.RequestBody(description = "List of user object", required = true) @Valid @RequestBody List user) { - return getDelegate().createUsersWithListInput(user); - } - - /** - * Delete user response entity. - * - * @param username the username - * @return the response entity - */ - @Operation(summary = "Creates list of users with given input array", tags = { "user" }) - @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "successful operation") }) - - @DeleteMapping(value = "/user/{username}") - default ResponseEntity deleteUser( - @io.swagger.v3.oas.annotations.parameters.RequestBody(description = "The name that needs to be deleted", required = true) @PathVariable("username") String username) { - return getDelegate().deleteUser(username); - } - - /** - * Gets user by name. - * - * @param username the username - * @return the user by name - */ - @Operation(summary = "Get user by user name", tags = { "user" }) - @ApiResponses(value = { - @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(schema = @Schema(implementation = User.class))), - @ApiResponse(responseCode = "400", description = "Invalid username supplied"), - @ApiResponse(responseCode = "404", description = "User not found") }) - - @GetMapping(value = "/user/{username}", produces = { "application/xml", "application/json" }) - default ResponseEntity getUserByName( - @Parameter(description = "The name that needs to be fetched. Use user1 for testing.", required = true) @PathVariable("username") String username) { - return getDelegate().getUserByName(username); - } - - /** - * Login user response entity. - * - * @param username the username - * @param password the password - * @return the response entity - */ - @Operation(summary = "Logs user into the system", tags = { "user" }) - @ApiResponses(value = { - @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(schema = @Schema(implementation = String.class))), - @ApiResponse(responseCode = "400", description = "Invalid username/password supplied") }) - @GetMapping(value = "/user/login", produces = { "application/xml", "application/json" }) - default ResponseEntity loginUser( - @NotNull @Parameter(description = "The user name for login", required = true) @Valid @RequestParam(value = "username", required = true) String username, - @NotNull @Parameter(description = "The password for login in clear text", required = true) @Valid @RequestParam(value = "password", required = true) String password) { - return getDelegate().loginUser(username, password); - } - - /** - * Logout user response entity. - * - * @return the response entity - */ - @Operation(summary = "Logs out current logged in user session", tags = { "user" }) - @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "successful operation") }) - @GetMapping(value = "/user/logout") - default ResponseEntity logoutUser() { - return getDelegate().logoutUser(); - } - - /** - * Update user response entity. - * - * @param username the username - * @param user the user - * @return the response entity - */ - @Operation(summary = "Updated user", tags = { "user" }) - @ApiResponses(value = { @ApiResponse(responseCode = "400", description = "Invalid user supplied"), - @ApiResponse(responseCode = "404", description = "User not found") }) - @PutMapping(value = "/user/{username}", consumes = { "application/json" }) - default ResponseEntity updateUser( - @Parameter(description = "name that need to be deleted", required = true) @PathVariable("username") String username, - @io.swagger.v3.oas.annotations.parameters.RequestBody(description = "Updated user object", required = true) @Valid @RequestBody User user) { - return getDelegate().updateUser(username, user); - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app105/api/user/UserApiController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app105/api/user/UserApiController.java deleted file mode 100644 index 98692328f..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app105/api/user/UserApiController.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app105.api.user; - -import java.util.Optional; - -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * The type User api controller. - */ -@jakarta.annotation.Generated(value = "org.springdoc.demo.app2.codegen.languages.SpringCodegen", date = "2019-07-11T00:09:29.839+02:00[Europe/Paris]") - -@RestController -@RequestMapping("${openapi.openAPIPetstore.base-path:/}") -class UserApiController implements UserApi { - - /** - * The Delegate. - */ - private final UserApiDelegate delegate; - - /** - * Instantiates a new User api controller. - * - * @param delegate the delegate - */ - public UserApiController(@org.springframework.beans.factory.annotation.Autowired(required = false) UserApiDelegate delegate) { - this.delegate = Optional.ofNullable(delegate).orElse(new UserApiDelegate() { - }); - } - - /** - * Gets delegate. - * - * @return the delegate - */ - @Override - public UserApiDelegate getDelegate() { - return delegate; - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app105/api/user/UserApiDelegate.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app105/api/user/UserApiDelegate.java deleted file mode 100644 index 2c5078888..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app105/api/user/UserApiDelegate.java +++ /dev/null @@ -1,160 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app105.api.user; - -import java.util.List; -import java.util.Optional; - -import test.org.springdoc.api.app105.api.ApiUtil; -import test.org.springdoc.api.app105.model.User; - -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; -import org.springframework.web.context.request.NativeWebRequest; - -/** - * A delegate to be called by the {@link UserApiController}}. - * Implement this interface with a {@link org.springframework.stereotype.Service} annotated class. - */ -@jakarta.annotation.Generated(value = "org.springdoc.demo.app2.codegen.languages.SpringCodegen", date = "2019-07-11T00:09:29.839+02:00[Europe/Paris]") - -public interface UserApiDelegate { - - /** - * Gets request. - * - * @return the request - */ - default Optional getRequest() { - return Optional.empty(); - } - - /** - * Create user response entity. - * - * @param user the user - * @return the response entity - * @see UserApi#createUser UserApi#createUser - */ - default ResponseEntity createUser(User user) { - return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); - - } - - /** - * Create users with array input response entity. - * - * @param user the user - * @return the response entity - * @see UserApi#createUsersWithArrayInput UserApi#createUsersWithArrayInput - */ - default ResponseEntity createUsersWithArrayInput(List user) { - return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); - - } - - /** - * Create users with list input response entity. - * - * @param user the user - * @return the response entity - * @see UserApi#createUsersWithListInput UserApi#createUsersWithListInput - */ - default ResponseEntity createUsersWithListInput(List user) { - return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); - - } - - /** - * Delete user response entity. - * - * @param username the username - * @return the response entity - * @see UserApi#deleteUser UserApi#deleteUser - */ - default ResponseEntity deleteUser(String username) { - return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); - - } - - /** - * Gets user by name. - * - * @param username the username - * @return the user by name - * @see UserApi#getUserByName UserApi#getUserByName - */ - default ResponseEntity getUserByName(String username) { - getRequest().ifPresent(request -> { - for (MediaType mediaType : MediaType.parseMediaTypes(request.getHeader("Accept"))) { - if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { - ApiUtil.setExampleResponse(request, "application/json", "{ \"firstName\" : \"firstName\", \"lastName\" : \"lastName\", \"password\" : \"password\", \"userStatus\" : 6, \"phone\" : \"phone\", \"id\" : 0, \"email\" : \"email\", \"username\" : \"username\"}"); - break; - } - if (mediaType.isCompatibleWith(MediaType.valueOf("application/xml"))) { - ApiUtil.setExampleResponse(request, "application/xml", " 123456789 aeiou aeiou aeiou aeiou aeiou aeiou 123"); - break; - } - } - }); - return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); - - } - - /** - * Login user response entity. - * - * @param username the username - * @param password the password - * @return the response entity - * @see UserApi#loginUser UserApi#loginUser - */ - default ResponseEntity loginUser(String username, - String password) { - return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); - - } - - /** - * Logout user response entity. - * - * @return the response entity - * @see UserApi#logoutUser UserApi#logoutUser - */ - default ResponseEntity logoutUser() { - return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); - - } - - /** - * Update user response entity. - * - * @param username the username - * @param user the user - * @return the response entity - * @see UserApi#updateUser UserApi#updateUser - */ - default ResponseEntity updateUser(String username, - User user) { - return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); - - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app105/api/user/UserApiDelegateImpl.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app105/api/user/UserApiDelegateImpl.java deleted file mode 100644 index 91f65c580..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app105/api/user/UserApiDelegateImpl.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app105.api.user; - -import org.springframework.stereotype.Service; - -/** - * The type User api delegate. - */ -@Service -class UserApiDelegateImpl implements UserApiDelegate { - - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app105/model/Category.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app105/model/Category.java deleted file mode 100644 index 70f61cf74..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app105/model/Category.java +++ /dev/null @@ -1,129 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app105.model; - -import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.v3.oas.annotations.media.Schema; - -/** - * The type Category. - */ -class Category { - - /** - * The Id. - */ - @Schema(description = "") - private Long id = null; - - /** - * The Name. - */ - @Schema(description = "") - private String name = null; - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - * @param o the o - * @return the string - */ - private static String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } - - /** - * Get id - * - * @return id id - */ - @JsonProperty("id") - public Long getId() { - return id; - } - - /** - * Sets id. - * - * @param id the id - */ - public void setId(Long id) { - this.id = id; - } - - /** - * Id category. - * - * @param id the id - * @return the category - */ - public Category id(Long id) { - this.id = id; - return this; - } - - /** - * Get name - * - * @return name name - */ - @JsonProperty("name") - public String getName() { - return name; - } - - /** - * Sets name. - * - * @param name the name - */ - public void setName(String name) { - this.name = name; - } - - /** - * Name category. - * - * @param name the name - * @return the category - */ - public Category name(String name) { - this.name = name; - return this; - } - - /** - * To string string. - * - * @return the string - */ - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class Category {\n"); - - sb.append(" id: ").append(toIndentedString(id)).append("\n"); - sb.append(" name: ").append(toIndentedString(name)).append("\n"); - sb.append("}"); - return sb.toString(); - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app105/model/ModelApiResponse.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app105/model/ModelApiResponse.java deleted file mode 100644 index f3cedc0d2..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app105/model/ModelApiResponse.java +++ /dev/null @@ -1,166 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app105.model; - -import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.v3.oas.annotations.media.Schema; - -/** - * The type Model api response. - */ -public class ModelApiResponse { - - /** - * The Code. - */ - @Schema(description = "") - private Integer code = null; - - /** - * The Type. - */ - @Schema(description = "") - private String type = null; - - /** - * The Message. - */ - @Schema(description = "") - private String message = null; - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - * @param o the o - * @return the string - */ - private static String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } - - /** - * Get code - * - * @return code code - */ - @JsonProperty("code") - public Integer getCode() { - return code; - } - - /** - * Sets code. - * - * @param code the code - */ - public void setCode(Integer code) { - this.code = code; - } - - /** - * Code model api response. - * - * @param code the code - * @return the model api response - */ - public ModelApiResponse code(Integer code) { - this.code = code; - return this; - } - - /** - * Get type - * - * @return type type - */ - @JsonProperty("type") - public String getType() { - return type; - } - - /** - * Sets type. - * - * @param type the type - */ - public void setType(String type) { - this.type = type; - } - - /** - * Type model api response. - * - * @param type the type - * @return the model api response - */ - public ModelApiResponse type(String type) { - this.type = type; - return this; - } - - /** - * Get message - * - * @return message message - */ - @JsonProperty("message") - public String getMessage() { - return message; - } - - /** - * Sets message. - * - * @param message the message - */ - public void setMessage(String message) { - this.message = message; - } - - /** - * Message model api response. - * - * @param message the message - * @return the model api response - */ - public ModelApiResponse message(String message) { - this.message = message; - return this; - } - - /** - * To string string. - * - * @return the string - */ - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class ModelApiResponse {\n"); - - sb.append(" code: ").append(toIndentedString(code)).append("\n"); - sb.append(" type: ").append(toIndentedString(type)).append("\n"); - sb.append(" message: ").append(toIndentedString(message)).append("\n"); - sb.append("}"); - return sb.toString(); - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app105/model/Order.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app105/model/Order.java deleted file mode 100644 index 225f2e5c6..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app105/model/Order.java +++ /dev/null @@ -1,356 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app105.model; - -import java.util.Date; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonValue; -import io.swagger.v3.oas.annotations.media.Schema; - -/** - * The type Order. - */ -public class Order { - - /** - * The Id. - */ - @Schema(description = "") - private Long id = null; - - /** - * The Pet id. - */ - @Schema(description = "") - private Long petId = null; - - /** - * The Quantity. - */ - @Schema(description = "") - private Integer quantity = null; - - /** - * The Ship date. - */ - @Schema(description = "") - private Date shipDate = null; - - /** - * The Status. - */ - @Schema(description = "Order Status") - /** - * Order Status - **/ - private StatusEnum status = null; - - /** - * The Complete. - */ - @Schema(description = "") - private Boolean complete = false; - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - * @param o the o - * @return the string - */ - private static String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } - - /** - * Get id - * - * @return id id - */ - @JsonProperty("id") - public Long getId() { - return id; - } - - /** - * Sets id. - * - * @param id the id - */ - public void setId(Long id) { - this.id = id; - } - - /** - * Id order. - * - * @param id the id - * @return the order - */ - public Order id(Long id) { - this.id = id; - return this; - } - - /** - * Get petId - * - * @return petId pet id - */ - @JsonProperty("petId") - public Long getPetId() { - return petId; - } - - /** - * Sets pet id. - * - * @param petId the pet id - */ - public void setPetId(Long petId) { - this.petId = petId; - } - - /** - * Pet id order. - * - * @param petId the pet id - * @return the order - */ - public Order petId(Long petId) { - this.petId = petId; - return this; - } - - /** - * Get quantity - * - * @return quantity quantity - */ - @JsonProperty("quantity") - public Integer getQuantity() { - return quantity; - } - - /** - * Sets quantity. - * - * @param quantity the quantity - */ - public void setQuantity(Integer quantity) { - this.quantity = quantity; - } - - /** - * Quantity order. - * - * @param quantity the quantity - * @return the order - */ - public Order quantity(Integer quantity) { - this.quantity = quantity; - return this; - } - - /** - * Get shipDate - * - * @return shipDate ship date - */ - @JsonProperty("shipDate") - public Date getShipDate() { - return shipDate; - } - - /** - * Sets ship date. - * - * @param shipDate the ship date - */ - public void setShipDate(Date shipDate) { - this.shipDate = shipDate; - } - - /** - * Ship date order. - * - * @param shipDate the ship date - * @return the order - */ - public Order shipDate(Date shipDate) { - this.shipDate = shipDate; - return this; - } - - /** - * Order Status - * - * @return status status - */ - @JsonProperty("status") - public String getStatus() { - if (status == null) { - return null; - } - return status.getValue(); - } - - /** - * Sets status. - * - * @param status the status - */ - public void setStatus(StatusEnum status) { - this.status = status; - } - - /** - * Status order. - * - * @param status the status - * @return the order - */ - public Order status(StatusEnum status) { - this.status = status; - return this; - } - - /** - * Get complete - * - * @return complete boolean - */ - @JsonProperty("complete") - public Boolean isisComplete() { - return complete; - } - - /** - * Sets complete. - * - * @param complete the complete - */ - public void setComplete(Boolean complete) { - this.complete = complete; - } - - /** - * Complete order. - * - * @param complete the complete - * @return the order - */ - public Order complete(Boolean complete) { - this.complete = complete; - return this; - } - - - /** - * To string string. - * - * @return the string - */ - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class Order {\n"); - - sb.append(" id: ").append(toIndentedString(id)).append("\n"); - sb.append(" petId: ").append(toIndentedString(petId)).append("\n"); - sb.append(" quantity: ").append(toIndentedString(quantity)).append("\n"); - sb.append(" shipDate: ").append(toIndentedString(shipDate)).append("\n"); - sb.append(" status: ").append(toIndentedString(status)).append("\n"); - sb.append(" complete: ").append(toIndentedString(complete)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * The enum Status enum. - */ - public enum StatusEnum { - /** - *Placed status enum. - */ - PLACED("placed"), - /** - *Approved status enum. - */ - APPROVED("approved"), - /** - *Delivered status enum. - */ - DELIVERED("delivered"); - - /** - * The Value. - */ - private String value; - - /** - * Instantiates a new Status enum. - * - * @param value the value - */ - StatusEnum(String value) { - this.value = value; - } - - /** - * From value status enum. - * - * @param text the text - * @return the status enum - */ - @JsonCreator - public static StatusEnum fromValue(String text) { - for (StatusEnum b : StatusEnum.values()) { - if (String.valueOf(b.value).equals(text)) { - return b; - } - } - return null; - } - - /** - * Gets value. - * - * @return the value - */ - @JsonValue - public String getValue() { - return value; - } - - /** - * To string string. - * - * @return the string - */ - @Override - public String toString() { - return String.valueOf(value); - } - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app105/model/Pet.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app105/model/Pet.java deleted file mode 100644 index 62c3b4370..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app105/model/Pet.java +++ /dev/null @@ -1,384 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app105.model; - -import java.util.ArrayList; -import java.util.List; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonValue; -import io.swagger.v3.oas.annotations.media.Schema; -import jakarta.validation.constraints.NotNull; - -/** - * The type Pet. - */ -public class Pet { - - /** - * The Id. - */ - @Schema(description = "") - private Long id = null; - - /** - * The Category. - */ - @Schema(description = "") - private Category category = null; - - /** - * The Name. - */ - @Schema(example = "doggie", required = true, description = "") - private String name = null; - - /** - * The Photo urls. - */ - @Schema(required = true, description = "") - private List photoUrls = new ArrayList(); - - /** - * The Tags. - */ - @Schema(description = "") - private List tags = null; - - /** - * The Status. - */ - @Schema(description = "pet status in the store") - /** - * pet status in the store - **/ - private StatusEnum status = null; - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - * @param o the o - * @return the string - */ - private static String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } - - /** - * Get id - * - * @return id id - */ - @JsonProperty("id") - public Long getId() { - return id; - } - - /** - * Sets id. - * - * @param id the id - */ - public void setId(Long id) { - this.id = id; - } - - /** - * Id pet. - * - * @param id the id - * @return the pet - */ - public Pet id(Long id) { - this.id = id; - return this; - } - - /** - * Get category - * - * @return category category - */ - @JsonProperty("category") - public Category getCategory() { - return category; - } - - /** - * Sets category. - * - * @param category the category - */ - public void setCategory(Category category) { - this.category = category; - } - - /** - * Category pet. - * - * @param category the category - * @return the pet - */ - public Pet category(Category category) { - this.category = category; - return this; - } - - /** - * Get name - * - * @return name name - */ - @JsonProperty("name") - @NotNull - public String getName() { - return name; - } - - /** - * Sets name. - * - * @param name the name - */ - public void setName(String name) { - this.name = name; - } - - /** - * Name pet. - * - * @param name the name - * @return the pet - */ - public Pet name(String name) { - this.name = name; - return this; - } - - /** - * Get photoUrls - * - * @return photoUrls photo urls - */ - @JsonProperty("photoUrls") - @NotNull - public List getPhotoUrls() { - return photoUrls; - } - - /** - * Sets photo urls. - * - * @param photoUrls the photo urls - */ - public void setPhotoUrls(List photoUrls) { - this.photoUrls = photoUrls; - } - - /** - * Photo urls pet. - * - * @param photoUrls the photo urls - * @return the pet - */ - public Pet photoUrls(List photoUrls) { - this.photoUrls = photoUrls; - return this; - } - - /** - * Add photo urls item pet. - * - * @param photoUrlsItem the photo urls item - * @return the pet - */ - public Pet addPhotoUrlsItem(String photoUrlsItem) { - this.photoUrls.add(photoUrlsItem); - return this; - } - - /** - * Get tags - * - * @return tags tags - */ - @JsonProperty("tags") - public List getTags() { - return tags; - } - - /** - * Sets tags. - * - * @param tags the tags - */ - public void setTags(List tags) { - this.tags = tags; - } - - /** - * Tags pet. - * - * @param tags the tags - * @return the pet - */ - public Pet tags(List tags) { - this.tags = tags; - return this; - } - - /** - * Add tags item pet. - * - * @param tagsItem the tags item - * @return the pet - */ - public Pet addTagsItem(Tag tagsItem) { - if (this.tags == null) { - this.tags = new ArrayList<>(); - } - this.tags.add(tagsItem); - return this; - } - - /** - * pet status in the store - * - * @return status status - */ - @JsonProperty("status") - public StatusEnum getStatus() { - if (status == null) { - return null; - } - return status; - } - - /** - * Sets status. - * - * @param status the status - */ - public void setStatus(StatusEnum status) { - this.status = status; - } - - /** - * Status pet. - * - * @param status the status - * @return the pet - */ - public Pet status(StatusEnum status) { - this.status = status; - return this; - } - - /** - * To string string. - * - * @return the string - */ - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class Pet {\n"); - - sb.append(" id: ").append(toIndentedString(id)).append("\n"); - sb.append(" category: ").append(toIndentedString(category)).append("\n"); - sb.append(" name: ").append(toIndentedString(name)).append("\n"); - sb.append(" photoUrls: ").append(toIndentedString(photoUrls)).append("\n"); - sb.append(" tags: ").append(toIndentedString(tags)).append("\n"); - sb.append(" status: ").append(toIndentedString(status)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * The enum Status enum. - */ - public enum StatusEnum { - /** - *Available status enum. - */ - AVAILABLE("available"), - /** - *Pending status enum. - */ - PENDING("pending"), - /** - *Sold status enum. - */ - SOLD("sold"); - - /** - * The Value. - */ - private String value; - - /** - * Instantiates a new Status enum. - * - * @param value the value - */ - StatusEnum(String value) { - this.value = value; - } - - /** - * From value status enum. - * - * @param text the text - * @return the status enum - */ - @JsonCreator - public static StatusEnum fromValue(String text) { - for (StatusEnum b : StatusEnum.values()) { - if (String.valueOf(b.value).equals(text)) { - return b; - } - } - return null; - } - - /** - * Gets value. - * - * @return the value - */ - @JsonValue - public String getValue() { - return value; - } - - /** - * To string string. - * - * @return the string - */ - @Override - public String toString() { - return String.valueOf(value); - } - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app105/model/Tag.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app105/model/Tag.java deleted file mode 100644 index 2b5bde9af..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app105/model/Tag.java +++ /dev/null @@ -1,129 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app105.model; - -import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.v3.oas.annotations.media.Schema; - -/** - * The type Tag. - */ -class Tag { - - /** - * The Id. - */ - @Schema(description = "") - private Long id = null; - - /** - * The Name. - */ - @Schema(description = "") - private String name = null; - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - * @param o the o - * @return the string - */ - private static String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } - - /** - * Get id - * - * @return id id - */ - @JsonProperty("id") - public Long getId() { - return id; - } - - /** - * Sets id. - * - * @param id the id - */ - public void setId(Long id) { - this.id = id; - } - - /** - * Id tag. - * - * @param id the id - * @return the tag - */ - public Tag id(Long id) { - this.id = id; - return this; - } - - /** - * Get name - * - * @return name name - */ - @JsonProperty("name") - public String getName() { - return name; - } - - /** - * Sets name. - * - * @param name the name - */ - public void setName(String name) { - this.name = name; - } - - /** - * Name tag. - * - * @param name the name - * @return the tag - */ - public Tag name(String name) { - this.name = name; - return this; - } - - /** - * To string string. - * - * @return the string - */ - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class Tag {\n"); - - sb.append(" id: ").append(toIndentedString(id)).append("\n"); - sb.append(" name: ").append(toIndentedString(name)).append("\n"); - sb.append("}"); - return sb.toString(); - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app105/model/User.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app105/model/User.java deleted file mode 100644 index 1a460b197..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app105/model/User.java +++ /dev/null @@ -1,354 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app105.model; - -import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.v3.oas.annotations.media.Schema; - -/** - * The type User. - */ -public class User { - - /** - * The Id. - */ - @Schema(description = "") - private Long id = null; - - /** - * The Username. - */ - @Schema(description = "") - private String username = null; - - /** - * The First name. - */ - @Schema(description = "") - private String firstName = null; - - /** - * The Last name. - */ - @Schema(description = "") - private String lastName = null; - - /** - * The Email. - */ - @Schema(description = "") - private String email = null; - - /** - * The Password. - */ - @Schema(description = "") - private String password = null; - - /** - * The Phone. - */ - @Schema(description = "") - private String phone = null; - - /** - * The User status. - */ - @Schema(description = "User Status") - /** - * User Status - **/ - private Integer userStatus = null; - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - * @param o the o - * @return the string - */ - private static String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } - - /** - * Get id - * - * @return id id - */ - @JsonProperty("id") - public Long getId() { - return id; - } - - /** - * Sets id. - * - * @param id the id - */ - public void setId(Long id) { - this.id = id; - } - - /** - * Id user. - * - * @param id the id - * @return the user - */ - public User id(Long id) { - this.id = id; - return this; - } - - /** - * Get username - * - * @return username username - */ - @JsonProperty("username") - public String getUsername() { - return username; - } - - /** - * Sets username. - * - * @param username the username - */ - public void setUsername(String username) { - this.username = username; - } - - /** - * Username user. - * - * @param username the username - * @return the user - */ - public User username(String username) { - this.username = username; - return this; - } - - /** - * Get firstName - * - * @return firstName first name - */ - @JsonProperty("firstName") - public String getFirstName() { - return firstName; - } - - /** - * Sets first name. - * - * @param firstName the first name - */ - public void setFirstName(String firstName) { - this.firstName = firstName; - } - - /** - * First name user. - * - * @param firstName the first name - * @return the user - */ - public User firstName(String firstName) { - this.firstName = firstName; - return this; - } - - /** - * Get lastName - * - * @return lastName last name - */ - @JsonProperty("lastName") - public String getLastName() { - return lastName; - } - - /** - * Sets last name. - * - * @param lastName the last name - */ - public void setLastName(String lastName) { - this.lastName = lastName; - } - - /** - * Last name user. - * - * @param lastName the last name - * @return the user - */ - public User lastName(String lastName) { - this.lastName = lastName; - return this; - } - - /** - * Get email - * - * @return email email - */ - @JsonProperty("email") - public String getEmail() { - return email; - } - - /** - * Sets email. - * - * @param email the email - */ - public void setEmail(String email) { - this.email = email; - } - - /** - * Email user. - * - * @param email the email - * @return the user - */ - public User email(String email) { - this.email = email; - return this; - } - - /** - * Get password - * - * @return password password - */ - @JsonProperty("password") - public String getPassword() { - return password; - } - - /** - * Sets password. - * - * @param password the password - */ - public void setPassword(String password) { - this.password = password; - } - - /** - * Password user. - * - * @param password the password - * @return the user - */ - public User password(String password) { - this.password = password; - return this; - } - - /** - * Get phone - * - * @return phone phone - */ - @JsonProperty("phone") - public String getPhone() { - return phone; - } - - /** - * Sets phone. - * - * @param phone the phone - */ - public void setPhone(String phone) { - this.phone = phone; - } - - /** - * Phone user. - * - * @param phone the phone - * @return the user - */ - public User phone(String phone) { - this.phone = phone; - return this; - } - - /** - * User Status - * - * @return userStatus user status - */ - @JsonProperty("userStatus") - public Integer getUserStatus() { - return userStatus; - } - - /** - * Sets user status. - * - * @param userStatus the user status - */ - public void setUserStatus(Integer userStatus) { - this.userStatus = userStatus; - } - - /** - * User status user. - * - * @param userStatus the user status - * @return the user - */ - public User userStatus(Integer userStatus) { - this.userStatus = userStatus; - return this; - } - - /** - * To string string. - * - * @return the string - */ - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class User {\n"); - - sb.append(" id: ").append(toIndentedString(id)).append("\n"); - sb.append(" username: ").append(toIndentedString(username)).append("\n"); - sb.append(" firstName: ").append(toIndentedString(firstName)).append("\n"); - sb.append(" lastName: ").append(toIndentedString(lastName)).append("\n"); - sb.append(" email: ").append(toIndentedString(email)).append("\n"); - sb.append(" password: ").append(toIndentedString(password)).append("\n"); - sb.append(" phone: ").append(toIndentedString(phone)).append("\n"); - sb.append(" userStatus: ").append(toIndentedString(userStatus)).append("\n"); - sb.append("}"); - return sb.toString(); - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app106/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app106/HelloController.java deleted file mode 100644 index fb5acdcab..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app106/HelloController.java +++ /dev/null @@ -1,40 +0,0 @@ -package test.org.springdoc.api.app106; - -import java.time.Instant; - -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.enums.ParameterIn; -import io.swagger.v3.oas.annotations.media.Schema; - -import org.springframework.http.HttpHeaders; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RestController; - -/** - * The type Hello controller. - */ -@RestController -class HelloController { - - /** - * Find articles response entity. - * - * @param modifiedSince the modified since - * @return the response entity - */ - @Operation(summary = "find-articles") - @GetMapping - @Parameter(name = HttpHeaders.IF_MODIFIED_SINCE, - description = "DateTime", - in = ParameterIn.HEADER, - schema = @Schema(type = "string", format = "date-time"), - example = "2020-01-01T00:00:00.000Z" - ) - public ResponseEntity findArticles(@RequestHeader(value = HttpHeaders.IF_MODIFIED_SINCE, required = false) Instant modifiedSince) { - return null; - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app106/SpringDocApp106Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app106/SpringDocApp106Test.java deleted file mode 100644 index 7bd888b6f..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app106/SpringDocApp106Test.java +++ /dev/null @@ -1,16 +0,0 @@ -package test.org.springdoc.api.app106; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * The type Spring doc app 106 test. - */ -class SpringDocApp106Test extends AbstractSpringDocTest { - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app107/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app107/HelloController.java deleted file mode 100644 index d3197e70f..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app107/HelloController.java +++ /dev/null @@ -1,59 +0,0 @@ -package test.org.springdoc.api.app107; - -import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.v3.oas.annotations.media.Schema; - -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * The type Hello controller. - */ -@RestController -class HelloController { - - /** - * Gets entity b. - * - * @return the entity b - */ - @GetMapping(path = "/entity-b", produces = { "application/json", "application/xml" }) - public EntityB getEntityB() { - return new EntityB(); - } - - /** - * The type Entity b. - */ - class EntityB { - - /** - * The Field b. - */ - @Schema(required = true) - @JsonProperty("fieldB") - private String fieldB; - - /** - * The Entity a. - */ - @Schema(required = true) - @JsonProperty("entityA") - private EntityA entityA; - //Getters and setters... - } - - /** - * The type Entity a. - */ - class EntityA { - /** - * The Field a. - */ - @Schema(required = true) - @JsonProperty("fieldA") - private String fieldA; - //Getters and setters... - } -} - diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app107/SpringDocApp107Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app107/SpringDocApp107Test.java deleted file mode 100644 index 7b9c5e512..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app107/SpringDocApp107Test.java +++ /dev/null @@ -1,16 +0,0 @@ -package test.org.springdoc.api.app107; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * The type Spring doc app 107 test. - */ -class SpringDocApp107Test extends AbstractSpringDocTest { - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app108/ActionResult.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app108/ActionResult.java deleted file mode 100644 index 0389238b9..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app108/ActionResult.java +++ /dev/null @@ -1,147 +0,0 @@ -package test.org.springdoc.api.app108; - -/** - * The type Action result. - * - * @param the type parameter - */ -class ActionResult { - - /** - * The Value. - */ - protected T value; - - /** - * The Success. - */ - protected boolean success; - - /** - * The Error code. - */ - protected String errorCode; - - /** - * The Message. - */ - protected String message; - - /** - * The Error value. - */ - protected Object errorValue; - - /** - * The Target url. - */ - protected String targetUrl; - - /** - * Gets value. - * - * @return the value - */ - public T getValue() { - return value; - } - - /** - * Sets value. - * - * @param value the value - */ - public void setValue(T value) { - this.value = value; - } - - /** - * Is success boolean. - * - * @return the boolean - */ - public boolean isSuccess() { - return success; - } - - /** - * Sets success. - * - * @param success the success - */ - public void setSuccess(boolean success) { - this.success = success; - } - - /** - * Gets error code. - * - * @return the error code - */ - public String getErrorCode() { - return errorCode; - } - - /** - * Sets error code. - * - * @param errorCode the error code - */ - public void setErrorCode(String errorCode) { - this.errorCode = errorCode; - } - - /** - * Gets message. - * - * @return the message - */ - public String getMessage() { - return message; - } - - /** - * Sets message. - * - * @param message the message - */ - public void setMessage(String message) { - this.message = message; - } - - /** - * Gets error value. - * - * @return the error value - */ - public Object getErrorValue() { - return errorValue; - } - - /** - * Sets error value. - * - * @param errorValue the error value - */ - public void setErrorValue(Object errorValue) { - this.errorValue = errorValue; - } - - /** - * Gets target url. - * - * @return the target url - */ - public String getTargetUrl() { - return targetUrl; - } - - /** - * Sets target url. - * - * @param targetUrl the target url - */ - public void setTargetUrl(String targetUrl) { - this.targetUrl = targetUrl; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app108/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app108/HelloController.java deleted file mode 100644 index fcb84cde4..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app108/HelloController.java +++ /dev/null @@ -1,23 +0,0 @@ -package test.org.springdoc.api.app108; - -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * The type Hello controller. - */ -@RestController -class HelloController { - - /** - * Update action result. - * - * @param toto the toto - * @return the action result - */ - @PostMapping - public ActionResult update(String toto) { - return null; - } -} - diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app108/SpringDocApp108Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app108/SpringDocApp108Test.java deleted file mode 100644 index f633f2db1..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app108/SpringDocApp108Test.java +++ /dev/null @@ -1,16 +0,0 @@ -package test.org.springdoc.api.app108; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * The type Spring doc app 108 test. - */ -class SpringDocApp108Test extends AbstractSpringDocTest { - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app109/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app109/HelloController.java deleted file mode 100644 index 2475eb449..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app109/HelloController.java +++ /dev/null @@ -1,38 +0,0 @@ -package test.org.springdoc.api.app109; - -import io.swagger.v3.oas.annotations.media.Content; -import io.swagger.v3.oas.annotations.media.Schema; -import io.swagger.v3.oas.annotations.responses.ApiResponse; - -import org.springframework.core.io.ByteArrayResource; -import org.springframework.core.io.Resource; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * The type Hello controller. - */ -@RestController -class HelloController { - - /** - * Gets resource. - * - * @return the resource - */ - @GetMapping("/api/v1/resource") - public Resource getResource() { - return new ByteArrayResource(new byte[] {}); - } - - /** - * Get byte array byte [ ]. - * - * @return the byte [ ] - */ - @GetMapping("/api/v1/bytearray") - @ApiResponse(content = @Content(schema = @Schema(type = "string", format = "binary"))) - public byte[] getByteArray() { - return new byte[] {}; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app109/SpringDocApp109Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app109/SpringDocApp109Test.java deleted file mode 100644 index d54099659..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app109/SpringDocApp109Test.java +++ /dev/null @@ -1,16 +0,0 @@ -package test.org.springdoc.api.app109; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * The type Spring doc app 109 test. - */ -class SpringDocApp109Test extends AbstractSpringDocTest { - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app11/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app11/HelloController.java deleted file mode 100644 index d331c6143..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app11/HelloController.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app11; - -import java.util.List; - -import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; -import org.springframework.web.bind.annotation.ResponseBody; -import org.springframework.web.bind.annotation.RestController; -import org.springframework.web.multipart.MultipartFile; - -/** - * The type Hello controller. - */ -@RestController -class HelloController { - - /** - * Upload documents response entity. - * - * @param multipartFiles the multipart files - * @return the response entity - */ - @PostMapping(path = "/documents", consumes = "multipart/form-data") - public ResponseEntity uploadDocuments(@RequestPart("doc") List multipartFiles) { - return null; - } - - /** - * Post track string. - * - * @param file the file - * @return the string - */ - @RequestMapping(value = "/tracks", method = RequestMethod.POST, consumes = { MediaType.MULTIPART_FORM_DATA_VALUE }) - public @ResponseBody - String postTrack(@RequestParam("file") MultipartFile file) { - return "redirect:/"; - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app11/SpringDocApp11Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app11/SpringDocApp11Test.java deleted file mode 100644 index 12305efa6..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app11/SpringDocApp11Test.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app11; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * The type Spring doc app 11 test. - */ -class SpringDocApp11Test extends AbstractSpringDocTest { - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} - -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app110/ErrorMessage.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app110/ErrorMessage.java deleted file mode 100644 index acaf87337..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app110/ErrorMessage.java +++ /dev/null @@ -1,68 +0,0 @@ -package test.org.springdoc.api.app110; - -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - - -/** - * The type Error message. - */ -class ErrorMessage { - - /** - * The Errors. - */ - private List errors; - - /** - * Instantiates a new Error message. - */ - public ErrorMessage() { - } - - /** - * Instantiates a new Error message. - * - * @param errors the errors - */ - public ErrorMessage(List errors) { - this.errors = errors; - } - - /** - * Instantiates a new Error message. - * - * @param error the error - */ - public ErrorMessage(String error) { - this(Collections.singletonList(error)); - } - - /** - * Instantiates a new Error message. - * - * @param errors the errors - */ - public ErrorMessage(String... errors) { - this(Arrays.asList(errors)); - } - - /** - * Gets errors. - * - * @return the errors - */ - public List getErrors() { - return errors; - } - - /** - * Sets errors. - * - * @param errors the errors - */ - public void setErrors(List errors) { - this.errors = errors; - } -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app110/GlobalControllerAdvice.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app110/GlobalControllerAdvice.java deleted file mode 100644 index c6d326ac5..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app110/GlobalControllerAdvice.java +++ /dev/null @@ -1,166 +0,0 @@ -package test.org.springdoc.api.app110; - -import java.util.ArrayList; -import java.util.List; -import java.util.Set; -import java.util.UUID; - -import jakarta.validation.ConstraintViolation; -import jakarta.validation.ConstraintViolationException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; -import org.springframework.http.converter.HttpMessageNotReadableException; -import org.springframework.validation.FieldError; -import org.springframework.validation.ObjectError; -import org.springframework.web.HttpMediaTypeNotSupportedException; -import org.springframework.web.bind.MethodArgumentNotValidException; -import org.springframework.web.bind.MissingServletRequestParameterException; -import org.springframework.web.bind.annotation.ControllerAdvice; -import org.springframework.web.bind.annotation.ExceptionHandler; -import org.springframework.web.bind.annotation.ResponseStatus; - - -/** - * The type Global controller advice. - */ -@ControllerAdvice(assignableTypes = PersonController.class) -class GlobalControllerAdvice //extends ResponseEntityExceptionHandler -{ - /** - * Note use base class if you wish to leverage its handling. - * Some code will need changing. - */ - private static final Logger logger = LoggerFactory.getLogger(GlobalControllerAdvice.class); - - /** - * Problem response entity. - * - * @param e the e - * @return the response entity - */ - @ExceptionHandler(Throwable.class) - @ResponseStatus(code = HttpStatus.INTERNAL_SERVER_ERROR) - public ResponseEntity problem(final Throwable e) { - String message = "Problem occured"; - UUID uuid = UUID.randomUUID(); - String logRef = uuid.toString(); - logger.error("logRef=" + logRef, message, e); - return new ResponseEntity(new Problem(logRef, message), HttpStatus.INTERNAL_SERVER_ERROR); - } - - - /** - * Handle method argument not valid response entity. - * - * @param ex the ex - * @return the response entity - */ - @ExceptionHandler(MethodArgumentNotValidException.class) - @ResponseStatus(code = HttpStatus.BAD_REQUEST) - public ResponseEntity handleMethodArgumentNotValid(MethodArgumentNotValidException ex - ) { - List fieldErrors = ex.getBindingResult().getFieldErrors(); - List globalErrors = ex.getBindingResult().getGlobalErrors(); - List errors = new ArrayList<>(fieldErrors.size() + globalErrors.size()); - String error; - for (FieldError fieldError : fieldErrors) { - error = fieldError.getField() + ", " + fieldError.getDefaultMessage(); - errors.add(error); - } - for (ObjectError objectError : globalErrors) { - error = objectError.getObjectName() + ", " + objectError.getDefaultMessage(); - errors.add(error); - } - ErrorMessage errorMessage = new ErrorMessage(errors); - - //Object result=ex.getBindingResult();//instead of above can allso pass the more detailed bindingResult - return new ResponseEntity(errorMessage, HttpStatus.BAD_REQUEST); - } - - /** - * Handle constraint violated exception response entity. - * - * @param ex the ex - * @return the response entity - */ - @ExceptionHandler(ConstraintViolationException.class) - @ResponseStatus(code = HttpStatus.BAD_REQUEST) - public ResponseEntity handleConstraintViolatedException(ConstraintViolationException ex - ) { - Set> constraintViolations = ex.getConstraintViolations(); - - - List errors = new ArrayList<>(constraintViolations.size()); - String error; - for (ConstraintViolation constraintViolation : constraintViolations) { - - error = constraintViolation.getMessage(); - errors.add(error); - } - - ErrorMessage errorMessage = new ErrorMessage(errors); - return new ResponseEntity(errorMessage, HttpStatus.BAD_REQUEST); - } - - /** - * Handle missing servlet request parameter exception response entity. - * - * @param ex the ex - * @return the response entity - */ - @ExceptionHandler(MissingServletRequestParameterException.class) - @ResponseStatus(code = HttpStatus.BAD_REQUEST) - public ResponseEntity handleMissingServletRequestParameterException(MissingServletRequestParameterException ex - ) { - - List errors = new ArrayList<>(); - String error = ex.getParameterName() + ", " + ex.getMessage(); - errors.add(error); - ErrorMessage errorMessage = new ErrorMessage(errors); - return new ResponseEntity(errorMessage, HttpStatus.BAD_REQUEST); - } - - - /** - * Handle http media type not supported response entity. - * - * @param ex the ex - * @return the response entity - */ - @ExceptionHandler(HttpMediaTypeNotSupportedException.class) - @ResponseStatus(code = HttpStatus.UNSUPPORTED_MEDIA_TYPE) - public ResponseEntity handleHttpMediaTypeNotSupported(HttpMediaTypeNotSupportedException ex - ) { - String unsupported = "Unsupported content type: " + ex.getContentType(); - String supported = "Supported content types: " + MediaType.toString(ex.getSupportedMediaTypes()); - ErrorMessage errorMessage = new ErrorMessage(unsupported, supported); - return new ResponseEntity(errorMessage, HttpStatus.UNSUPPORTED_MEDIA_TYPE); - } - - /** - * Handle http message not readable response entity. - * - * @param ex the ex - * @return the response entity - */ - @ExceptionHandler(HttpMessageNotReadableException.class) - @ResponseStatus(code = HttpStatus.BAD_REQUEST) - public ResponseEntity handleHttpMessageNotReadable(HttpMessageNotReadableException ex) { - Throwable mostSpecificCause = ex.getMostSpecificCause(); - ErrorMessage errorMessage; - if (mostSpecificCause != null) { - String exceptionName = mostSpecificCause.getClass().getName(); - String message = mostSpecificCause.getMessage(); - errorMessage = new ErrorMessage(exceptionName, message); - } - else { - errorMessage = new ErrorMessage(ex.getMessage()); - } - return new ResponseEntity(errorMessage, HttpStatus.BAD_REQUEST); - } - -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app110/Person.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app110/Person.java deleted file mode 100644 index b9a8733a9..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app110/Person.java +++ /dev/null @@ -1,186 +0,0 @@ -package test.org.springdoc.api.app110; - -import jakarta.validation.constraints.Email; -import jakarta.validation.constraints.Max; -import jakarta.validation.constraints.Min; -import jakarta.validation.constraints.NotBlank; -import jakarta.validation.constraints.NotNull; -import jakarta.validation.constraints.Pattern; -import jakarta.validation.constraints.Size; -import org.hibernate.validator.constraints.CreditCardNumber; - - -/** - * The type Person. - */ -class Person { - /** - * The Id. - */ - private long id; - - /** - * The First name. - */ - private String firstName; - - /** - * The Last name. - */ - @NotNull - @NotBlank - @Size(max = 10) - private String lastName; - - /** - * The Email. - */ - @Pattern(regexp = ".+@.+\\..+", message = "Please provide a valid email address") - private String email; - - /** - * The Email 1. - */ - @Email() - private String email1; - - /** - * The Age. - */ - @Min(18) - @Max(30) - private int age; - - /** - * The Credit card number. - */ - @CreditCardNumber - private String creditCardNumber; - - /** - * Gets credit card number. - * - * @return the credit card number - */ - public String getCreditCardNumber() { - return creditCardNumber; - } - - /** - * Sets credit card number. - * - * @param creditCardNumber the credit card number - */ - public void setCreditCardNumber(String creditCardNumber) { - this.creditCardNumber = creditCardNumber; - } - - /** - * Gets id. - * - * @return the id - */ - public long getId() { - return id; - } - - /** - * Sets id. - * - * @param id the id - */ - public void setId(long id) { - this.id = id; - } - - /** - * Gets email 1. - * - * @return the email 1 - */ - public String getEmail1() { - return email1; - } - - /** - * Sets email 1. - * - * @param email1 the email 1 - */ - public void setEmail1(String email1) { - this.email1 = email1; - } - - /** - * Gets first name. - * - * @return the first name - */ - @Size(min = 2) - public String getFirstName() { - return firstName; - } - - /** - * Sets first name. - * - * @param firstName the first name - */ - public void setFirstName(String firstName) { - this.firstName = firstName; - } - - /** - * Gets last name. - * - * @return the last name - */ - public String getLastName() { - return lastName; - } - - /** - * Sets last name. - * - * @param lastName the last name - */ - public void setLastName(String lastName) { - this.lastName = lastName; - } - - /** - * Gets email. - * - * @return the email - */ - public String getEmail() { - return email; - } - - /** - * Sets email. - * - * @param email the email - */ - public void setEmail(String email) { - this.email = email; - } - - /** - * Gets age. - * - * @return the age - */ - public int getAge() { - return age; - } - - /** - * Sets age. - * - * @param age the age - */ - public void setAge(int age) { - this.age = age; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app110/PersonController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app110/PersonController.java deleted file mode 100644 index 14a140054..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app110/PersonController.java +++ /dev/null @@ -1,70 +0,0 @@ -package test.org.springdoc.api.app110; - -import java.util.ArrayList; -import java.util.List; -import java.util.Random; - -import jakarta.validation.Valid; -import jakarta.validation.constraints.NotBlank; -import jakarta.validation.constraints.NotNull; -import jakarta.validation.constraints.Size; - -import org.springframework.validation.annotation.Validated; -import org.springframework.web.HttpMediaTypeNotSupportedException; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -/** - * The type Person controller. - */ -@RestController -@Validated -class PersonController { - /** - * The Ran. - */ - private Random ran = new Random(); - - /** - * Person person. - * - * @param person the person - * @return the person - */ - @RequestMapping(path = "/person", method = RequestMethod.POST) - public Person person(@Valid @RequestBody Person person) throws HttpMediaTypeNotSupportedException { - - int nxt = ran.nextInt(10); - if (nxt >= 5) { - throw new RuntimeException("Breaking logic"); - } - return person; - } - - /** - * Find by last name list. - * - * @param lastName the last name - * @return the list - */ - @RequestMapping(path = "/personByLastName", method = RequestMethod.GET) - public List findByLastName(@RequestParam(name = "lastName", required = true) @NotNull - @NotBlank - @Size(max = 10) String lastName) throws HttpMediaTypeNotSupportedException { - List hardCoded = new ArrayList<>(); - Person person = new Person(); - person.setAge(20); - person.setCreditCardNumber("4111111111111111"); - person.setEmail("abc@abc.com"); - person.setEmail1("abc1@abc.com"); - person.setFirstName("Somefirstname"); - person.setLastName(lastName); - person.setId(1); - hardCoded.add(person); - return hardCoded; - - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app110/PersonController2.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app110/PersonController2.java deleted file mode 100644 index 4eaede510..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app110/PersonController2.java +++ /dev/null @@ -1,69 +0,0 @@ -package test.org.springdoc.api.app110; - -import java.util.ArrayList; -import java.util.List; -import java.util.Random; - -import jakarta.validation.Valid; -import jakarta.validation.constraints.NotBlank; -import jakarta.validation.constraints.NotNull; -import jakarta.validation.constraints.Size; - -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -/** - * The type Person controller 2. - */ -@RestController -@Validated -class PersonController2 { - /** - * The Ran. - */ - private Random ran = new Random(); - - /** - * Person person. - * - * @param person the person - * @return the person - */ - @RequestMapping(path = "/person2", method = RequestMethod.POST) - public Person person(@Valid @RequestBody Person person) { - - int nxt = ran.nextInt(10); - if (nxt >= 5) { - throw new RuntimeException("Breaking logic"); - } - return person; - } - - /** - * Find by last name list. - * - * @param lastName the last name - * @return the list - */ - @RequestMapping(path = "/personByLastName2", method = RequestMethod.GET) - public List findByLastName(@RequestParam(name = "lastName", required = true) @NotNull - @NotBlank - @Size(max = 10) String lastName) { - List hardCoded = new ArrayList<>(); - Person person = new Person(); - person.setAge(20); - person.setCreditCardNumber("4111111111111111"); - person.setEmail("abc@abc.com"); - person.setEmail1("abc1@abc.com"); - person.setFirstName("Somefirstname"); - person.setLastName(lastName); - person.setId(1); - hardCoded.add(person); - return hardCoded; - - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app110/Problem.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app110/Problem.java deleted file mode 100644 index 96317413b..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app110/Problem.java +++ /dev/null @@ -1,73 +0,0 @@ -package test.org.springdoc.api.app110; - -/** - * The type Problem. - */ -class Problem { - - /** - * The Log ref. - */ - private String logRef; - - /** - * The Message. - */ - private String message; - - /** - * Instantiates a new Problem. - * - * @param logRef the log ref - * @param message the message - */ - public Problem(String logRef, String message) { - super(); - this.logRef = logRef; - this.message = message; - } - - /** - * Instantiates a new Problem. - */ - public Problem() { - super(); - - } - - /** - * Gets log ref. - * - * @return the log ref - */ - public String getLogRef() { - return logRef; - } - - /** - * Sets log ref. - * - * @param logRef the log ref - */ - public void setLogRef(String logRef) { - this.logRef = logRef; - } - - /** - * Gets message. - * - * @return the message - */ - public String getMessage() { - return message; - } - - /** - * Sets message. - * - * @param message the message - */ - public void setMessage(String message) { - this.message = message; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app110/SpringDocApp110Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app110/SpringDocApp110Test.java deleted file mode 100644 index 5436f3051..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app110/SpringDocApp110Test.java +++ /dev/null @@ -1,46 +0,0 @@ -package test.org.springdoc.api.app110; - -import io.swagger.v3.oas.models.OpenAPI; -import io.swagger.v3.oas.models.info.Info; -import io.swagger.v3.oas.models.info.License; -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.Bean; -import org.springframework.test.context.TestPropertySource; - -/** - * The type Spring doc app 110 test. - */ -@TestPropertySource(properties = { - "application-description=description", - "application-version=v1" }) -class SpringDocApp110Test extends AbstractSpringDocTest { - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp { - - /** - * Custom open api open api. - * - * @param appDesciption the app desciption - * @param appVersion the app version - * @return the open api - */ - @Bean - public OpenAPI customOpenAPI(@Value("${application-description}") String appDesciption, @Value("${application-version}") String appVersion) { - - return new OpenAPI() - .info(new Info() - .title("sample application API") - .version(appVersion) - .description(appDesciption) - .termsOfService("http://swagger.io/terms/") - .license(new License().name("Apache 2.0").url("http://springdoc.org"))); - } - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app111/ErrorMessage.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app111/ErrorMessage.java deleted file mode 100644 index 987d07087..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app111/ErrorMessage.java +++ /dev/null @@ -1,68 +0,0 @@ -package test.org.springdoc.api.app111; - -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - - -/** - * The type Error message. - */ -class ErrorMessage { - - /** - * The Errors. - */ - private List errors; - - /** - * Instantiates a new Error message. - */ - public ErrorMessage() { - } - - /** - * Instantiates a new Error message. - * - * @param errors the errors - */ - public ErrorMessage(List errors) { - this.errors = errors; - } - - /** - * Instantiates a new Error message. - * - * @param error the error - */ - public ErrorMessage(String error) { - this(Collections.singletonList(error)); - } - - /** - * Instantiates a new Error message. - * - * @param errors the errors - */ - public ErrorMessage(String... errors) { - this(Arrays.asList(errors)); - } - - /** - * Gets errors. - * - * @return the errors - */ - public List getErrors() { - return errors; - } - - /** - * Sets errors. - * - * @param errors the errors - */ - public void setErrors(List errors) { - this.errors = errors; - } -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app111/GlobalControllerAdvice.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app111/GlobalControllerAdvice.java deleted file mode 100644 index f33033e8d..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app111/GlobalControllerAdvice.java +++ /dev/null @@ -1,166 +0,0 @@ -package test.org.springdoc.api.app111; - -import java.util.ArrayList; -import java.util.List; -import java.util.Set; -import java.util.UUID; - -import jakarta.validation.ConstraintViolation; -import jakarta.validation.ConstraintViolationException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; -import org.springframework.http.converter.HttpMessageNotReadableException; -import org.springframework.validation.FieldError; -import org.springframework.validation.ObjectError; -import org.springframework.web.HttpMediaTypeNotSupportedException; -import org.springframework.web.bind.MethodArgumentNotValidException; -import org.springframework.web.bind.MissingServletRequestParameterException; -import org.springframework.web.bind.annotation.ControllerAdvice; -import org.springframework.web.bind.annotation.ExceptionHandler; -import org.springframework.web.bind.annotation.ResponseStatus; - - -/** - * The type Global controller advice. - */ -@ControllerAdvice(basePackages = "test.org.springdoc.api.appzzz") -class GlobalControllerAdvice //extends ResponseEntityExceptionHandler -{ - /** - * Note use base class if you wish to leverage its handling. - * Some code will need changing. - */ - private static final Logger logger = LoggerFactory.getLogger(GlobalControllerAdvice.class); - - /** - * Problem response entity. - * - * @param e the e - * @return the response entity - */ - @ExceptionHandler(Throwable.class) - @ResponseStatus(code = HttpStatus.INTERNAL_SERVER_ERROR) - public ResponseEntity problem(final Throwable e) { - String message = "Problem occured"; - UUID uuid = UUID.randomUUID(); - String logRef = uuid.toString(); - logger.error("logRef=" + logRef, message, e); - return new ResponseEntity(new Problem(logRef, message), HttpStatus.INTERNAL_SERVER_ERROR); - } - - - /** - * Handle method argument not valid response entity. - * - * @param ex the ex - * @return the response entity - */ - @ExceptionHandler(MethodArgumentNotValidException.class) - @ResponseStatus(code = HttpStatus.BAD_REQUEST) - public ResponseEntity handleMethodArgumentNotValid(MethodArgumentNotValidException ex - ) { - List fieldErrors = ex.getBindingResult().getFieldErrors(); - List globalErrors = ex.getBindingResult().getGlobalErrors(); - List errors = new ArrayList<>(fieldErrors.size() + globalErrors.size()); - String error; - for (FieldError fieldError : fieldErrors) { - error = fieldError.getField() + ", " + fieldError.getDefaultMessage(); - errors.add(error); - } - for (ObjectError objectError : globalErrors) { - error = objectError.getObjectName() + ", " + objectError.getDefaultMessage(); - errors.add(error); - } - ErrorMessage errorMessage = new ErrorMessage(errors); - - //Object result=ex.getBindingResult();//instead of above can allso pass the more detailed bindingResult - return new ResponseEntity(errorMessage, HttpStatus.BAD_REQUEST); - } - - /** - * Handle constraint violated exception response entity. - * - * @param ex the ex - * @return the response entity - */ - @ExceptionHandler(ConstraintViolationException.class) - @ResponseStatus(code = HttpStatus.BAD_REQUEST) - public ResponseEntity handleConstraintViolatedException(ConstraintViolationException ex - ) { - Set> constraintViolations = ex.getConstraintViolations(); - - - List errors = new ArrayList<>(constraintViolations.size()); - String error; - for (ConstraintViolation constraintViolation : constraintViolations) { - - error = constraintViolation.getMessage(); - errors.add(error); - } - - ErrorMessage errorMessage = new ErrorMessage(errors); - return new ResponseEntity(errorMessage, HttpStatus.BAD_REQUEST); - } - - /** - * Handle missing servlet request parameter exception response entity. - * - * @param ex the ex - * @return the response entity - */ - @ExceptionHandler(MissingServletRequestParameterException.class) - @ResponseStatus(code = HttpStatus.BAD_REQUEST) - public ResponseEntity handleMissingServletRequestParameterException(MissingServletRequestParameterException ex - ) { - - List errors = new ArrayList<>(); - String error = ex.getParameterName() + ", " + ex.getMessage(); - errors.add(error); - ErrorMessage errorMessage = new ErrorMessage(errors); - return new ResponseEntity(errorMessage, HttpStatus.BAD_REQUEST); - } - - - /** - * Handle http media type not supported response entity. - * - * @param ex the ex - * @return the response entity - */ - @ExceptionHandler(HttpMediaTypeNotSupportedException.class) - @ResponseStatus(code = HttpStatus.UNSUPPORTED_MEDIA_TYPE) - public ResponseEntity handleHttpMediaTypeNotSupported(HttpMediaTypeNotSupportedException ex - ) { - String unsupported = "Unsupported content type: " + ex.getContentType(); - String supported = "Supported content types: " + MediaType.toString(ex.getSupportedMediaTypes()); - ErrorMessage errorMessage = new ErrorMessage(unsupported, supported); - return new ResponseEntity(errorMessage, HttpStatus.UNSUPPORTED_MEDIA_TYPE); - } - - /** - * Handle http message not readable response entity. - * - * @param ex the ex - * @return the response entity - */ - @ExceptionHandler(HttpMessageNotReadableException.class) - @ResponseStatus(code = HttpStatus.BAD_REQUEST) - public ResponseEntity handleHttpMessageNotReadable(HttpMessageNotReadableException ex) { - Throwable mostSpecificCause = ex.getMostSpecificCause(); - ErrorMessage errorMessage; - if (mostSpecificCause != null) { - String exceptionName = mostSpecificCause.getClass().getName(); - String message = mostSpecificCause.getMessage(); - errorMessage = new ErrorMessage(exceptionName, message); - } - else { - errorMessage = new ErrorMessage(ex.getMessage()); - } - return new ResponseEntity(errorMessage, HttpStatus.BAD_REQUEST); - } - -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app111/Person.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app111/Person.java deleted file mode 100644 index a73ca5b25..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app111/Person.java +++ /dev/null @@ -1,186 +0,0 @@ -package test.org.springdoc.api.app111; - -import jakarta.validation.constraints.Email; -import jakarta.validation.constraints.Max; -import jakarta.validation.constraints.Min; -import jakarta.validation.constraints.NotBlank; -import jakarta.validation.constraints.NotNull; -import jakarta.validation.constraints.Pattern; -import jakarta.validation.constraints.Size; -import org.hibernate.validator.constraints.CreditCardNumber; - - -/** - * The type Person. - */ -class Person { - /** - * The Id. - */ - private long id; - - /** - * The First name. - */ - private String firstName; - - /** - * The Last name. - */ - @NotNull - @NotBlank - @Size(max = 10) - private String lastName; - - /** - * The Email. - */ - @Pattern(regexp = ".+@.+\\..+", message = "Please provide a valid email address") - private String email; - - /** - * The Email 1. - */ - @Email() - private String email1; - - /** - * The Age. - */ - @Min(18) - @Max(30) - private int age; - - /** - * The Credit card number. - */ - @CreditCardNumber - private String creditCardNumber; - - /** - * Gets credit card number. - * - * @return the credit card number - */ - public String getCreditCardNumber() { - return creditCardNumber; - } - - /** - * Sets credit card number. - * - * @param creditCardNumber the credit card number - */ - public void setCreditCardNumber(String creditCardNumber) { - this.creditCardNumber = creditCardNumber; - } - - /** - * Gets id. - * - * @return the id - */ - public long getId() { - return id; - } - - /** - * Sets id. - * - * @param id the id - */ - public void setId(long id) { - this.id = id; - } - - /** - * Gets email 1. - * - * @return the email 1 - */ - public String getEmail1() { - return email1; - } - - /** - * Sets email 1. - * - * @param email1 the email 1 - */ - public void setEmail1(String email1) { - this.email1 = email1; - } - - /** - * Gets first name. - * - * @return the first name - */ - @Size(min = 2) - public String getFirstName() { - return firstName; - } - - /** - * Sets first name. - * - * @param firstName the first name - */ - public void setFirstName(String firstName) { - this.firstName = firstName; - } - - /** - * Gets last name. - * - * @return the last name - */ - public String getLastName() { - return lastName; - } - - /** - * Sets last name. - * - * @param lastName the last name - */ - public void setLastName(String lastName) { - this.lastName = lastName; - } - - /** - * Gets email. - * - * @return the email - */ - public String getEmail() { - return email; - } - - /** - * Sets email. - * - * @param email the email - */ - public void setEmail(String email) { - this.email = email; - } - - /** - * Gets age. - * - * @return the age - */ - public int getAge() { - return age; - } - - /** - * Sets age. - * - * @param age the age - */ - public void setAge(int age) { - this.age = age; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app111/PersonController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app111/PersonController.java deleted file mode 100644 index dc9549618..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app111/PersonController.java +++ /dev/null @@ -1,69 +0,0 @@ -package test.org.springdoc.api.app111; - -import java.util.ArrayList; -import java.util.List; -import java.util.Random; - -import jakarta.validation.Valid; -import jakarta.validation.constraints.NotBlank; -import jakarta.validation.constraints.NotNull; -import jakarta.validation.constraints.Size; - -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -/** - * The type Person controller. - */ -@RestController -@Validated -class PersonController { - /** - * The Ran. - */ - private Random ran = new Random(); - - /** - * Person person. - * - * @param person the person - * @return the person - */ - @RequestMapping(path = "/person", method = RequestMethod.POST) - public Person person(@Valid @RequestBody Person person) { - - int nxt = ran.nextInt(10); - if (nxt >= 5) { - throw new RuntimeException("Breaking logic"); - } - return person; - } - - /** - * Find by last name list. - * - * @param lastName the last name - * @return the list - */ - @RequestMapping(path = "/personByLastName", method = RequestMethod.GET) - public List findByLastName(@RequestParam(name = "lastName", required = true) @NotNull - @NotBlank - @Size(max = 10) String lastName) { - List hardCoded = new ArrayList<>(); - Person person = new Person(); - person.setAge(20); - person.setCreditCardNumber("4111111111111111"); - person.setEmail("abc@abc.com"); - person.setEmail1("abc1@abc.com"); - person.setFirstName("Somefirstname"); - person.setLastName(lastName); - person.setId(1); - hardCoded.add(person); - return hardCoded; - - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app111/PersonController2.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app111/PersonController2.java deleted file mode 100644 index 8d915472a..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app111/PersonController2.java +++ /dev/null @@ -1,69 +0,0 @@ -package test.org.springdoc.api.app111; - -import java.util.ArrayList; -import java.util.List; -import java.util.Random; - -import jakarta.validation.Valid; -import jakarta.validation.constraints.NotBlank; -import jakarta.validation.constraints.NotNull; -import jakarta.validation.constraints.Size; - -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -/** - * The type Person controller 2. - */ -@RestController -@Validated -class PersonController2 { - /** - * The Ran. - */ - private Random ran = new Random(); - - /** - * Person person. - * - * @param person the person - * @return the person - */ - @RequestMapping(path = "/person2", method = RequestMethod.POST) - public Person person(@Valid @RequestBody Person person) { - - int nxt = ran.nextInt(10); - if (nxt >= 5) { - throw new RuntimeException("Breaking logic"); - } - return person; - } - - /** - * Find by last name list. - * - * @param lastName the last name - * @return the list - */ - @RequestMapping(path = "/personByLastName2", method = RequestMethod.GET) - public List findByLastName(@RequestParam(name = "lastName", required = true) @NotNull - @NotBlank - @Size(max = 10) String lastName) { - List hardCoded = new ArrayList<>(); - Person person = new Person(); - person.setAge(20); - person.setCreditCardNumber("4111111111111111"); - person.setEmail("abc@abc.com"); - person.setEmail1("abc1@abc.com"); - person.setFirstName("Somefirstname"); - person.setLastName(lastName); - person.setId(1); - hardCoded.add(person); - return hardCoded; - - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app111/Problem.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app111/Problem.java deleted file mode 100644 index 088ca0795..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app111/Problem.java +++ /dev/null @@ -1,73 +0,0 @@ -package test.org.springdoc.api.app111; - -/** - * The type Problem. - */ -class Problem { - - /** - * The Log ref. - */ - private String logRef; - - /** - * The Message. - */ - private String message; - - /** - * Instantiates a new Problem. - * - * @param logRef the log ref - * @param message the message - */ - public Problem(String logRef, String message) { - super(); - this.logRef = logRef; - this.message = message; - } - - /** - * Instantiates a new Problem. - */ - public Problem() { - super(); - - } - - /** - * Gets log ref. - * - * @return the log ref - */ - public String getLogRef() { - return logRef; - } - - /** - * Sets log ref. - * - * @param logRef the log ref - */ - public void setLogRef(String logRef) { - this.logRef = logRef; - } - - /** - * Gets message. - * - * @return the message - */ - public String getMessage() { - return message; - } - - /** - * Sets message. - * - * @param message the message - */ - public void setMessage(String message) { - this.message = message; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app111/SpringDocApp111Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app111/SpringDocApp111Test.java deleted file mode 100644 index 5894369f9..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app111/SpringDocApp111Test.java +++ /dev/null @@ -1,45 +0,0 @@ -package test.org.springdoc.api.app111; - -import io.swagger.v3.oas.models.OpenAPI; -import io.swagger.v3.oas.models.info.Info; -import io.swagger.v3.oas.models.info.License; -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.Bean; -import org.springframework.test.context.TestPropertySource; - -/** - * The type Spring doc app 111 test. - */ -@TestPropertySource(properties = { - "application-description=description", - "application-version=v1" }) -class SpringDocApp111Test extends AbstractSpringDocTest { - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp { - - /** - * Custom open api open api. - * - * @param appDesciption the app desciption - * @param appVersion the app version - * @return the open api - */ - @Bean - public OpenAPI customOpenAPI(@Value("${application-description}") String appDesciption, @Value("${application-version}") String appVersion) { - return new OpenAPI() - .info(new Info() - .title("sample application API") - .version(appVersion) - .description(appDesciption) - .termsOfService("http://swagger.io/terms/") - .license(new License().name("Apache 2.0").url("http://springdoc.org"))); - } - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app112/ErrorMessage.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app112/ErrorMessage.java deleted file mode 100644 index f0404171c..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app112/ErrorMessage.java +++ /dev/null @@ -1,68 +0,0 @@ -package test.org.springdoc.api.app112; - -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - - -/** - * The type Error message. - */ -class ErrorMessage { - - /** - * The Errors. - */ - private List errors; - - /** - * Instantiates a new Error message. - */ - public ErrorMessage() { - } - - /** - * Instantiates a new Error message. - * - * @param errors the errors - */ - public ErrorMessage(List errors) { - this.errors = errors; - } - - /** - * Instantiates a new Error message. - * - * @param error the error - */ - public ErrorMessage(String error) { - this(Collections.singletonList(error)); - } - - /** - * Instantiates a new Error message. - * - * @param errors the errors - */ - public ErrorMessage(String... errors) { - this(Arrays.asList(errors)); - } - - /** - * Gets errors. - * - * @return the errors - */ - public List getErrors() { - return errors; - } - - /** - * Sets errors. - * - * @param errors the errors - */ - public void setErrors(List errors) { - this.errors = errors; - } -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app112/GlobalControllerAdvice.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app112/GlobalControllerAdvice.java deleted file mode 100644 index 1de9557f6..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app112/GlobalControllerAdvice.java +++ /dev/null @@ -1,166 +0,0 @@ -package test.org.springdoc.api.app112; - -import java.util.ArrayList; -import java.util.List; -import java.util.Set; -import java.util.UUID; - -import jakarta.validation.ConstraintViolation; -import jakarta.validation.ConstraintViolationException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; -import org.springframework.http.converter.HttpMessageNotReadableException; -import org.springframework.validation.FieldError; -import org.springframework.validation.ObjectError; -import org.springframework.web.HttpMediaTypeNotSupportedException; -import org.springframework.web.bind.MethodArgumentNotValidException; -import org.springframework.web.bind.MissingServletRequestParameterException; -import org.springframework.web.bind.annotation.ControllerAdvice; -import org.springframework.web.bind.annotation.ExceptionHandler; -import org.springframework.web.bind.annotation.ResponseStatus; - - -/** - * The type Global controller advice. - */ -@ControllerAdvice(basePackages = "test.org.springdoc.api.app112.sample") -class GlobalControllerAdvice //extends ResponseEntityExceptionHandler -{ - /** - * Note use base class if you wish to leverage its handling. - * Some code will need changing. - */ - private static final Logger logger = LoggerFactory.getLogger(GlobalControllerAdvice.class); - - /** - * Problem response entity. - * - * @param e the e - * @return the response entity - */ - @ExceptionHandler(Throwable.class) - @ResponseStatus(code = HttpStatus.INTERNAL_SERVER_ERROR) - public ResponseEntity problem(final Throwable e) { - String message = "Problem occured"; - UUID uuid = UUID.randomUUID(); - String logRef = uuid.toString(); - logger.error("logRef=" + logRef, message, e); - return new ResponseEntity(new Problem(logRef, message), HttpStatus.INTERNAL_SERVER_ERROR); - } - - - /** - * Handle method argument not valid response entity. - * - * @param ex the ex - * @return the response entity - */ - @ExceptionHandler(MethodArgumentNotValidException.class) - @ResponseStatus(code = HttpStatus.BAD_REQUEST) - public ResponseEntity handleMethodArgumentNotValid(MethodArgumentNotValidException ex - ) { - List fieldErrors = ex.getBindingResult().getFieldErrors(); - List globalErrors = ex.getBindingResult().getGlobalErrors(); - List errors = new ArrayList<>(fieldErrors.size() + globalErrors.size()); - String error; - for (FieldError fieldError : fieldErrors) { - error = fieldError.getField() + ", " + fieldError.getDefaultMessage(); - errors.add(error); - } - for (ObjectError objectError : globalErrors) { - error = objectError.getObjectName() + ", " + objectError.getDefaultMessage(); - errors.add(error); - } - ErrorMessage errorMessage = new ErrorMessage(errors); - - //Object result=ex.getBindingResult();//instead of above can allso pass the more detailed bindingResult - return new ResponseEntity(errorMessage, HttpStatus.BAD_REQUEST); - } - - /** - * Handle constraint violated exception response entity. - * - * @param ex the ex - * @return the response entity - */ - @ExceptionHandler(ConstraintViolationException.class) - @ResponseStatus(code = HttpStatus.BAD_REQUEST) - public ResponseEntity handleConstraintViolatedException(ConstraintViolationException ex - ) { - Set> constraintViolations = ex.getConstraintViolations(); - - - List errors = new ArrayList<>(constraintViolations.size()); - String error; - for (ConstraintViolation constraintViolation : constraintViolations) { - - error = constraintViolation.getMessage(); - errors.add(error); - } - - ErrorMessage errorMessage = new ErrorMessage(errors); - return new ResponseEntity(errorMessage, HttpStatus.BAD_REQUEST); - } - - /** - * Handle missing servlet request parameter exception response entity. - * - * @param ex the ex - * @return the response entity - */ - @ExceptionHandler(MissingServletRequestParameterException.class) - @ResponseStatus(code = HttpStatus.BAD_REQUEST) - public ResponseEntity handleMissingServletRequestParameterException(MissingServletRequestParameterException ex - ) { - - List errors = new ArrayList<>(); - String error = ex.getParameterName() + ", " + ex.getMessage(); - errors.add(error); - ErrorMessage errorMessage = new ErrorMessage(errors); - return new ResponseEntity(errorMessage, HttpStatus.BAD_REQUEST); - } - - - /** - * Handle http media type not supported response entity. - * - * @param ex the ex - * @return the response entity - */ - @ExceptionHandler(HttpMediaTypeNotSupportedException.class) - @ResponseStatus(code = HttpStatus.UNSUPPORTED_MEDIA_TYPE) - public ResponseEntity handleHttpMediaTypeNotSupported(HttpMediaTypeNotSupportedException ex - ) { - String unsupported = "Unsupported content type: " + ex.getContentType(); - String supported = "Supported content types: " + MediaType.toString(ex.getSupportedMediaTypes()); - ErrorMessage errorMessage = new ErrorMessage(unsupported, supported); - return new ResponseEntity(errorMessage, HttpStatus.UNSUPPORTED_MEDIA_TYPE); - } - - /** - * Handle http message not readable response entity. - * - * @param ex the ex - * @return the response entity - */ - @ExceptionHandler(HttpMessageNotReadableException.class) - @ResponseStatus(code = HttpStatus.BAD_REQUEST) - public ResponseEntity handleHttpMessageNotReadable(HttpMessageNotReadableException ex) { - Throwable mostSpecificCause = ex.getMostSpecificCause(); - ErrorMessage errorMessage; - if (mostSpecificCause != null) { - String exceptionName = mostSpecificCause.getClass().getName(); - String message = mostSpecificCause.getMessage(); - errorMessage = new ErrorMessage(exceptionName, message); - } - else { - errorMessage = new ErrorMessage(ex.getMessage()); - } - return new ResponseEntity(errorMessage, HttpStatus.BAD_REQUEST); - } - -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app112/Person.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app112/Person.java deleted file mode 100644 index 4846397e0..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app112/Person.java +++ /dev/null @@ -1,186 +0,0 @@ -package test.org.springdoc.api.app112; - -import jakarta.validation.constraints.Email; -import jakarta.validation.constraints.Max; -import jakarta.validation.constraints.Min; -import jakarta.validation.constraints.NotBlank; -import jakarta.validation.constraints.NotNull; -import jakarta.validation.constraints.Pattern; -import jakarta.validation.constraints.Size; -import org.hibernate.validator.constraints.CreditCardNumber; - - -/** - * The type Person. - */ -public class Person { - /** - * The Id. - */ - private long id; - - /** - * The First name. - */ - private String firstName; - - /** - * The Last name. - */ - @NotNull - @NotBlank - @Size(max = 10) - private String lastName; - - /** - * The Email. - */ - @Pattern(regexp = ".+@.+\\..+", message = "Please provide a valid email address") - private String email; - - /** - * The Email 1. - */ - @Email() - private String email1; - - /** - * The Age. - */ - @Min(18) - @Max(30) - private int age; - - /** - * The Credit card number. - */ - @CreditCardNumber - private String creditCardNumber; - - /** - * Gets credit card number. - * - * @return the credit card number - */ - public String getCreditCardNumber() { - return creditCardNumber; - } - - /** - * Sets credit card number. - * - * @param creditCardNumber the credit card number - */ - public void setCreditCardNumber(String creditCardNumber) { - this.creditCardNumber = creditCardNumber; - } - - /** - * Gets id. - * - * @return the id - */ - public long getId() { - return id; - } - - /** - * Sets id. - * - * @param id the id - */ - public void setId(long id) { - this.id = id; - } - - /** - * Gets email 1. - * - * @return the email 1 - */ - public String getEmail1() { - return email1; - } - - /** - * Sets email 1. - * - * @param email1 the email 1 - */ - public void setEmail1(String email1) { - this.email1 = email1; - } - - /** - * Gets first name. - * - * @return the first name - */ - @Size(min = 2) - public String getFirstName() { - return firstName; - } - - /** - * Sets first name. - * - * @param firstName the first name - */ - public void setFirstName(String firstName) { - this.firstName = firstName; - } - - /** - * Gets last name. - * - * @return the last name - */ - public String getLastName() { - return lastName; - } - - /** - * Sets last name. - * - * @param lastName the last name - */ - public void setLastName(String lastName) { - this.lastName = lastName; - } - - /** - * Gets email. - * - * @return the email - */ - public String getEmail() { - return email; - } - - /** - * Sets email. - * - * @param email the email - */ - public void setEmail(String email) { - this.email = email; - } - - /** - * Gets age. - * - * @return the age - */ - public int getAge() { - return age; - } - - /** - * Sets age. - * - * @param age the age - */ - public void setAge(int age) { - this.age = age; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app112/PersonController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app112/PersonController.java deleted file mode 100644 index 4d81dd572..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app112/PersonController.java +++ /dev/null @@ -1,69 +0,0 @@ -package test.org.springdoc.api.app112; - -import java.util.ArrayList; -import java.util.List; -import java.util.Random; - -import jakarta.validation.Valid; -import jakarta.validation.constraints.NotBlank; -import jakarta.validation.constraints.NotNull; -import jakarta.validation.constraints.Size; - -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -/** - * The type Person controller. - */ -@RestController -@Validated -class PersonController { - /** - * The Ran. - */ - private Random ran = new Random(); - - /** - * Person person. - * - * @param person the person - * @return the person - */ - @RequestMapping(path = "/person", method = RequestMethod.POST) - public Person person(@Valid @RequestBody Person person) { - - int nxt = ran.nextInt(10); - if (nxt >= 5) { - throw new RuntimeException("Breaking logic"); - } - return person; - } - - /** - * Find by last name list. - * - * @param lastName the last name - * @return the list - */ - @RequestMapping(path = "/personByLastName", method = RequestMethod.GET) - public List findByLastName(@RequestParam(name = "lastName", required = true) @NotNull - @NotBlank - @Size(max = 10) String lastName) { - List hardCoded = new ArrayList<>(); - Person person = new Person(); - person.setAge(20); - person.setCreditCardNumber("4111111111111111"); - person.setEmail("abc@abc.com"); - person.setEmail1("abc1@abc.com"); - person.setFirstName("Somefirstname"); - person.setLastName(lastName); - person.setId(1); - hardCoded.add(person); - return hardCoded; - - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app112/Problem.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app112/Problem.java deleted file mode 100644 index ee5127936..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app112/Problem.java +++ /dev/null @@ -1,73 +0,0 @@ -package test.org.springdoc.api.app112; - -/** - * The type Problem. - */ -class Problem { - - /** - * The Log ref. - */ - private String logRef; - - /** - * The Message. - */ - private String message; - - /** - * Instantiates a new Problem. - * - * @param logRef the log ref - * @param message the message - */ - public Problem(String logRef, String message) { - super(); - this.logRef = logRef; - this.message = message; - } - - /** - * Instantiates a new Problem. - */ - public Problem() { - super(); - - } - - /** - * Gets log ref. - * - * @return the log ref - */ - public String getLogRef() { - return logRef; - } - - /** - * Sets log ref. - * - * @param logRef the log ref - */ - public void setLogRef(String logRef) { - this.logRef = logRef; - } - - /** - * Gets message. - * - * @return the message - */ - public String getMessage() { - return message; - } - - /** - * Sets message. - * - * @param message the message - */ - public void setMessage(String message) { - this.message = message; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app112/SpringDocApp112Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app112/SpringDocApp112Test.java deleted file mode 100644 index 83cd397c3..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app112/SpringDocApp112Test.java +++ /dev/null @@ -1,45 +0,0 @@ -package test.org.springdoc.api.app112; - -import io.swagger.v3.oas.models.OpenAPI; -import io.swagger.v3.oas.models.info.Info; -import io.swagger.v3.oas.models.info.License; -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.Bean; -import org.springframework.test.context.TestPropertySource; - -/** - * The type Spring doc app 112 test. - */ -@TestPropertySource(properties = { - "application-description=description", - "application-version=v1" }) -class SpringDocApp112Test extends AbstractSpringDocTest { - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp { - - /** - * Custom open api open api. - * - * @param appDesciption the app desciption - * @param appVersion the app version - * @return the open api - */ - @Bean - public OpenAPI customOpenAPI(@Value("${application-description}") String appDesciption, @Value("${application-version}") String appVersion) { - return new OpenAPI() - .info(new Info() - .title("sample application API") - .version(appVersion) - .description(appDesciption) - .termsOfService("http://swagger.io/terms/") - .license(new License().name("Apache 2.0").url("http://springdoc.org"))); - } - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app112/sample/PersonController2.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app112/sample/PersonController2.java deleted file mode 100644 index 99c5556a1..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app112/sample/PersonController2.java +++ /dev/null @@ -1,71 +0,0 @@ -package test.org.springdoc.api.app112.sample; - -import java.util.ArrayList; -import java.util.List; -import java.util.Random; - -import jakarta.validation.Valid; -import jakarta.validation.constraints.NotBlank; -import jakarta.validation.constraints.NotNull; -import jakarta.validation.constraints.Size; -import test.org.springdoc.api.app112.Person; - -import org.springframework.validation.annotation.Validated; -import org.springframework.web.HttpMediaTypeNotSupportedException; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -/** - * The type Person controller 2. - */ -@RestController -@Validated -class PersonController2 { - /** - * The Ran. - */ - private Random ran = new Random(); - - /** - * Person person. - * - * @param person the person - * @return the person - */ - @RequestMapping(path = "/person2", method = RequestMethod.POST) - public Person person(@Valid @RequestBody Person person) throws HttpMediaTypeNotSupportedException { - - int nxt = ran.nextInt(10); - if (nxt >= 5) { - throw new RuntimeException("Breaking logic"); - } - return person; - } - - /** - * Find by last name list. - * - * @param lastName the last name - * @return the list - */ - @RequestMapping(path = "/personByLastName2", method = RequestMethod.GET) - public List findByLastName(@RequestParam(name = "lastName", required = true) @NotNull - @NotBlank - @Size(max = 10) String lastName) throws HttpMediaTypeNotSupportedException { - List hardCoded = new ArrayList<>(); - Person person = new Person(); - person.setAge(20); - person.setCreditCardNumber("4111111111111111"); - person.setEmail("abc@abc.com"); - person.setEmail1("abc1@abc.com"); - person.setFirstName("Somefirstname"); - person.setLastName(lastName); - person.setId(1); - hardCoded.add(person); - return hardCoded; - - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app113/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app113/HelloController.java deleted file mode 100644 index 9ae9acdcf..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app113/HelloController.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app113; - -import java.util.Optional; - -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RestController; - -/** - * The type Hello controller. - */ -@RestController -class HelloController { - - /** - * Test. - * - * @param body the body - */ - @PostMapping("/lol") - public void test(@RequestBody(required = false) Body body) { - } - - /** - * Test 2. - * - * @param body the body - */ - @PostMapping("/lol2") - public void test2(@RequestBody Optional body) { - } - - /** - * The type Body. - */ - class Body { - /** - * The Field. - */ - public String field; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app113/SpringDocApp113Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app113/SpringDocApp113Test.java deleted file mode 100644 index 12bdcb85c..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app113/SpringDocApp113Test.java +++ /dev/null @@ -1,18 +0,0 @@ -package test.org.springdoc.api.app113; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - - -/** - * The type Spring doc app 113 test. - */ -class SpringDocApp113Test extends AbstractSpringDocTest { - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app114/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app114/HelloController.java deleted file mode 100644 index cc51c4e91..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app114/HelloController.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app114; - -import javax.money.MonetaryAmount; - -import com.fasterxml.jackson.annotation.JsonProperty; - -import org.springframework.http.MediaType; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RestController; - -/** - * The type Hello controller. - */ -@RestController -class HelloController { - - /** - * Gets currency. - * - * @param carDTO the car dto - * @return the currency - */ - @PostMapping(value = "/foos1", consumes = MediaType.APPLICATION_JSON_VALUE) - MonetaryAmount getCurrency(@RequestBody CarDTO carDTO) { - return carDTO.price; - } - - /** - * The type Car dto. - */ - class CarDTO { - /** - * The Price. - */ - @JsonProperty("price") - MonetaryAmount price; - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app114/SpringDocApp114Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app114/SpringDocApp114Test.java deleted file mode 100644 index 1f1fa7634..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app114/SpringDocApp114Test.java +++ /dev/null @@ -1,25 +0,0 @@ -package test.org.springdoc.api.app114; - -import javax.money.MonetaryAmount; - -import org.springdoc.core.utils.SpringDocUtils; -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - - -/** - * The type Spring doc app 114 test. - */ -class SpringDocApp114Test extends AbstractSpringDocTest { - - static { - SpringDocUtils.getConfig().replaceWithClass(MonetaryAmount.class, org.springdoc.core.converters.models.MonetaryAmount.class); - } - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app115/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app115/HelloController.java deleted file mode 100644 index 63f6a4f38..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app115/HelloController.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app115; - -import java.time.Duration; - -import org.springframework.http.MediaType; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * The type Hello controller. - */ -@RestController -class HelloController { - - /** - * Timeouts duration. - * - * @return the duration - */ - @GetMapping(value = "/api/v2/timeout", - consumes = { MediaType.ALL_VALUE }, - produces = { MediaType.APPLICATION_JSON_VALUE }) - public Duration timeouts() { - return Duration.ofSeconds(5); - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app115/JavaTimeOperationCustomizer.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app115/JavaTimeOperationCustomizer.java deleted file mode 100644 index 5295dcced..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app115/JavaTimeOperationCustomizer.java +++ /dev/null @@ -1,42 +0,0 @@ -package test.org.springdoc.api.app115; - -import java.time.Duration; -import java.util.Map; - -import io.swagger.v3.oas.models.Operation; -import io.swagger.v3.oas.models.media.Content; -import io.swagger.v3.oas.models.media.Schema; -import org.springdoc.core.customizers.OperationCustomizer; - -import org.springframework.http.MediaType; -import org.springframework.stereotype.Component; -import org.springframework.web.method.HandlerMethod; - -/** - * The type Java time operation customizer. - */ -@Component -class JavaTimeOperationCustomizer implements OperationCustomizer { - /** - * Customize operation. - * - * @param operation the operation - * @param handlerMethod the handler method - * @return the operation - */ - @Override - public Operation customize(Operation operation, HandlerMethod handlerMethod) { - if (handlerMethod.getReturnType().getParameterType().isAssignableFrom(Duration.class)) { - for (Map.Entry entry : operation.getResponses().entrySet()) { - io.swagger.v3.oas.models.responses.ApiResponse response = entry.getValue(); - Content content = response.getContent(); - if (content.containsKey(MediaType.APPLICATION_JSON_VALUE)) { - Schema schema = content.get(MediaType.APPLICATION_JSON_VALUE).getSchema(); - schema.getProperties().clear(); - schema.setType("string"); - } - } - } - return operation; - } -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app115/SpringDocApp115Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app115/SpringDocApp115Test.java deleted file mode 100644 index 745e9d73e..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app115/SpringDocApp115Test.java +++ /dev/null @@ -1,19 +0,0 @@ -package test.org.springdoc.api.app115; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - - -/** - * The type Spring doc app 115 test. - */ -class SpringDocApp115Test extends AbstractSpringDocTest { - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app116/FooErrorHandler.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app116/FooErrorHandler.java deleted file mode 100644 index 01be608ce..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app116/FooErrorHandler.java +++ /dev/null @@ -1,24 +0,0 @@ -package test.org.springdoc.api.app116; - -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.ControllerAdvice; -import org.springframework.web.bind.annotation.ExceptionHandler; - -/** - * The type Foo error handler. - */ -@ControllerAdvice(assignableTypes = HelloController.class) -class FooErrorHandler { - - /** - * Store assignment publishing error response entity. - * - * @param e the e - * @return the response entity - */ - @ExceptionHandler - public ResponseEntity storeAssignmentPublishingError(Exception e) { - return new ResponseEntity<>("foo", HttpStatus.INTERNAL_SERVER_ERROR); - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app116/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app116/HelloController.java deleted file mode 100644 index 22d268c45..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app116/HelloController.java +++ /dev/null @@ -1,32 +0,0 @@ -package test.org.springdoc.api.app116; - -import io.swagger.v3.oas.annotations.OpenAPIDefinition; -import io.swagger.v3.oas.annotations.info.Info; -import io.swagger.v3.oas.annotations.tags.Tag; - -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * The type Hello controller. - */ -@RestController -@RequestMapping("/api") -@OpenAPIDefinition(info = @Info(title = "API Examples", version = "1.0"), tags = @Tag(name = "Operations")) -class HelloController { - - /** - * Create string. - * - * @param foo the foo - * @return the string - */ - @PostMapping("/foo") - public String create(@RequestBody String foo) { - return "foo"; - } -} - - diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app116/SpringDocApp116Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app116/SpringDocApp116Test.java deleted file mode 100644 index dce40d52b..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app116/SpringDocApp116Test.java +++ /dev/null @@ -1,19 +0,0 @@ -package test.org.springdoc.api.app116; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - - -/** - * The type Spring doc app 116 test. - */ -class SpringDocApp116Test extends AbstractSpringDocTest { - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app117/HelloApplication.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app117/HelloApplication.java deleted file mode 100644 index 3a8e2ec50..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app117/HelloApplication.java +++ /dev/null @@ -1,278 +0,0 @@ -package test.org.springdoc.api.app117; - -import java.io.IOException; -import java.net.URI; -import java.util.HashSet; -import java.util.Set; -import java.util.concurrent.atomic.AtomicLong; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.enums.ParameterIn; -import jakarta.servlet.FilterChain; -import jakarta.servlet.GenericFilter; -import jakarta.servlet.ServletException; -import jakarta.servlet.ServletRequest; -import jakarta.servlet.ServletResponse; -import org.springdoc.core.annotations.RouterOperation; -import org.springdoc.core.annotations.RouterOperations; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.stereotype.Component; -import org.springframework.stereotype.Service; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RestController; -import org.springframework.web.servlet.function.RouterFunction; -import org.springframework.web.servlet.function.ServerRequest; -import org.springframework.web.servlet.function.ServerResponse; - -import static org.springframework.web.servlet.function.RouterFunctions.route; -import static org.springframework.web.servlet.function.ServerResponse.ok; - -/** - * The type Hello application. - */ -@Configuration -class HelloApplication { - - /** - * Routes router function. - * - * @param ph the ph - * @return the router function - */ - @Bean - @RouterOperations({ @RouterOperation(path = "/people", method = RequestMethod.GET, beanClass = PersonService.class, beanMethod = "all"), - @RouterOperation(path = "/people/{id}", beanClass = PersonService.class, beanMethod = "byId"), - @RouterOperation(path = "/people", method = RequestMethod.POST, beanClass = PersonService.class, beanMethod = "save") }) - RouterFunction routes(PersonHandler ph) { - String root = ""; - return route() - .GET(root + "/people", ph::handleGetAllPeople) - .GET(root + "/people/{id}", ph::handleGetPersonById) - .POST(root + "/people", ph::handlePostPerson) - .filter((serverRequest, handlerFunction) -> { - return handlerFunction.handle(serverRequest); - }) - .build(); - } -} - -/** - * The type Simple filter. - */ -@Component -class SimpleFilter extends GenericFilter { - - /** - * Do filter. - * - * @param req the req - * @param res the res - * @param filterChain the filter chain - * @throws IOException the io exception - * @throws ServletException the servlet exception - */ - @Override - public void doFilter(ServletRequest req, ServletResponse res, - FilterChain filterChain) throws IOException, ServletException { - filterChain.doFilter(req, res); - } -} - -/** - * The type Person handler. - */ -@Component -class PersonHandler { - - /** - * The Person service. - */ - private final PersonService personService; - - /** - * Instantiates a new Person handler. - * - * @param personService the person service - */ - PersonHandler(PersonService personService) { - this.personService = personService; - } - - /** - * Handle get all people server response. - * - * @param serverRequest the server request - * @return the server response - */ - ServerResponse handleGetAllPeople(ServerRequest serverRequest) { - return ok().body(personService.all()); - } - - /** - * Handle post person server response. - * - * @param r the r - * @return the server response - * @throws ServletException the servlet exception - * @throws IOException the io exception - */ - ServerResponse handlePostPerson(ServerRequest r) throws ServletException, IOException { - Person result = personService.save(new Person(null, r.body(Person.class).getName())); - URI uri = URI.create("/people/" + result.getId()); - return ServerResponse.created(uri).body(result); - } - - /** - * Handle get person by id server response. - * - * @param r the r - * @return the server response - */ - ServerResponse handleGetPersonById(ServerRequest r) { - return ok().body(personService.byId(Long.parseLong(r.pathVariable("id")))); - } -} - -/** - * The type Greetings rest controller. - */ -@RestController -class GreetingsRestController { - - /** - * Greet string. - * - * @param name the name - * @return the string - */ - @GetMapping("/greet/{name}") - String greet(@PathVariable String name) { - return "hello " + name + "!"; - } -} - -/** - * The type Person service. - */ -@Service -class PersonService { - - /** - * The Counter. - */ - private final AtomicLong counter = new AtomicLong(); - - /** - * The People. - */ - private final Set people = Stream.of( - new Person(counter.incrementAndGet(), "Jane"), - new Person(counter.incrementAndGet(), "Josh"), - new Person(counter.incrementAndGet(), "Gordon")) - .collect(Collectors.toCollection(HashSet::new)); - - - /** - * Save person. - * - * @param p the p - * @return the person - */ - Person save(Person p) { - Person person = new Person(counter.incrementAndGet(), p.getName()); - this.people.add(person); - return person; - } - - /** - * All set. - * - * @return the set - */ - Set all() { - return this.people; - } - - /** - * By id person. - * - * @param id the id - * @return the person - */ - Person byId(@Parameter(in = ParameterIn.PATH) Long id) { - return this.people.stream() - .filter(p -> p.getId().equals(id)) - .findFirst() - .orElseThrow(() -> new IllegalArgumentException("no " + Person.class.getName() + " with that ID found!")); - } - -} - -/** - * The type Person. - */ -class Person { - - /** - * The Id. - */ - private Long id; - - /** - * The Name. - */ - private String name; - - /** - * Instantiates a new Person. - * - * @param id the id - * @param name the name - */ - public Person(Long id, String name) { - this.id = id; - this.name = name; - } - - /** - * Gets id. - * - * @return the id - */ - public Long getId() { - return id; - } - - /** - * Sets id. - * - * @param id the id - */ - public void setId(Long id) { - this.id = id; - } - - /** - * Gets name. - * - * @return the name - */ - public String getName() { - return name; - } - - /** - * Sets name. - * - * @param name the name - */ - public void setName(String name) { - this.name = name; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app117/SpringDocApp117Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app117/SpringDocApp117Test.java deleted file mode 100644 index 4841fba3c..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app117/SpringDocApp117Test.java +++ /dev/null @@ -1,18 +0,0 @@ -package test.org.springdoc.api.app117; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - - -/** - * The type Spring doc app 117 test. - */ -class SpringDocApp117Test extends AbstractSpringDocTest { - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app118/AbstractParent.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app118/AbstractParent.java deleted file mode 100644 index 16a07c0a6..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app118/AbstractParent.java +++ /dev/null @@ -1,95 +0,0 @@ -package test.org.springdoc.api.app118; - -import com.fasterxml.jackson.annotation.JsonSubTypes; -import com.fasterxml.jackson.annotation.JsonSubTypes.Type; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.JsonTypeInfo.Id; - -/** - * The type Abstract parent. - */ -@JsonTypeInfo(use = Id.NAME, property = "type") -@JsonSubTypes({ - @Type(ChildOfAbstract1.class), - @Type(ChildOfAbstract2.class) -}) -public abstract class AbstractParent { - /** - * The Id. - */ - private int id; - - /** - * Gets id. - * - * @return the id - */ - public int getId() { - return id; - } - - /** - * Sets id. - * - * @param id the id - */ - public void setId(int id) { - this.id = id; - } -} - -/** - * The type Child of abstract 1. - */ -class ChildOfAbstract1 extends AbstractParent { - /** - * The Abstrach child 1 param. - */ - private String abstrachChild1Param; - - /** - * Gets abstrach child 1 param. - * - * @return the abstrach child 1 param - */ - public String getAbstrachChild1Param() { - return abstrachChild1Param; - } - - /** - * Sets abstrach child 1 param. - * - * @param abstrachChild1Param the abstrach child 1 param - */ - public void setAbstrachChild1Param(String abstrachChild1Param) { - this.abstrachChild1Param = abstrachChild1Param; - } -} - -/** - * The type Child of abstract 2. - */ -class ChildOfAbstract2 extends AbstractParent { - /** - * The Abstract child 2 param. - */ - private String abstractChild2Param; - - /** - * Gets abstract child 2 param. - * - * @return the abstract child 2 param - */ - public String getAbstractChild2Param() { - return abstractChild2Param; - } - - /** - * Sets abstract child 2 param. - * - * @param abstractChild2Param the abstract child 2 param - */ - public void setAbstractChild2Param(String abstractChild2Param) { - this.abstractChild2Param = abstractChild2Param; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app118/ConcreteParent.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app118/ConcreteParent.java deleted file mode 100644 index 5355669b9..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app118/ConcreteParent.java +++ /dev/null @@ -1,95 +0,0 @@ -package test.org.springdoc.api.app118; - -import com.fasterxml.jackson.annotation.JsonSubTypes; -import com.fasterxml.jackson.annotation.JsonSubTypes.Type; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import com.fasterxml.jackson.annotation.JsonTypeInfo.Id; - -/** - * The type Concrete parent. - */ -@JsonTypeInfo(use = Id.NAME, property = "type") -@JsonSubTypes({ - @Type(ChildOfConcrete1.class), - @Type(ChildOfConcrete2.class) -}) -class ConcreteParent { - /** - * The Id. - */ - private int id; - - /** - * Gets id. - * - * @return the id - */ - public int getId() { - return id; - } - - /** - * Sets id. - * - * @param id the id - */ - public void setId(int id) { - this.id = id; - } -} - -/** - * The type Child of concrete 1. - */ -class ChildOfConcrete1 extends ConcreteParent { - /** - * The Concrete child 1 param. - */ - private String concreteChild1Param; - - /** - * Gets concrete child 1 param. - * - * @return the concrete child 1 param - */ - public String getConcreteChild1Param() { - return concreteChild1Param; - } - - /** - * Sets concrete child 1 param. - * - * @param concreteChild1Param the concrete child 1 param - */ - public void setConcreteChild1Param(String concreteChild1Param) { - this.concreteChild1Param = concreteChild1Param; - } -} - -/** - * The type Child of concrete 2. - */ -class ChildOfConcrete2 extends ConcreteParent { - /** - * The Concrete child 2 param. - */ - private String concreteChild2Param; - - /** - * Gets concrete child 2 param. - * - * @return the concrete child 2 param - */ - public String getConcreteChild2Param() { - return concreteChild2Param; - } - - /** - * Sets concrete child 2 param. - * - * @param concreteChild2Param the concrete child 2 param - */ - public void setConcreteChild2Param(String concreteChild2Param) { - this.concreteChild2Param = concreteChild2Param; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app118/Controller.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app118/Controller.java deleted file mode 100644 index 34f86e513..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app118/Controller.java +++ /dev/null @@ -1,88 +0,0 @@ -package test.org.springdoc.api.app118; - -import java.util.List; - -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * The type Controller. - */ -@RestController -@RequestMapping("class-hierarchy") -class Controller { - /** - * Abstract parent response. - * - * @param payload the payload - * @return the response - */ - @PostMapping("abstract-parent") - public Response abstractParent(@RequestBody AbstractParent payload) { - return null; - } - - /** - * Concrete parent response. - * - * @param payload the payload - * @return the response - */ - @PostMapping("concrete-parent") - public Response concreteParent(@RequestBody ConcreteParent payload) { - return null; - } -} - -/** - * The type Response. - */ -class Response { - /** - * The Abstract parent. - */ - AbstractParent abstractParent; - - /** - * The Concrete parents. - */ - List concreteParents; - - /** - * Gets abstract parent. - * - * @return the abstract parent - */ - public AbstractParent getAbstractParent() { - return abstractParent; - } - - /** - * Sets abstract parent. - * - * @param abstractParent the abstract parent - */ - public void setAbstractParent(AbstractParent abstractParent) { - this.abstractParent = abstractParent; - } - - /** - * Gets concrete parents. - * - * @return the concrete parents - */ - public List getConcreteParents() { - return concreteParents; - } - - /** - * Sets concrete parents. - * - * @param concreteParents the concrete parents - */ - public void setConcreteParents(List concreteParents) { - this.concreteParents = concreteParents; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app118/SpringDocApp118Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app118/SpringDocApp118Test.java deleted file mode 100644 index 57c55ff5b..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app118/SpringDocApp118Test.java +++ /dev/null @@ -1,18 +0,0 @@ -package test.org.springdoc.api.app118; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - - -/** - * The type Spring doc app 118 test. - */ -class SpringDocApp118Test extends AbstractSpringDocTest { - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app119/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app119/HelloController.java deleted file mode 100644 index 66b0b2568..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app119/HelloController.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app119; - -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.media.Content; - -import org.springframework.http.MediaType; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestPart; -import org.springframework.web.bind.annotation.RestController; -import org.springframework.web.multipart.MultipartFile; - -/** - * The type Hello controller. - */ -@RestController -class HelloController { - - /** - * Multi files in multi part string. - * - * @param jsonRequest the json request - * @param file1 the file 1 - * @param file2 the file 2 - * @return the string - */ - @Operation(summary = "Multiple files and JSON payloads as multi part request") - @PostMapping( - value = "multi", - consumes = MediaType.MULTIPART_FORM_DATA_VALUE, - produces = MediaType.TEXT_PLAIN_VALUE) - public String multiFilesInMultiPart( - @RequestPart("params") - @Parameter( - description = "This is the configuration", - content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE)) final JsonRequest jsonRequest, - @RequestPart(value = "file1", required = false) @Parameter(description = "This is file1") final MultipartFile file1, - @RequestPart(value = "file2", required = false) @Parameter(description = "This is file2") final MultipartFile file2) { - return "Hello World " + jsonRequest.getName(); - } -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app119/JsonRequest.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app119/JsonRequest.java deleted file mode 100644 index 5f0baf0b1..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app119/JsonRequest.java +++ /dev/null @@ -1,30 +0,0 @@ -package test.org.springdoc.api.app119; - -/** - * The type Json request. - */ -class JsonRequest { - - /** - * The Name. - */ - private String name; - - /** - * Gets name. - * - * @return the name - */ - public String getName() { - return name; - } - - /** - * Sets name. - * - * @param name the name - */ - public void setName(String name) { - this.name = name; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app119/SpringDocApp119Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app119/SpringDocApp119Test.java deleted file mode 100644 index cf9ae5ca3..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app119/SpringDocApp119Test.java +++ /dev/null @@ -1,18 +0,0 @@ -package test.org.springdoc.api.app119; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - - -/** - * The type Spring doc app 119 test. - */ -class SpringDocApp119Test extends AbstractSpringDocTest { - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app12/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app12/HelloController.java deleted file mode 100644 index b5ccfec4e..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app12/HelloController.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app12; - -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.enums.ParameterIn; -import io.swagger.v3.oas.annotations.media.Schema; - -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * The type Hello controller. - */ -@RestController -class HelloController { - - /** - * Persons string. - * - * @return the string - */ - @GetMapping(value = "/persons") - @Operation(parameters = { - @Parameter(name = "name", in = ParameterIn.QUERY, schema = @Schema(implementation = String.class)) }) - public String persons() { - return "OK"; - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app12/SpringDocApp12Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app12/SpringDocApp12Test.java deleted file mode 100644 index 65ee8b3e9..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app12/SpringDocApp12Test.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app12; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * The type Spring doc app 12 test. - */ -class SpringDocApp12Test extends AbstractSpringDocTest { - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app120/AccountId.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app120/AccountId.java deleted file mode 100644 index e749a5d29..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app120/AccountId.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app120; - -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.enums.ParameterIn; -import io.swagger.v3.oas.annotations.media.Schema; - -import org.springframework.core.annotation.AliasFor; - -import static java.lang.annotation.ElementType.ANNOTATION_TYPE; -import static java.lang.annotation.ElementType.METHOD; -import static java.lang.annotation.ElementType.PARAMETER; - -/** - * The interface Account id. - */ -@Target({ PARAMETER, METHOD, ANNOTATION_TYPE }) -@Retention(RetentionPolicy.RUNTIME) -@Parameter(description = "non alias description") -public @interface AccountId { - - /** - * Name string. - * - * @return the string - */ - @AliasFor(annotation = Parameter.class, value = "name") - String name() default ""; - - /** - * Example string. - * - * @return the string - */ - @AliasFor(annotation = Parameter.class, value = "example") - String example() default "123456"; - - /** - * In parameter in. - * - * @return the parameter in - */ - @AliasFor(annotation = Parameter.class, value = "in") - ParameterIn in() default ParameterIn.DEFAULT; - - /** - * Schema schema. - * - * @return the schema - */ - @AliasFor(annotation = Parameter.class, value = "schema") - Schema schema() default @Schema(); -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app120/MetaAnnotationController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app120/MetaAnnotationController.java deleted file mode 100644 index 811b21f62..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app120/MetaAnnotationController.java +++ /dev/null @@ -1,293 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app120; - -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.enums.Explode; -import io.swagger.v3.oas.annotations.enums.ParameterIn; -import io.swagger.v3.oas.annotations.enums.ParameterStyle; -import io.swagger.v3.oas.annotations.extensions.Extension; -import io.swagger.v3.oas.annotations.media.ArraySchema; -import io.swagger.v3.oas.annotations.media.Content; -import io.swagger.v3.oas.annotations.media.ExampleObject; -import io.swagger.v3.oas.annotations.media.Schema; - -import org.springframework.core.annotation.AliasFor; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -import static java.lang.annotation.ElementType.ANNOTATION_TYPE; -import static java.lang.annotation.ElementType.METHOD; -import static java.lang.annotation.ElementType.PARAMETER; - -/** - * The type Meta annotation controller. - */ -@RestController -class MetaAnnotationController { - - /** - * Simple test string. - * - * @param accountId the account id - * @return the string - */ - @GetMapping(value = "/simpleTest/{accountId}") - String simpleTest(@PathVariable @AccountId String accountId) { - return accountId; - } - - /** - * When there is a top level {@code @Parameter} annotation it has precedence over the meta-annotation - * So the id parameter should have all the defaults, with a name of "id" - * @param accountId the account id - * @return the string - */ - @GetMapping(value = "/testTopLevelParamAnnotationOverrides/{id}") - String testTopLevelParamAnnotationOverrides(@PathVariable @AccountId @Parameter(name = "id") String accountId) { - return accountId; - } - - /** - * Test query param string. - * - * @param accountId the account id - * @return the string - */ - @GetMapping(value = "/testQueryParam") - String testQueryParam(@RequestParam @AccountId String accountId) { - return accountId; - } - - /** - * {@code @AliasFor} in the {@code @AccountId} annotation allows us to override the default it provides. - * @param accountId the account id - * @return the string - */ - @GetMapping(value = "/testAliasFor") - String testAliasFor(@RequestParam @AccountId(example = "OVERRIDDEN EXAMPLE") String accountId) { - return accountId; - } - - /** - * Test meta meta annotation string. - * - * @param queryAccountId the query account id - * @param accountId the account id - * @return the string - */ - @GetMapping(value = "/testMetaMetaAnnotation/{accountId}") - String testMetaMetaAnnotation( - @RequestParam @QueryAccountId String queryAccountId, - @PathVariable @AccountId String accountId) { - return accountId; - } - - /** - * Test all attributes as alias string. - * - * @param name the name - * @return the string - */ - @GetMapping(value = "/testAllAttributesAsAlias/") - String testAllAttributesAsAlias( - @RequestParam @TestAllAttributesAsAlias String name) { - return name; - } - - /** - * Test no alias fors string. - * - * @param name the name - * @return the string - */ - @GetMapping(value = "/testNoAliasFors/") - String testNoAliasFors( - @RequestParam @TestAllAttributesAsAlias String name) { - return name; - } - - /** - * This should inherent all the attributes of {@code @AccountId}, but give it a different name - */ - @Target({ PARAMETER, METHOD, ANNOTATION_TYPE }) - @Retention(RetentionPolicy.RUNTIME) - @AccountId(name = "queryAccountId") - @interface QueryAccountId { - } - - /** - * The interface Test all attributes as alias. - */ - @Target({ PARAMETER, METHOD, ANNOTATION_TYPE }) - @Retention(RetentionPolicy.RUNTIME) - @Parameter - @interface TestAllAttributesAsAlias { - - /** - * Name string. - * - * @return the string - */ - @AliasFor(annotation = Parameter.class, attribute = "name") - String name() default "name"; - - /** - * In parameter in. - * - * @return the parameter in - */ - @AliasFor(annotation = Parameter.class, attribute = "in") - ParameterIn in() default ParameterIn.QUERY; - - /** - * Description string. - * - * @return the string - */ - @AliasFor(annotation = Parameter.class, attribute = "description") - String description() default "desc"; - - /** - * Required boolean. - * - * @return the boolean - */ - @AliasFor(annotation = Parameter.class, attribute = "required") - boolean required() default true; - - /** - * Deprecated boolean. - * - * @return the boolean - */ - @AliasFor(annotation = Parameter.class, attribute = "deprecated") - boolean deprecated() default true; - - /** - * Allow empty value boolean. - * - * @return the boolean - */ - @AliasFor(annotation = Parameter.class, attribute = "allowEmptyValue") - boolean allowEmptyValue() default true; - - /** - * Style parameter style. - * - * @return the parameter style - */ - @AliasFor(annotation = Parameter.class, attribute = "style") - ParameterStyle style() default ParameterStyle.DEEPOBJECT; - - /** - * Explode explode. - * - * @return the explode - */ - @AliasFor(annotation = Parameter.class, attribute = "explode") - Explode explode() default Explode.TRUE; - - /** - * Allow reserved boolean. - * - * @return the boolean - */ - @AliasFor(annotation = Parameter.class, attribute = "allowReserved") - boolean allowReserved() default true; - - /** - * Schema schema. - * - * @return the schema - */ - @AliasFor(annotation = Parameter.class, attribute = "schema") - Schema schema() default @Schema(name = "special schema", implementation = Boolean.class); - - /** - * Array array schema. - * - * @return the array schema - */ - @AliasFor(annotation = Parameter.class, attribute = "array") - ArraySchema array() default @ArraySchema(); - - /** - * Content content [ ]. - * - * @return the content [ ] - */ - @AliasFor(annotation = Parameter.class, attribute = "content") - Content[] content() default {}; - - /** - * Hidden boolean. - * - * @return the boolean - */ - @AliasFor(annotation = Parameter.class, attribute = "hidden") - boolean hidden() default false; - - /** - * Examples example object [ ]. - * - * @return the example object [ ] - */ - @AliasFor(annotation = Parameter.class, attribute = "examples") - ExampleObject[] examples() default {}; - - /** - * Example string. - * - * @return the string - */ - @AliasFor(annotation = Parameter.class, attribute = "example") - String example() default "1234"; - - /** - * Extensions extension [ ]. - * - * @return the extension [ ] - */ - @AliasFor(annotation = Parameter.class, attribute = "extensions") - Extension[] extensions() default {}; - - /** - * Ref string. - * - * @return the string - */ - @AliasFor(annotation = Parameter.class, attribute = "ref") - String ref() default ""; - } - - /** - * The interface Test no alias fors. - */ - @Target({ PARAMETER, METHOD, ANNOTATION_TYPE }) - @Retention(RetentionPolicy.RUNTIME) - @Parameter(name = "name", description = "desc", schema = @Schema(implementation = Boolean.class)) - @interface TestNoAliasFors { - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app120/SpringDocApp120Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app120/SpringDocApp120Test.java deleted file mode 100644 index 1302ab5fc..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app120/SpringDocApp120Test.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app120; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - - -/** - * Tests Spring meta-annotations as method parameters - */ -class SpringDocApp120Test extends AbstractSpringDocTest { - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app121/InheritedRequestParams.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app121/InheritedRequestParams.java deleted file mode 100644 index ae7ba5a49..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app121/InheritedRequestParams.java +++ /dev/null @@ -1,33 +0,0 @@ -package test.org.springdoc.api.app121; - -import jakarta.validation.constraints.NotBlank; - -/** - * The type Inherited request params. - */ -class InheritedRequestParams extends RequestParams { - - /** - * parameter from child of RequestParams - */ - @NotBlank - private String childParam; - - /** - * Gets child param. - * - * @return the child param - */ - public String getChildParam() { - return childParam; - } - - /** - * Sets child param. - * - * @param childParam the child param - */ - public void setChildParam(String childParam) { - this.childParam = childParam; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app121/RequestParams.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app121/RequestParams.java deleted file mode 100644 index 42c96a2ec..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app121/RequestParams.java +++ /dev/null @@ -1,255 +0,0 @@ -package test.org.springdoc.api.app121; - -import java.math.BigInteger; -import java.util.List; -import java.util.Optional; - -import io.swagger.v3.oas.annotations.Parameter; - - -/** - * The type Request params. - */ -class RequestParams { - - /** - * The String param. - */ - @Parameter(description = "string parameter") - private String stringParam; - - /** - * The String param 1. - */ - @Deprecated - private String stringParam1; - - /** - * The String param 2. - */ - @Parameter(description = "string parameter2", required = true) - private String stringParam2; - - /** - * The Int param. - */ - @Parameter(description = "int parameter") - private int intParam; - - /** - * The Int param 2. - */ - private Optional intParam2; - - /** - * The Int param 3. - */ - private String intParam3; - - /** - * The Nested. - */ - private Nested nested; - - /** - * The Nested list. - */ - private List nestedList; - - /** - * Gets string param. - * - * @return the string param - */ - public String getStringParam() { - return stringParam; - } - - /** - * Sets string param. - * - * @param stringParam the string param - */ - public void setStringParam(String stringParam) { - this.stringParam = stringParam; - } - - /** - * Gets int param. - * - * @return the int param - */ - public int getIntParam() { - return intParam; - } - - /** - * Sets int param. - * - * @param intParam the int param - */ - public void setIntParam(int intParam) { - this.intParam = intParam; - } - - /** - * Gets int param 2. - * - * @return the int param 2 - */ - public Optional getIntParam2() { - return intParam2; - } - - /** - * Sets int param 2. - * - * @param intParam2 the int param 2 - */ - public void setIntParam2(Optional intParam2) { - this.intParam2 = intParam2; - } - - /** - * Gets int param 3. - * - * @return the int param 3 - */ - public String getIntParam3() { - return intParam3; - } - - /** - * Sets int param 3. - * - * @param intParam3 the int param 3 - */ - public void setIntParam3(String intParam3) { - this.intParam3 = intParam3; - } - - /** - * Gets string param 1. - * - * @return the string param 1 - */ - public String getStringParam1() { - return stringParam1; - } - - /** - * Sets string param 1. - * - * @param stringParam1 the string param 1 - */ - public void setStringParam1(String stringParam1) { - this.stringParam1 = stringParam1; - } - - /** - * Gets string param 2. - * - * @return the string param 2 - */ - public String getStringParam2() { - return stringParam2; - } - - /** - * Sets string param 2. - * - * @param stringParam2 the string param 2 - */ - public void setStringParam2(String stringParam2) { - this.stringParam2 = stringParam2; - } - - /** - * Gets nested. - * - * @return the nested - */ - public Nested getNested() { - return nested; - } - - /** - * Sets nested. - * - * @param nested the nested - */ - public void setNested(Nested nested) { - this.nested = nested; - } - - /** - * Gets nested list. - * - * @return the nested list - */ - public List getNestedList() { - return nestedList; - } - - /** - * Sets nested list. - * - * @param nestedList the nested list - */ - public void setNestedList(List nestedList) { - this.nestedList = nestedList; - } - - /** - * The type Nested. - */ - public static class Nested { - /** - * The Param 1. - */ - private String param1; - - /** - * The Param 2. - */ - private BigInteger param2; - - /** - * Gets param 1. - * - * @return the param 1 - */ - @Parameter(description = "nested string parameter") - public String getParam1() { - return param1; - } - - /** - * Sets param 1. - * - * @param param1 the param 1 - */ - public void setParam1(String param1) { - this.param1 = param1; - } - - /** - * Gets param 2. - * - * @return the param 2 - */ - @Parameter(description = "nested BigInteger parameter") - public BigInteger getParam2() { - return param2; - } - - /** - * Sets param 2. - * - * @param param2 the param 2 - */ - public void setParam2(BigInteger param2) { - this.param2 = param2; - } - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app121/SpringDocApp121Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app121/SpringDocApp121Test.java deleted file mode 100644 index c67567556..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app121/SpringDocApp121Test.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * - * * - * * * - * * * * Copyright 2019-2020 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.app121; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - - -/** - * Tests Spring meta-annotations as method parameters - */ -class SpringDocApp121Test extends AbstractSpringDocTest { - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app121/TestController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app121/TestController.java deleted file mode 100644 index da5c4470f..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app121/TestController.java +++ /dev/null @@ -1,26 +0,0 @@ -package test.org.springdoc.api.app121; - -import org.springdoc.core.annotations.ParameterObject; - -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -/** - * The type Test controller. - */ -@RestController -class TestController { - - /** - * Gets test. - * - * @param param the param - * @param requestParams the request params - * @return the test - */ - @PostMapping("test") - public InheritedRequestParams getTest(@RequestParam String param, @ParameterObject InheritedRequestParams requestParams) { - return requestParams; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app122/BaseController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app122/BaseController.java deleted file mode 100644 index 71c93a12d..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app122/BaseController.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * - * * - * * * - * * * * Copyright 2019-2020 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.app122; - -import io.swagger.v3.oas.annotations.Operation; - -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RestController; - -/** - * The type Base controller. - * - * @param the type parameter - */ -@RestController -public abstract class BaseController { - - /** - * Create response entity. - * - * @param payload the payload - * @return the response entity - */ - @PostMapping - @Operation(summary = "create") - public ResponseEntity create(@RequestBody Wrapper payload) { - return null; - } -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app122/BaseObject.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app122/BaseObject.java deleted file mode 100644 index 3623d55d7..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app122/BaseObject.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * - * * - * * * - * * * * Copyright 2019-2020 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.app122; - -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * The type Base object. - */ -class BaseObject { - - /** - * The Base str. - */ - @JsonProperty("baseStr") - private String baseStr; -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app122/CustomerDto.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app122/CustomerDto.java deleted file mode 100644 index b7f53ca04..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app122/CustomerDto.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * - * * - * * * - * * * * Copyright 2019-2020 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.app122; - -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * The type Customer dto. - */ -class CustomerDto extends BaseObject { - - /** - * The Customer name. - */ - @JsonProperty("customerName") - private String customerName; -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app122/FirstController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app122/FirstController.java deleted file mode 100644 index 05cb73f9d..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app122/FirstController.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * - * * - * * * - * * * * Copyright 2019-2020 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.app122; - -import io.swagger.v3.oas.annotations.tags.Tag; - -import org.springframework.web.bind.annotation.RestController; - -/** - * The type First controller. - */ -@RestController -@Tag(name = "example") -class FirstController extends BaseController { - -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app122/SpringDocApp122Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app122/SpringDocApp122Test.java deleted file mode 100644 index 580a8447d..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app122/SpringDocApp122Test.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * - * * - * * * - * * * * Copyright 2019-2020 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.app122; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - - -/** - * Tests Spring meta-annotations as method parameters - */ -class SpringDocApp122Test extends AbstractSpringDocTest { - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app122/Wrapper.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app122/Wrapper.java deleted file mode 100644 index 9912cc1a3..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app122/Wrapper.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * - * * - * * * - * * * * Copyright 2019-2020 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.app122; - -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * The type Wrapper. - * - * @param the type parameter - */ -class Wrapper { - - - /** - * The Wrapper. - */ - @JsonProperty("wrapper") - private String wrapper; - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app123/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app123/HelloController.java deleted file mode 100644 index 9b2f80143..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app123/HelloController.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app123; - -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.responses.ApiResponse; - -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RestController; - -/** - * The type Hello controller. - * - * @param the type parameter - */ -@RestController -class HelloController { - - /** - * Index t. - * - * @param numTel the num tel - * @param adresse the adresse - * @return the t - */ - @GetMapping(value = "/hello/{numTelco}") - @Operation(summary = "GET Persons", responses = @ApiResponse(responseCode = "418")) - public T index(@PathVariable("numTelco") String numTel, String adresse) { - return null; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app123/MyExceptionHandler.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app123/MyExceptionHandler.java deleted file mode 100644 index 2e6942fba..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app123/MyExceptionHandler.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app123; - -import io.swagger.v3.oas.annotations.media.Content; -import io.swagger.v3.oas.annotations.responses.ApiResponse; - -import org.springframework.http.HttpStatus; -import org.springframework.web.bind.annotation.ExceptionHandler; -import org.springframework.web.bind.annotation.ResponseStatus; -import org.springframework.web.bind.annotation.RestControllerAdvice; - -/** - * The type My exception handler. - */ -@RestControllerAdvice -class MyExceptionHandler { - - /** - * Bad. - * - * @param e the e - */ - @ExceptionHandler(IllegalArgumentException.class) - @ApiResponse(responseCode = "404", description = "Not here", content = @Content) - @ResponseStatus(HttpStatus.NOT_FOUND) - public void bad(IllegalArgumentException e) { - - } - - /** - * Gateway object. - * - * @param e the e - * @return the object - */ - @ExceptionHandler(RuntimeException.class) - @ResponseStatus(HttpStatus.BAD_GATEWAY) - public Object gateway(RuntimeException e) { - return null; - } -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app123/SpringDocApp123Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app123/SpringDocApp123Test.java deleted file mode 100644 index abfe6fa0b..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app123/SpringDocApp123Test.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * - * * - * * * - * * * * Copyright 2019-2020 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.app123; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - - -/** - * Tests Spring meta-annotations as method parameters - */ -class SpringDocApp123Test extends AbstractSpringDocTest { - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app124/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app124/HelloController.java deleted file mode 100644 index 5a86bb351..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app124/HelloController.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app124; - -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.media.Content; -import io.swagger.v3.oas.annotations.responses.ApiResponse; - -import org.springframework.http.HttpStatus; -import org.springframework.web.bind.annotation.ExceptionHandler; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.ResponseStatus; -import org.springframework.web.bind.annotation.RestController; - -/** - * The type Hello controller. - * - * @param the type parameter - */ -@RestController -class HelloController { - - /** - * Bad. - * - * @param e the e - */ - @ExceptionHandler(IllegalArgumentException.class) - @ApiResponse(responseCode = "404", description = "Not here", content = @Content) - @ResponseStatus(HttpStatus.NOT_FOUND) - public void bad(IllegalArgumentException e) { - - } - - /** - * Index t. - * - * @param numTel the num tel - * @param adresse the adresse - * @return the t - */ - @GetMapping(value = "/hello/{numTelco}") - @Operation(summary = "GET Persons", responses = @ApiResponse(responseCode = "418")) - public T index(@PathVariable("numTelco") String numTel, String adresse) { - throw new IllegalArgumentException(); - - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app124/MyExceptionHandler.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app124/MyExceptionHandler.java deleted file mode 100644 index 53a315624..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app124/MyExceptionHandler.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app124; - -import org.springframework.http.HttpStatus; -import org.springframework.web.bind.annotation.ExceptionHandler; -import org.springframework.web.bind.annotation.ResponseStatus; -import org.springframework.web.bind.annotation.RestControllerAdvice; - -/** - * The type My exception handler. - */ -@RestControllerAdvice -class MyExceptionHandler { - - /** - * Gateway object. - * - * @param e the e - * @return the object - */ - @ExceptionHandler(RuntimeException.class) - @ResponseStatus(HttpStatus.BAD_GATEWAY) - public Object gateway(RuntimeException e) { - return null; - } -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app124/SpringDocApp124Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app124/SpringDocApp124Test.java deleted file mode 100644 index 91a4d1629..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app124/SpringDocApp124Test.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * - * * - * * * - * * * * Copyright 2019-2020 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.app124; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - - -/** - * Tests Spring meta-annotations as method parameters - */ -class SpringDocApp124Test extends AbstractSpringDocTest { - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app125/DeprecatedEntity.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app125/DeprecatedEntity.java deleted file mode 100644 index 023a0927d..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app125/DeprecatedEntity.java +++ /dev/null @@ -1,60 +0,0 @@ -package test.org.springdoc.api.app125; - -import io.swagger.v3.oas.annotations.media.Schema; - -/** - * The type Deprecated entity. - * @author bnasslahsen - */ -class DeprecatedEntity { - /** - * The My non deprecated field. - */ - @Schema(deprecated = false) - private String myNonDeprecatedField; - - /** - * The Mydeprecated field. - */ - @Schema(deprecated = true) - private String mydeprecatedField; - - /** - * Gets my non deprecated field. - * - * @return the my non deprecated field - */ - public String getMyNonDeprecatedField() { - return myNonDeprecatedField; - } - - /** - * Sets my non deprecated field. - * - * @param myNonDeprecatedField the my non deprecated field - * @return the my non deprecated field - */ - @Deprecated - public DeprecatedEntity setMyNonDeprecatedField(String myNonDeprecatedField) { - this.myNonDeprecatedField = myNonDeprecatedField; - return this; - } - - /** - * Gets mydeprecated field. - * - * @return the mydeprecated field - */ - public String getMydeprecatedField() { - return mydeprecatedField; - } - - /** - * Sets mydeprecated field. - * - * @param mydeprecatedField the mydeprecated field - */ - public void setMydeprecatedField(String mydeprecatedField) { - this.mydeprecatedField = mydeprecatedField; - } -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app125/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app125/HelloController.java deleted file mode 100644 index a62df822d..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app125/HelloController.java +++ /dev/null @@ -1,26 +0,0 @@ -package test.org.springdoc.api.app125; - -import jakarta.validation.constraints.NotNull; - -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * The type Hello controller. - * @author bnasslahsen - */ -@RestController -class HelloController { - - /** - * Gets all pets. - * - * @param toto the toto - * @return the all pets - */ - @GetMapping(value = "/search", produces = { "application/xml", "application/json" }) - public DeprecatedEntity getAllPets(@NotNull String toto) { - return null; - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app125/SpringDocApp125Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app125/SpringDocApp125Test.java deleted file mode 100644 index a3ee34fcf..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app125/SpringDocApp125Test.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * - * * - * * * - * * * * Copyright 2019-2020 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.app125; - -import java.util.Optional; - -import io.swagger.v3.core.converter.ModelConverter; -import io.swagger.v3.core.converter.ModelConverters; -import org.springdoc.core.converters.SchemaPropertyDeprecatingConverter; -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.test.context.TestPropertySource; - - -/** - * Tests Spring meta-annotations as method parameters - */ -@TestPropertySource(properties = "springdoc.model-converters.deprecating-converter.enabled=false") -class SpringDocApp125Test extends AbstractSpringDocTest { - - static { - Optional deprecatingConverterOptional = - ModelConverters.getInstance().getConverters() - .stream().filter(modelConverter -> modelConverter instanceof SchemaPropertyDeprecatingConverter).findAny(); - deprecatingConverterOptional.ifPresent(ModelConverters.getInstance()::removeConverter); - } - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app126/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app126/HelloController.java deleted file mode 100644 index e79a7e570..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app126/HelloController.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app126; - -import java.util.ArrayList; -import java.util.Collection; - -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.responses.ApiResponse; -import io.swagger.v3.oas.annotations.responses.ApiResponses; - -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -import static org.springframework.http.ResponseEntity.ok; - -/** - * The type Hello controller. - * - * @param the type parameter - */ -@RestController -@ApiResponses(value = { - @ApiResponse(responseCode = "401", ref = SecurityProblemResponsesConfiguration.UNAUTHORIZED_401_NO_TOKEN_RESPONSE_REF), - @ApiResponse(responseCode = "401", ref = SecurityProblemResponsesConfiguration.UNAUTHORIZED_401_BAD_TOKEN_RESPONSE_REF), - @ApiResponse(responseCode = "403", ref = SecurityProblemResponsesConfiguration.FORBIDDEN_403_RESPONSE_REF) }) -//@ApiResponses(value = { -// @ApiResponse(responseCode = "401", description = "Invalid authentication.", content = {@Content(schema = @Schema(implementation = Problem.class), mediaType = APPLICATION_PROBLEM_JSON_VALUE)}), -// @ApiResponse(responseCode = "401", description = "Invalid authentication.",content = {@Content(schema = @Schema(implementation = Problem.class), mediaType = APPLICATION_PROBLEM_JSON_VALUE)}), -// @ApiResponse(responseCode = "403", description = "Missing authorities.",content = {@Content(schema = @Schema(implementation = Problem.class), mediaType = APPLICATION_PROBLEM_JSON_VALUE)}) }) -class HelloController { - - /** - * The constant CURRENCIES. - */ - private static final Collection CURRENCIES = new ArrayList<>(); - - static { - CURRENCIES.add("EUR"); - CURRENCIES.add("USD"); - } - - /** - * Gets all currencies. - * - * @return the all currencies - */ - @GetMapping - @Operation(description = "Get all currencies", summary = "getAllCurrencies") - @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "All currencies returned") }) - public ResponseEntity> getAllCurrencies() { - return ok(CURRENCIES); - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app126/Problem.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app126/Problem.java deleted file mode 100644 index 6a9fae852..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app126/Problem.java +++ /dev/null @@ -1,79 +0,0 @@ -package test.org.springdoc.api.app126; - -import java.net.URI; -import java.util.Collections; -import java.util.Map; - -/** - * The interface Problem. - */ -public interface Problem { - - /** - * The constant DEFAULT_TYPE. - */ - URI DEFAULT_TYPE = URI.create("about:blank"); - - /** - * An absolute URI that identifies the problem type. When dereferenced, - * it SHOULD provide human-readable documentation for the problem type - * (e.g., using HTML). When this member is not present, its value is - * assumed to be "about:blank". - * - * @return an absolute URI that identifies this problem's type - */ - default URI getType() { - return DEFAULT_TYPE; - } - - /** - * A short, human-readable summary of the problem type. It SHOULD NOT - * change from occurrence to occurrence of the problem, except for - * purposes of localisation. - * - * @return a short, human-readable summary of this problem - */ - default String getTitle() { - return null; - } - - /** - * The HTTP status code generated by the origin server for this - * occurrence of the problem. - * - * @return the HTTP status code - */ - default Integer getStatus() { - return null; - } - - /** - * A human readable explanation specific to this occurrence of the problem. - * - * @return A human readable explaination of this problem - */ - default String getDetail() { - return null; - } - - /** - * An absolute URI that identifies the specific occurrence of the problem. - * It may or may not yield further information if dereferenced. - * - * @return an absolute URI that identifies this specific problem - */ - default URI getInstance() { - return null; - } - - /** - * Optional, additional attributes of the problem. Implementations can choose to ignore this in favor of concrete, - * typed fields. - * - * @return additional parameters - */ - default Map getParameters() { - return Collections.emptyMap(); - } - -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app126/SecurityProblemResponsesConfiguration.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app126/SecurityProblemResponsesConfiguration.java deleted file mode 100644 index da9a2a38c..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app126/SecurityProblemResponsesConfiguration.java +++ /dev/null @@ -1,103 +0,0 @@ -package test.org.springdoc.api.app126; - -import java.io.IOException; -import java.util.AbstractMap; -import java.util.Map; - -import io.swagger.v3.oas.models.media.Content; -import io.swagger.v3.oas.models.media.MediaType; -import io.swagger.v3.oas.models.media.Schema; -import io.swagger.v3.oas.models.responses.ApiResponse; - -import org.springframework.beans.factory.parsing.Problem; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -import static org.springframework.http.MediaType.APPLICATION_PROBLEM_JSON_VALUE; - -/** - * Configuration class defining standard OpenAPI Specification for operations - */ -@Configuration -class SecurityProblemResponsesConfiguration { - - /** - * The constant HTTP_401_NO_TOKEN. - */ - private static final String HTTP_401_NO_TOKEN = "http401NoToken"; - - /** - * The constant UNAUTHORIZED_401_NO_TOKEN_RESPONSE_REF. - */ - public static final String UNAUTHORIZED_401_NO_TOKEN_RESPONSE_REF = "#/components/responses/" + HTTP_401_NO_TOKEN; - - /** - * The constant HTTP_401_BAD_TOKEN. - */ - private static final String HTTP_401_BAD_TOKEN = "http401BadToken"; - - /** - * The constant UNAUTHORIZED_401_BAD_TOKEN_RESPONSE_REF. - */ - public static final String UNAUTHORIZED_401_BAD_TOKEN_RESPONSE_REF = "#/components/responses/" + HTTP_401_BAD_TOKEN; - - /** - * The constant HTTP_403. - */ - private static final String HTTP_403 = "http403"; - - /** - * The constant FORBIDDEN_403_RESPONSE_REF. - */ - public static final String FORBIDDEN_403_RESPONSE_REF = "#/components/responses/" + HTTP_403; - - /** - * Http 401 no token response map . entry. - * - * @return the map . entry - * @throws IOException the io exception - */ - @Bean - public Map.Entry http401NoTokenResponse() throws IOException { - return simpleResponse(HTTP_401_NO_TOKEN, "Invalid authentication."); - } - - /** - * Http 401 bad token response map . entry. - * - * @return the map . entry - * @throws IOException the io exception - */ - @Bean - public Map.Entry http401BadTokenResponse() throws IOException { - return simpleResponse(HTTP_401_BAD_TOKEN, "Invalid authentication."); - } - - /** - * Http 403 example map . entry. - * - * @return the map . entry - * @throws IOException the io exception - */ - @Bean - public Map.Entry http403Example() throws IOException { - return simpleResponse(HTTP_403, "Missing authorities."); - } - - /** - * Simple response map . entry. - * - * @param code the code - * @param description the description - * @return the map . entry - * @throws IOException the io exception - */ - private Map.Entry simpleResponse(String code, String description) throws IOException { - ApiResponse response = new ApiResponse().description(description).content(new Content().addMediaType( - APPLICATION_PROBLEM_JSON_VALUE, - new MediaType() - .schema(new Schema().$ref("#/components/schemas/Problem")))); - return new AbstractMap.SimpleEntry<>(code, response); - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app126/SpringDocApp126Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app126/SpringDocApp126Test.java deleted file mode 100644 index 2d2c16ebb..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app126/SpringDocApp126Test.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * - * * - * * * - * * * * Copyright 2019-2020 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.app126; - -import java.util.List; -import java.util.Map; - -import io.swagger.v3.core.converter.AnnotatedType; -import io.swagger.v3.core.converter.ModelConverters; -import io.swagger.v3.core.converter.ResolvedSchema; -import io.swagger.v3.oas.models.responses.ApiResponse; -import org.springdoc.core.customizers.OpenApiCustomizer; -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.Bean; - - -/** - * Tests Spring meta-annotations as method parameters - */ -class SpringDocApp126Test extends AbstractSpringDocTest { - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp { - - /** - * Response registration customizer open api customiser. - * - * @param responsesToRegister the responses to register - * @return the open api customiser - */ - @Bean - public OpenApiCustomizer responseRegistrationCustomizer(List> responsesToRegister) { - ResolvedSchema resolvedSchema = ModelConverters.getInstance() - .resolveAsResolvedSchema(new AnnotatedType(Problem.class)); - return openApi -> { - openApi.getComponents().addSchemas("Problem", resolvedSchema.schema); - responsesToRegister.forEach(entry -> openApi.getComponents().addResponses(entry.getKey(), entry.getValue())); - }; - } - - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app127/AbstractObject.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app127/AbstractObject.java deleted file mode 100644 index a17504cd9..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app127/AbstractObject.java +++ /dev/null @@ -1,57 +0,0 @@ -package test.org.springdoc.api.app127; - -import com.fasterxml.jackson.annotation.JsonSubTypes; -import com.fasterxml.jackson.annotation.JsonTypeInfo; - -/** - * The type Abstract object. - */ -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, - include = JsonTypeInfo.As.EXISTING_PROPERTY, - property = "type", - visible = true -) -@JsonSubTypes({ - @JsonSubTypes.Type(value = ConcreteObjectA.class, name = "Type A") -}) -public abstract class AbstractObject { - - /** - * The Type. - */ - private final ConcreteType type; - - /** - * The Name. - */ - private final String name; - - /** - * Instantiates a new Abstract object. - * - * @param type the type - * @param name the name - */ - protected AbstractObject(ConcreteType type, String name) { - this.type = type; - this.name = name; - } - - /** - * Gets type. - * - * @return the type - */ - public ConcreteType getType() { - return type; - } - - /** - * Gets name. - * - * @return the name - */ - public String getName() { - return name; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app127/ConcreteObjectA.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app127/ConcreteObjectA.java deleted file mode 100644 index d3339226f..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app127/ConcreteObjectA.java +++ /dev/null @@ -1,32 +0,0 @@ -package test.org.springdoc.api.app127; - -/** - * The type Concrete object a. - */ -class ConcreteObjectA extends AbstractObject { - - /** - * The Description. - */ - private final String description; - - /** - * Instantiates a new Concrete object a. - * - * @param name the name - * @param description the description - */ - public ConcreteObjectA(String name, String description) { - super(ConcreteType.TYPE_A, name); - this.description = description; - } - - /** - * Gets description. - * - * @return the description - */ - public String getDescription() { - return description; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app127/ConcreteType.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app127/ConcreteType.java deleted file mode 100644 index cfe532ec0..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app127/ConcreteType.java +++ /dev/null @@ -1,38 +0,0 @@ -package test.org.springdoc.api.app127; - -/** - * The enum Concrete type. - */ -public enum ConcreteType { - /** - * The Type a. - */ - TYPE_A("Type A"), - /** - * The Type b. - */ - TYPE_B("Type B"); - - /** - * The Name. - */ - private final String name; - - /** - * Instantiates a new Concrete type. - * - * @param name the name - */ - ConcreteType(String name) { - this.name = name; - } - - /** - * Gets name. - * - * @return the name - */ - public String getName() { - return name; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app127/Controller.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app127/Controller.java deleted file mode 100644 index b0be57945..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app127/Controller.java +++ /dev/null @@ -1,36 +0,0 @@ -package test.org.springdoc.api.app127; - -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.media.Content; -import io.swagger.v3.oas.annotations.media.ExampleObject; -import io.swagger.v3.oas.annotations.media.Schema; -import io.swagger.v3.oas.annotations.responses.ApiResponse; - -import org.springframework.http.MediaType; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * The type Controller. - */ -@RestController -class Controller { - - /** - * Bug umbrella. - * - * @return the umbrella - */ - @Operation(summary = "Test Bug", responses = { - @ApiResponse(responseCode = "200", description = "OK", - content = @Content( - schema = @Schema(implementation = Umbrella.class), - examples = @ExampleObject(ref = "#/components/examples/umbrellaExample", name = "Example with weird YAML tag") - ) - ) - }) - @GetMapping(value = "/bug", produces = MediaType.APPLICATION_JSON_VALUE) - public Umbrella bug() { - return new Umbrella(new ConcreteObjectA("a", "b")); - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app127/SpringDocApp127Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app127/SpringDocApp127Test.java deleted file mode 100644 index 7fe0afa53..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app127/SpringDocApp127Test.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * - * * - * * * - * * * * Copyright 2019-2020 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.app127; - -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; -import org.springdoc.core.utils.Constants; -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.test.web.servlet.MvcResult; - -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; - - -/** - * Tests Spring meta-annotations as method parameters - */ -class SpringDocApp127Test extends AbstractSpringDocTest { - - /** - * Test app. - * - * @throws Exception the exception - */ - @Test - protected void testApp() throws Exception { - className = getClass().getSimpleName(); - String testNumber = className.replaceAll("[^0-9]", ""); - MvcResult mockMvcResult = mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL + ".yaml")).andExpect(status().isOk()).andReturn(); - String result = mockMvcResult.getResponse().getContentAsString(); - Assertions.assertTrue(!result.contains("!")); - } - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app127/Umbrella.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app127/Umbrella.java deleted file mode 100644 index ee696ace2..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app127/Umbrella.java +++ /dev/null @@ -1,33 +0,0 @@ -package test.org.springdoc.api.app127; - -import io.swagger.v3.oas.annotations.media.Schema; - -/** - * The type Umbrella. - */ -class Umbrella { - - /** - * The Object. - */ - @Schema(description = "This reference to abstract class causes weird YAML tag to be added", anyOf = ConcreteObjectA.class) - private final AbstractObject object; - - /** - * Instantiates a new Umbrella. - * - * @param object the object - */ - public Umbrella(AbstractObject object) { - this.object = object; - } - - /** - * Gets object. - * - * @return the object - */ - public AbstractObject getObject() { - return object; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app129/ActualReturnedEntity.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app129/ActualReturnedEntity.java deleted file mode 100644 index a0f3f4c98..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app129/ActualReturnedEntity.java +++ /dev/null @@ -1,16 +0,0 @@ -package test.org.springdoc.api.app129; - -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * The type Actual returned entity. - */ -class ActualReturnedEntity { - - /** - * The Result. - */ - @JsonProperty - String result; - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app129/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app129/HelloController.java deleted file mode 100644 index b38288785..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app129/HelloController.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app129; - -import io.swagger.v3.oas.annotations.responses.ApiResponse; -import io.swagger.v3.oas.annotations.responses.ApiResponses; - -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; -import org.springframework.web.context.request.async.DeferredResult; - -/** - * The type Hello controller. - */ -@RestController -@RequestMapping(path = "/api", headers = { "userId", "registrationId" }) -class HelloController { - - /** - * Update deferred result. - * - * @param entity the entity - * @return the deferred result - * @throws Exception the exception - */ - @PostMapping("/test") - @ApiResponses({ @ApiResponse(responseCode = "200") }) - public DeferredResult> update( - @RequestBody ActualReturnedEntity entity) throws Exception { - return null; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app129/OperationResponse.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app129/OperationResponse.java deleted file mode 100644 index 7b41eb0e3..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app129/OperationResponse.java +++ /dev/null @@ -1,17 +0,0 @@ -package test.org.springdoc.api.app129; - -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * The type Operation response. - * - * @param the type parameter - */ -class OperationResponse { - - /** - * The Operation result. - */ - @JsonProperty - String operationResult; -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app129/SpringDocApp129Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app129/SpringDocApp129Test.java deleted file mode 100644 index 2dfe85a0c..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app129/SpringDocApp129Test.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * - * * - * * * - * * * * Copyright 2019-2020 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.app129; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - - -/** - * Tests Spring meta-annotations as method parameters - */ -class SpringDocApp129Test extends AbstractSpringDocTest { - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app13/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app13/HelloController.java deleted file mode 100644 index cd48b3d0f..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app13/HelloController.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app13; - -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * The type Hello controller. - */ -@RestController -class HelloController { - - /** - * Persons string. - * - * @param dto the dto - * @return the string - */ - @GetMapping(value = "/persons") - public String persons(final PersonDTO dto) { - return "OK"; - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app13/PersonDTO.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app13/PersonDTO.java deleted file mode 100644 index 17e68752d..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app13/PersonDTO.java +++ /dev/null @@ -1,116 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app13; - -import com.fasterxml.jackson.databind.PropertyNamingStrategies; -import com.fasterxml.jackson.databind.annotation.JsonNaming; - -/** - * The type Person dto. - */ -@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) -class PersonDTO { - /** - * The Email. - */ - private String email; - - /** - * The First name. - */ - private String firstName; - - /** - * The Last name. - */ - private String lastName; - - /** - * Instantiates a new Person dto. - */ - public PersonDTO() { - } - - /** - * Instantiates a new Person dto. - * - * @param email the email - * @param firstName the first name - * @param lastName the last name - */ - public PersonDTO(final String email, final String firstName, final String lastName) { - this.email = email; - this.firstName = firstName; - this.lastName = lastName; - } - - /** - * Gets email. - * - * @return the email - */ - public String getEmail() { - return email; - } - - /** - * Sets email. - * - * @param email the email - */ - public void setEmail(final String email) { - this.email = email; - } - - /** - * Gets first name. - * - * @return the first name - */ - public String getFirstName() { - return firstName; - } - - /** - * Sets first name. - * - * @param firstName the first name - */ - public void setFirstName(final String firstName) { - this.firstName = firstName; - } - - /** - * Gets last name. - * - * @return the last name - */ - public String getLastName() { - return lastName; - } - - /** - * Sets last name. - * - * @param lastName the last name - */ - public void setLastName(final String lastName) { - this.lastName = lastName; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app13/SpringDocApp13Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app13/SpringDocApp13Test.java deleted file mode 100644 index a1483e4e7..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app13/SpringDocApp13Test.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app13; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * The type Spring doc app 13 test. - */ -class SpringDocApp13Test extends AbstractSpringDocTest { - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app130/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app130/HelloController.java deleted file mode 100644 index 1e3e5e5ac..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app130/HelloController.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app130; - -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * The type Hello controller. - */ -@RestController -class HelloController { - - /** - * List tracker data. - * - * @param toto the toto - * @return the tracker data - */ - @PostMapping(value = "/values/data") - TrackerData list(TrackerData toto) { - return toto; - } - - /** - * Get tracker data. - * - * @param toto the toto - * @return the tracker data - */ - @GetMapping(value = "/values/datakk") - TrackerData get(TrackerData toto) { - return toto; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app130/SpringDocApp130Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app130/SpringDocApp130Test.java deleted file mode 100644 index 755a6a025..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app130/SpringDocApp130Test.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * - * * - * * * - * * * * Copyright 2019-2020 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.app130; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - - -/** - * Tests Spring meta-annotations as method parameters - */ -class SpringDocApp130Test extends AbstractSpringDocTest { - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app130/TrackerData.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app130/TrackerData.java deleted file mode 100644 index 2dd4405e6..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app130/TrackerData.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app130; - -import java.time.Instant; - -import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.v3.oas.annotations.Hidden; -import io.swagger.v3.oas.annotations.media.Schema; - -/** - * The type Tracker data. - */ -@Hidden -class TrackerData { - - /** - * The Tracker id. - */ - @JsonProperty("trackerId") - String trackerId; - - /** - * The Timestamp. - */ - @Schema(name = "timestamp", type = "string", format = "date-time", required = true, example = "2018-01-01T00:00:00Z") - @JsonProperty("timestamp") - Instant timestamp; - - /** - * The Value. - */ - @Schema(name = "value", type = "number", format = "double", description = "The data value", required = true, example = "19.0") - @JsonProperty("value") - Double value; - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app131/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app131/HelloController.java deleted file mode 100644 index 8b8e4f561..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app131/HelloController.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app131; - -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.media.Content; -import io.swagger.v3.oas.annotations.media.Schema; -import io.swagger.v3.oas.annotations.responses.ApiResponse; -import io.swagger.v3.oas.annotations.responses.ApiResponses; - -import org.springframework.http.HttpStatus; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.ResponseStatus; -import org.springframework.web.bind.annotation.RestController; - -/** - * The type Hello controller. - * - * @param the type parameter - */ -@RestController -class HelloController { - - - /** - * Create organization. - * - * @param organization the organization - */ - @Operation(summary = "Create the organization", description = "Create the organization") - @ApiResponses( - value = { - @ApiResponse( - responseCode = "204", - description = "The organization was created successfully"), - @ApiResponse( - responseCode = "400", - description = "Invalid argument", - content = - @Content( - mediaType = "application/json", - schema = @Schema(implementation = RestControllerError.class))), - @ApiResponse( - responseCode = "409", - description = "An organization with the specified ID already exists", - content = - @Content( - mediaType = "application/json", - schema = @Schema(implementation = RestControllerError.class))), - @ApiResponse( - responseCode = "500", - description = - "An error has occurred and the request could not be processed at this time", - content = - @Content( - mediaType = "application/json", - schema = @Schema(implementation = RestControllerError.class))) - }) - @RequestMapping( - value = "/organizations", - method = RequestMethod.POST, - produces = "application/json") - @ResponseStatus(HttpStatus.NO_CONTENT) - public void createOrganization( - @Parameter(name = "organization", required = true) - @RequestBody - Organization organization) { - - - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app131/Organization.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app131/Organization.java deleted file mode 100644 index 98c01ca42..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app131/Organization.java +++ /dev/null @@ -1,78 +0,0 @@ -package test.org.springdoc.api.app131; - - -import java.util.UUID; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; -import io.swagger.v3.oas.annotations.media.Schema; - -/** - * The type Organization. - */ -@Schema(description = - "This is the description being overwritten") -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({ "id", "name" }) -class Organization { - - /** - * The Id. - */ - @Schema( - description = - "The Universally Unique Identifier (UUID) uniquely identifying the organization", - required = true) - @JsonProperty(required = true) - private UUID id; - - /** - * The Name. - */ - @Schema(description = "The name of the organization", required = true) - @JsonProperty(required = true) - private String name; - - /** - * Instantiates a new Organization. - */ - public Organization() { - } - - /** - * Gets id. - * - * @return the id - */ - public UUID getId() { - return id; - } - - /** - * Sets id. - * - * @param id the id - */ - public void setId(UUID id) { - this.id = id; - } - - /** - * Gets name. - * - * @return the name - */ - public String getName() { - return name; - } - - /** - * Sets name. - * - * @param name the name - */ - public void setName(String name) { - this.name = name; - } -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app131/RestControllerError.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app131/RestControllerError.java deleted file mode 100644 index d49ae4d19..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app131/RestControllerError.java +++ /dev/null @@ -1,22 +0,0 @@ -package test.org.springdoc.api.app131; - -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * The type Rest controller error. - */ -class RestControllerError { - - /** - * The Id. - */ - @JsonProperty - private String id; - - /** - * The Message. - */ - @JsonProperty - private String message; - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app131/SpringDocApp131Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app131/SpringDocApp131Test.java deleted file mode 100644 index a7e2bd634..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app131/SpringDocApp131Test.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * - * * - * * * - * * * * Copyright 2019-2020 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.app131; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - - -/** - * Tests Spring meta-annotations as method parameters - */ -class SpringDocApp131Test extends AbstractSpringDocTest { - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app132/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app132/HelloController.java deleted file mode 100644 index a038354b5..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app132/HelloController.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app132; - -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.media.Content; -import io.swagger.v3.oas.annotations.media.Schema; -import io.swagger.v3.oas.annotations.responses.ApiResponse; -import io.swagger.v3.oas.annotations.responses.ApiResponses; - -import org.springframework.http.HttpStatus; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.ResponseStatus; -import org.springframework.web.bind.annotation.RestController; - -/** - * The type Hello controller. - * - * @param the type parameter - */ -@RestController -class HelloController { - - - /** - * Create organization. - * - * @param organization the organization - */ - @Operation(summary = "Create the organization", description = "Create the organization") - @ApiResponses( - value = { - @ApiResponse( - responseCode = "204", - description = "The organization was created successfully"), - @ApiResponse( - responseCode = "400", - description = "Invalid argument", - content = - @Content( - mediaType = "application/json", - schema = @Schema(implementation = RestControllerError.class))), - @ApiResponse( - responseCode = "409", - description = "An organization with the specified ID already exists", - content = - @Content( - mediaType = "application/json", - schema = @Schema(implementation = RestControllerError.class))), - @ApiResponse( - responseCode = "500", - description = - "An error has occurred and the request could not be processed at this time", - content = - @Content( - mediaType = "application/json", - schema = @Schema(implementation = RestControllerError.class))) - }) - @RequestMapping( - value = "/organizations", - method = RequestMethod.POST, - produces = "application/json") - @ResponseStatus(HttpStatus.NO_CONTENT) - public void createOrganization( - @Parameter(name = "organization", description = "i want to override the description of this object", required = true) - @RequestBody - Organization organization) { - - - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app132/Organization.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app132/Organization.java deleted file mode 100644 index cd1e1127c..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app132/Organization.java +++ /dev/null @@ -1,78 +0,0 @@ -package test.org.springdoc.api.app132; - - -import java.util.UUID; - -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; -import io.swagger.v3.oas.annotations.media.Schema; - -/** - * The type Organization. - */ -@Schema(description = - "This is the description being overwritten") -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({ "id", "name" }) -class Organization { - - /** - * The Id. - */ - @Schema( - description = - "The Universally Unique Identifier (UUID) uniquely identifying the organization", - required = true) - @JsonProperty(required = true) - private UUID id; - - /** - * The Name. - */ - @Schema(description = "The name of the organization", required = true) - @JsonProperty(required = true) - private String name; - - /** - * Instantiates a new Organization. - */ - public Organization() { - } - - /** - * Gets id. - * - * @return the id - */ - public UUID getId() { - return id; - } - - /** - * Sets id. - * - * @param id the id - */ - public void setId(UUID id) { - this.id = id; - } - - /** - * Gets name. - * - * @return the name - */ - public String getName() { - return name; - } - - /** - * Sets name. - * - * @param name the name - */ - public void setName(String name) { - this.name = name; - } -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app132/RestControllerError.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app132/RestControllerError.java deleted file mode 100644 index d716511b1..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app132/RestControllerError.java +++ /dev/null @@ -1,22 +0,0 @@ -package test.org.springdoc.api.app132; - -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * The type Rest controller error. - */ -class RestControllerError { - - /** - * The Id. - */ - @JsonProperty - private String id; - - /** - * The Message. - */ - @JsonProperty - private String message; - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app132/SpringDocApp132Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app132/SpringDocApp132Test.java deleted file mode 100644 index 5d5d8fd98..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app132/SpringDocApp132Test.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * - * * - * * * - * * * * Copyright 2019-2020 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.app132; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - - -/** - * Tests Spring meta-annotations as method parameters - */ -class SpringDocApp132Test extends AbstractSpringDocTest { - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app133/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app133/HelloController.java deleted file mode 100644 index 7133d1542..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app133/HelloController.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app133; - -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.media.Schema; - -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RestController; - -/** - * The type Hello controller. - */ -@RestController -class HelloController { - - /** - * Gets message from header 1. - * - * @param header the header - * @return the message from header 1 - */ - @GetMapping(path = "/test1", headers = { "myHeader" }) - public String getMessageFromHeader1( - @Parameter(name = "myHeader", description = "A header", schema = @Schema(allowableValues = { "foo", "bar" })) - @RequestHeader("myHeader") String header - ) { - return "bar " + header; - } - - /** - * Gets message from header 2. - * - * @param header the header - * @return the message from header 2 - */ - @GetMapping("/test2") - public String getMessageFromHeader2( - @Parameter(name = "myHeader", description = "A header", schema = @Schema(type = "integer")) - @RequestHeader("myHeader") Integer header - ) { - return "bar " + header; - } - - /** - * Gets message from header 3. - * - * @param header the header - * @return the message from header 3 - */ - @GetMapping(path = "/test3", headers = { "myHeader" }) - public String getMessageFromHeader3( - @Parameter(name = "myHeader", description = "A header", schema = @Schema(type = "integer")) - @RequestHeader("myHeader") Integer header - ) { - return "bar " + header; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app133/SpringDocApp133Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app133/SpringDocApp133Test.java deleted file mode 100644 index 62453d06c..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app133/SpringDocApp133Test.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * - * * - * * * - * * * * Copyright 2019-2020 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.app133; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - - -/** - * Tests Spring meta-annotations as method parameters - */ -class SpringDocApp133Test extends AbstractSpringDocTest { - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app134/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app134/HelloController.java deleted file mode 100644 index e1379a952..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app134/HelloController.java +++ /dev/null @@ -1,220 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app134; - -import java.util.Collections; -import java.util.List; - -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.media.ArraySchema; -import io.swagger.v3.oas.annotations.media.Content; -import io.swagger.v3.oas.annotations.media.Schema; -import io.swagger.v3.oas.annotations.responses.ApiResponse; -import io.swagger.v3.oas.annotations.tags.Tag; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.http.HttpStatus; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.ResponseStatus; -import org.springframework.web.bind.annotation.RestController; - - -/** - * The type Hello controller. - */ -@SpringBootApplication -@RestController -@Tag(name = "The sample resource") -class HelloController { - - // ----------------------------------------------------------------------------------------------------------------- - - /** - * The constant VERSION_1. - */ - public static final String VERSION_1 = "application/vnd.samples.v1+json"; - - /** - * The constant VERSION_2. - */ - public static final String VERSION_2 = "application/vnd.samples.v2+json"; - - /** - * The constant HEADER_1. - */ - public static final String HEADER_1 = "X-API-VERSION=1"; - - /** - * The constant HEADER_2. - */ - public static final String HEADER_2 = "Accept-version=v2"; - - /** - * Gets sample v 1. - * - * @param id the id - * @return the sample v 1 - */ - @GetMapping(value = "/{id}", produces = VERSION_1, headers = HEADER_1) - @ResponseStatus(HttpStatus.OK) - @Operation(operationId = "getSampleV1", deprecated = true, description = "Get the sample by its id." - ) - @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = SampleV1.class))) - public SampleV1 getSampleV1(@Parameter(description = "The sample's id", required = true) - @PathVariable final String id) { - return new SampleV1(id); - } - - /** - * Gets sample v 2. - * - * @param id the id - * @return the sample v 2 - */ - @GetMapping(value = "/{id}", produces = VERSION_2, headers = { HEADER_2, HEADER_1 }) - @ResponseStatus(HttpStatus.OK) - @Operation(operationId = "getSampleV2", description = "Get the sample by its id. This represents V2.") - @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = SampleV1.class))) - public SampleV2 getSampleV2(@Parameter(description = "The sample's id", required = true) - @PathVariable final Long id) { - return new SampleV2(id); - } - - /** - * Search samples list. - * - * @param searchRequest the search request - * @return the list - */ - @PostMapping(path = "/search", consumes = VERSION_2, produces = VERSION_2) - @Operation(description = "Searches for sample objects using the given search request.") - @ApiResponse(responseCode = "200", - content = @Content(array = @ArraySchema(schema = @Schema(implementation = SampleV2.class)))) - public List searchSamples(@RequestBody final SampleSearchRequest searchRequest) { - return Collections.singletonList(new SampleV2(searchRequest.getId())); - } - - - /** - * The type Sample v 1. - */ - private class SampleV1 { - - /** - * The Id. - */ - private String id; - - /** - * Instantiates a new Sample v 1. - * - * @param id the id - */ - public SampleV1(String id) { - this.id = id; - } - - /** - * Gets id. - * - * @return the id - */ - public String getId() { - return id; - } - - /** - * Sets id. - * - * @param id the id - */ - public void setId(String id) { - this.id = id; - } - } - - /** - * The type Sample v 2. - */ - private class SampleV2 { - /** - * The Id. - */ - private long id; - - /** - * Instantiates a new Sample v 2. - * - * @param id the id - */ - public SampleV2(long id) { - this.id = id; - } - - /** - * Gets id. - * - * @return the id - */ - public long getId() { - return id; - } - - /** - * Sets id. - * - * @param id the id - */ - public void setId(long id) { - this.id = id; - } - } - - /** - * The type Sample search request. - */ - private class SampleSearchRequest { - /** - * The Id. - */ - private final long id; - - /** - * Instantiates a new Sample search request. - * - * @param id the id - */ - public SampleSearchRequest(long id) { - this.id = id; - } - - /** - * Gets id. - * - * @return the id - */ - public long getId() { - return id; - } - } -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app134/OpenApiConfig.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app134/OpenApiConfig.java deleted file mode 100644 index aac5b73df..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app134/OpenApiConfig.java +++ /dev/null @@ -1,73 +0,0 @@ -package test.org.springdoc.api.app134; - -import org.springdoc.core.models.GroupedOpenApi; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -/** - * The type Open api config. - */ -@Configuration -class OpenApiConfig { - - /** - * Group v 1 open api grouped open api. - * - * @return the grouped open api - */ - @Bean - public GroupedOpenApi groupV1OpenApi() { - return GroupedOpenApi.builder() - .group("v1-group").producesToMatch(HelloController.VERSION_1) - .build(); - } - - /** - * Group v 2 open api grouped open api. - * - * @return the grouped open api - */ - @Bean - public GroupedOpenApi groupV2OpenApi() { - return GroupedOpenApi.builder() - .group("v2-group").producesToMatch(HelloController.VERSION_2) - .build(); - } - - /** - * Group v 3 open api grouped open api. - * - * @return the grouped open api - */ - @Bean - public GroupedOpenApi groupV3OpenApi() { - return GroupedOpenApi.builder() - .group("v2-consumes-group").consumesToMatch(HelloController.VERSION_2) - .build(); - } - - /** - * Group v 4 open api grouped open api. - * - * @return the grouped open api - */ - @Bean - public GroupedOpenApi groupV4OpenApi() { - return GroupedOpenApi.builder() - .group("v1-headers-group").headersToMatch(HelloController.HEADER_1) - .build(); - } - - /** - * Group v 5 open api grouped open api. - * - * @return the grouped open api - */ - @Bean - public GroupedOpenApi groupV5OpenApi() { - return GroupedOpenApi.builder() - .group("v1-v2-headers-group").headersToMatch(HelloController.HEADER_1, HelloController.HEADER_2) - .build(); - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app134/SpringDocApp134Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app134/SpringDocApp134Test.java deleted file mode 100644 index f619e2ca7..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app134/SpringDocApp134Test.java +++ /dev/null @@ -1,113 +0,0 @@ -/* - * - * * - * * * - * * * * Copyright 2019-2020 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.app134; - -import org.junit.jupiter.api.Test; -import org.springdoc.core.utils.Constants; -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -import static org.hamcrest.Matchers.is; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; - - -/** - * Tests Spring meta-annotations as method parameters - */ -class SpringDocApp134Test extends AbstractSpringDocTest { - - /** - * Test app. - * - * @throws Exception the exception - */ - @Test - protected void testApp() throws Exception { - mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL + "/v1-group")) - .andExpect(status().isOk()) - .andExpect(jsonPath("$.openapi", is("3.0.1"))) - .andExpect(content().json(getContent("results/app134-1.json"), true)); - } - - /** - * Test app 2. - * - * @throws Exception the exception - */ - @Test - void testApp2() throws Exception { - mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL + "/v2-group")) - .andExpect(status().isOk()) - .andExpect(jsonPath("$.openapi", is("3.0.1"))) - .andExpect(content().json(getContent("results/app134-2.json"), true)); - } - - /** - * Test app 3. - * - * @throws Exception the exception - */ - @Test - void testApp3() throws Exception { - mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL + "/v1-headers-group")) - .andExpect(status().isOk()) - .andExpect(jsonPath("$.openapi", is("3.0.1"))) - .andExpect(content().json(getContent("results/app134-3.json"), true)); - } - - /** - * Test app 4. - * - * @throws Exception the exception - */ - @Test - void testApp4() throws Exception { - mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL + "/v1-v2-headers-group")) - .andExpect(status().isOk()) - .andExpect(jsonPath("$.openapi", is("3.0.1"))) - .andExpect(content().json(getContent("results/app134-4.json"), true)); - } - - /** - * Test app 5. - * - * @throws Exception the exception - */ - @Test - void testApp5() throws Exception { - mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL + "/v2-consumes-group")) - .andExpect(status().isOk()) - .andExpect(jsonPath("$.openapi", is("3.0.1"))) - .andExpect(content().json(getContent("results/app134-5.json"), true)); - } - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app135/Book.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app135/Book.java deleted file mode 100644 index 9ea698276..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app135/Book.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * - * * - * * * Copyright 2019-2020 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.app135; - -/** - * The type Book. - */ -class Book { - - /** - * The Id. - */ - private String id; - - /** - * The Title. - */ - private String title; - - /** - * The Author. - */ - private String author; - - /** - * Instantiates a new Book. - * - * @param id the id - * @param title the title - * @param author the author - */ - public Book(String id, String title, String author) { - this.id = id; - this.title = title; - this.author = author; - } - - /** - * Gets id. - * - * @return the id - */ - public String getId() { - return id; - } - - /** - * Sets id. - * - * @param id the id - */ - public void setId(String id) { - this.id = id; - } - - /** - * Gets title. - * - * @return the title - */ - public String getTitle() { - return title; - } - - /** - * Sets title. - * - * @param title the title - */ - public void setTitle(String title) { - this.title = title; - } - - /** - * Gets author. - * - * @return the author - */ - public String getAuthor() { - return author; - } - - /** - * Sets author. - * - * @param author the author - */ - public void setAuthor(String author) { - this.author = author; - } -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app135/BookRepository.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app135/BookRepository.java deleted file mode 100644 index caf653823..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app135/BookRepository.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * - * * - * * * Copyright 2019-2020 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.app135; - -import java.util.Arrays; -import java.util.List; - -import org.springframework.stereotype.Component; - -/** - * The type Book repository. - */ -@Component -class BookRepository { - - /** - * Find by author list. - * - * @param author the author - * @return the list - */ - List findByAuthor(String author) { - Book[] books = { new Book("1", "title1", "author1") }; - return Arrays.asList(books); - } - - /** - * Find all list. - * - * @return the list - */ - List findAll() { - Book[] books = { new Book("2", "title2", "author2") }; - return Arrays.asList(books); - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app135/BookRouter.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app135/BookRouter.java deleted file mode 100644 index af0eff3e6..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app135/BookRouter.java +++ /dev/null @@ -1,134 +0,0 @@ -/* - * - * * - * * * Copyright 2019-2020 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.app135; - -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.enums.ParameterIn; -import org.springdoc.core.annotations.RouterOperation; -import org.springdoc.core.annotations.RouterOperations; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.http.MediaType; -import org.springframework.web.servlet.function.RequestPredicates; -import org.springframework.web.servlet.function.RouterFunction; -import org.springframework.web.servlet.function.RouterFunctions; -import org.springframework.web.servlet.function.ServerResponse; - -import static org.springframework.web.servlet.function.RouterFunctions.nest; -import static org.springframework.web.servlet.function.RouterFunctions.route; -import static org.springframework.web.servlet.function.ServerResponse.ok; - -/** - * The type Book router. - */ -@Configuration -class BookRouter { - - /** - * Routes router function. - * - * @param br the br - * @return the router function - */ - @Bean - @RouterOperations({ - @RouterOperation(path = "/greeter/greeter2/books", produces = { MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE }, beanClass = BookRepository.class, beanMethod = "findAll"), - @RouterOperation(path = "/greeter/greeter2/books", produces = { MediaType.TEXT_PLAIN_VALUE, MediaType.APPLICATION_XML_VALUE }, beanClass = BookRepository.class, beanMethod = "findAll"), - @RouterOperation(path = "/greeter/greeter2/books/{author}", beanClass = BookRepository.class, beanMethod = "findByAuthor", - operation = @Operation(operationId = "findByAuthor" - , parameters = { @Parameter(in = ParameterIn.PATH, name = "author") })) }) - RouterFunction routes(BookRepository br) { - return - RouterFunctions.nest(RequestPredicates.path("/greeter").and(RequestPredicates.path("/greeter2")), - RouterFunctions.route(RequestPredicates.GET("/books").and(RequestPredicates.accept(MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML)), req -> ok().body(br.findAll())) - .and(route(RequestPredicates.GET("/books").and(RequestPredicates.accept(MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN)), req -> ok().body(br.findAll()))) - .andRoute(RequestPredicates.GET("/books/{author}"), req -> ok().body(br.findByAuthor(req.pathVariable("author"))))); - } - - /** - * Routes 1 router function. - * - * @param br the br - * @return the router function - */ - @Bean - @RouterOperations({ - @RouterOperation(path = "/books", produces = { MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE }, beanClass = BookRepository.class, beanMethod = "findAll"), - @RouterOperation(path = "/books/{author}", beanClass = BookRepository.class, beanMethod = "findByAuthor", - operation = @Operation(operationId = "findByAuthor" - , parameters = { @Parameter(in = ParameterIn.PATH, name = "author") })) }) - RouterFunction routes1(BookRepository br) { - return - RouterFunctions.nest(RequestPredicates.accept(MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML), - RouterFunctions.route(RequestPredicates.GET("/books"), req -> ServerResponse.ok().body(br.findAll())) - .andRoute(RequestPredicates.GET("/books/{author}"), req -> ServerResponse.ok().body(br.findByAuthor(req.pathVariable("author"))))); - } - - /** - * Routes 3 router function. - * - * @param br the br - * @return the router function - */ - @Bean - @RouterOperations({ - @RouterOperation(path = "/greeter/books", produces = { MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE }, beanClass = BookRepository.class, beanMethod = "findAll"), - @RouterOperation(path = "/greeter/books", produces = { MediaType.TEXT_PLAIN_VALUE, MediaType.APPLICATION_XML_VALUE }, beanClass = BookRepository.class, beanMethod = "findAll"), - @RouterOperation(path = "/greeter/books/{author}", beanClass = BookRepository.class, beanMethod = "findByAuthor", - operation = @Operation(operationId = "findByAuthor" - , parameters = { @Parameter(in = ParameterIn.PATH, name = "author") })), - @RouterOperation(path = "/greeter2/books", produces = { MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE }, beanClass = BookRepository.class, beanMethod = "findAll"), - @RouterOperation(path = "/greeter2/books", produces = { MediaType.TEXT_PLAIN_VALUE, MediaType.APPLICATION_XML_VALUE }, beanClass = BookRepository.class, beanMethod = "findAll"), - @RouterOperation(path = "/greeter2/books/{author}", beanClass = BookRepository.class, beanMethod = "findByAuthor", - operation = @Operation(operationId = "findByAuthor" - , parameters = { @Parameter(in = ParameterIn.PATH, name = "author") })) }) - RouterFunction routes3(BookRepository br) { - return - nest(RequestPredicates.path("/greeter").or(RequestPredicates.path("/greeter2")), - route(RequestPredicates.GET("/books").and(RequestPredicates.accept(MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML)), req -> ok().body(br.findAll())) - .and(route(RequestPredicates.GET("/books").and(RequestPredicates.accept(MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN)), req -> ok().body(br.findAll()))) - .andRoute(RequestPredicates.GET("/books/{author}"), req -> ok().body(br.findByAuthor(req.pathVariable("author"))))); - } - - /** - * Routes 4 router function. - * - * @param br the br - * @return the router function - */ - @Bean - @RouterOperations({ - @RouterOperation(path = "/test/greeter/greeter2/books", produces = { MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE }, beanClass = BookRepository.class, beanMethod = "findAll"), - @RouterOperation(path = "/test/greeter/greeter2/books", produces = { MediaType.TEXT_PLAIN_VALUE, MediaType.APPLICATION_XML_VALUE }, beanClass = BookRepository.class, beanMethod = "findAll"), - @RouterOperation(path = "/test/greeter/greeter2/books/{author}", beanClass = BookRepository.class, beanMethod = "findByAuthor", - operation = @Operation(operationId = "findByAuthor" - , parameters = { @Parameter(in = ParameterIn.PATH, name = "author") })) }) - RouterFunction routes4(BookRepository br) { - return - nest(RequestPredicates.path("/test"), - nest(RequestPredicates.path("/greeter").and(RequestPredicates.path("/greeter2")), - route(RequestPredicates.GET("/books").and(RequestPredicates.accept(MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML)), req -> ok().body(br.findAll())) - .and(route(RequestPredicates.GET("/books").and(RequestPredicates.accept(MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN)), req -> ok().body(br.findAll()))) - .andRoute(RequestPredicates.GET("/books/{author}"), req -> ok().body(br.findByAuthor(req.pathVariable("author")))))); - } -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app135/SpringDocApp135Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app135/SpringDocApp135Test.java deleted file mode 100644 index fc78132ae..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app135/SpringDocApp135Test.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * - * * - * * * - * * * * Copyright 2019-2020 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.app135; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - - -/** - * Tests Spring meta-annotations as method parameters - */ -class SpringDocApp135Test extends AbstractSpringDocTest { - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app137/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app137/HelloController.java deleted file mode 100644 index d3fb51c33..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app137/HelloController.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app137; - -import io.swagger.v3.oas.annotations.security.SecurityRequirement; - -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * The type Hello controller. - */ -@RestController -@SecurityRequirement(name = "security_auth") -class HelloController { - - /** - * Test. - * - * @param hello the hello - */ - @GetMapping("/test") - public void test(String hello) { - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app137/OpenApiConfig.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app137/OpenApiConfig.java deleted file mode 100644 index c48254014..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app137/OpenApiConfig.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app137; - -import io.swagger.v3.oas.annotations.OpenAPIDefinition; -import io.swagger.v3.oas.annotations.enums.SecuritySchemeType; -import io.swagger.v3.oas.annotations.info.Info; -import io.swagger.v3.oas.annotations.security.OAuthFlow; -import io.swagger.v3.oas.annotations.security.OAuthFlows; -import io.swagger.v3.oas.annotations.security.SecurityScheme; -import io.swagger.v3.oas.annotations.servers.Server; - -/** - * The type Open api config. - */ -@OpenAPIDefinition(servers = @Server(url = "${test.server}", description = "${test.desc}"), info = @Info(title = "My App", - description = "Some long and useful description", version = "v1")) -@SecurityScheme(name = "security_auth", type = SecuritySchemeType.OAUTH2, - flows = @OAuthFlows(authorizationCode = @OAuthFlow( - authorizationUrl = "http://authorization.url" - , tokenUrl = "http://token.url", scopes = {}))) -class OpenApiConfig {} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app137/SpringDocApp137Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app137/SpringDocApp137Test.java deleted file mode 100644 index a952c0967..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app137/SpringDocApp137Test.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * - * * - * * * - * * * * Copyright 2019-2020 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.app137; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.test.context.TestPropertySource; - - -/** - * Tests Spring meta-annotations as method parameters - */ -@TestPropertySource(properties = { "test.server=http://test.toto.com", "test.desc=toto desc" }) -class SpringDocApp137Test extends AbstractSpringDocTest { - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app138/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app138/HelloController.java deleted file mode 100644 index 73e75a5ce..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app138/HelloController.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app138; - -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * The type Hello controller. - */ -@RestController -class HelloController { - - /** - * Test a. - * - * @param hello the hello - */ - @GetMapping("/testA") - public void testA(String hello) { - } - - /** - * Test b. - * - * @param hello the hello - */ - @GetMapping("/testB") - public void testB(String hello) { - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app138/SpringDocApp138Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app138/SpringDocApp138Test.java deleted file mode 100644 index d88d76d96..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app138/SpringDocApp138Test.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * - * * - * * * - * * * * Copyright 2019-2020 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.app138; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.test.context.TestPropertySource; - - -/** - * Tests Spring meta-annotations as method parameters - */ -@TestPropertySource(properties = "springdoc.writer-with-order-by-keys=true") -class SpringDocApp138Test extends AbstractSpringDocTest { - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app139/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app139/HelloController.java deleted file mode 100644 index 7357246fa..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app139/HelloController.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app139; - -import org.springframework.http.MediaType; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -/** - * The type Hello controller. - */ -@RestController -class HelloController { - - /** - * Echo 1 string. - * - * @param text the text - * @return the string - */ - @GetMapping(produces = MediaType.TEXT_PLAIN_VALUE, path = "/test1") - public String echo1(@RequestParam(name = "${test.name}", defaultValue = "${test.default-value}") String text) { - return text; - } - - /** - * Echo 2 string. - * - * @param text the text - * @return the string - */ - @GetMapping(produces = MediaType.TEXT_PLAIN_VALUE, path = "/test2") - public String echo2(@RequestParam(value = "${test.value}", defaultValue = "${test.default-value}") String text) { - return text; - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app139/SpringDocApp139Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app139/SpringDocApp139Test.java deleted file mode 100644 index 0c4918c4f..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app139/SpringDocApp139Test.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * - * * - * * * - * * * * Copyright 2019-2020 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.app139; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.test.context.TestPropertySource; - - -/** - * Tests Spring meta-annotations as method parameters - */ -@TestPropertySource(properties = { "test.name=text", "test.value=text", "test.default-value=default-text" }) -class SpringDocApp139Test extends AbstractSpringDocTest { - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app14/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app14/HelloController.java deleted file mode 100644 index 101fb8a55..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app14/HelloController.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app14; - -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; - -/** - * The type Hello controller. - */ -@RestController -class HelloController { - - /** - * Persons. - * - * @param name the name - */ - @GetMapping("/persons") - public void persons(@Valid @NotBlank String name) { - - } - - /** - * Demo 2 http entity. - * - * @return the http entity - */ - @GetMapping("/test") - public HttpEntity demo2() { - return null; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app14/SpringDocApp14Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app14/SpringDocApp14Test.java deleted file mode 100644 index 0faffab68..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app14/SpringDocApp14Test.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app14; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * The type Spring doc app 14 test. - */ -class SpringDocApp14Test extends AbstractSpringDocTest { - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app140/HelloApplication.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app140/HelloApplication.java deleted file mode 100644 index 73eab0685..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app140/HelloApplication.java +++ /dev/null @@ -1,311 +0,0 @@ -/* - * - * - * * - * * * - * * * * Copyright 2019-2020 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.app140; - -import java.io.IOException; -import java.net.URI; -import java.util.HashSet; -import java.util.Set; -import java.util.concurrent.atomic.AtomicLong; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.enums.ParameterIn; -import jakarta.servlet.FilterChain; -import jakarta.servlet.GenericFilter; -import jakarta.servlet.ServletException; -import jakarta.servlet.ServletRequest; -import jakarta.servlet.ServletResponse; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.stereotype.Component; -import org.springframework.stereotype.Service; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RestController; -import org.springframework.web.servlet.function.HandlerFunction; -import org.springframework.web.servlet.function.RouterFunction; -import org.springframework.web.servlet.function.ServerRequest; -import org.springframework.web.servlet.function.ServerResponse; - -import static org.springdoc.core.fn.builders.operation.Builder.operationBuilder; -import static org.springdoc.core.utils.Constants.OPERATION_ATTRIBUTE; -import static org.springframework.web.servlet.function.RouterFunctions.route; -import static org.springframework.web.servlet.function.ServerResponse.ok; - -/** - * The type Hello application. - */ -@Configuration -class HelloApplication { - - /** - * Filter server response. - * - * @param serverRequest the server request - * @param handlerFunction the handler function - * @return the server response - * @throws Exception the exception - */ - private static ServerResponse filter(ServerRequest serverRequest, HandlerFunction handlerFunction) throws Exception { - return handlerFunction.handle(serverRequest); - } - - /** - * Routes router function. - * - * @param ph the ph - * @return the router function - */ - @Bean - RouterFunction routes(PersonHandler ph) { - String root = ""; - return route() - .GET(root + "/people", ph::handleGetAllPeople) - .withAttribute(OPERATION_ATTRIBUTE, operationBuilder().beanClass(PersonService.class).beanMethod("all")) - .GET(root + "/people/{id}", ph::handleGetPersonById) - .withAttribute(OPERATION_ATTRIBUTE, operationBuilder().beanClass(PersonService.class).beanMethod("byId")) - .POST(root + "/people", ph::handlePostPerson) - .withAttribute(OPERATION_ATTRIBUTE, operationBuilder().beanClass(PersonService.class).beanMethod("save")) - .filter(HelloApplication::filter) - .build(); - } -} - -/** - * The type Simple filter. - */ -@Component -class SimpleFilter extends GenericFilter { - - /** - * Do filter. - * - * @param req the req - * @param res the res - * @param filterChain the filter chain - * @throws IOException the io exception - * @throws ServletException the servlet exception - */ - @Override - public void doFilter(ServletRequest req, ServletResponse res, - FilterChain filterChain) throws IOException, ServletException { - filterChain.doFilter(req, res); - } -} - -/** - * The type Person handler. - */ -@Component -class PersonHandler { - - /** - * The Person service. - */ - private final PersonService personService; - - /** - * Instantiates a new Person handler. - * - * @param personService the person service - */ - PersonHandler(PersonService personService) { - this.personService = personService; - } - - /** - * Handle get all people server response. - * - * @param serverRequest the server request - * @return the server response - */ - ServerResponse handleGetAllPeople(ServerRequest serverRequest) { - return ok().body(personService.all()); - } - - /** - * Handle post person server response. - * - * @param r the r - * @return the server response - * @throws ServletException the servlet exception - * @throws IOException the io exception - */ - ServerResponse handlePostPerson(ServerRequest r) throws ServletException, IOException { - Person result = personService.save(new Person(null, r.body(Person.class).getName())); - URI uri = URI.create("/people/" + result.getId()); - return ServerResponse.created(uri).body(result); - } - - /** - * Handle get person by id server response. - * - * @param r the r - * @return the server response - */ - ServerResponse handleGetPersonById(ServerRequest r) { - return ok().body(personService.byId(Long.parseLong(r.pathVariable("id")))); - } -} - -/** - * The type Greetings rest controller. - */ -@RestController -class GreetingsRestController { - - /** - * Greet string. - * - * @param name the name - * @return the string - */ - @GetMapping("/greet/{name}") - String greet(@PathVariable String name) { - return "hello " + name + "!"; - } -} - -/** - * The type Person service. - */ -@Service -class PersonService { - - /** - * The Counter. - */ - private final AtomicLong counter = new AtomicLong(); - - /** - * The People. - */ - private final Set people = Stream.of( - new Person(counter.incrementAndGet(), "Jane"), - new Person(counter.incrementAndGet(), "Josh"), - new Person(counter.incrementAndGet(), "Gordon")) - .collect(Collectors.toCollection(HashSet::new)); - - - /** - * Save person. - * - * @param p the p - * @return the person - */ - Person save(Person p) { - Person person = new Person(counter.incrementAndGet(), p.getName()); - this.people.add(person); - return person; - } - - /** - * All set. - * - * @return the set - */ - Set all() { - return this.people; - } - - /** - * By id person. - * - * @param id the id - * @return the person - */ - Person byId(@Parameter(in = ParameterIn.PATH) Long id) { - return this.people.stream() - .filter(p -> p.getId().equals(id)) - .findFirst() - .orElseThrow(() -> new IllegalArgumentException("no " + Person.class.getName() + " with that ID found!")); - } - -} - -/** - * The type Person. - */ -class Person { - - /** - * The Id. - */ - private Long id; - - /** - * The Name. - */ - private String name; - - /** - * Instantiates a new Person. - * - * @param id the id - * @param name the name - */ - public Person(Long id, String name) { - this.id = id; - this.name = name; - } - - /** - * Gets id. - * - * @return the id - */ - public Long getId() { - return id; - } - - /** - * Sets id. - * - * @param id the id - */ - public void setId(Long id) { - this.id = id; - } - - /** - * Gets name. - * - * @return the name - */ - public String getName() { - return name; - } - - /** - * Sets name. - * - * @param name the name - */ - public void setName(String name) { - this.name = name; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app140/SpringDocApp140Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app140/SpringDocApp140Test.java deleted file mode 100644 index d4d169907..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app140/SpringDocApp140Test.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * - * - * * - * * * - * * * * Copyright 2019-2020 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.app140; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - - -/** - * The type Spring doc app 140 test. - */ -class SpringDocApp140Test extends AbstractSpringDocTest { - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app141/Book.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app141/Book.java deleted file mode 100644 index b0ad55ea9..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app141/Book.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * - * - * * - * * * - * * * * Copyright 2019-2020 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.app141; - -/** - * The type Book. - */ -class Book { - - /** - * The Id. - */ - private String id; - - /** - * The Title. - */ - private String title; - - /** - * The Author. - */ - private String author; - - /** - * Instantiates a new Book. - * - * @param id the id - * @param title the title - * @param author the author - */ - public Book(String id, String title, String author) { - this.id = id; - this.title = title; - this.author = author; - } - - /** - * Gets id. - * - * @return the id - */ - public String getId() { - return id; - } - - /** - * Sets id. - * - * @param id the id - */ - public void setId(String id) { - this.id = id; - } - - /** - * Gets title. - * - * @return the title - */ - public String getTitle() { - return title; - } - - /** - * Sets title. - * - * @param title the title - */ - public void setTitle(String title) { - this.title = title; - } - - /** - * Gets author. - * - * @return the author - */ - public String getAuthor() { - return author; - } - - /** - * Sets author. - * - * @param author the author - */ - public void setAuthor(String author) { - this.author = author; - } -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app141/BookRepository.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app141/BookRepository.java deleted file mode 100644 index 06974d0a7..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app141/BookRepository.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * - * - * * - * * * - * * * * Copyright 2019-2020 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.app141; - -import java.util.Arrays; -import java.util.List; - -import org.springframework.stereotype.Component; - -/** - * The type Book repository. - */ -@Component -class BookRepository { - - /** - * Find by author list. - * - * @param author the author - * @return the list - */ - List findByAuthor(String author) { - Book[] books = { new Book("1", "title1", "author1") }; - return Arrays.asList(books); - } - - /** - * Find all list. - * - * @return the list - */ - List findAll() { - Book[] books = { new Book("2", "title2", "author2") }; - return Arrays.asList(books); - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app141/BookRouter.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app141/BookRouter.java deleted file mode 100644 index 0781203e4..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app141/BookRouter.java +++ /dev/null @@ -1,132 +0,0 @@ -/* - * - * - * * - * * * - * * * * Copyright 2019-2020 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.app141; - -import io.swagger.v3.oas.annotations.enums.ParameterIn; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.http.MediaType; -import org.springframework.web.servlet.function.RouterFunction; - -import static org.springdoc.core.fn.builders.operation.Builder.operationBuilder; -import static org.springdoc.core.fn.builders.parameter.Builder.parameterBuilder; -import static org.springdoc.core.utils.Constants.OPERATION_ATTRIBUTE; -import static org.springframework.web.servlet.function.RequestPredicates.GET; -import static org.springframework.web.servlet.function.RequestPredicates.accept; -import static org.springframework.web.servlet.function.RequestPredicates.path; -import static org.springframework.web.servlet.function.RouterFunctions.nest; -import static org.springframework.web.servlet.function.RouterFunctions.route; -import static org.springframework.web.servlet.function.ServerResponse.ok; - -/** - * The type Book router. - */ -@Configuration -class BookRouter { - - - /** - * Routes router function. - * - * @param br the br - * @return the router function - */ - @Bean - RouterFunction routes(BookRepository br) { - return nest(path("/greeter").and(path("/greeter2")), - route(GET("/books").and(accept(MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML)), req -> ok().body(br.findAll())) - .withAttribute(OPERATION_ATTRIBUTE, operationBuilder().beanClass(BookRepository.class).beanMethod("findAll")) - - .and(route(GET("/books").and(accept(MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN)), req -> ok().body(br.findAll())) - .withAttribute(OPERATION_ATTRIBUTE, operationBuilder().beanClass(BookRepository.class).beanMethod("findAll"))) - - .and(route(GET("/books/{author}"), req -> ok().body(br.findByAuthor(req.pathVariable("author")))) - .withAttribute(OPERATION_ATTRIBUTE, operationBuilder() - .operationId("findByAuthor").parameter(parameterBuilder().name("author").in(ParameterIn.PATH)) - .beanClass(BookRepository.class).beanMethod("findByAuthor"))) - ); - } - - /** - * Routes 1 router function. - * - * @param br the br - * @return the router function - */ - @Bean - RouterFunction routes1(BookRepository br) { - return nest(accept(MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML), - route(GET("/books"), req -> ok().body(br.findAll())) - .withAttribute(OPERATION_ATTRIBUTE, operationBuilder().beanClass(BookRepository.class).beanMethod("findAll")) - - .and(route(GET("/books/{author}"), req -> ok().body(br.findByAuthor(req.pathVariable("author")))) - .withAttribute(OPERATION_ATTRIBUTE, operationBuilder() - .operationId("findByAuthor").parameter(parameterBuilder().name("author").in(ParameterIn.PATH)) - .beanClass(BookRepository.class).beanMethod("findByAuthor")))); - } - - /** - * Routes 3 router function. - * - * @param br the br - * @return the router function - */ - @Bean - RouterFunction routes3(BookRepository br) { - return nest(path("/greeter").or(path("/greeter2")), - route(GET("/books").and(accept(MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML)), req -> ok().body(br.findAll())) - .withAttribute(OPERATION_ATTRIBUTE, operationBuilder().beanClass(BookRepository.class).beanMethod("findAll")) - - - .and(route(GET("/books").and(accept(MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN)), req -> ok().body(br.findAll())) - .withAttribute(OPERATION_ATTRIBUTE, operationBuilder().beanClass(BookRepository.class).beanMethod("findAll"))) - - .and(route(GET("/books/{author}"), req -> ok().body(br.findByAuthor(req.pathVariable("author")))) - .withAttribute(OPERATION_ATTRIBUTE, operationBuilder() - .operationId("findByAuthor").parameter(parameterBuilder().name("author").in(ParameterIn.PATH)) - .beanClass(BookRepository.class).beanMethod("findByAuthor")))); - } - - /** - * Routes 4 router function. - * - * @param br the br - * @return the router function - */ - @Bean - RouterFunction routes4(BookRepository br) { - return nest(path("/test"), nest(path("/greeter").and(path("/greeter2")), - route(GET("/books").and(accept(MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML)), req -> ok().body(br.findAll())) - .withAttribute(OPERATION_ATTRIBUTE, operationBuilder().beanClass(BookRepository.class).beanMethod("findAll")) - - .and(route(GET("/books").and(accept(MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN)), req -> ok().body(br.findAll())) - .withAttribute(OPERATION_ATTRIBUTE, operationBuilder().beanClass(BookRepository.class).beanMethod("findAll"))) - - .and(route(GET("/books/{author}"), req -> ok().body(br.findByAuthor(req.pathVariable("author")))) - .withAttribute(OPERATION_ATTRIBUTE, operationBuilder() - .operationId("findByAuthor").parameter(parameterBuilder().name("author").in(ParameterIn.PATH)) - .beanClass(BookRepository.class).beanMethod("findByAuthor"))))); - } -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app141/SpringDocApp141Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app141/SpringDocApp141Test.java deleted file mode 100644 index 4cf55c8dc..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app141/SpringDocApp141Test.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * - * - * * - * * * - * * * * Copyright 2019-2020 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.app141; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - - -/** - * Tests Spring meta-annotations as method parameters - */ -class SpringDocApp141Test extends AbstractSpringDocTest { - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app142/HelloApplication.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app142/HelloApplication.java deleted file mode 100644 index 4a53475d1..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app142/HelloApplication.java +++ /dev/null @@ -1,293 +0,0 @@ -/* - * - * - * * - * * * - * * * * Copyright 2019-2020 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.app142; - -import java.io.IOException; -import java.net.URI; -import java.util.HashSet; -import java.util.Set; -import java.util.concurrent.atomic.AtomicLong; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.enums.ParameterIn; -import jakarta.servlet.FilterChain; -import jakarta.servlet.GenericFilter; -import jakarta.servlet.ServletException; -import jakarta.servlet.ServletRequest; -import jakarta.servlet.ServletResponse; -import org.springdoc.webmvc.core.fn.SpringdocRouteBuilder; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.stereotype.Component; -import org.springframework.stereotype.Service; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RestController; -import org.springframework.web.servlet.function.RouterFunction; -import org.springframework.web.servlet.function.ServerRequest; -import org.springframework.web.servlet.function.ServerResponse; - -import static org.springframework.web.servlet.function.ServerResponse.ok; - -/** - * The type Hello application. - */ -@Configuration -class HelloApplication { - - - /** - * Routes router function. - * - * @param ph the ph - * @return the router function - */ - @Bean - RouterFunction routes(PersonHandler ph) { - String root = ""; - return SpringdocRouteBuilder.route() - .GET(root + "/people", ph::handleGetAllPeople, ops -> ops.beanClass(PersonService.class).beanMethod("all")) - .GET(root + "/people/{id}", ph::handleGetPersonById, ops -> ops.beanClass(PersonService.class).beanMethod("byId")) - .POST(root + "/people", ph::handlePostPerson, ops -> ops.beanClass(PersonService.class).beanMethod("save")).build(); - } - -} - -/** - * The type Simple filter. - */ -@Component -class SimpleFilter extends GenericFilter { - - /** - * Do filter. - * - * @param req the req - * @param res the res - * @param filterChain the filter chain - * @throws IOException the io exception - * @throws ServletException the servlet exception - */ - @Override - public void doFilter(ServletRequest req, ServletResponse res, - FilterChain filterChain) throws IOException, ServletException { - filterChain.doFilter(req, res); - } -} - -/** - * The type Person handler. - */ -@Component -class PersonHandler { - - /** - * The Person service. - */ - private final PersonService personService; - - /** - * Instantiates a new Person handler. - * - * @param personService the person service - */ - PersonHandler(PersonService personService) { - this.personService = personService; - } - - /** - * Handle get all people server response. - * - * @param serverRequest the server request - * @return the server response - */ - ServerResponse handleGetAllPeople(ServerRequest serverRequest) { - return ok().body(personService.all()); - } - - /** - * Handle post person server response. - * - * @param r the r - * @return the server response - * @throws ServletException the servlet exception - * @throws IOException the io exception - */ - ServerResponse handlePostPerson(ServerRequest r) throws ServletException, IOException { - Person result = personService.save(new Person(null, r.body(Person.class).getName())); - URI uri = URI.create("/people/" + result.getId()); - return ServerResponse.created(uri).body(result); - } - - /** - * Handle get person by id server response. - * - * @param r the r - * @return the server response - */ - ServerResponse handleGetPersonById(ServerRequest r) { - return ok().body(personService.byId(Long.parseLong(r.pathVariable("id")))); - } -} - -/** - * The type Greetings rest controller. - */ -@RestController -class GreetingsRestController { - - /** - * Greet string. - * - * @param name the name - * @return the string - */ - @GetMapping("/greet/{name}") - String greet(@PathVariable String name) { - return "hello " + name + "!"; - } -} - -/** - * The type Person service. - */ -@Service -class PersonService { - - /** - * The Counter. - */ - private final AtomicLong counter = new AtomicLong(); - - /** - * The People. - */ - private final Set people = Stream.of( - new Person(counter.incrementAndGet(), "Jane"), - new Person(counter.incrementAndGet(), "Josh"), - new Person(counter.incrementAndGet(), "Gordon")) - .collect(Collectors.toCollection(HashSet::new)); - - - /** - * Save person. - * - * @param p the p - * @return the person - */ - Person save(Person p) { - Person person = new Person(counter.incrementAndGet(), p.getName()); - this.people.add(person); - return person; - } - - /** - * All set. - * - * @return the set - */ - Set all() { - return this.people; - } - - /** - * By id person. - * - * @param id the id - * @return the person - */ - Person byId(@Parameter(in = ParameterIn.PATH) Long id) { - return this.people.stream() - .filter(p -> p.getId().equals(id)) - .findFirst() - .orElseThrow(() -> new IllegalArgumentException("no " + Person.class.getName() + " with that ID found!")); - } - -} - -/** - * The type Person. - */ -class Person { - - /** - * The Id. - */ - private Long id; - - /** - * The Name. - */ - private String name; - - /** - * Instantiates a new Person. - * - * @param id the id - * @param name the name - */ - public Person(Long id, String name) { - this.id = id; - this.name = name; - } - - /** - * Gets id. - * - * @return the id - */ - public Long getId() { - return id; - } - - /** - * Sets id. - * - * @param id the id - */ - public void setId(Long id) { - this.id = id; - } - - /** - * Gets name. - * - * @return the name - */ - public String getName() { - return name; - } - - /** - * Sets name. - * - * @param name the name - */ - public void setName(String name) { - this.name = name; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app142/SpringDocApp142Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app142/SpringDocApp142Test.java deleted file mode 100644 index 243c78eea..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app142/SpringDocApp142Test.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * - * - * * - * * * - * * * * Copyright 2019-2020 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.app142; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - - -/** - * The type Spring doc app 142 test. - */ -class SpringDocApp142Test extends AbstractSpringDocTest { - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app149/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app149/HelloController.java deleted file mode 100644 index ad2c4ba32..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app149/HelloController.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app149; - -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.media.Content; -import io.swagger.v3.oas.annotations.media.Schema; -import io.swagger.v3.oas.annotations.responses.ApiResponse; - -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.ResponseBody; -import org.springframework.web.servlet.ModelAndView; - -/** - * To test the case a user does not use @RestController but puts @Operation on handler methods - * and wants these methods to be exposed. - * - * @author Azige - */ -@Controller -class HelloController { - - /** - * Hello string. - * - * @return the string - */ - @GetMapping("/hello") - @Operation(responses = @ApiResponse( - responseCode = "200", - description = "OK", - content = @Content(schema = @Schema(implementation = HelloMessage.class)) - )) - public String hello() { - return "forward:/message"; - } - - /** - * Message hello message. - * - * @return the hello message - */ - @GetMapping("/message") - @Operation - @ResponseBody - public HelloMessage message() { - return new HelloMessage("Lucky numbers!", 777); - } - - /** - * Hello model and view model and view. - * - * @return the model and view - */ - @GetMapping("/helloModelAndView") - @Operation(responses = @ApiResponse( - responseCode = "200", - description = "OK", - content = @Content(schema = @Schema(implementation = HelloMessage.class)) - )) - public ModelAndView helloModelAndView() { - ModelAndView mav = new ModelAndView(); - mav.setViewName("forward:/message"); - return mav; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app149/HelloMessage.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app149/HelloMessage.java deleted file mode 100644 index 5a59bec2e..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app149/HelloMessage.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app149; - -/** - * The type Hello message. - */ -class HelloMessage { - /** - * The Text. - */ - public String text; - - /** - * The Number. - */ - public int number; - - /** - * Instantiates a new Hello message. - * - * @param text the text - * @param number the number - */ - public HelloMessage(String text, int number) { - this.text = text; - this.number = number; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app149/SpringDocApp149Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app149/SpringDocApp149Test.java deleted file mode 100644 index c744382ba..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app149/SpringDocApp149Test.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app149; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.test.context.TestPropertySource; - -/** - * The type Spring doc app 149 test. - */ -@TestPropertySource(properties = "springdoc.model-and-view-allowed=true") -class SpringDocApp149Test extends AbstractSpringDocTest { - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app15/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app15/HelloController.java deleted file mode 100644 index e45ae4fc0..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app15/HelloController.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app15; - -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.media.Content; -import io.swagger.v3.oas.annotations.media.Schema; -import io.swagger.v3.oas.annotations.responses.ApiResponse; -import org.json.JSONObject; - -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * The type Hello controller. - */ -@RestController -class HelloController { - - /** - * Persons json object. - * - * @return the json object - */ - @GetMapping(value = "/persons") - @Operation(description = "${springdoc.operation-descriptions.myOperation}", responses = @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(hidden = true)))) - public JSONObject persons() { - return new JSONObject(); - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app15/SpringDocApp15Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app15/SpringDocApp15Test.java deleted file mode 100644 index edf10ffbe..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app15/SpringDocApp15Test.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app15; - -import io.swagger.v3.oas.annotations.OpenAPIDefinition; -import io.swagger.v3.oas.annotations.info.Contact; -import io.swagger.v3.oas.annotations.info.Info; -import io.swagger.v3.oas.annotations.info.License; -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.test.context.TestPropertySource; - -/** - * The type Spring doc app 15 test. - */ -@TestPropertySource(properties = { - "springdoc.operation-descriptions.myOperation=My Desc", - "springdoc.openapidefinition.info.title=My title", - "springdoc.openapidefinition.info.desc=My description", - "springdoc.openapidefinition.info.version=My version", - "springdoc.openapidefinition.info.terms=My terms", - "springdoc.openapidefinition.info.license.name=My license name", - "springdoc.openapidefinition.info.license.url=My license url", - "springdoc.openapidefinition.info.contact.name=My contact name", - "springdoc.openapidefinition.info.contact.email=My contact email", - "springdoc.openapidefinition.info.contact.url=My contact url" -}) -class SpringDocApp15Test extends AbstractSpringDocTest { - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - @OpenAPIDefinition(info = @Info( - title = "${springdoc.openapidefinition.info.title}", - description = "${springdoc.openapidefinition.info.desc}", - version = "${springdoc.openapidefinition.info.version}", - termsOfService = "${springdoc.openapidefinition.info.terms}", - license = @License( - name = "${springdoc.openapidefinition.info.license.name}", - url = "${springdoc.openapidefinition.info.license.url}" - ), - contact = @Contact( - name = "${springdoc.openapidefinition.info.contact.name}", - email = "${springdoc.openapidefinition.info.contact.email}", - url = "${springdoc.openapidefinition.info.contact.url}" - ) - )) - static class SpringDocTestApp {} -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app150/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app150/HelloController.java deleted file mode 100644 index d57664d6a..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app150/HelloController.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app150; - -import java.time.LocalDate; -import java.util.List; - -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.media.Schema; -import io.swagger.v3.oas.annotations.responses.ApiResponse; - -import org.springframework.format.annotation.DateTimeFormat; -import org.springframework.http.HttpStatus; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.ResponseStatus; -import org.springframework.web.bind.annotation.RestController; - -import static org.springframework.format.annotation.DateTimeFormat.ISO.DATE; - -/** - * The type Hello controller. - */ -@RestController -class HelloController { - - /** - * Test. - * - * @param toto the toto - */ - @GetMapping("/test/") - @ApiResponse(responseCode = "204", description = "No content") - @ResponseStatus(value = HttpStatus.NO_CONTENT) - public void test(@RequestParam(defaultValue = "1") Integer toto) { - - } - - /** - * Test 1. - * - * @param toto the toto - */ - @GetMapping("/test1") - @ApiResponse(responseCode = "204", description = "No content") - @ResponseStatus(value = HttpStatus.NO_CONTENT) - public void test1(@RequestParam @Parameter(schema = @Schema(defaultValue = "false", type = "boolean")) boolean toto) { - - } - - /** - * Test 3. - * - * @param toto the toto - */ - @GetMapping("/test3") - @ApiResponse(responseCode = "204", description = "No content") - @ResponseStatus(value = HttpStatus.NO_CONTENT) - public void test3(@RequestParam(defaultValue = "users,123") List toto) { - - } - - /** - * Test 4. - * - * @param localDate the local date - */ - @GetMapping("/test4") - @ApiResponse(responseCode = "204", description = "No content") - @ResponseStatus(value = HttpStatus.NO_CONTENT) - public void test4(@DateTimeFormat(iso = DATE) @RequestParam(defaultValue = "2021-03-08") LocalDate localDate) { - - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app150/SpringDocApp150Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app150/SpringDocApp150Test.java deleted file mode 100644 index c5f419fca..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app150/SpringDocApp150Test.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app150; - - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * Tests Spring meta-annotations as method parameters - */ -class SpringDocApp150Test extends AbstractSpringDocTest { - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app151/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app151/HelloController.java deleted file mode 100644 index ddfa63685..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app151/HelloController.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app151; - -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * The type Hello controller. - */ -@RestController -@RequestMapping("/test") -class HelloController { - - /** - * Test int. - * - * @return the int - */ - @GetMapping("") - /** - * A test endpoint mounted under `/test` - * @return 0 - */ - public int test() { - return 0; - } -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app151/SpringDocApp151Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app151/SpringDocApp151Test.java deleted file mode 100644 index 9adcff886..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app151/SpringDocApp151Test.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app151; - - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * Tests Spring meta-annotations as method parameters - */ -class SpringDocApp151Test extends AbstractSpringDocTest { - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app152/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app152/HelloController.java deleted file mode 100644 index cf60ae7e8..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app152/HelloController.java +++ /dev/null @@ -1,46 +0,0 @@ -package test.org.springdoc.api.app152; - -import org.springframework.context.annotation.Configuration; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; -import org.springframework.web.servlet.config.annotation.PathMatchConfigurer; -import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; -import org.springframework.web.util.pattern.PathPatternParser; - -/** - * The type Hello controller. - */ -@RestController -@RequestMapping("/api") -class HelloController { - - /** - * Hello world string. - * - * @return the string - */ - @GetMapping - public String helloWorld() { - return "ok"; - } - - /** - * The type Web config. - */ - @Configuration - class WebConfig implements WebMvcConfigurer { - - /** - * Configure path match. - * - * @param configurer the configurer - */ - @Override - public void configurePathMatch(PathMatchConfigurer configurer) { - configurer.setPatternParser(new PathPatternParser()); - } - - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app152/SpringDocApp152Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app152/SpringDocApp152Test.java deleted file mode 100644 index f2a86f532..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app152/SpringDocApp152Test.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app152; - - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * Tests Spring meta-annotations as method parameters - */ -class SpringDocApp152Test extends AbstractSpringDocTest { - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app153/OrderState.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app153/OrderState.java deleted file mode 100644 index 4ac62d79c..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app153/OrderState.java +++ /dev/null @@ -1,42 +0,0 @@ -package test.org.springdoc.api.app153; - -import io.swagger.v3.oas.annotations.media.Schema; - - -/** - * The enum Order state. - */ -@Schema(type = "string", allowableValues = { "finished", "new" }) -public enum OrderState { - /** - *Finished order state. - */ - FINISHED("finished"), - /** - *New order state. - */ - NEW("new"); - - /** - * The Value. - */ - private final String value; - - /** - * Instantiates a new Order state. - * - * @param value the value - */ - OrderState(String value) { - this.value = value; - } - - /** - * Gets value. - * - * @return the value - */ - public String getValue() { - return value; - } -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app153/OrderStateMapper.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app153/OrderStateMapper.java deleted file mode 100644 index f887b0985..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app153/OrderStateMapper.java +++ /dev/null @@ -1,27 +0,0 @@ -package test.org.springdoc.api.app153; - -import java.beans.PropertyEditorSupport; -import java.util.Arrays; - -import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException; - -/** - * The type Order state mapper. - */ -class OrderStateMapper extends PropertyEditorSupport { - - /** - * Sets as text. - * - * @param text the text - */ - @Override - public void setAsText(String text) { - setValue( - Arrays.stream(OrderState.class.getEnumConstants()) - .filter(e -> e.getValue().equals(text)) - .findFirst() - .orElseThrow(() -> new MethodArgumentTypeMismatchException( - text, OrderState.class, "orderState", null, null))); - } -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app153/SpringDocApp153Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app153/SpringDocApp153Test.java deleted file mode 100644 index 730e8bebd..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app153/SpringDocApp153Test.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app153; - - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * Tests Spring meta-annotations as method parameters - */ -class SpringDocApp153Test extends AbstractSpringDocTest { - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app153/TestController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app153/TestController.java deleted file mode 100644 index 59da34044..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app153/TestController.java +++ /dev/null @@ -1,36 +0,0 @@ -package test.org.springdoc.api.app153; - -import org.springframework.web.bind.WebDataBinder; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.InitBinder; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -/** - * The type Test controller. - */ -@RestController -class TestController { - - /** - * Init binder. - * - * @param dataBinder the data binder - */ - @InitBinder - public void initBinder(WebDataBinder dataBinder) { - dataBinder.registerCustomEditor(OrderState.class, new OrderStateMapper()); - } - - /** - * Method object. - * - * @param orderState the order state - * @return the object - */ - @GetMapping(value = { "/orders" }) - public Object method( - @RequestParam(value = "state", defaultValue = "finished") OrderState orderState) { - return null; - } -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app154/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app154/HelloController.java deleted file mode 100644 index c1d29d062..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app154/HelloController.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app154; - -import java.time.Instant; - -import org.springdoc.core.annotations.ParameterObject; - -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RestController; - -/** - * The type Hello controller. - */ -@RestController -class HelloController { - - - /** - * Hello string. - * - * @return the string - */ - @GetMapping(path = "/") - public String hello() { - return "Hello world at " + Instant.now().toString(); - } - - /** - * Create. - * - * @param id the id - * @param o the o - */ - @PostMapping(value = "/persons") - public void create(@ParameterObject Long id, @RequestBody Object o) { - - } - - /** - * Createone. - * - * @param id the id - * @param o the o - */ - @PostMapping(value = "/personsone") - public void createone(Long id, @RequestBody Object o) { - - } - - /** - * Createtwo. - * - * @param id the id - */ - @PostMapping(value = "/createtwo") - public void createtwo(int id) { - - } - - /** - * Createthree. - * - * @param id the id - */ - @PostMapping(value = "/createthree") - public void createthree(Integer id) { - - } - -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app154/OpenApiConfiguration.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app154/OpenApiConfiguration.java deleted file mode 100644 index afb45b440..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app154/OpenApiConfiguration.java +++ /dev/null @@ -1,30 +0,0 @@ -package test.org.springdoc.api.app154; - -import io.swagger.v3.oas.annotations.OpenAPIDefinition; -import io.swagger.v3.oas.annotations.enums.SecuritySchemeType; -import io.swagger.v3.oas.annotations.info.Info; -import io.swagger.v3.oas.annotations.security.SecurityRequirement; -import io.swagger.v3.oas.annotations.security.SecurityScheme; -import io.swagger.v3.oas.annotations.security.SecuritySchemes; - -/** - * The type Open api configuration. - */ -@OpenAPIDefinition(info = @Info(title = "toto", version = "1.0"), - security = { @SecurityRequirement(name = "basicAuth"), @SecurityRequirement(name = "bearerToken") } -) -@SecuritySchemes({ - @SecurityScheme( - name = "basicAuth", - type = SecuritySchemeType.HTTP, - scheme = "basic" - ), - @SecurityScheme( - name = "bearerToken", - type = SecuritySchemeType.HTTP, - scheme = "bearer", - bearerFormat = "JWT" - ) -}) -class OpenApiConfiguration { -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app154/SpringDocApp154Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app154/SpringDocApp154Test.java deleted file mode 100644 index 7f7df1839..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app154/SpringDocApp154Test.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app154; - - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * Tests Spring meta-annotations as method parameters - */ -class SpringDocApp154Test extends AbstractSpringDocTest { - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app155/AbstractIntParameterObject.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app155/AbstractIntParameterObject.java deleted file mode 100644 index 0d89e059d..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app155/AbstractIntParameterObject.java +++ /dev/null @@ -1,55 +0,0 @@ -package test.org.springdoc.api.app155; - -/** - * The type Abstract int parameter object. - * - * @param the type parameter - */ -class AbstractIntParameterObject { - - /** - * The Primitive base field. - */ - int primitiveBaseField; - - /** - * The Generic field. - */ - T genericField; - - /** - * Gets primitive base field. - * - * @return the primitive base field - */ - public int getPrimitiveBaseField() { - return primitiveBaseField; - } - - /** - * Sets primitive base field. - * - * @param primitiveBaseField the primitive base field - */ - public void setPrimitiveBaseField(int primitiveBaseField) { - this.primitiveBaseField = primitiveBaseField; - } - - /** - * Gets generic field. - * - * @return the generic field - */ - public T getGenericField() { - return genericField; - } - - /** - * Sets generic field. - * - * @param genericField the generic field - */ - public void setGenericField(T genericField) { - this.genericField = genericField; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app155/AbstractParameterObject.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app155/AbstractParameterObject.java deleted file mode 100644 index 664a456fd..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app155/AbstractParameterObject.java +++ /dev/null @@ -1,59 +0,0 @@ -package test.org.springdoc.api.app155; - -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.media.Schema; - -/** - * The type Abstract parameter object. - * - * @param the type parameter - */ -class AbstractParameterObject> { - - /** - * The Primitive base field. - */ - int primitiveBaseField; - - /** - * The Generic field. - */ - @Parameter(schema = @Schema(type = "string", allowableValues = { "ONE", "TWO" })) - T genericField; - - /** - * Gets primitive base field. - * - * @return the primitive base field - */ - public int getPrimitiveBaseField() { - return primitiveBaseField; - } - - /** - * Sets primitive base field. - * - * @param primitiveBaseField the primitive base field - */ - public void setPrimitiveBaseField(int primitiveBaseField) { - this.primitiveBaseField = primitiveBaseField; - } - - /** - * Gets generic field. - * - * @return the generic field - */ - public T getGenericField() { - return genericField; - } - - /** - * Sets generic field. - * - * @param genericField the generic field - */ - public void setGenericField(T genericField) { - this.genericField = genericField; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app155/ConcreteEnum.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app155/ConcreteEnum.java deleted file mode 100644 index 66595bea8..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app155/ConcreteEnum.java +++ /dev/null @@ -1,17 +0,0 @@ -package test.org.springdoc.api.app155; - - -/** - * The enum Concrete enum. - */ -enum ConcreteEnum { - /** - *One concrete enum. - */ - ONE, - /** - *Two concrete enum. - */ - TWO - -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app155/ConcreteIntParameterObject.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app155/ConcreteIntParameterObject.java deleted file mode 100644 index 97ef003ac..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app155/ConcreteIntParameterObject.java +++ /dev/null @@ -1,30 +0,0 @@ -package test.org.springdoc.api.app155; - -/** - * The type Concrete int parameter object. - */ -class ConcreteIntParameterObject extends AbstractIntParameterObject { - - /** - * The Primitive concrete field. - */ - int primitiveConcreteField; - - /** - * Gets primitive concrete field. - * - * @return the primitive concrete field - */ - public int getPrimitiveConcreteField() { - return primitiveConcreteField; - } - - /** - * Sets primitive concrete field. - * - * @param primitiveConcreteField the primitive concrete field - */ - public void setPrimitiveConcreteField(int primitiveConcreteField) { - this.primitiveConcreteField = primitiveConcreteField; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app155/ConcreteParameterObject.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app155/ConcreteParameterObject.java deleted file mode 100644 index e2a21351d..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app155/ConcreteParameterObject.java +++ /dev/null @@ -1,30 +0,0 @@ -package test.org.springdoc.api.app155; - -/** - * The type Concrete parameter object. - */ -class ConcreteParameterObject extends AbstractParameterObject { - - /** - * The Primitive concrete field. - */ - int primitiveConcreteField; - - /** - * Gets primitive concrete field. - * - * @return the primitive concrete field - */ - public int getPrimitiveConcreteField() { - return primitiveConcreteField; - } - - /** - * Sets primitive concrete field. - * - * @param primitiveConcreteField the primitive concrete field - */ - public void setPrimitiveConcreteField(int primitiveConcreteField) { - this.primitiveConcreteField = primitiveConcreteField; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app155/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app155/HelloController.java deleted file mode 100644 index 0587ca62e..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app155/HelloController.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app155; - -import org.springdoc.core.annotations.ParameterObject; - -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * The type Hello controller. - */ -@RestController -class HelloController { - - /** - * Say hello response entity. - * - * @param test the test - * @return the response entity - */ - @GetMapping("/test1") - public ResponseEntity sayHello(@ParameterObject final ConcreteParameterObject test) { - System.out.println("Field B = " + test); - return new ResponseEntity("{\"Say\": \"Hello\"}", HttpStatus.OK); - } - - /** - * Say hello response entity. - * - * @param test the test - * @return the response entity - */ - @GetMapping("/test2") - public ResponseEntity sayHello(@ParameterObject final ConcreteIntParameterObject test) { - System.out.println("Field B = " + test); - return new ResponseEntity("{\"Say\": \"Hello\"}", HttpStatus.OK); - } - -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app155/SpringDocApp155Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app155/SpringDocApp155Test.java deleted file mode 100644 index f27a7c5b8..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app155/SpringDocApp155Test.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app155; - - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * Tests Spring meta-annotations as method parameters - */ -class SpringDocApp155Test extends AbstractSpringDocTest { - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app156/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app156/HelloController.java deleted file mode 100644 index d645edb0c..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app156/HelloController.java +++ /dev/null @@ -1,54 +0,0 @@ -package test.org.springdoc.api.app156; - -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.media.ArraySchema; -import io.swagger.v3.oas.annotations.media.Schema; - -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -import static io.swagger.v3.oas.annotations.enums.ParameterIn.QUERY; - -/** - * The type Hello controller. - */ -@RestController -class HelloController { - /** - * Hello string. - * - * @param user the user - * @return the string - */ - @GetMapping("/hello") - @Parameter(name = "someEnums", in = QUERY, description = "SomeEum decs", - array = @ArraySchema(schema = @Schema(implementation = SomeEnum.class))) - @Parameter(name = "textSet", in = QUERY, description = "First decs", - array = @ArraySchema(schema = @Schema(implementation = String.class))) - @Parameter(name = "someText", in = QUERY, description = "Second decs", - schema = @Schema(type = "string")) - public String hello(@Parameter(hidden = true) User user) { - String forReturn = "Hello "; - StringBuilder stringBuilder = new StringBuilder(forReturn); - - if (user.getSomeEnums() != null) { - for (SomeEnum some : user.getSomeEnums()) { - stringBuilder.append(some); - stringBuilder.append(" "); - } - } - - if (user.getSomeText() != null) { - for (String text : user.getTextSet()) { - stringBuilder.append(text); - stringBuilder.append(" "); - } - } - - if (user.getSomeText() != null) { - stringBuilder.append(user.getSomeText()); - } - - return stringBuilder.toString(); - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app156/SomeEnum.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app156/SomeEnum.java deleted file mode 100644 index 85410b4a7..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app156/SomeEnum.java +++ /dev/null @@ -1,15 +0,0 @@ -package test.org.springdoc.api.app156; - -/** - * The enum Some enum. - */ -public enum SomeEnum { - /** - *First some enum. - */ - FIRST, - /** - *Second some enum. - */ - SECOND -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app156/SpringDocApp156Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app156/SpringDocApp156Test.java deleted file mode 100644 index caeac0895..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app156/SpringDocApp156Test.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app156; - - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * Tests Spring meta-annotations as method parameters - */ -class SpringDocApp156Test extends AbstractSpringDocTest { - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app156/User.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app156/User.java deleted file mode 100644 index f4ec1eceb..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app156/User.java +++ /dev/null @@ -1,77 +0,0 @@ -package test.org.springdoc.api.app156; - -import java.util.Set; - -/** - * The type User. - */ -class User { - /** - * The Some text. - */ - private String someText; - - /** - * The Text set. - */ - private Set textSet; - - /** - * The Some enums. - */ - private Set someEnums; - - /** - * Gets some text. - * - * @return the some text - */ - public String getSomeText() { - return someText; - } - - /** - * Sets some text. - * - * @param someText the some text - */ - public void setSomeText(String someText) { - this.someText = someText; - } - - /** - * Gets text set. - * - * @return the text set - */ - public Set getTextSet() { - return textSet; - } - - /** - * Sets text set. - * - * @param textSet the text set - */ - public void setTextSet(Set textSet) { - this.textSet = textSet; - } - - /** - * Gets some enums. - * - * @return the some enums - */ - public Set getSomeEnums() { - return someEnums; - } - - /** - * Sets some enums. - * - * @param someEnums the some enums - */ - public void setSomeEnums(Set someEnums) { - this.someEnums = someEnums; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app157/Bar.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app157/Bar.java deleted file mode 100644 index 4fa42edae..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app157/Bar.java +++ /dev/null @@ -1,20 +0,0 @@ -package test.org.springdoc.api.app157; - -/** - * A class without a String in it - */ -class Bar { - /** - * The Child. - */ - private Object child; - - /** - * Gets child. - * - * @return the child - */ - public Object getChild() { - return this.child; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app157/Foo.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app157/Foo.java deleted file mode 100644 index 05b8c39a7..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app157/Foo.java +++ /dev/null @@ -1,20 +0,0 @@ -package test.org.springdoc.api.app157; - -/** - * A class with a String in it - */ -class Foo { - /** - * The Child. - */ - private String child; - - /** - * Gets child. - * - * @return the child - */ - public String getChild() { - return this.child; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app157/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app157/HelloController.java deleted file mode 100644 index 4265a2bdf..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app157/HelloController.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app157; - -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * Put Foo and Bar in the schema's components, make sure there is an ignored wrapper - * ({@code ResponseEntity}). - */ -@RestController -class HelloController { - - /** - * Gets foo. - * - * @return the foo - */ - @GetMapping("/foo") - public ResponseEntity getFoo() { - return new ResponseEntity(HttpStatus.OK); - } - - /** - * Gets bar. - * - * @return the bar - */ - @GetMapping("/bar") - public ResponseEntity getBar() { - return new ResponseEntity(HttpStatus.OK); - } - -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app157/SpringDocApp157Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app157/SpringDocApp157Test.java deleted file mode 100644 index ffedde82f..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app157/SpringDocApp157Test.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * - * * - * * * - * * * * - * * * * * 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.app157; - -import java.util.ArrayList; - -import io.swagger.v3.core.converter.ModelConverters; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.Test; -import org.springdoc.core.utils.Constants; -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -import static org.hamcrest.Matchers.hasProperty; -import static org.hamcrest.Matchers.is; -import static org.hamcrest.Matchers.not; -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; - -/** - * This test is to make sure that a new model converter can access the parent of a type, even if - * the type is enclosed in an ignored wrapper. We test this by setting up a model converter which - * adds "stringy" to the "required" property of a schema's parent, when the sub schema is a String. - */ -class SpringDocApp157Test extends AbstractSpringDocTest { - - /** - * The Converters. - */ - private final ModelConverters converters = ModelConverters.getInstance(); - - @Autowired - private StringyConverter stringyConverter; - - /** - * Unregister converter. - */ - @AfterEach - public void unregisterConverter() { - converters.removeConverter(stringyConverter); - } - - /** - * Test app. - * - * @throws Exception the exception - */ - @Test - protected void testApp() throws Exception { - mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL)) - .andExpect(status().isOk()) - .andExpect(jsonPath("$.openapi", is("3.0.1"))) - .andExpect(jsonPath("$.components.schemas.Foo.required", is(new ArrayList() {{ - add("stringy"); - }}))) - .andExpect(jsonPath("$.components.schemas.Bar", not(hasProperty("required")))); - } - - /** - * The type Spring boot app. - */ - @SpringBootApplication - static class SpringBootApp {} -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app157/StringyConverter.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app157/StringyConverter.java deleted file mode 100644 index 97e650607..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app157/StringyConverter.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * - * * - * * * - * * * * - * * * * * 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.app157; - -import java.util.Iterator; - -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.oas.models.media.Schema; -import org.springdoc.core.providers.ObjectMapperProvider; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - - -@Component -class StringyConverter implements ModelConverter { - - @Autowired - ObjectMapperProvider objectMapperProvider; - - public StringyConverter(ObjectMapperProvider objectMapperProvider) { - this.objectMapperProvider = objectMapperProvider; - } - - - @Override - public Schema resolve(AnnotatedType type, ModelConverterContext context, - Iterator chain) { - - JavaType javaType = objectMapperProvider.jsonMapper().constructType(type.getType()); - - if (javaType.getRawClass().equals(String.class)) { - type.getParent().addRequiredItem("stringy"); - } - return chain.next().resolve(type, context, chain); - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app158/CommonFooErrorHandler.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app158/CommonFooErrorHandler.java deleted file mode 100644 index 47230839c..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app158/CommonFooErrorHandler.java +++ /dev/null @@ -1,23 +0,0 @@ -package test.org.springdoc.api.app158; - -import org.springframework.http.HttpStatus; -import org.springframework.web.bind.annotation.ExceptionHandler; -import org.springframework.web.bind.annotation.ResponseStatus; - -/** - * The type Common foo error handler. - */ -class CommonFooErrorHandler { - - /** - * On exception error dto. - * - * @param e the e - * @return the error dto - */ - @ExceptionHandler - @ResponseStatus(HttpStatus.CONFLICT) - public ErrorDTO onException(Exception e) { - return new ErrorDTO("Something wrong has happened"); - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app158/ErrorDTO.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app158/ErrorDTO.java deleted file mode 100644 index 1b3eeef92..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app158/ErrorDTO.java +++ /dev/null @@ -1,44 +0,0 @@ -package test.org.springdoc.api.app158; - -/** - * The type Error dto. - */ -class ErrorDTO { - /** - * The Message. - */ - private String message; - - /** - * Instantiates a new Error dto. - */ - public ErrorDTO() { - } - - /** - * Instantiates a new Error dto. - * - * @param message the message - */ - public ErrorDTO(String message) { - this.message = message; - } - - /** - * Gets message. - * - * @return the message - */ - public String getMessage() { - return message; - } - - /** - * Sets message. - * - * @param message the message - */ - public void setMessage(String message) { - this.message = message; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app158/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app158/HelloController.java deleted file mode 100644 index 0360f2779..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app158/HelloController.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app158; - -import io.swagger.v3.oas.annotations.OpenAPIDefinition; -import io.swagger.v3.oas.annotations.info.Info; -import io.swagger.v3.oas.annotations.tags.Tag; - -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * The type Hello controller. - */ -@RestController -@RequestMapping("/api") -@OpenAPIDefinition(info = @Info(title = "API Examples", version = "1.0"), tags = @Tag(name = "Operations")) -class HelloController { - - /** - * Hello simple dto. - * - * @return the simple dto - */ - @GetMapping("/foo") - public SimpleDTO hello() { - return new SimpleDTO("foo"); - } -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app158/SimpleDTO.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app158/SimpleDTO.java deleted file mode 100644 index 33618eb50..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app158/SimpleDTO.java +++ /dev/null @@ -1,46 +0,0 @@ -package test.org.springdoc.api.app158; - -/** - * The type Simple dto. - */ -class SimpleDTO { - - /** - * The Payload. - */ - private String payload; - - /** - * Instantiates a new Simple dto. - */ - public SimpleDTO() { - } - - /** - * Instantiates a new Simple dto. - * - * @param payload the payload - */ - public SimpleDTO(String payload) { - this.payload = payload; - } - - /** - * Gets payload. - * - * @return the payload - */ - public String getPayload() { - return payload; - } - - /** - * Sets payload. - * - * @param payload the payload - */ - public void setPayload(String payload) { - this.payload = payload; - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app158/SpecificFooErrorHandler.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app158/SpecificFooErrorHandler.java deleted file mode 100644 index 4680982ae..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app158/SpecificFooErrorHandler.java +++ /dev/null @@ -1,10 +0,0 @@ -package test.org.springdoc.api.app158; - -import org.springframework.web.bind.annotation.ControllerAdvice; - -/** - * The type Specific foo error handler. - */ -@ControllerAdvice(assignableTypes = HelloController.class) -class SpecificFooErrorHandler extends CommonFooErrorHandler { -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app158/SpringDocApp158Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app158/SpringDocApp158Test.java deleted file mode 100644 index 9a06672ae..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app158/SpringDocApp158Test.java +++ /dev/null @@ -1,18 +0,0 @@ -package test.org.springdoc.api.app158; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * The type Spring doc app 158 test. - */ -class SpringDocApp158Test extends AbstractSpringDocTest { - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} - -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app159/CustomException.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app159/CustomException.java deleted file mode 100644 index 7ac1e9802..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app159/CustomException.java +++ /dev/null @@ -1,15 +0,0 @@ -package test.org.springdoc.api.app159; - -/** - * The type Custom exception. - */ -class CustomException extends RuntimeException { - /** - * Instantiates a new Custom exception. - * - * @param message the message - */ - public CustomException(String message) { - super(message); - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app159/FooBean.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app159/FooBean.java deleted file mode 100644 index 93849d8ce..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app159/FooBean.java +++ /dev/null @@ -1,67 +0,0 @@ -package test.org.springdoc.api.app159; - -import com.fasterxml.jackson.annotation.JsonView; - -/** - * The type Foo bean. - */ -class FooBean { - /** - * The Message. - */ - @JsonView(Views.View2.class) - private String message; - - /** - * The Code. - */ - @JsonView(Views.View1.class) - private int code; - - /** - * Instantiates a new Foo bean. - * - * @param message the message - * @param code the code - */ - public FooBean(String message, int code) { - this.message = message; - this.code = code; - } - - /** - * Gets message. - * - * @return the message - */ - public String getMessage() { - return message; - } - - /** - * Sets message. - * - * @param message the message - */ - public void setMessage(String message) { - this.message = message; - } - - /** - * Gets code. - * - * @return the code - */ - public int getCode() { - return code; - } - - /** - * Sets code. - * - * @param code the code - */ - public void setCode(int code) { - this.code = code; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app159/FooErrorHandler.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app159/FooErrorHandler.java deleted file mode 100644 index 352a93f65..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app159/FooErrorHandler.java +++ /dev/null @@ -1,42 +0,0 @@ -package test.org.springdoc.api.app159; - -import com.fasterxml.jackson.annotation.JsonView; - -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.ControllerAdvice; -import org.springframework.web.bind.annotation.ExceptionHandler; -import org.springframework.web.bind.annotation.ResponseStatus; - -/** - * The type Foo error handler. - */ -@ControllerAdvice(assignableTypes = HelloController.class) -class FooErrorHandler { - - /** - * Store assignment publishing error response entity. - * - * @param e the e - * @return the response entity - */ - @ExceptionHandler - @ResponseStatus(value = HttpStatus.INTERNAL_SERVER_ERROR) - @JsonView(Views.View1.class) - public ResponseEntity storeAssignmentPublishingError(Exception e) { - return new ResponseEntity<>(new FooBean("INTERNAL_SERVER_ERROR", 500), HttpStatus.INTERNAL_SERVER_ERROR); - } - - /** - * Store assignment publishing error response entity. - * - * @param e the e - * @return the response entity - */ - @ExceptionHandler - @ResponseStatus(value = HttpStatus.BAD_REQUEST) - @JsonView(Views.View2.class) - public ResponseEntity storeAssignmentPublishingError(CustomException e) { - return new ResponseEntity<>(new FooBean("BAD Request", 400), HttpStatus.BAD_REQUEST); - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app159/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app159/HelloController.java deleted file mode 100644 index 865a3ab2b..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app159/HelloController.java +++ /dev/null @@ -1,31 +0,0 @@ -package test.org.springdoc.api.app159; - -import io.swagger.v3.oas.annotations.OpenAPIDefinition; -import io.swagger.v3.oas.annotations.info.Info; -import io.swagger.v3.oas.annotations.tags.Tag; - -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * The type Hello controller. - */ -@RestController -@RequestMapping("/api") -@OpenAPIDefinition(info = @Info(title = "API Examples", version = "1.0"), tags = @Tag(name = "Operations")) -class HelloController { - - /** - * Create string. - * - * @param foo the foo - * @return the string - */ - @PostMapping("/foo") - public String create(@RequestBody String foo) { - return "foo"; - } -} - diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app159/SpringDocApp159Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app159/SpringDocApp159Test.java deleted file mode 100644 index c725aa27c..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app159/SpringDocApp159Test.java +++ /dev/null @@ -1,18 +0,0 @@ -package test.org.springdoc.api.app159; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * The type Spring doc app 159 test. - */ -class SpringDocApp159Test extends AbstractSpringDocTest { - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app159/Views.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app159/Views.java deleted file mode 100644 index a1dbcf1e0..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app159/Views.java +++ /dev/null @@ -1,18 +0,0 @@ -package test.org.springdoc.api.app159; - -/** - * The type Views. - */ -class Views { - /** - * The type View 1. - */ - public static class View1 { - } - - /** - * The type View 2. - */ - public static class View2 extends View1 { - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app16/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app16/HelloController.java deleted file mode 100644 index dc4bd8641..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app16/HelloController.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app16; - -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * The type Hello controller. - */ -@RestController -class HelloController { - - /** - * Persons string. - * - * @return the string - */ - @GetMapping("/persons") - public String persons() { - return "OK"; - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app16/SpringDocApp16Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app16/SpringDocApp16Test.java deleted file mode 100644 index 2899cdd77..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app16/SpringDocApp16Test.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app16; - -import org.junit.jupiter.api.Test; -import org.springdoc.core.utils.Constants; -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.SpringBootConfiguration; -import org.springframework.test.context.TestPropertySource; - -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; - -/** - * The type Spring doc app 16 test. - */ -@TestPropertySource(properties = "springdoc.api-docs.enabled=false") -class SpringDocApp16Test extends AbstractSpringDocTest { - - /** - * Test app. - * - * @throws Exception the exception - */ - @Test - protected void testApp() throws Exception { - mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL)) - .andExpect(status().isNotFound()); - } - - /** - * The type Spring doc test app. - */ - @SpringBootConfiguration - static class SpringDocTestApp {} -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app160/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app160/HelloController.java deleted file mode 100644 index c81884999..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app160/HelloController.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app160; - -import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.v3.oas.annotations.media.Schema; -import org.springdoc.core.models.GroupedOpenApi; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.PropertySource; -import org.springframework.context.support.ResourceBundleMessageSource; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * The type Hello controller. - */ -@RestController -class HelloController { - - /** - * Do something interesting error response. - * - * @return the error response - */ - @PostMapping("test") - public ErrorResponse doSomethingInteresting() { - return null; - } - - /** - * Bundle api grouped open api. - * - * @return the grouped open api - */ - @Bean - public GroupedOpenApi bundleApi() { - return GroupedOpenApi.builder() - .group("test") - .pathsToMatch("/**") - .build(); - } - - /** - * Translator resource bundle message source. - * - * @return the resource bundle message source - */ - @Bean - public ResourceBundleMessageSource translator() { - ResourceBundleMessageSource source = new ResourceBundleMessageSource(); - source.setBasenames("swagger-message-160"); - source.setUseCodeAsDefaultMessage(true); - source.setDefaultEncoding("utf-8"); - return source; - } - - /** - * The type Swagger message. - */ - @PropertySource("classpath:swagger-message-160.properties") - @Configuration - class SwaggerMessage {} - - /** - * The type Error response. - */ - @Schema(description = "${ErrorResponse}") - class ErrorResponse { - - /** - * The Error code. - */ - @Schema(description = "${ErrorCode}", required = true) - @JsonProperty - private Integer errorCode; - - /** - * The Error message. - */ - @Schema(description = "${ErrorMessage}") - @JsonProperty - private String errorMessage; - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app160/SpringDocApp160Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app160/SpringDocApp160Test.java deleted file mode 100644 index 84a5a06c7..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app160/SpringDocApp160Test.java +++ /dev/null @@ -1,20 +0,0 @@ -package test.org.springdoc.api.app160; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.test.context.TestPropertySource; - -/** - * The type Spring doc app 160 test. - */ -@TestPropertySource(properties = "springdoc.api-docs.resolve-schema-properties=true") -class SpringDocApp160Test extends AbstractSpringDocTest { - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app161/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app161/HelloController.java deleted file mode 100644 index add930dc7..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app161/HelloController.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app161; - -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; - -import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestPart; -import org.springframework.web.bind.annotation.RestController; - -/** - * The type Hello controller. - */ -@RestController -class HelloController { - - - /** - * Add response entity. - * - * @param content the content - * @return the response entity - * @throws Exception the exception - */ - @Operation(summary = "add") - @PostMapping(value = "/add", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.MULTIPART_FORM_DATA_VALUE) - public ResponseEntity add(@Parameter(description = "content") @RequestPart(value = "content") String content) throws Exception { - return null; - } - - - /** - * Add 2 response entity. - * - * @param content the content - * @param type the type - * @return the response entity - */ - @Operation(summary = "add2") - @PostMapping(value = "/add2", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.MULTIPART_FORM_DATA_VALUE) - public ResponseEntity add2( - @Parameter(description = "content") @RequestPart(value = "content") String content, - @RequestPart(value = "type") String type - ) { - return null; - } - - /** - * Test. - * - * @param strValue the str value - * @param intValue the int value - */ - @PostMapping(produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.MULTIPART_FORM_DATA_VALUE) - @Operation(summary = "test") - public void test(@RequestPart("strValue") String strValue, - @RequestPart("intValue") Integer intValue) { - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app161/SpringDocApp161Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app161/SpringDocApp161Test.java deleted file mode 100644 index 13c84e5ad..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app161/SpringDocApp161Test.java +++ /dev/null @@ -1,18 +0,0 @@ -package test.org.springdoc.api.app161; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * The type Spring doc app 161 test. - */ -class SpringDocApp161Test extends AbstractSpringDocTest { - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app162/SpringDocApp162Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app162/SpringDocApp162Test.java deleted file mode 100644 index 1bca98ed2..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app162/SpringDocApp162Test.java +++ /dev/null @@ -1,38 +0,0 @@ -package test.org.springdoc.api.app162; - -import io.swagger.v3.oas.models.OpenAPI; -import io.swagger.v3.oas.models.info.Info; -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.Bean; -import org.springframework.test.context.TestPropertySource; - -/** - * The type Spring doc app 162 test. - */ -@TestPropertySource(properties = "springdoc.override-with-generic-response=true") -class SpringDocApp162Test extends AbstractSpringDocTest { - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp { - /** - * Custom open api open api. - * - * @return the open api - */ - @Bean - public OpenAPI customOpenAPI() { - return new OpenAPI() - .info(new Info() - .title("SpringShop API") - .version("v1") - .description("The description of the api")); - } - - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app162/exception/NoResultException.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app162/exception/NoResultException.java deleted file mode 100644 index 3af9a55f7..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app162/exception/NoResultException.java +++ /dev/null @@ -1,4 +0,0 @@ -package test.org.springdoc.api.app162.exception; - -public class NoResultException extends RuntimeException { -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app162/exception/NonUniqueResultException.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app162/exception/NonUniqueResultException.java deleted file mode 100644 index bed7df86a..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app162/exception/NonUniqueResultException.java +++ /dev/null @@ -1,7 +0,0 @@ -package test.org.springdoc.api.app162.exception; - -/** - * Multiple results found instead of a unique result. - */ -public class NonUniqueResultException extends RuntimeException { -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app162/rest/JavadocOnlyRestController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app162/rest/JavadocOnlyRestController.java deleted file mode 100644 index 18df12bde..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app162/rest/JavadocOnlyRestController.java +++ /dev/null @@ -1,90 +0,0 @@ -package test.org.springdoc.api.app162.rest; - -import java.util.List; - -import test.org.springdoc.api.app162.exception.NoResultException; -import test.org.springdoc.api.app162.exception.NonUniqueResultException; -import test.org.springdoc.api.app162.rest.dto.JavadocOnlyRestDto; - -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.ResponseStatus; -import org.springframework.web.bind.annotation.RestController; - -/** - * This is the {@code JavadocOnlyRestController} class javadoc. - */ -@RestController -@RequestMapping("/javadoc-only") -class JavadocOnlyRestController { - /** - * This is the create method's javadoc. - * The method's signature: {@code #create(JavadocOnlyRestDto)} - * - * @param input the {@code @param input} javadoc for the {@code #create(JavadocOnlyRestDto)} method - * @return the {@code @return} javadoc for the {@code #create(JavadocOnlyRestDto)} method - */ - @PostMapping(consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) - @ResponseStatus(HttpStatus.CREATED) - public ResponseEntity create(@RequestBody JavadocOnlyRestDto input) { - return new ResponseEntity<>(HttpStatus.CREATED); - } - - /** - * This is the update method's javadoc. - * The method's signature: {@code #update(String, JavadocOnlyRestDto)} - * - * @param guid the {@code @param input} javadoc for the {@code #update(String, JavadocOnlyRestDto)} method - * @return the {@code @return} javadoc for the {@code #update(String, JavadocOnlyRestDto)} method - */ - @PutMapping(path = "{guid}", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) - @ResponseStatus(HttpStatus.OK) - public ResponseEntity update(@PathVariable String guid, @RequestBody JavadocOnlyRestDto input) throws NoResultException { - return new ResponseEntity<>(HttpStatus.CREATED); - } - - /** - * This is the list method's javadoc. - * The method's signature: {@code #list()} - * - * @return the {@code @return} javadoc for the {@code #list()} method - */ - @GetMapping(produces = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity> list() { - return new ResponseEntity<>(HttpStatus.OK); - } - - /** - * This is the find method's javadoc. - * The method's signature: {@code #find(String)} - * - * @param guid the {@code @param guid} javadoc for the {@code #find(String)} method - * @return the {@code @return} javadoc for the {@code #find(String)} method - * @throws NoResultException the {@code @throws NoResultException} javadoc for the {@code #find(String)} method - */ - @GetMapping(path = "{guid}", produces = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity find(@PathVariable String guid) throws NoResultException { - return new ResponseEntity<>(HttpStatus.OK); - } - - /** - * This is the findStartsBy method's javadoc. - * The method's signature: {@code #findStartsBy(String)} - * - * @param prefix the {@code @param prefix} javadoc for the {@code #findStartsBy(String)} method - * @return the {@code @return} javadoc for the {@code #findStartsBy(String)} method - * @throws NoResultException the {@code @throws NoResultException} javadoc for the {@code #findStartsBy(String)} method - * @throws NonUniqueResultException the {@code @throws NonUniqueResultException} javadoc for the {@code #findStartsBy(String)} method - */ - @GetMapping(path = "startsBy/{prefix}", produces = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity findStartsBy(@PathVariable String prefix) throws NoResultException, NonUniqueResultException { - return new ResponseEntity<>(HttpStatus.OK); - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app162/rest/dto/JavadocOnlyRestDto.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app162/rest/dto/JavadocOnlyRestDto.java deleted file mode 100644 index b0fef4237..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app162/rest/dto/JavadocOnlyRestDto.java +++ /dev/null @@ -1,59 +0,0 @@ -package test.org.springdoc.api.app162.rest.dto; - -/** - * This is the {@code JavadocOnlyRestDto} class javadoc. - */ -public class JavadocOnlyRestDto { - /** - * This is the private {@code #guid} field's javadoc. - */ - private String guid; - - /** - * This is the private {@code #inner} field's javadoc. - * - * This javadoc description is ignored by the REST documentation: - * the {@code $ref} can't have a description as any sibling elements of a $ref are ignored. - */ - private JavadocOnlyStaticInnerRestDto inner; - - public JavadocOnlyRestDto() { - } - - public String getGuid() { - return guid; - } - - public void setGuid(String guid) { - this.guid = guid; - } - - public JavadocOnlyStaticInnerRestDto getInner() { - return inner; - } - - public void setInner(JavadocOnlyStaticInnerRestDto inner) { - this.inner = inner; - } - - /** - * This is the {@code JavadocOnlyStaticInnerRestDto} class javadoc. - */ - public static class JavadocOnlyStaticInnerRestDto { - /** - * This is the private {@code #content} field's javadoc. - */ - private String content; - - public JavadocOnlyStaticInnerRestDto() { - } - - public String getContent() { - return content; - } - - public void setContent(String content) { - this.content = content; - } - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app162/rest/util/RestExceptionHandler.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app162/rest/util/RestExceptionHandler.java deleted file mode 100644 index f921989d6..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app162/rest/util/RestExceptionHandler.java +++ /dev/null @@ -1,45 +0,0 @@ -package test.org.springdoc.api.app162.rest.util; - -import test.org.springdoc.api.app162.exception.NoResultException; -import test.org.springdoc.api.app162.exception.NonUniqueResultException; - -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.ExceptionHandler; -import org.springframework.web.bind.annotation.ResponseStatus; -import org.springframework.web.bind.annotation.RestControllerAdvice; - -/** - * REST exception handlers. - * - * This javadoc description is ignored by the REST documentation. - */ -@RestControllerAdvice -class RestExceptionHandler { - /** - * REST exception handler for {@code NoResultException}. - * - * This javadoc description is ignored by the REST documentation. - * - * @return the {@code return} javadoc for the {@code #handleNotFoundException(NoResultException)} method - */ - @ExceptionHandler(NoResultException.class) - @ResponseStatus(code = HttpStatus.NOT_FOUND) - public ResponseEntity handleNotFoundException(NoResultException exception) { - return new ResponseEntity<>("No result for the arguments.", HttpStatus.NOT_FOUND); - } - - /** - * REST exception handler for {@code NonUniqueResultException}. - * - * This javadoc description is ignored by the REST documentation. - * - * @return the {@code return} javadoc for the {@code #handleNonUniqueResultException(NonUniqueResultException)} method - */ - @ExceptionHandler(NonUniqueResultException.class) - @ResponseStatus(code = HttpStatus.BAD_REQUEST) - public ResponseEntity handleNonUniqueResultException(NonUniqueResultException exception) { - return new ResponseEntity<>("No unique result found for the arguments.", HttpStatus.BAD_REQUEST); - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app163/SpringDocApp163Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app163/SpringDocApp163Test.java deleted file mode 100644 index 4fc870f61..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app163/SpringDocApp163Test.java +++ /dev/null @@ -1,38 +0,0 @@ -package test.org.springdoc.api.app163; - -import io.swagger.v3.oas.models.OpenAPI; -import io.swagger.v3.oas.models.info.Info; -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.Bean; -import org.springframework.test.context.TestPropertySource; - -/** - * The type Spring doc app 163 test. - */ -@TestPropertySource(properties = "springdoc.override-with-generic-response=true") -class SpringDocApp163Test extends AbstractSpringDocTest { - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp { - /** - * Custom open api open api. - * - * @return the open api - */ - @Bean - public OpenAPI customOpenAPI() { - return new OpenAPI() - .info(new Info() - .title("SpringShop API") - .version("v1") - .description("The description of the api")); - } - - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app163/exception/NoResultException.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app163/exception/NoResultException.java deleted file mode 100644 index b051533bc..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app163/exception/NoResultException.java +++ /dev/null @@ -1,4 +0,0 @@ -package test.org.springdoc.api.app163.exception; - -public class NoResultException extends RuntimeException { -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app163/exception/NonUniqueResultException.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app163/exception/NonUniqueResultException.java deleted file mode 100644 index 081f53264..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app163/exception/NonUniqueResultException.java +++ /dev/null @@ -1,7 +0,0 @@ -package test.org.springdoc.api.app163.exception; - -/** - * Multiple results found instead of a unique result. - */ -public class NonUniqueResultException extends RuntimeException { -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app163/rest/AnnotationOverrideForJavadocRestController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app163/rest/AnnotationOverrideForJavadocRestController.java deleted file mode 100644 index ebdce97de..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app163/rest/AnnotationOverrideForJavadocRestController.java +++ /dev/null @@ -1,105 +0,0 @@ -package test.org.springdoc.api.app163.rest; - -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.responses.ApiResponse; -import io.swagger.v3.oas.annotations.tags.Tag; -import test.org.springdoc.api.app163.exception.NoResultException; -import test.org.springdoc.api.app163.exception.NonUniqueResultException; -import test.org.springdoc.api.app163.rest.dto.AnnotationOverrideForJavadocRestDto; - -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.ResponseStatus; -import org.springframework.web.bind.annotation.RestController; - -/** - * This is the {@code AnnotationOverrideForJavadocRestController} class javadoc. - */ -@Tag( - name = "annotation-override", - description = "Description for the tag." -) -@RestController -@RequestMapping("/annotation-override") -class AnnotationOverrideForJavadocRestController { - /** - * This is the update method's javadoc. - * The method's signature: {@code #update(String, AnnotationOverrideForJavadocRestDto)} - * - * @param guid the {@code @param input} javadoc for the {@code #update(String, AnnotationOverrideForJavadocRestDto)} method - * @return the {@code @return} javadoc for the {@code #update(String, AnnotationOverrideForJavadocRestDto)} method - */ - @Operation( - summary = "Summary for #update(String, AnnotationOverrideForJavadocRestDto)" - ) - @PutMapping(path = "{guid}", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) - @ResponseStatus(HttpStatus.OK) - public ResponseEntity update(@PathVariable String guid, @RequestBody AnnotationOverrideForJavadocRestDto input) throws NoResultException { - return new ResponseEntity<>(HttpStatus.CREATED); - } - - /** - * This is the create method's javadoc. - * The method's signature: {@code #create(AnnotationOverrideForJavadocRestDto)} - * - * @param input the {@code @param input} javadoc for the {@code #create(AnnotationOverrideForJavadocRestDto)} method - * @return the {@code @return} javadoc for the {@code #create(AnnotationOverrideForJavadocRestDto)} method - */ - @Operation( - summary = "Summary for #create(AnnotationOverrideForJavadocRestDto)", - description = "Description for #create(AnnotationOverrideForJavadocRestDto)", - requestBody = @io.swagger.v3.oas.annotations.parameters.RequestBody( - description = "Request body for #create(AnnotationOverrideForJavadocRestDto)" - ), - responses = { - @ApiResponse( - description = "API Response 201 for #create(AnnotationOverrideForJavadocRestDto)" - ) - } - ) - @PostMapping(consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) - @ResponseStatus(HttpStatus.CREATED) - public ResponseEntity create(@RequestBody AnnotationOverrideForJavadocRestDto input) { - return new ResponseEntity<>(HttpStatus.CREATED); - } - - /** - * This is the findStartsBy method's javadoc. - * The method's signature: {@code #findStartsBy(String)} - * - * @param prefix the {@code @param prefix} javadoc for the {@code #findStartsBy(String)} method - * @return the {@code @return} javadoc for the {@code #findStartsBy(String)} method - * @throws NoResultException the {@code @throws NoResultException} javadoc for the {@code #findStartsBy(String)} method - * @throws NonUniqueResultException the {@code @throws NonUniqueResultException} javadoc for the {@code #findStartsBy(String)} method - */ - @Operation( - parameters = { - @Parameter( - name = "prefix", - description = "Parameter prefix" - ) - }, - responses = { - @ApiResponse( - responseCode = "200", - description = "API Response 200 for #findStartsBy(prefix)" - ), - @ApiResponse( - responseCode = "400", - description = "API Response 400 for #findStartsBy(prefix)" - ) - } - ) - @GetMapping(path = "startsBy/{prefix}", produces = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity findStartsBy(@PathVariable String prefix) throws NoResultException, NonUniqueResultException { - return new ResponseEntity<>(HttpStatus.OK); - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app163/rest/dto/AnnotationOverrideForJavadocRestDto.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app163/rest/dto/AnnotationOverrideForJavadocRestDto.java deleted file mode 100644 index 42401b4bc..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app163/rest/dto/AnnotationOverrideForJavadocRestDto.java +++ /dev/null @@ -1,60 +0,0 @@ -package test.org.springdoc.api.app163.rest.dto; - -import io.swagger.v3.oas.annotations.media.Schema; - -/** - * This is the {@code AnnotationOverrideForJavadocRestDto} class javadoc. - */ -@Schema( - title = "annotation-override-dto", - description = "Description for the tag." -) -public class AnnotationOverrideForJavadocRestDto { - /** - * This is the private {@code #guid} field's javadoc. - */ - @Schema(description = "Description for the #guid field") - private String guid; - - /** - * This is the private {@code #inner} field's javadoc. - *

- * This javadoc description is ignored by the REST documentation: - * the {@code $ref} can't have a description as any sibling elements of a $ref are ignored. - */ - private AnnotationOverrideForJavadocStaticInnerRestDto inner; - - public String getGuid() { - return guid; - } - - public void setGuid(String guid) { - this.guid = guid; - } - - public AnnotationOverrideForJavadocStaticInnerRestDto getInner() { - return inner; - } - - public void setInner(AnnotationOverrideForJavadocStaticInnerRestDto inner) { - this.inner = inner; - } - - /** - * This is the {@code AnnotationOverrideForJavadocStaticInnerRestDto} class javadoc. - */ - public static class AnnotationOverrideForJavadocStaticInnerRestDto { - /** - * This is the private {@code #content} field's javadoc. - */ - private String content; - - public String getContent() { - return content; - } - - public void setContent(String content) { - this.content = content; - } - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app163/rest/dto/AnnotationOverrideForJavadocRestDto2.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app163/rest/dto/AnnotationOverrideForJavadocRestDto2.java deleted file mode 100644 index b8908c924..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app163/rest/dto/AnnotationOverrideForJavadocRestDto2.java +++ /dev/null @@ -1,20 +0,0 @@ -package test.org.springdoc.api.app163.rest.dto; - -/** - * This is the {@code AnnotationOverrideForJavadocRestDto2} class javadoc. - */ -class AnnotationOverrideForJavadocRestDto2 { - /** - * This is the private {@code #guid3} field's javadoc. - */ - private String guid3; - - public String getGuid3() { - return guid3; - } - - public void setGuid3(String guid3) { - this.guid3 = guid3; - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app163/rest/dto/AnnotationOverrideForJavadocRestDto3.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app163/rest/dto/AnnotationOverrideForJavadocRestDto3.java deleted file mode 100644 index b5714e4b2..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app163/rest/dto/AnnotationOverrideForJavadocRestDto3.java +++ /dev/null @@ -1,20 +0,0 @@ -package test.org.springdoc.api.app163.rest.dto; - -/** - * This is the {@code AnnotationOverrideForJavadocRestDto3} class javadoc. - */ -class AnnotationOverrideForJavadocRestDto3 { - /** - * This is the private {@code #guid4} field's javadoc. - */ - private String guid4; - - public String getGuid4() { - return guid4; - } - - public void setGuid4(String guid4) { - this.guid4 = guid4; - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app163/rest/util/RestExceptionHandler.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app163/rest/util/RestExceptionHandler.java deleted file mode 100644 index 6c0d1e800..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app163/rest/util/RestExceptionHandler.java +++ /dev/null @@ -1,45 +0,0 @@ -package test.org.springdoc.api.app163.rest.util; - -import test.org.springdoc.api.app163.exception.NoResultException; -import test.org.springdoc.api.app163.exception.NonUniqueResultException; - -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.ExceptionHandler; -import org.springframework.web.bind.annotation.ResponseStatus; -import org.springframework.web.bind.annotation.RestControllerAdvice; - -/** - * REST exception handlers. - * - * This javadoc description is ignored by the REST documentation. - */ -@RestControllerAdvice -class RestExceptionHandler { - /** - * REST exception handler for {@code NoResultException}. - * - * This javadoc description is ignored by the REST documentation. - * - * @return the {@code return} javadoc for the {@code #handleNotFoundException(NoResultException)} method - */ - @ExceptionHandler(NoResultException.class) - @ResponseStatus(code = HttpStatus.NOT_FOUND) - public ResponseEntity handleNotFoundException(NoResultException exception) { - return new ResponseEntity<>("No result for the arguments.", HttpStatus.NOT_FOUND); - } - - /** - * REST exception handler for {@code NonUniqueResultException}. - * - * This javadoc description is ignored by the REST documentation. - * - * @return the {@code return} javadoc for the {@code #handleNonUniqueResultException(NonUniqueResultException)} method - */ - @ExceptionHandler(NonUniqueResultException.class) - @ResponseStatus(code = HttpStatus.BAD_REQUEST) - public ResponseEntity handleNonUniqueResultException(NonUniqueResultException exception) { - return new ResponseEntity<>("No unique result found for the arguments.", HttpStatus.BAD_REQUEST); - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app164/SpringDocApp164Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app164/SpringDocApp164Test.java deleted file mode 100644 index bcfa41c01..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app164/SpringDocApp164Test.java +++ /dev/null @@ -1,36 +0,0 @@ -package test.org.springdoc.api.app164; - -import io.swagger.v3.oas.models.OpenAPI; -import io.swagger.v3.oas.models.info.Info; -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.Bean; - -/** - * The type Spring doc app 164 test. - */ -class SpringDocApp164Test extends AbstractSpringDocTest { - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp { - /** - * Custom open api open api. - * - * @return the open api - */ - @Bean - public OpenAPI customOpenAPI() { - return new OpenAPI() - .info(new Info() - .title("SpringShop API") - .version("v1") - .description("The description of the api")); - } - - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app164/SpringDocJavadocProviderTest.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app164/SpringDocJavadocProviderTest.java deleted file mode 100644 index f6c43aee7..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app164/SpringDocJavadocProviderTest.java +++ /dev/null @@ -1,61 +0,0 @@ -package test.org.springdoc.api.app164; - -import java.util.stream.Stream; - -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.Arguments; -import org.junit.jupiter.params.provider.MethodSource; -import org.springdoc.core.providers.JavadocProvider; -import org.springdoc.core.providers.SpringDocJavadocProvider; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.jupiter.params.provider.Arguments.arguments; - -class SpringDocJavadocProviderTest { - private JavadocProvider javadocProvider; - - static Stream getFirstSentence() { - return Stream.of( - arguments(null, null), - arguments("", ""), - arguments("A b c. D e f", "A b c."), - arguments("A b c", "A b c"), - arguments("A b c

D e f", "A b c"), - arguments("A b c. D

e f", "A b c"), - arguments("A b c

D. e f", "A b c"), - arguments("

A b c

D e f", "A b c"), - arguments("

A b c. D

e f", "A b c"), - arguments("A b c.d e f", "A b c.d e f") - ); - } - - /** - * Edge cases not handled by the implementation. - */ - static Stream getFirstSentenceNotHandled() { - return Stream.of( - arguments("

A b c

d e f

", "A b c") - ); - } - - @BeforeEach - public void setup() { - javadocProvider = new SpringDocJavadocProvider(); - } - - @ParameterizedTest - @MethodSource - public void getFirstSentence(String javadoc, String expectedFirstSentence) { - assertThat(javadocProvider.getFirstSentence(javadoc)) - .isEqualTo(expectedFirstSentence); - } - - @ParameterizedTest - @MethodSource - public void getFirstSentenceNotHandled(String javadoc, String correctFirstSentence) { - assertThat(javadocProvider.getFirstSentence(javadoc)) - .isNotEqualTo(correctFirstSentence); - } - -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app164/exception/NoResultException.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app164/exception/NoResultException.java deleted file mode 100644 index ced3e68df..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app164/exception/NoResultException.java +++ /dev/null @@ -1,4 +0,0 @@ -package test.org.springdoc.api.app164.exception; - -public class NoResultException extends RuntimeException { -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app164/exception/NonUniqueResultException.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app164/exception/NonUniqueResultException.java deleted file mode 100644 index 3e4fd48a9..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app164/exception/NonUniqueResultException.java +++ /dev/null @@ -1,7 +0,0 @@ -package test.org.springdoc.api.app164.exception; - -/** - * Multiple results found instead of a unique result. - */ -public class NonUniqueResultException extends RuntimeException { -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app164/rest/NoGenericOverrideRestController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app164/rest/NoGenericOverrideRestController.java deleted file mode 100644 index a1072449b..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app164/rest/NoGenericOverrideRestController.java +++ /dev/null @@ -1,49 +0,0 @@ -package test.org.springdoc.api.app164.rest; - -import test.org.springdoc.api.app164.exception.NoResultException; -import test.org.springdoc.api.app164.exception.NonUniqueResultException; - -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.ResponseStatus; -import org.springframework.web.bind.annotation.RestController; - -/** - * This is the {@code JavadocOnlyRestController} class javadoc. - */ -@RestController -@RequestMapping("/no-generic-override") -class NoGenericOverrideRestController { - /** - * This is the create method's javadoc. - * The method's signature: {@code #create(JavadocOnlyRestDto)} - * - * @param input the {@code @param input} javadoc for the {@code #create(JavadocOnlyRestDto)} method - * @return the {@code @return} javadoc for the {@code #create(JavadocOnlyRestDto)} method - */ - @PostMapping(consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) - @ResponseStatus(HttpStatus.CREATED) - public ResponseEntity create(@RequestBody String input) { - return new ResponseEntity<>(HttpStatus.CREATED); - } - - /** - * This is the findStartsBy method's javadoc. - * The method's signature: {@code #findStartsBy(String)} - * - * @param prefix the {@code @param prefix} javadoc for the {@code #findStartsBy(String)} method - * @return the {@code @return} javadoc for the {@code #findStartsBy(String)} method - * @throws NoResultException the {@code @throws NoResultException} javadoc for the {@code #findStartsBy(String)} method - * @throws NonUniqueResultException the {@code @throws NonUniqueResultException} javadoc for the {@code #findStartsBy(String)} method - */ - @GetMapping(path = "startsBy/{prefix}", produces = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity findStartsBy(@PathVariable String prefix) throws NoResultException, NonUniqueResultException { - return new ResponseEntity<>(HttpStatus.OK); - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app164/rest/util/RestExceptionHandler.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app164/rest/util/RestExceptionHandler.java deleted file mode 100644 index 3bc2c4f54..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app164/rest/util/RestExceptionHandler.java +++ /dev/null @@ -1,45 +0,0 @@ -package test.org.springdoc.api.app164.rest.util; - -import test.org.springdoc.api.app164.exception.NoResultException; -import test.org.springdoc.api.app164.exception.NonUniqueResultException; - -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.ExceptionHandler; -import org.springframework.web.bind.annotation.ResponseStatus; -import org.springframework.web.bind.annotation.RestControllerAdvice; - -/** - * REST exception handlers. - * - * This javadoc description is ignored by the REST documentation. - */ -@RestControllerAdvice -class RestExceptionHandler { - /** - * REST exception handler for {@code NoResultException}. - * - * This javadoc description is ignored by the REST documentation. - * - * @return the {@code return} javadoc for the {@code #handleNotFoundException(NoResultException)} method - */ - @ExceptionHandler(NoResultException.class) - @ResponseStatus(code = HttpStatus.NOT_FOUND) - public ResponseEntity handleNotFoundException(NoResultException exception) { - return new ResponseEntity<>("No result for the arguments.", HttpStatus.NOT_FOUND); - } - - /** - * REST exception handler for {@code NonUniqueResultException}. - * - * This javadoc description is ignored by the REST documentation. - * - * @return the {@code return} javadoc for the {@code #handleNonUniqueResultException(NonUniqueResultException)} method - */ - @ExceptionHandler(NonUniqueResultException.class) - @ResponseStatus(code = HttpStatus.BAD_REQUEST) - public ResponseEntity handleNonUniqueResultException(NonUniqueResultException exception) { - return new ResponseEntity<>("No unique result found for the arguments.", HttpStatus.BAD_REQUEST); - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app166/ConcreteSubclassFromGeneric.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app166/ConcreteSubclassFromGeneric.java deleted file mode 100644 index d2c390853..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app166/ConcreteSubclassFromGeneric.java +++ /dev/null @@ -1,13 +0,0 @@ -package test.org.springdoc.api.app166; - -class ConcreteSubclassFromGeneric extends SimpleGeneric { - - /** - * Return the top name - */ - private String topName; - - public String getTopName() { - return topName; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app166/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app166/HelloController.java deleted file mode 100644 index 9079a8c4c..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app166/HelloController.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * - * * - * * * - * * * * 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.app166; - - -import org.springdoc.core.annotations.ParameterObject; - -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -@RestController -class HelloController { - @GetMapping("/nested") - public ResponseEntity nested(@ParameterObject final SimpleOuterClass filter) { - return new ResponseEntity<>("{\"Say\": \"Hello\"}", HttpStatus.OK); - } - - @GetMapping("/nestedTypeErasureGeneric") - public ResponseEntity nestedTypeErasureGeneric(@ParameterObject final SimpleGeneric filter) { - return new ResponseEntity<>("{\"Say\": \"Hello\"}", HttpStatus.OK); - } - - @GetMapping("/nestedReifiableGeneric") - public ResponseEntity nestedReifiableGeneric(@ParameterObject final ConcreteSubclassFromGeneric filter) { - return new ResponseEntity<>("{\"Say\": \"Hello\"}", HttpStatus.OK); - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app166/MyData.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app166/MyData.java deleted file mode 100644 index 6a06f045b..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app166/MyData.java +++ /dev/null @@ -1,22 +0,0 @@ -package test.org.springdoc.api.app166; - -class MyData { - - /** - * Returns the first name - */ - private String firstName; - - /** - * Returns the max number - */ - private Integer maxNumber; - - public Integer getMaxNumber() { - return maxNumber; - } - - public String getFirstName() { - return firstName; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app166/SimpleGeneric.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app166/SimpleGeneric.java deleted file mode 100644 index f17f82d3d..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app166/SimpleGeneric.java +++ /dev/null @@ -1,22 +0,0 @@ -package test.org.springdoc.api.app166; - -class SimpleGeneric { - - /** - * Returns name - */ - private String name; - - /** - * Returns the generic child - */ - private T child; - - public T getChild() { - return child; - } - - public String getName() { - return name; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app166/SimpleInnerClass.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app166/SimpleInnerClass.java deleted file mode 100644 index 2066685ff..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app166/SimpleInnerClass.java +++ /dev/null @@ -1,31 +0,0 @@ -package test.org.springdoc.api.app166; - -class SimpleInnerClass { - - /** - * Returns the inner inner class - */ - private SimpleInnerInnerClass innerInnerClass; - - /** - * Returns the boolean name - */ - private Boolean name; - - /** - * Returns the max number - */ - private Integer maxNumber; - - public Integer getMaxNumber() { - return maxNumber; - } - - public Boolean getName() { - return name; - } - - public SimpleInnerInnerClass getInnerInnerClass() { - return innerInnerClass; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app166/SimpleInnerInnerClass.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app166/SimpleInnerInnerClass.java deleted file mode 100644 index cce502f14..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app166/SimpleInnerInnerClass.java +++ /dev/null @@ -1,21 +0,0 @@ -package test.org.springdoc.api.app166; - -class SimpleInnerInnerClass { - /** - * Returns the name of the inner inner class - */ - Boolean name; - - /** - * Returns the maxNumber of the inner inner class - */ - private Integer maxNumber; - - public Integer getMaxNumber() { - return maxNumber; - } - - public Boolean getName() { - return name; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app166/SimpleOuterClass.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app166/SimpleOuterClass.java deleted file mode 100644 index 0b27785e3..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app166/SimpleOuterClass.java +++ /dev/null @@ -1,22 +0,0 @@ -package test.org.springdoc.api.app166; - -class SimpleOuterClass { - - /** - * Returns the name of the outer class - */ - private String name; - - /** - * Returns the inner class - */ - private SimpleInnerClass innerClass; - - public String getName() { - return name; - } - - public SimpleInnerClass getInnerClass() { - return innerClass; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app166/SpringDocApp166Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app166/SpringDocApp166Test.java deleted file mode 100644 index 326d7e07d..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app166/SpringDocApp166Test.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app166; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * The type Spring doc app 165 test. - */ -class SpringDocApp166Test extends AbstractSpringDocTest { - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp { - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app167/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app167/HelloController.java deleted file mode 100644 index ecb71d40a..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app167/HelloController.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app167; - -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * The type Hello controller. - */ -@RestController("/api") -class HelloController { - - @RequestMapping("/process") - public void process() { - - } -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app167/SpringDocApp167Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app167/SpringDocApp167Test.java deleted file mode 100644 index 4a4b62b9a..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app167/SpringDocApp167Test.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app167; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * The type Spring doc app 167 test. - */ -class SpringDocApp167Test extends AbstractSpringDocTest { - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp { - } -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app168/DescriptionFieldInRequestBodyIsNullController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app168/DescriptionFieldInRequestBodyIsNullController.java deleted file mode 100644 index b22cd3cb1..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app168/DescriptionFieldInRequestBodyIsNullController.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * - * * Copyright 2019-2023 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.app168; - -import io.swagger.v3.oas.annotations.media.Content; -import io.swagger.v3.oas.annotations.media.Schema; - -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * If the RequestBody description field is null, get the description from the javadoc. - */ -@RestController -@RequestMapping("description-in-requestbody-is-null") -class DescriptionFieldInRequestBodyIsNullController { - - /** - * Person person. - * - * @param person the person - */ - @PostMapping - public void person( - @io.swagger.v3.oas.annotations.parameters.RequestBody(content = @Content(schema = @Schema(implementation = Person.class))) @RequestBody Person person) { - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app168/Person.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app168/Person.java deleted file mode 100644 index 005af9d69..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app168/Person.java +++ /dev/null @@ -1,29 +0,0 @@ -package test.org.springdoc.api.app168; - -/** - * The type Person. - */ -class Person { - /** - * The Id. - */ - private long id; - - /** - * Gets id. - * - * @return the id - */ - public long getId() { - return id; - } - - /** - * Sets id. - * - * @param id the id - */ - public void setId(long id) { - this.id = id; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app168/SpringDocApp168Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app168/SpringDocApp168Test.java deleted file mode 100644 index 600327a20..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app168/SpringDocApp168Test.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * - * * Copyright 2019-2023 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.app168; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * The type Spring doc app 168 test. - */ -class SpringDocApp168Test extends AbstractSpringDocTest { - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp { - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app169/RecordController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app169/RecordController.java deleted file mode 100644 index 0e35bbf72..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app169/RecordController.java +++ /dev/null @@ -1,16 +0,0 @@ -package test.org.springdoc.api.app169; - -import org.springdoc.core.annotations.ParameterObject; - -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -@RestController -@RequestMapping("record") -class RecordController { - @GetMapping - public SimpleOuterClass index(@ParameterObject SimpleOuterClass filter) { - return null; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app169/SimpleInnerClass.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app169/SimpleInnerClass.java deleted file mode 100644 index 36a885ea3..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app169/SimpleInnerClass.java +++ /dev/null @@ -1,10 +0,0 @@ -package test.org.springdoc.api.app169; - -/** - * simple inner class - * - * @param name the boolean name - * @param maxNumber the max number - */ -public record SimpleInnerClass(Boolean name, Integer maxNumber) { -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app169/SimpleOuterClass.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app169/SimpleOuterClass.java deleted file mode 100644 index 9223ef9dc..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app169/SimpleOuterClass.java +++ /dev/null @@ -1,10 +0,0 @@ -package test.org.springdoc.api.app169; - -/** - * simple outer class - * - * @param name the name of the outer class - * @param simpleInnerClass the inner class - */ -public record SimpleOuterClass(String name, SimpleInnerClass simpleInnerClass) { -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app169/SpringDocApp169Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app169/SpringDocApp169Test.java deleted file mode 100644 index ef59a25aa..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app169/SpringDocApp169Test.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * - * * Copyright 2019-2023 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.app169; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * The type Spring doc app 169 test. - */ -class SpringDocApp169Test extends AbstractSpringDocTest { - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp { - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app17/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app17/HelloController.java deleted file mode 100644 index 3afd50f7d..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app17/HelloController.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app17; - -import jakarta.validation.Valid; -import jakarta.validation.constraints.Size; - -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -/** - * The type Hello controller. - */ -@RestController -class HelloController { - - /** - * Persons. - * - * @param name the name - */ - @GetMapping(value = "/persons") - public void persons(@Valid @RequestParam @Size(min = 4, max = 6) String name) { - - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app17/SpringDocApp17Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app17/SpringDocApp17Test.java deleted file mode 100644 index 1459831ac..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app17/SpringDocApp17Test.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app17; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * The type Spring doc app 17 test. - */ -class SpringDocApp17Test extends AbstractSpringDocTest { - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app170/Animal.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app170/Animal.java deleted file mode 100644 index b3494ed3b..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app170/Animal.java +++ /dev/null @@ -1,17 +0,0 @@ -package test.org.springdoc.api.app170; - - -import com.fasterxml.jackson.annotation.JsonSubTypes; -import com.fasterxml.jackson.annotation.JsonTypeInfo; -import io.swagger.v3.oas.annotations.media.Schema; - -/** - * Interface of the Animal. - */ -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.WRAPPER_OBJECT) -@JsonSubTypes({ - @JsonSubTypes.Type(value = Dog.class, name = "dog"), - @JsonSubTypes.Type(value = Cat.class, name = "cat"), -}) -@Schema(description = "Represents an Animal class.") -public interface Animal {} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app170/BasicController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app170/BasicController.java deleted file mode 100644 index 82484d5a0..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app170/BasicController.java +++ /dev/null @@ -1,19 +0,0 @@ -package test.org.springdoc.api.app170; - -import io.swagger.v3.oas.annotations.Operation; - -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -@RestController -@RequestMapping(path = "/") -class BasicController { - - @GetMapping("/test1") - @Operation(summary = "get1", description = "Provides an animal.") - public Animal get1() { - - return new Dog("Foo", 12); - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app170/Cat.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app170/Cat.java deleted file mode 100644 index 842c381be..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app170/Cat.java +++ /dev/null @@ -1,22 +0,0 @@ -package test.org.springdoc.api.app170; - - -import io.swagger.v3.oas.annotations.media.Schema; - -@Schema -class Cat implements Animal { - - private Integer speed; - - public Cat(Integer speed) { - this.speed = speed; - } - - public Integer getSpeed() { - return speed; - } - - public void setSpeed(Integer speed) { - this.speed = speed; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app170/Dog.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app170/Dog.java deleted file mode 100644 index 2cf7b0d61..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app170/Dog.java +++ /dev/null @@ -1,33 +0,0 @@ -package test.org.springdoc.api.app170; - - -import io.swagger.v3.oas.annotations.media.Schema; - -@Schema(description = "Represents a Dog class.") -class Dog implements Animal { - - private String name; - - private Integer age; - - public Dog(String name, Integer age) { - this.name = name; - this.age = age; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public Integer getAge() { - return age; - } - - public void setAge(Integer age) { - this.age = age; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app170/SpringDocApp170Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app170/SpringDocApp170Test.java deleted file mode 100644 index ad6c52307..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app170/SpringDocApp170Test.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * - * * Copyright 2019-2023 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.app170; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * The type Spring doc app 193 test. - */ -class SpringDocApp170Test extends AbstractSpringDocTest { - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp { - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app171/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app171/HelloController.java deleted file mode 100644 index b2aba84a3..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app171/HelloController.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * - * * Copyright 2019-2023 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.app171; - -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * The type Hello controller. - */ -@RestController -class HelloController { - - /** - * PersonProjection interface. - * - * @return the PersonProjection - */ - @GetMapping(value = "/persons") - public PersonProjection persons() { - return new PersonDTO(); - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app171/PersonDTO.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app171/PersonDTO.java deleted file mode 100644 index f85cddf1b..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app171/PersonDTO.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * - * * Copyright 2019-2023 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.app171; - -/** - * Simulate a dynamically generated class that implements the PersonProjection interface. - */ -class PersonDTO implements PersonProjection { - private String email; - - private String firstName; - - private String lastName; - - /** - * Instantiates a new Person dto. - */ - public PersonDTO() { - } - - /** - * Instantiates a new Person dto. - * - * @param email the email - * @param firstName the first name - * @param lastName the last name - */ - public PersonDTO(final String email, final String firstName, final String lastName) { - this.email = email; - this.firstName = firstName; - this.lastName = lastName; - } - - public String getEmail() { - return email; - } - - public void setEmail(final String email) { - this.email = email; - } - - public String getFirstName() { - return firstName; - } - - public void setFirstName(final String firstName) { - this.firstName = firstName; - } - - public String getLastName() { - return lastName; - } - - public void setLastName(final String lastName) { - this.lastName = lastName; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app171/PersonProjection.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app171/PersonProjection.java deleted file mode 100644 index a750b8573..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app171/PersonProjection.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * - * * Copyright 2019-2023 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.app171; - -/** - * The type PersonProjection dto interface. - */ -public interface PersonProjection { - /** - * The Email. - * - */ - String getEmail(); - - /** - * The First name. - * - */ - String getFirstName(); - - /** - * The Last name. - * - */ - String getLastName(); -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app171/SpringDocApp171Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app171/SpringDocApp171Test.java deleted file mode 100644 index 552bb8fc4..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app171/SpringDocApp171Test.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * - * * Copyright 2019-2023 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.app171; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * The type Spring doc app 193 test. - */ -class SpringDocApp171Test extends AbstractSpringDocTest { - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp { - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app172/JavadocPropertyCustomizerTest.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app172/JavadocPropertyCustomizerTest.java deleted file mode 100644 index 568353766..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app172/JavadocPropertyCustomizerTest.java +++ /dev/null @@ -1,140 +0,0 @@ -/* - * - * * - * * * - * * * * Copyright 2019-2023 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.app172; - -import java.beans.IntrospectionException; -import java.beans.Introspector; -import java.beans.PropertyDescriptor; -import java.io.File; -import java.io.FileWriter; -import java.io.IOException; -import java.io.PrintWriter; -import java.lang.reflect.Field; -import java.net.URL; -import java.net.URLClassLoader; -import java.util.Arrays; -import java.util.List; -import java.util.Map; - -import javax.tools.JavaCompiler; -import javax.tools.ToolProvider; - -import io.swagger.v3.oas.models.media.ObjectSchema; -import io.swagger.v3.oas.models.media.Schema; -import io.swagger.v3.oas.models.media.StringSchema; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Nested; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.condition.EnabledForJreRange; -import org.junit.jupiter.api.condition.JRE; -import org.junit.jupiter.api.io.TempDir; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; -import org.springdoc.core.customizers.JavadocPropertyCustomizer; -import org.springdoc.core.providers.JavadocProvider; -import org.springdoc.core.providers.ObjectMapperProvider; -import org.springdoc.core.providers.SpringDocJavadocProvider; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -/** - * Tests for {@link JavadocPropertyCustomizer}. - */ -class JavadocPropertyCustomizerTest { - @TempDir - private File tempDir; - - private JavadocProvider javadocProvider; - - @Mock - private ObjectMapperProvider objectMapperProvider; - - private JavadocPropertyCustomizer javadocPropertyCustomizer; - - @BeforeEach - void setup() { - MockitoAnnotations.openMocks(this); - this.javadocProvider = new SpringDocJavadocProvider(); - this.javadocPropertyCustomizer = new JavadocPropertyCustomizer(javadocProvider, objectMapperProvider); - } - - - /** - * Tests for {@link JavadocPropertyCustomizer#setJavadocDescription(Class, List, List, Schema)}. - */ - @Nested - class setJavadocDescription { - @Test - @EnabledForJreRange(min = JRE.JAVA_17) - void ifRecordObjectShouldGetField() throws IOException, ClassNotFoundException, IntrospectionException { - File recordObject = new File(tempDir, "RecordObject.java"); - try (PrintWriter writer = new PrintWriter(new FileWriter(recordObject))) { - writer.println("/**"); - writer.println(" * Record Object"); - writer.println(" *"); - writer.println(" * @param id the id"); - writer.println(" * @param name the name"); - writer.println(" */"); - writer.println("public record RecordObject(String id, String name){"); - writer.println("}"); - } - File recordObjectJavadocJson = new File(tempDir, "RecordObject__Javadoc.json"); - try (PrintWriter writer = new PrintWriter(new FileWriter(recordObjectJavadocJson))) { - writer.print("{"); - writer.print("\"doc\":\"Record Object\\n\\n @param id the id\\n @param name the name\","); - writer.print("\"fields\":[],"); - writer.print("\"methods\":[],"); - writer.print("\"constructors\":[]"); - writer.println("}"); - } - - String[] args = { - recordObject.getAbsolutePath() - }; - JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); - int r = compiler.run(null, null, null, args); - if (r != 0) { - throw new IllegalStateException("Compilation failed"); - } - URL[] urls = { tempDir.toURI().toURL() }; - ClassLoader loader = URLClassLoader.newInstance(urls); - - Class cls = loader.loadClass("RecordObject"); - - List fields = Arrays.asList(cls.getFields()); - - Schema existingSchema = new ObjectSchema().name("RecordObject") - .addProperty("id", new StringSchema().name("id")) - .addProperty("name", new StringSchema().name("name")); - - List propertyDescriptors = Arrays.asList(Introspector.getBeanInfo(cls).getPropertyDescriptors()); - javadocPropertyCustomizer.setJavadocDescription(cls, fields, propertyDescriptors, existingSchema,false); - - assertEquals("Record Object", existingSchema.getDescription()); - Map properties = existingSchema.getProperties(); - assertEquals(2, properties.size()); - assertEquals("the id", properties.get("id").getDescription()); - assertEquals("the name", properties.get("name").getDescription()); - } - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app173/Example.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app173/Example.java deleted file mode 100644 index 82ef811f3..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app173/Example.java +++ /dev/null @@ -1,21 +0,0 @@ -package test.org.springdoc.api.app173; - -import io.swagger.v3.oas.annotations.media.Schema; - -/** - * The Example object - */ -@Schema -class Example { - - private String name; - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app173/ExampleController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app173/ExampleController.java deleted file mode 100644 index 03cf2f588..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app173/ExampleController.java +++ /dev/null @@ -1,39 +0,0 @@ -package test.org.springdoc.api.app173; - -import java.util.UUID; - -import io.swagger.v3.oas.annotations.Operation; - -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.PatchMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RestController; - -import static org.springframework.http.HttpStatus.OK; - -/** - * The Example Controller - */ -@RestController -class ExampleController { - - @PostMapping("/example") - @Operation(summary = "insert example", description = "Allows to insert an example") - public ResponseEntity postExample(@io.swagger.v3.oas.annotations.parameters.RequestBody(description = "${example.description}") @RequestBody Example example) { - return new ResponseEntity<>(UUID.randomUUID(), OK); - } - - @PutMapping("/example") - @Operation(summary = "update example", description = "Allows to update an example") - public ResponseEntity putExample(@io.swagger.v3.oas.annotations.parameters.RequestBody(description = "${example2.description:Default description for example}") @RequestBody Example example) { - return new ResponseEntity<>(UUID.randomUUID(), OK); - } - - @PatchMapping("/example") - @Operation(summary = "patch example", description = "Allows to patch an example") - public ResponseEntity patchExample(@io.swagger.v3.oas.annotations.parameters.RequestBody(description = "Description without the use of variables") @RequestBody Example example) { - return new ResponseEntity<>(UUID.randomUUID(), OK); - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app173/SpringDocApp173Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app173/SpringDocApp173Test.java deleted file mode 100644 index 84d942153..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app173/SpringDocApp173Test.java +++ /dev/null @@ -1,21 +0,0 @@ -package test.org.springdoc.api.app173; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.test.context.TestPropertySource; - -/** - * The type Spring doc app 173 test. - */ -@TestPropertySource(properties = "example.description=The example object") -class SpringDocApp173Test extends AbstractSpringDocTest { - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp { - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app174/ExampleController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app174/ExampleController.java deleted file mode 100644 index 85c78cae4..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app174/ExampleController.java +++ /dev/null @@ -1,24 +0,0 @@ -package test.org.springdoc.api.app174; - -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * The Example Controller - */ -@RestController -class ExampleController { - - @PostMapping - public Test post(){ - return null; - } - -} - - - - - - - diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app174/Question.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app174/Question.java deleted file mode 100644 index d0ebf7952..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app174/Question.java +++ /dev/null @@ -1,42 +0,0 @@ -package test.org.springdoc.api.app174; - -import com.fasterxml.jackson.annotation.JsonSubTypes; -import com.fasterxml.jackson.annotation.JsonTypeInfo; - -/** - * The type Question. - * - * @author bnasslahsen base class for all questions in test with polymorphism - */ -@JsonTypeInfo( - use = JsonTypeInfo.Id.NAME, - property = "type") -@JsonSubTypes({ - @JsonSubTypes.Type(value = TestQuestion.class, name = "test"), - @JsonSubTypes.Type(value = TextQuestion.class, name = "text") -}) -public abstract class Question { - private final String question; - private final String type; - - public Question(String question, String type) { - this.question = question; - this.type = type; - } - - public String getQuestion() { - return question; - } - - public String getType() { - return type; - } - - @Override - public String toString() { - return "Question{" + - "question='" + question + '\'' + - ", type='" + type + '\'' + - '}'; - } -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app174/SpringDocApp174Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app174/SpringDocApp174Test.java deleted file mode 100644 index a69cd90ec..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app174/SpringDocApp174Test.java +++ /dev/null @@ -1,19 +0,0 @@ -package test.org.springdoc.api.app174; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * The type Spring doc app 174 test. - */ -class SpringDocApp174Test extends AbstractSpringDocTest { - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp { - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app174/Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app174/Test.java deleted file mode 100644 index 6c872392b..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app174/Test.java +++ /dev/null @@ -1,44 +0,0 @@ -package test.org.springdoc.api.app174; - -import java.io.Serializable; -import java.util.List; - -/** - * The type Test. - * - * @author bnasslahsen - */ - -class Test implements Serializable { - - private static final long serialVersionUID = 1L; // Recommended for Serializable classes - - private List questions; - - // No-argument constructor - public Test() { - } - - // Constructor with arguments - public Test(List questions) { - this.questions = questions; - } - - // Getter method for 'questions' - public List getQuestions() { - return questions; - } - - // Setter method for 'questions' - public void setQuestions(List questions) { - this.questions = questions; - } - - // Optionally, you can override toString, hashCode, equals, etc. - @Override - public String toString() { - return "Test{" + - "questions=" + questions + - '}'; - } -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app174/TestQuestion.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app174/TestQuestion.java deleted file mode 100644 index 2483f271f..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app174/TestQuestion.java +++ /dev/null @@ -1,42 +0,0 @@ -package test.org.springdoc.api.app174; - -import java.util.List; - -/** - * The type Test question. - * - * @author bnasslahsen test question - */ -class TestQuestion extends Question { - /** - * list of variants - */ - private final List variants; - /** - * correct answer - */ - private final int answer; - - public TestQuestion(String question, String type, List variants, int answer) { - super(question, type); - this.variants = variants; - this.answer = answer; - } - - public List getVariants() { - return variants; - } - - public int getAnswer() { - return answer; - } - - @Override - public String toString() { - return "TestQuestion{" + - "question='" + getQuestion() + '\'' + - ", variants=" + variants + - ", answer=" + answer + - '}'; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app174/TextQuestion.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app174/TextQuestion.java deleted file mode 100644 index 1e6cac956..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app174/TextQuestion.java +++ /dev/null @@ -1,28 +0,0 @@ -package test.org.springdoc.api.app174; - -/** - * The type Text question. - * - * @author bnasslahsen - */ -class TextQuestion extends Question { - private final String answer; - - public TextQuestion(String question, String type, String answer) { - super(question, type); - this.answer = answer; - } - - public String getAnswer() { - return answer; - } - - @Override - public String toString() { - return "TextQuestion{" + - "question='" + getQuestion() + '\'' + - ", type='" + getType() + '\'' + - ", answer='" + answer + '\'' + - '}'; - } -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app18/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app18/HelloController.java deleted file mode 100644 index 5521bf253..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app18/HelloController.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app18; - -import io.swagger.v3.oas.annotations.Parameter; -import jakarta.validation.constraints.NegativeOrZero; -import jakarta.validation.constraints.NotBlank; -import jakarta.validation.constraints.NotEmpty; -import jakarta.validation.constraints.PositiveOrZero; - -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -/** - * The type Hello controller. - */ -@RestController -class HelloController { - - /** - * Persons string. - * - * @param name the name - * @return the string - */ - @GetMapping(value = "/persons") - public String persons(@NotBlank String name) { - return "OK"; - } - - /** - * Persons 2 string. - * - * @param name the name - * @return the string - */ - @GetMapping(value = "/persons2") - public String persons2(@NotBlank @Parameter(description = "persons name") String name) { - return "OK"; - } - - /** - * Persons 3 string. - * - * @param name the name - * @return the string - */ - @GetMapping(value = "/persons3") - public String persons3(@NotBlank @Parameter(description = "persons name") @RequestParam String name) { - return "OK"; - } - - /** - * Persons 4 string. - * - * @param age the age - * @return the string - */ - @GetMapping(value = "/persons4") - public String persons4(@PositiveOrZero int age) { - return "OK"; - } - - /** - * Persons 5 string. - * - * @param age the age - * @return the string - */ - @GetMapping(value = "/persons5") - public String persons5(@NegativeOrZero int age) { - return "OK"; - } - - /** - * Persons 6 string. - * - * @param name the name - * @return the string - */ - @GetMapping(value = "/persons6") - public String persons6(@NotEmpty @Parameter(description = "persons name") String name) { - return "OK"; - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app18/SpringDocApp18Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app18/SpringDocApp18Test.java deleted file mode 100644 index 12807f317..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app18/SpringDocApp18Test.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app18; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.test.context.TestPropertySource; - -/** - * The type Spring doc app 18 test. - */ -@TestPropertySource(properties = "springdoc.pre-loading-enabled=true") -class SpringDocApp18Test extends AbstractSpringDocTest { - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app19/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app19/HelloController.java deleted file mode 100644 index 64862233e..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app19/HelloController.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app19; - -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.parameters.RequestBody; -import jakarta.validation.constraints.NotBlank; - -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * The type Hello controller. - */ -@RestController -class HelloController { - - /** - * Persons string. - * - * @param name the name - * @return the string - */ - @PostMapping(value = "/persons") - public String persons(@RequestBody(description = "requestBody description as parameter") String name) { - return "OK"; - } - - /** - * Persons 2 string. - * - * @param name the name - * @return the string - */ - @RequestBody(description = "requestBody description outside") - @PostMapping(value = "/persons2") - public String persons2(String name) { - return "OK"; - } - - /** - * Persons 3 string. - * - * @param name the name - * @return the string - */ - @Operation(requestBody = @RequestBody(description = "requestBody inside operation annotation")) - @PostMapping(value = "/persons3") - public String persons3(@NotBlank String name) { - return "OK"; - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app19/SpringDocApp19Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app19/SpringDocApp19Test.java deleted file mode 100644 index a6daf77dc..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app19/SpringDocApp19Test.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app19; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * The type Spring doc app 19 test. - */ -class SpringDocApp19Test extends AbstractSpringDocTest { - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app2/SpringDocApp2Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app2/SpringDocApp2Test.java deleted file mode 100644 index 22da251c5..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app2/SpringDocApp2Test.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app2; - -import io.swagger.v3.oas.models.Components; -import io.swagger.v3.oas.models.OpenAPI; -import io.swagger.v3.oas.models.info.Info; -import io.swagger.v3.oas.models.info.License; -import io.swagger.v3.oas.models.security.SecurityScheme; -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.Bean; - -/** - * The type Spring doc app 2 test. - */ -class SpringDocApp2Test extends AbstractSpringDocTest { - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp { - /** - * Custom open api open api. - * - * @return the open api - */ - @Bean - public OpenAPI customOpenAPI() { - return new OpenAPI() - .components(new Components().addSecuritySchemes("basicScheme", - new SecurityScheme().type(SecurityScheme.Type.HTTP).scheme("basic"))) - .info(new Info().title("Petstore API").version("v0").description( - "This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.") - .termsOfService("http://swagger.io/terms/") - .license(new License().name("Apache 2.0").url("http://springdoc.org"))); - } - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app2/api/ApiUtil.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app2/api/ApiUtil.java deleted file mode 100644 index 424fa0e23..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app2/api/ApiUtil.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app2.api; - -import java.io.IOException; - -import jakarta.servlet.http.HttpServletResponse; - -import org.springframework.http.HttpStatus; -import org.springframework.web.context.request.NativeWebRequest; -import org.springframework.web.server.ResponseStatusException; - -/** - * The type Api util. - */ -class ApiUtil { - - /** - * Sets example response. - * - * @param req the req - * @param contentType the content type - * @param example the example - */ - public static void setExampleResponse(NativeWebRequest req, String contentType, String example) { - try { - req.getNativeResponse(HttpServletResponse.class).addHeader("Content-Type", contentType); - req.getNativeResponse(HttpServletResponse.class).getOutputStream().print(example); - } - catch (IOException e) { - throw new RuntimeException(e); - } - } - - /** - * Check api key. - * - * @param req the req - */ - public static void checkApiKey(NativeWebRequest req) { - if (!"1".equals(System.getenv("DISABLE_API_KEY")) && !"special-key".equals(req.getHeader("api_key"))) { - throw new ResponseStatusException(HttpStatus.UNAUTHORIZED, "Missing API key!"); - } - } -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app2/api/ExceptionTranslator.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app2/api/ExceptionTranslator.java deleted file mode 100644 index 12fe1d702..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app2/api/ExceptionTranslator.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app2.api; - -import java.util.Map; - -import jakarta.validation.ConstraintViolationException; - -import org.springframework.boot.web.error.ErrorAttributeOptions; -import org.springframework.boot.web.servlet.error.ErrorAttributes; -import org.springframework.http.HttpStatus; -import org.springframework.web.bind.annotation.ExceptionHandler; -import org.springframework.web.bind.annotation.ResponseStatus; -import org.springframework.web.bind.annotation.RestControllerAdvice; -import org.springframework.web.context.request.RequestAttributes; -import org.springframework.web.context.request.WebRequest; - -/** - * The type Exception translator. - */ -@RestControllerAdvice -class ExceptionTranslator { - - /** - * The Error attributes. - */ - private final ErrorAttributes errorAttributes; - - /** - * Instantiates a new Exception translator. - * - * @param errorAttributes the error attributes - */ - public ExceptionTranslator(ErrorAttributes errorAttributes) { - this.errorAttributes = errorAttributes; - } - - /** - * Process constraint violation exception map. - * - * @param request the request - * @return the map - */ - @ExceptionHandler(ConstraintViolationException.class) - @ResponseStatus(HttpStatus.BAD_REQUEST) - public Map processConstraintViolationException(WebRequest request) { - request.setAttribute("jakarta.servlet.error.status_code", HttpStatus.BAD_REQUEST.value(), RequestAttributes.SCOPE_REQUEST); - return errorAttributes.getErrorAttributes(request, ErrorAttributeOptions.defaults()); - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app2/api/HomeController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app2/api/HomeController.java deleted file mode 100644 index 19a4c29ba..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app2/api/HomeController.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app2.api; - -import org.springframework.beans.factory.annotation.Value; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.GetMapping; - -import static org.springdoc.core.utils.Constants.SWAGGER_UI_PATH; -import static org.springframework.util.AntPathMatcher.DEFAULT_PATH_SEPARATOR; -import static org.springframework.web.servlet.view.UrlBasedViewResolver.REDIRECT_URL_PREFIX; - -/** - * Home redirection to swagger api documentation - */ -@Controller -class HomeController { - - /** - * The Swagger ui path. - */ - @Value(SWAGGER_UI_PATH) - private String swaggerUiPath; - - /** - * Index string. - * - * @return the string - */ - @GetMapping(DEFAULT_PATH_SEPARATOR) - public String index() { - return REDIRECT_URL_PREFIX + swaggerUiPath; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app2/api/PetApi.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app2/api/PetApi.java deleted file mode 100644 index 424dd04be..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app2/api/PetApi.java +++ /dev/null @@ -1,221 +0,0 @@ -/* - * - * * Copyright 2019-2020 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. - * - */ - -/** - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (3.0.0). - * https://openapi-generator.tech - * Do not edit the class manually. - */ -package test.org.springdoc.api.app2.api; - -import java.util.List; - -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.enums.SecuritySchemeType; -import io.swagger.v3.oas.annotations.media.ArraySchema; -import io.swagger.v3.oas.annotations.media.Content; -import io.swagger.v3.oas.annotations.media.Schema; -import io.swagger.v3.oas.annotations.responses.ApiResponse; -import io.swagger.v3.oas.annotations.responses.ApiResponses; -import io.swagger.v3.oas.annotations.security.OAuthFlow; -import io.swagger.v3.oas.annotations.security.OAuthFlows; -import io.swagger.v3.oas.annotations.security.OAuthScope; -import io.swagger.v3.oas.annotations.security.SecurityRequirement; -import io.swagger.v3.oas.annotations.security.SecurityScheme; -import io.swagger.v3.oas.annotations.tags.Tag; -import jakarta.validation.Valid; -import jakarta.validation.constraints.NotNull; -import test.org.springdoc.api.app2.model.ModelApiResponse; -import test.org.springdoc.api.app2.model.Pet; - -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.DeleteMapping; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RequestPart; -import org.springframework.web.bind.annotation.ResponseBody; -import org.springframework.web.multipart.MultipartFile; - -/** - * The interface Pet api. - */ -@SecurityScheme(name = "petstore_auth", type = SecuritySchemeType.OAUTH2, flows = @OAuthFlows(implicit = @OAuthFlow(authorizationUrl = "http://petstore.swagger.io/oauth/dialog", scopes = { - @OAuthScope(name = "write:pets", description = "modify pets in your account"), - @OAuthScope(name = "read:pets", description = "read your pets") }))) -@Tag(name = "pet", description = "the pet API") -@ResponseBody -public interface PetApi { - - /** - * Gets delegate. - * - * @return the delegate - */ - default PetApiDelegate getDelegate() { - return new PetApiDelegate() { - }; - } - - /** - * Add pet. - * - * @param pet the pet - */ - @Operation(summary = "Add a new pet to the store", description = "", security = { - @SecurityRequirement(name = "petstore_auth", scopes = { "write:pets", "read:pets" }) }, tags = { "pet" }) - @ApiResponses(value = { @ApiResponse(responseCode = "405", description = "Invalid input") }) - @PostMapping(value = "/pet", consumes = { "application/json", "application/xml" }) - default void addPet( - @io.swagger.v3.oas.annotations.parameters.RequestBody(description = "Pet object that needs to be added to the store", required = true) @Valid @RequestBody Pet pet) { - // return getDelegate().addPet(pet); - } - - /** - * Delete pet response entity. - * - * @param petId the pet id - * @param apiKey the api key - * @return the response entity - */ - @Operation(summary = "Deletes a pet", description = "", security = { - @SecurityRequirement(name = "petstore_auth", scopes = { "write:pets", "read:pets" }) }, tags = { "pet" }) - @ApiResponses(value = { @ApiResponse(responseCode = "400", description = "Invalid ID supplied"), - @ApiResponse(responseCode = "404", description = "Pet not found") }) - @DeleteMapping(value = "/pet/{petId}") - default ResponseEntity deletePet( - @Parameter(description = "Pet id to delete", required = true) @PathVariable("petId") Long petId, - @Parameter(description = "") @RequestHeader(value = "api_key", required = false) String apiKey) { - return getDelegate().deletePet(petId, apiKey); - } - - /** - * Find pets by status response entity. - * - * @param status the status - * @return the response entity - */ - @Operation(summary = "Finds Pets by status", description = "Multiple status values can be provided with comma separated strings", security = { - @SecurityRequirement(name = "petstore_auth", scopes = { "write:pets", "read:pets" }) }, tags = { "pet" }) - @ApiResponses(value = { - @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(array = @ArraySchema(schema = @Schema(implementation = Pet.class)))), - @ApiResponse(responseCode = "400", description = "Invalid status value") }) - @GetMapping(value = "/pet/findByStatus", produces = { "application/xml", "application/json" }) - default ResponseEntity> findPetsByStatus( - @NotNull @Parameter(description = "Status values that need to be considered for filter", required = true) @Valid @RequestParam(value = "status", required = true) List status) { - return getDelegate().findPetsByStatus(status); - } - - /** - * Find pets by tags response entity. - * - * @param tags the tags - * @return the response entity - */ - @Operation(summary = "Finds Pets by tags", description = "Muliple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.", security = { - @SecurityRequirement(name = "petstore_auth", scopes = { "write:pets", "read:pets" }) }, tags = { "pet" }) - @ApiResponses(value = { - @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(array = @ArraySchema(schema = @Schema(implementation = Pet.class)))), - @ApiResponse(responseCode = "400", description = "Invalid tag value") }) - @GetMapping(value = "/pet/findByTags", produces = { "application/xml", "application/json" }) - default ResponseEntity> findPetsByTags( - @NotNull @Parameter(description = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) List tags) { - return getDelegate().findPetsByTags(tags); - } - - /** - * Gets pet by id. - * - * @param petId the pet id - * @return the pet by id - */ - @Operation(summary = "Find pet by ID", description = "Returns a single pet", security = { - @SecurityRequirement(name = "api_key") }, tags = { "pet" }) - @ApiResponses(value = { - @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(schema = @Schema(implementation = Pet.class))), - @ApiResponse(responseCode = "400", description = "Invalid ID supplied"), - @ApiResponse(responseCode = "404", description = "Pet not found") }) - @GetMapping(value = "/pet/{petId}", produces = { "application/xml", "application/json" }) - default ResponseEntity getPetById( - @Parameter(description = "ID of pet to return", required = true) @PathVariable("petId") Long petId) { - return getDelegate().getPetById(petId); - } - - /** - * Update pet response entity. - * - * @param pet the pet - * @return the response entity - */ - @Operation(summary = "Update an existing pet", description = "", security = { - @SecurityRequirement(name = "petstore_auth", scopes = { "write:pets", "read:pets" }) }, tags = { "pet" }) - @ApiResponses(value = { @ApiResponse(responseCode = "400", description = "Invalid ID supplied"), - @ApiResponse(responseCode = "404", description = "Pet not found"), - @ApiResponse(responseCode = "405", description = "Validation exception") }) - @PutMapping(value = "/pet", consumes = { "application/json", "application/xml" }) - default ResponseEntity updatePet( - @io.swagger.v3.oas.annotations.parameters.RequestBody(description = "Pet object that needs to be added to the store", required = true) @Valid @RequestBody Pet pet) { - return getDelegate().updatePet(pet); - } - - /** - * Update pet with form response entity. - * - * @param petId the pet id - * @param name the name - * @param status the status - * @return the response entity - */ - @Operation(summary = "Updates a pet in the store with form data", description = "", security = { - @SecurityRequirement(name = "petstore_auth", scopes = { "write:pets", "read:pets" }) }, tags = { "pet" }) - @ApiResponses(value = { @ApiResponse(responseCode = "405", description = "Invalid input") }) - @PostMapping(value = "/pet/{petId}", consumes = { "application/x-www-form-urlencoded" }) - default ResponseEntity updatePetWithForm( - @Parameter(description = "ID of pet that needs to be updated", required = true) @PathVariable("petId") Long petId, - @Parameter(description = "Updated name of the pet") @RequestParam(value = "name", required = false) String name, - @Parameter(description = "Updated status of the pet") @RequestParam(value = "status", required = false) String status) { - return getDelegate().updatePetWithForm(petId, name, status); - } - - /** - * Upload file response entity. - * - * @param petId the pet id - * @param additionalMetadata the additional metadata - * @param file the file - * @return the response entity - */ - @Operation(summary = "uploads an image", description = "", security = { - @SecurityRequirement(name = "petstore_auth", scopes = { "write:pets", "read:pets" }) }, tags = { "pet" }) - @ApiResponses(value = { - @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(schema = @Schema(implementation = ModelApiResponse.class))) }) - @PostMapping(value = "/pet/{petId}/uploadImage", produces = { "application/json" }, consumes = { - "multipart/form-data" }) - default ResponseEntity uploadFile( - @Parameter(description = "ID of pet to update", required = true) @PathVariable("petId") Long petId, - @Parameter(description = "Additional data to pass to server") @RequestParam(value = "additionalMetadata", required = false) String additionalMetadata, - @Parameter(description = "file detail") @Valid @RequestPart("file") MultipartFile file) { - return getDelegate().uploadFile(petId, additionalMetadata, file); - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app2/api/PetApiController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app2/api/PetApiController.java deleted file mode 100644 index afca46da4..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app2/api/PetApiController.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app2.api; - -import java.util.Optional; - -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; - -/** - * The type Pet api controller. - */ -@jakarta.annotation.Generated(value = "org.springdoc.demo.app2.codegen.languages.SpringCodegen", date = "2019-07-11T00:09:29.839+02:00[Europe/Paris]") - -@Controller -@RequestMapping("${openapi.openAPIPetstore.base-path:/}") -class PetApiController implements PetApi { - - /** - * The Delegate. - */ - private final PetApiDelegate delegate; - - /** - * Instantiates a new Pet api controller. - * - * @param delegate the delegate - */ - public PetApiController(@org.springframework.beans.factory.annotation.Autowired(required = false) PetApiDelegate delegate) { - this.delegate = Optional.ofNullable(delegate).orElse(new PetApiDelegate() { - }); - } - - /** - * Gets delegate. - * - * @return the delegate - */ - @Override - public PetApiDelegate getDelegate() { - return delegate; - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app2/api/PetApiDelegate.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app2/api/PetApiDelegate.java deleted file mode 100644 index ae8eab18c..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app2/api/PetApiDelegate.java +++ /dev/null @@ -1,184 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app2.api; - -import java.util.List; -import java.util.Optional; - -import jakarta.validation.Valid; -import test.org.springdoc.api.app2.model.ModelApiResponse; -import test.org.springdoc.api.app2.model.Pet; - -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; -import org.springframework.web.context.request.NativeWebRequest; -import org.springframework.web.multipart.MultipartFile; - -/** - * A delegate to be called by the {@link PetApiController}}. - * Implement this interface with a {@link org.springframework.stereotype.Service} annotated class. - */ -@jakarta.annotation.Generated(value = "org.springdoc.demo.app2.codegen.languages.SpringCodegen", date = "2019-07-11T00:09:29.839+02:00[Europe/Paris]") - -public interface PetApiDelegate { - - /** - * Gets request. - * - * @return the request - */ - default Optional getRequest() { - return Optional.empty(); - } - - /** - * Add pet. - * - * @param pet the pet - * @see PetApi#addPet PetApi#addPet - */ - default void addPet(Pet pet) { - - } - - /** - * Delete pet response entity. - * - * @param petId the pet id - * @param apiKey the api key - * @return the response entity - * @see PetApi#deletePet PetApi#deletePet - */ - default ResponseEntity deletePet(Long petId, - String apiKey) { - return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); - - } - - /** - * Find pets by status response entity. - * - * @param status the status - * @return the response entity - * @see PetApi#findPetsByStatus PetApi#findPetsByStatus - */ - default ResponseEntity> findPetsByStatus(List status) { - extract(); - return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); - - } - - /** - * Extract. - */ - default void extract() { - getRequest().ifPresent(request -> { - for (MediaType mediaType : MediaType.parseMediaTypes(request.getHeader("Accept"))) { - if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { - ApiUtil.setExampleResponse(request, "application/json", "{ \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\"}"); - break; - } - if (mediaType.isCompatibleWith(MediaType.valueOf("application/xml"))) { - ApiUtil.setExampleResponse(request, "application/xml", " 123456789 doggie aeiou aeiou"); - break; - } - } - }); - } - - /** - * Find pets by tags response entity. - * - * @param tags the tags - * @return the response entity - * @see PetApi#findPetsByTags PetApi#findPetsByTags - */ - default ResponseEntity> findPetsByTags(List tags) { - extract(); - return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); - - } - - /** - * Gets pet by id. - * - * @param petId the pet id - * @return the pet by id - * @see PetApi#getPetById PetApi#getPetById - */ - default ResponseEntity getPetById(Long petId) { - extract(); - return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); - - } - - /** - * Update pet response entity. - * - * @param pet the pet - * @return the response entity - * @see PetApi#updatePet PetApi#updatePet - */ - default ResponseEntity updatePet(Pet pet) { - return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); - - } - - /** - * Update pet with form response entity. - * - * @param petId the pet id - * @param name the name - * @param status the status - * @return the response entity - * @see PetApi#updatePetWithForm PetApi#updatePetWithForm - */ - default ResponseEntity updatePetWithForm(Long petId, - String name, - String status) { - return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); - - } - - /** - * Upload file response entity. - * - * @param petId the pet id - * @param additionalMetadata the additional metadata - * @param file the file - * @return the response entity - * @see PetApi#uploadFile PetApi#uploadFile - */ - default ResponseEntity uploadFile(Long petId, - String additionalMetadata, - @Valid MultipartFile file) { - getRequest().ifPresent(request -> { - for (MediaType mediaType : MediaType.parseMediaTypes(request.getHeader("Accept"))) { - if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { - ApiUtil.setExampleResponse(request, "application/json", "{ \"code\" : 0, \"type\" : \"type\", \"message\" : \"message\"}"); - break; - } - } - }); - return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); - - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app2/api/PetApiDelegateImpl.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app2/api/PetApiDelegateImpl.java deleted file mode 100644 index cde0ed585..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app2/api/PetApiDelegateImpl.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app2.api; - -import org.springframework.stereotype.Service; - -/** - * The type Pet api delegate. - */ -@Service -class PetApiDelegateImpl implements PetApiDelegate { - - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app2/api/StoreApi.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app2/api/StoreApi.java deleted file mode 100644 index 4c1e4eb7b..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app2/api/StoreApi.java +++ /dev/null @@ -1,135 +0,0 @@ -/* - * - * * Copyright 2019-2020 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. - * - */ - -/** - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (3.0.0). - * https://openapi-generator.tech - * Do not edit the class manually. - */ -package test.org.springdoc.api.app2.api; - -import java.util.Map; - -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.media.ArraySchema; -import io.swagger.v3.oas.annotations.media.Content; -import io.swagger.v3.oas.annotations.media.Schema; -import io.swagger.v3.oas.annotations.responses.ApiResponse; -import io.swagger.v3.oas.annotations.responses.ApiResponses; -import io.swagger.v3.oas.annotations.security.SecurityRequirement; -import io.swagger.v3.oas.annotations.tags.Tag; -import jakarta.validation.Valid; -import jakarta.validation.constraints.Max; -import jakarta.validation.constraints.Min; -import test.org.springdoc.api.app2.model.Order; - -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.DeleteMapping; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.ResponseBody; - -/** - * The interface Store api. - */ -@jakarta.annotation.Generated(value = "org.springdoc.demo.app2.codegen.languages.SpringCodegen", date = "2019-07-11T00:09:29.839+02:00[Europe/Paris]") - -@Tag(name = "store", description = "the store API") -public interface StoreApi { - - /** - * Gets delegate. - * - * @return the delegate - */ - default StoreApiDelegate getDelegate() { - return new StoreApiDelegate() { - }; - } - - /** - * Delete order response entity. - * - * @param orderId the order id - * @return the response entity - */ - @Operation(summary = "Delete purchase order by ID", tags = { "store" }) - @ApiResponses(value = { @ApiResponse(responseCode = "400", description = "Invalid ID supplied"), - @ApiResponse(responseCode = "404", description = "Order not found") }) - @DeleteMapping(value = "/store/order/{orderId}") - @ResponseBody - default ResponseEntity deleteOrder( - @Parameter(description = "ID of the order that needs to be deleted", required = true) @PathVariable("orderId") String orderId) { - return getDelegate().deleteOrder(orderId); - } - - /** - * Gets inventory. - * - * @return the inventory - */ - @Operation(summary = "Returns pet inventories by status", description = "Returns a map of status codes to quantities", security = { - @SecurityRequirement(name = "api_key") }, tags = { "store" }) - @ApiResponses(value = { - @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(array = @ArraySchema(schema = @Schema(implementation = Map.class)))) }) - @GetMapping(value = "/store/inventory", produces = { "application/json" }) - @ResponseBody - default ResponseEntity> getInventory() { - return getDelegate().getInventory(); - } - - /** - * Gets order by id. - * - * @param orderId the order id - * @return the order by id - */ - @Operation(summary = "Find purchase order by ID", tags = { "store" }) - @ApiResponses(value = { - @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(schema = @Schema(implementation = Order.class))), - @ApiResponse(responseCode = "400", description = "Invalid ID supplied"), - @ApiResponse(responseCode = "404", description = "Order not found") }) - @GetMapping(value = "/store/order/{orderId}", produces = { "application/xml", "application/json" }) - @ResponseBody - default ResponseEntity getOrderById( - @Min(1L) @Max(5L) @Parameter(description = "ID of pet that needs to be fetched", required = true) @PathVariable("orderId") Long orderId) { - return getDelegate().getOrderById(orderId); - } - - /** - * Place order response entity. - * - * @param order the order - * @return the response entity - */ - @Operation(summary = "Place an order for a pet", tags = { "store" }) - @ApiResponses(value = { - @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(schema = @Schema(implementation = Order.class))), - @ApiResponse(responseCode = "400", description = "Invalid Order") }) - @PostMapping(value = "/store/order", produces = { "application/xml", "application/json" }, consumes = { - "application/json" }) - @ResponseBody - default ResponseEntity placeOrder( - @Parameter(description = "order placed for purchasing the pet", required = true) @Valid @RequestBody Order order) { - return getDelegate().placeOrder(order); - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app2/api/StoreApiController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app2/api/StoreApiController.java deleted file mode 100644 index 475a59209..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app2/api/StoreApiController.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app2.api; - -import java.util.Optional; - -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; - -/** - * The type Store api controller. - */ -@jakarta.annotation.Generated(value = "org.springdoc.demo.app2.codegen.languages.SpringCodegen", date = "2019-07-11T00:09:29.839+02:00[Europe/Paris]") - -@Controller -@RequestMapping("${openapi.openAPIPetstore.base-path:/}") -class StoreApiController implements StoreApi { - - /** - * The Delegate. - */ - private final StoreApiDelegate delegate; - - /** - * Instantiates a new Store api controller. - * - * @param delegate the delegate - */ - public StoreApiController(@org.springframework.beans.factory.annotation.Autowired(required = false) StoreApiDelegate delegate) { - this.delegate = Optional.ofNullable(delegate).orElse(new StoreApiDelegate() { - }); - } - - /** - * Gets delegate. - * - * @return the delegate - */ - @Override - public StoreApiDelegate getDelegate() { - return delegate; - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app2/api/StoreApiDelegate.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app2/api/StoreApiDelegate.java deleted file mode 100644 index 728cbcb05..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app2/api/StoreApiDelegate.java +++ /dev/null @@ -1,115 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app2.api; - -import java.util.Map; -import java.util.Optional; - -import test.org.springdoc.api.app2.model.Order; - -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; -import org.springframework.web.context.request.NativeWebRequest; - -/** - * A delegate to be called by the {@link StoreApiController}}. - * Implement this interface with a {@link org.springframework.stereotype.Service} annotated class. - */ -@jakarta.annotation.Generated(value = "org.springdoc.demo.app2.codegen.languages.SpringCodegen", date = "2019-07-11T00:09:29.839+02:00[Europe/Paris]") - -public interface StoreApiDelegate { - - /** - * Gets request. - * - * @return the request - */ - default Optional getRequest() { - return Optional.empty(); - } - - /** - * Delete order response entity. - * - * @param orderId the order id - * @return the response entity - * @see StoreApi#deleteOrder StoreApi#deleteOrder - */ - default ResponseEntity deleteOrder(String orderId) { - return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); - - } - - /** - * Gets inventory. - * - * @return the inventory - * @see StoreApi#getInventory StoreApi#getInventory - */ - default ResponseEntity> getInventory() { - return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); - - } - - /** - * Gets order by id. - * - * @param orderId the order id - * @return the order by id - * @see StoreApi#getOrderById StoreApi#getOrderById - */ - default ResponseEntity getOrderById(Long orderId) { - extract(); - return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); - - } - - /** - * Extract. - */ - default void extract() { - getRequest().ifPresent(request -> { - for (MediaType mediaType : MediaType.parseMediaTypes(request.getHeader("Accept"))) { - if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { - ApiUtil.setExampleResponse(request, "application/json", "{ \"petId\" : 6, \"quantity\" : 1, \"id\" : 0, \"shipDate\" : \"2000-01-23T04:56:07.000+00:00\", \"complete\" : false, \"status\" : \"placed\"}"); - break; - } - if (mediaType.isCompatibleWith(MediaType.valueOf("application/xml"))) { - ApiUtil.setExampleResponse(request, "application/xml", " 123456789 123456789 123 2000-01-23T04:56:07.000Z aeiou true"); - break; - } - } - }); - } - - /** - * Place order response entity. - * - * @param order the order - * @return the response entity - * @see StoreApi#placeOrder StoreApi#placeOrder - */ - default ResponseEntity placeOrder(Order order) { - extract(); - return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); - - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app2/api/StoreApiDelegateImpl.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app2/api/StoreApiDelegateImpl.java deleted file mode 100644 index 48cca44fa..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app2/api/StoreApiDelegateImpl.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app2.api; - -import org.springframework.stereotype.Service; - -/** - * The type Store api delegate. - */ -@Service -class StoreApiDelegateImpl implements StoreApiDelegate { - - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app2/api/UserApi.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app2/api/UserApi.java deleted file mode 100644 index 4ad60538c..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app2/api/UserApi.java +++ /dev/null @@ -1,189 +0,0 @@ -/* - * - * * Copyright 2019-2020 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. - * - */ - -/** - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (3.0.0). - * https://openapi-generator.tech - * Do not edit the class manually. - */ -package test.org.springdoc.api.app2.api; - -import java.util.List; - -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.media.Content; -import io.swagger.v3.oas.annotations.media.Schema; -import io.swagger.v3.oas.annotations.responses.ApiResponse; -import io.swagger.v3.oas.annotations.responses.ApiResponses; -import io.swagger.v3.oas.annotations.tags.Tag; -import jakarta.validation.Valid; -import jakarta.validation.constraints.NotNull; -import test.org.springdoc.api.app2.model.User; - -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.DeleteMapping; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestParam; - -/** - * The interface User api. - */ -@jakarta.annotation.Generated(value = "org.springdoc.demo.app2.codegen.languages.SpringCodegen", date = "2019-07-11T00:09:29.839+02:00[Europe/Paris]") - -@Tag(name = "user", description = "the user API") -public interface UserApi { - - /** - * Gets delegate. - * - * @return the delegate - */ - default UserApiDelegate getDelegate() { - return new UserApiDelegate() { - }; - } - - /** - * Create user response entity. - * - * @param user the user - * @return the response entity - */ - @Operation(summary = "Create user", tags = { "user" }) - @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "successful operation") }) - @PostMapping(value = "/user", consumes = { "application/json" }) - default ResponseEntity createUser( - @io.swagger.v3.oas.annotations.parameters.RequestBody(description = "Created user object", required = true) @Valid @RequestBody User user) { - return getDelegate().createUser(user); - } - - /** - * Create users with array input response entity. - * - * @param user the user - * @return the response entity - */ - @Operation(summary = "Creates list of users with given input array", tags = { "user" }) - @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "successful operation") }) - - @PostMapping(value = "/user/createWithArray", consumes = { "application/json" }) - default ResponseEntity createUsersWithArrayInput( - @io.swagger.v3.oas.annotations.parameters.RequestBody(description = "List of user object", required = true) @Valid @RequestBody List user) { - return getDelegate().createUsersWithArrayInput(user); - } - - /** - * Create users with list input response entity. - * - * @param user the user - * @return the response entity - */ - @Operation(summary = "Creates list of users with given input array", tags = { "user" }) - @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "successful operation") }) - @PostMapping(value = "/user/createWithList", consumes = { "application/json" }) - default ResponseEntity createUsersWithListInput( - @io.swagger.v3.oas.annotations.parameters.RequestBody(description = "List of user object", required = true) @Valid @RequestBody List user) { - return getDelegate().createUsersWithListInput(user); - } - - /** - * Delete user response entity. - * - * @param username the username - * @return the response entity - */ - @Operation(summary = "Creates list of users with given input array", tags = { "user" }) - @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "successful operation") }) - - @DeleteMapping(value = "/user/{username}") - default ResponseEntity deleteUser( - @io.swagger.v3.oas.annotations.parameters.RequestBody(description = "The name that needs to be deleted", required = true) @PathVariable("username") String username) { - return getDelegate().deleteUser(username); - } - - /** - * Gets user by name. - * - * @param username the username - * @return the user by name - */ - @Operation(summary = "Get user by user name", tags = { "user" }) - @ApiResponses(value = { - @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(schema = @Schema(implementation = User.class))), - @ApiResponse(responseCode = "400", description = "Invalid username supplied"), - @ApiResponse(responseCode = "404", description = "User not found") }) - - @GetMapping(value = "/user/{username}", produces = { "application/xml", "application/json" }) - default ResponseEntity getUserByName( - @Parameter(description = "The name that needs to be fetched. Use user1 for testing.", required = true) @PathVariable("username") String username) { - return getDelegate().getUserByName(username); - } - - /** - * Login user response entity. - * - * @param username the username - * @param password the password - * @return the response entity - */ - @Operation(summary = "Logs user into the system", tags = { "user" }) - @ApiResponses(value = { - @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(schema = @Schema(implementation = String.class))), - @ApiResponse(responseCode = "400", description = "Invalid username/password supplied") }) - @GetMapping(value = "/user/login", produces = { "application/xml", "application/json" }) - default ResponseEntity loginUser( - @NotNull @Parameter(description = "The user name for login", required = true) @Valid @RequestParam(value = "username", required = true) String username, - @NotNull @Parameter(description = "The password for login in clear text", required = true) @Valid @RequestParam(value = "password", required = true) String password) { - return getDelegate().loginUser(username, password); - } - - /** - * Logout user response entity. - * - * @return the response entity - */ - @Operation(summary = "Logs out current logged in user session", tags = { "user" }) - @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "successful operation") }) - @GetMapping(value = "/user/logout") - default ResponseEntity logoutUser() { - return getDelegate().logoutUser(); - } - - /** - * Update user response entity. - * - * @param username the username - * @param user the user - * @return the response entity - */ - @Operation(summary = "Updated user", tags = { "user" }) - @ApiResponses(value = { @ApiResponse(responseCode = "400", description = "Invalid user supplied"), - @ApiResponse(responseCode = "404", description = "User not found") }) - @PutMapping(value = "/user/{username}", consumes = { "application/json" }) - default ResponseEntity updateUser( - @Parameter(description = "name that need to be deleted", required = true) @PathVariable("username") String username, - @io.swagger.v3.oas.annotations.parameters.RequestBody(description = "Updated user object", required = true) @Valid @RequestBody User user) { - return getDelegate().updateUser(username, user); - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app2/api/UserApiController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app2/api/UserApiController.java deleted file mode 100644 index a7900af95..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app2/api/UserApiController.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app2.api; - -import java.util.Optional; - -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.ResponseBody; - -/** - * The type User api controller. - */ -@jakarta.annotation.Generated(value = "org.springdoc.demo.app2.codegen.languages.SpringCodegen", date = "2019-07-11T00:09:29.839+02:00[Europe/Paris]") - -@Controller -@ResponseBody -@RequestMapping("${openapi.openAPIPetstore.base-path:/}") -class UserApiController implements UserApi { - - /** - * The Delegate. - */ - private final UserApiDelegate delegate; - - /** - * Instantiates a new User api controller. - * - * @param delegate the delegate - */ - public UserApiController(@org.springframework.beans.factory.annotation.Autowired(required = false) UserApiDelegate delegate) { - this.delegate = Optional.ofNullable(delegate).orElse(new UserApiDelegate() { - }); - } - - /** - * Gets delegate. - * - * @return the delegate - */ - @Override - public UserApiDelegate getDelegate() { - return delegate; - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app2/api/UserApiDelegate.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app2/api/UserApiDelegate.java deleted file mode 100644 index 57ddcaf9f..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app2/api/UserApiDelegate.java +++ /dev/null @@ -1,159 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app2.api; - -import java.util.List; -import java.util.Optional; - -import test.org.springdoc.api.app2.model.User; - -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; -import org.springframework.web.context.request.NativeWebRequest; - -/** - * A delegate to be called by the {@link UserApiController}}. - * Implement this interface with a {@link org.springframework.stereotype.Service} annotated class. - */ -@jakarta.annotation.Generated(value = "org.springdoc.demo.app2.codegen.languages.SpringCodegen", date = "2019-07-11T00:09:29.839+02:00[Europe/Paris]") - -public interface UserApiDelegate { - - /** - * Gets request. - * - * @return the request - */ - default Optional getRequest() { - return Optional.empty(); - } - - /** - * Create user response entity. - * - * @param user the user - * @return the response entity - * @see UserApi#createUser UserApi#createUser - */ - default ResponseEntity createUser(User user) { - return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); - - } - - /** - * Create users with array input response entity. - * - * @param user the user - * @return the response entity - * @see UserApi#createUsersWithArrayInput UserApi#createUsersWithArrayInput - */ - default ResponseEntity createUsersWithArrayInput(List user) { - return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); - - } - - /** - * Create users with list input response entity. - * - * @param user the user - * @return the response entity - * @see UserApi#createUsersWithListInput UserApi#createUsersWithListInput - */ - default ResponseEntity createUsersWithListInput(List user) { - return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); - - } - - /** - * Delete user response entity. - * - * @param username the username - * @return the response entity - * @see UserApi#deleteUser UserApi#deleteUser - */ - default ResponseEntity deleteUser(String username) { - return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); - - } - - /** - * Gets user by name. - * - * @param username the username - * @return the user by name - * @see UserApi#getUserByName UserApi#getUserByName - */ - default ResponseEntity getUserByName(String username) { - getRequest().ifPresent(request -> { - for (MediaType mediaType : MediaType.parseMediaTypes(request.getHeader("Accept"))) { - if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { - ApiUtil.setExampleResponse(request, "application/json", "{ \"firstName\" : \"firstName\", \"lastName\" : \"lastName\", \"password\" : \"password\", \"userStatus\" : 6, \"phone\" : \"phone\", \"id\" : 0, \"email\" : \"email\", \"username\" : \"username\"}"); - break; - } - if (mediaType.isCompatibleWith(MediaType.valueOf("application/xml"))) { - ApiUtil.setExampleResponse(request, "application/xml", " 123456789 aeiou aeiou aeiou aeiou aeiou aeiou 123"); - break; - } - } - }); - return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); - - } - - /** - * Login user response entity. - * - * @param username the username - * @param password the password - * @return the response entity - * @see UserApi#loginUser UserApi#loginUser - */ - default ResponseEntity loginUser(String username, - String password) { - return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); - - } - - /** - * Logout user response entity. - * - * @return the response entity - * @see UserApi#logoutUser UserApi#logoutUser - */ - default ResponseEntity logoutUser() { - return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); - - } - - /** - * Update user response entity. - * - * @param username the username - * @param user the user - * @return the response entity - * @see UserApi#updateUser UserApi#updateUser - */ - default ResponseEntity updateUser(String username, - User user) { - return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); - - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app2/api/UserApiDelegateImpl.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app2/api/UserApiDelegateImpl.java deleted file mode 100644 index 81c53dc09..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app2/api/UserApiDelegateImpl.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app2.api; - -import org.springframework.stereotype.Service; - -/** - * The type User api delegate. - */ -@Service -class UserApiDelegateImpl implements UserApiDelegate { - - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app2/model/Category.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app2/model/Category.java deleted file mode 100644 index 5673b8e34..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app2/model/Category.java +++ /dev/null @@ -1,126 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app2.model; - -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * The type Category. - */ -class Category { - - /** - * The Id. - */ - private Long id = null; - - /** - * The Name. - */ - private String name = null; - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - * @param o the o - * @return the string - */ - private static String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } - - /** - * Get id - * - * @return id id - */ - @JsonProperty("id") - public Long getId() { - return id; - } - - /** - * Sets id. - * - * @param id the id - */ - public void setId(Long id) { - this.id = id; - } - - /** - * Id category. - * - * @param id the id - * @return the category - */ - public Category id(Long id) { - this.id = id; - return this; - } - - /** - * Get name - * - * @return name name - */ - @JsonProperty("name") - public String getName() { - return name; - } - - /** - * Sets name. - * - * @param name the name - */ - public void setName(String name) { - this.name = name; - } - - /** - * Name category. - * - * @param name the name - * @return the category - */ - public Category name(String name) { - this.name = name; - return this; - } - - /** - * To string string. - * - * @return the string - */ - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class Category {\n"); - - sb.append(" id: ").append(toIndentedString(id)).append("\n"); - sb.append(" name: ").append(toIndentedString(name)).append("\n"); - sb.append("}"); - return sb.toString(); - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app2/model/ModelApiResponse.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app2/model/ModelApiResponse.java deleted file mode 100644 index e60dcf1f5..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app2/model/ModelApiResponse.java +++ /dev/null @@ -1,162 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app2.model; - -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * The type Model api response. - */ -public class ModelApiResponse { - - /** - * The Code. - */ - private Integer code = null; - - /** - * The Type. - */ - private String type = null; - - /** - * The Message. - */ - private String message = null; - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - * @param o the o - * @return the string - */ - private static String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } - - /** - * Get code - * - * @return code code - */ - @JsonProperty("code") - public Integer getCode() { - return code; - } - - /** - * Sets code. - * - * @param code the code - */ - public void setCode(Integer code) { - this.code = code; - } - - /** - * Code model api response. - * - * @param code the code - * @return the model api response - */ - public ModelApiResponse code(Integer code) { - this.code = code; - return this; - } - - /** - * Get type - * - * @return type type - */ - @JsonProperty("type") - public String getType() { - return type; - } - - /** - * Sets type. - * - * @param type the type - */ - public void setType(String type) { - this.type = type; - } - - /** - * Type model api response. - * - * @param type the type - * @return the model api response - */ - public ModelApiResponse type(String type) { - this.type = type; - return this; - } - - /** - * Get message - * - * @return message message - */ - @JsonProperty("message") - public String getMessage() { - return message; - } - - /** - * Sets message. - * - * @param message the message - */ - public void setMessage(String message) { - this.message = message; - } - - /** - * Message model api response. - * - * @param message the message - * @return the model api response - */ - public ModelApiResponse message(String message) { - this.message = message; - return this; - } - - /** - * To string string. - * - * @return the string - */ - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class ModelApiResponse {\n"); - - sb.append(" code: ").append(toIndentedString(code)).append("\n"); - sb.append(" type: ").append(toIndentedString(type)).append("\n"); - sb.append(" message: ").append(toIndentedString(message)).append("\n"); - sb.append("}"); - return sb.toString(); - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app2/model/Order.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app2/model/Order.java deleted file mode 100644 index 6f4c69e7b..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app2/model/Order.java +++ /dev/null @@ -1,352 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app2.model; - -import java.util.Date; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonValue; -import io.swagger.v3.oas.annotations.media.Schema; - -/** - * The type Order. - */ -public class Order { - - /** - * The Id. - */ - @Schema(description = "") - private Long id = null; - - /** - * The Pet id. - */ - @Schema(description = "") - private Long petId = null; - - /** - * The Quantity. - */ - @Schema(description = "") - private Integer quantity = null; - - /** - * The Ship date. - */ - @Schema(description = "") - private Date shipDate = null; - - /** - * Order Status - */ - private StatusEnum status = null; - - /** - * The Complete. - */ - @Schema(description = "") - private Boolean complete = false; - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - * @param o the o - * @return the string - */ - private static String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } - - /** - * Get id - * - * @return id id - */ - @JsonProperty("id") - public Long getId() { - return id; - } - - /** - * Sets id. - * - * @param id the id - */ - public void setId(Long id) { - this.id = id; - } - - /** - * Id order. - * - * @param id the id - * @return the order - */ - public Order id(Long id) { - this.id = id; - return this; - } - - /** - * Get petId - * - * @return petId pet id - */ - @JsonProperty("petId") - public Long getPetId() { - return petId; - } - - /** - * Sets pet id. - * - * @param petId the pet id - */ - public void setPetId(Long petId) { - this.petId = petId; - } - - /** - * Pet id order. - * - * @param petId the pet id - * @return the order - */ - public Order petId(Long petId) { - this.petId = petId; - return this; - } - - /** - * Get quantity - * - * @return quantity quantity - */ - @JsonProperty("quantity") - public Integer getQuantity() { - return quantity; - } - - /** - * Sets quantity. - * - * @param quantity the quantity - */ - public void setQuantity(Integer quantity) { - this.quantity = quantity; - } - - /** - * Quantity order. - * - * @param quantity the quantity - * @return the order - */ - public Order quantity(Integer quantity) { - this.quantity = quantity; - return this; - } - - /** - * Get shipDate - * - * @return shipDate ship date - */ - @JsonProperty("shipDate") - public Date getShipDate() { - return shipDate; - } - - /** - * Sets ship date. - * - * @param shipDate the ship date - */ - public void setShipDate(Date shipDate) { - this.shipDate = shipDate; - } - - /** - * Ship date order. - * - * @param shipDate the ship date - * @return the order - */ - public Order shipDate(Date shipDate) { - this.shipDate = shipDate; - return this; - } - - /** - * Order Status - * - * @return status status - */ - @JsonProperty("status") - public String getStatus() { - if (status == null) { - return null; - } - return status.getValue(); - } - - /** - * Sets status. - * - * @param status the status - */ - public void setStatus(StatusEnum status) { - this.status = status; - } - - /** - * Status order. - * - * @param status the status - * @return the order - */ - public Order status(StatusEnum status) { - this.status = status; - return this; - } - - /** - * Get complete - * - * @return complete boolean - */ - @JsonProperty("complete") - public Boolean isisComplete() { - return complete; - } - - /** - * Sets complete. - * - * @param complete the complete - */ - public void setComplete(Boolean complete) { - this.complete = complete; - } - - /** - * Complete order. - * - * @param complete the complete - * @return the order - */ - public Order complete(Boolean complete) { - this.complete = complete; - return this; - } - - - /** - * To string string. - * - * @return the string - */ - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class Order {\n"); - - sb.append(" id: ").append(toIndentedString(id)).append("\n"); - sb.append(" petId: ").append(toIndentedString(petId)).append("\n"); - sb.append(" quantity: ").append(toIndentedString(quantity)).append("\n"); - sb.append(" shipDate: ").append(toIndentedString(shipDate)).append("\n"); - sb.append(" status: ").append(toIndentedString(status)).append("\n"); - sb.append(" complete: ").append(toIndentedString(complete)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * The enum Status enum. - */ - public enum StatusEnum { - /** - *Placed status enum. - */ - PLACED("placed"), - /** - *Approved status enum. - */ - APPROVED("approved"), - /** - *Delivered status enum. - */ - DELIVERED("delivered"); - - /** - * The Value. - */ - private String value; - - /** - * Instantiates a new Status enum. - * - * @param value the value - */ - StatusEnum(String value) { - this.value = value; - } - - /** - * From value status enum. - * - * @param text the text - * @return the status enum - */ - @JsonCreator - public static StatusEnum fromValue(String text) { - for (StatusEnum b : StatusEnum.values()) { - if (String.valueOf(b.value).equals(text)) { - return b; - } - } - return null; - } - - /** - * Gets value. - * - * @return the value - */ - @JsonValue - public String getValue() { - return value; - } - - /** - * To string string. - * - * @return the string - */ - @Override - public String toString() { - return String.valueOf(value); - } - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app2/model/Pet.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app2/model/Pet.java deleted file mode 100644 index 2fdffd905..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app2/model/Pet.java +++ /dev/null @@ -1,384 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app2.model; - -import java.util.ArrayList; -import java.util.List; - -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonValue; -import io.swagger.v3.oas.annotations.media.Schema; -import jakarta.validation.constraints.NotNull; - -/** - * The type Pet. - */ -public class Pet { - - /** - * The Id. - */ - @Schema(description = "") - private Long id = null; - - /** - * The Category. - */ - @Schema(description = "") - private Category category = null; - - /** - * The Name. - */ - @Schema(example = "doggie", required = true, description = "") - private String name = null; - - /** - * The Photo urls. - */ - @Schema(required = true, description = "") - private List photoUrls = new ArrayList(); - - /** - * The Tags. - */ - @Schema(description = "") - private List tags = null; - - /** - * The Status. - */ - @Schema(description = "pet status in the store") - /** - * pet status in the store - **/ - private StatusEnum status = null; - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - * @param o the o - * @return the string - */ - private static String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } - - /** - * Get id - * - * @return id id - */ - @JsonProperty("id") - public Long getId() { - return id; - } - - /** - * Sets id. - * - * @param id the id - */ - public void setId(Long id) { - this.id = id; - } - - /** - * Id pet. - * - * @param id the id - * @return the pet - */ - public Pet id(Long id) { - this.id = id; - return this; - } - - /** - * Get category - * - * @return category category - */ - @JsonProperty("category") - public Category getCategory() { - return category; - } - - /** - * Sets category. - * - * @param category the category - */ - public void setCategory(Category category) { - this.category = category; - } - - /** - * Category pet. - * - * @param category the category - * @return the pet - */ - public Pet category(Category category) { - this.category = category; - return this; - } - - /** - * Get name - * - * @return name name - */ - @JsonProperty("name") - @NotNull - public String getName() { - return name; - } - - /** - * Sets name. - * - * @param name the name - */ - public void setName(String name) { - this.name = name; - } - - /** - * Name pet. - * - * @param name the name - * @return the pet - */ - public Pet name(String name) { - this.name = name; - return this; - } - - /** - * Get photoUrls - * - * @return photoUrls photo urls - */ - @JsonProperty("photoUrls") - @NotNull - public List getPhotoUrls() { - return photoUrls; - } - - /** - * Sets photo urls. - * - * @param photoUrls the photo urls - */ - public void setPhotoUrls(List photoUrls) { - this.photoUrls = photoUrls; - } - - /** - * Photo urls pet. - * - * @param photoUrls the photo urls - * @return the pet - */ - public Pet photoUrls(List photoUrls) { - this.photoUrls = photoUrls; - return this; - } - - /** - * Add photo urls item pet. - * - * @param photoUrlsItem the photo urls item - * @return the pet - */ - public Pet addPhotoUrlsItem(String photoUrlsItem) { - this.photoUrls.add(photoUrlsItem); - return this; - } - - /** - * Get tags - * - * @return tags tags - */ - @JsonProperty("tags") - public List getTags() { - return tags; - } - - /** - * Sets tags. - * - * @param tags the tags - */ - public void setTags(List tags) { - this.tags = tags; - } - - /** - * Tags pet. - * - * @param tags the tags - * @return the pet - */ - public Pet tags(List tags) { - this.tags = tags; - return this; - } - - /** - * Add tags item pet. - * - * @param tagsItem the tags item - * @return the pet - */ - public Pet addTagsItem(Tag tagsItem) { - if (this.tags == null) { - this.tags = new ArrayList<>(); - } - this.tags.add(tagsItem); - return this; - } - - /** - * pet status in the store - * - * @return status status - */ - @JsonProperty("status") - public StatusEnum getStatus() { - if (status == null) { - return null; - } - return status; - } - - /** - * Sets status. - * - * @param status the status - */ - public void setStatus(StatusEnum status) { - this.status = status; - } - - /** - * Status pet. - * - * @param status the status - * @return the pet - */ - public Pet status(StatusEnum status) { - this.status = status; - return this; - } - - /** - * To string string. - * - * @return the string - */ - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class Pet {\n"); - - sb.append(" id: ").append(toIndentedString(id)).append("\n"); - sb.append(" category: ").append(toIndentedString(category)).append("\n"); - sb.append(" name: ").append(toIndentedString(name)).append("\n"); - sb.append(" photoUrls: ").append(toIndentedString(photoUrls)).append("\n"); - sb.append(" tags: ").append(toIndentedString(tags)).append("\n"); - sb.append(" status: ").append(toIndentedString(status)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * The enum Status enum. - */ - public enum StatusEnum { - /** - *Available status enum. - */ - AVAILABLE("available"), - /** - *Pending status enum. - */ - PENDING("pending"), - /** - *Sold status enum. - */ - SOLD("sold"); - - /** - * The Value. - */ - private String value; - - /** - * Instantiates a new Status enum. - * - * @param value the value - */ - StatusEnum(String value) { - this.value = value; - } - - /** - * From value status enum. - * - * @param text the text - * @return the status enum - */ - @JsonCreator - public static StatusEnum fromValue(String text) { - for (StatusEnum b : StatusEnum.values()) { - if (String.valueOf(b.value).equals(text)) { - return b; - } - } - return null; - } - - /** - * Gets value. - * - * @return the value - */ - @JsonValue - public String getValue() { - return value; - } - - /** - * To string string. - * - * @return the string - */ - @Override - public String toString() { - return String.valueOf(value); - } - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app2/model/Tag.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app2/model/Tag.java deleted file mode 100644 index dc541984c..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app2/model/Tag.java +++ /dev/null @@ -1,129 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app2.model; - -import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.v3.oas.annotations.media.Schema; - -/** - * The type Tag. - */ -class Tag { - - /** - * The Id. - */ - @Schema(description = "") - private Long id = null; - - /** - * The Name. - */ - @Schema(description = "") - private String name = null; - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - * @param o the o - * @return the string - */ - private static String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } - - /** - * Get id - * - * @return id id - */ - @JsonProperty("id") - public Long getId() { - return id; - } - - /** - * Sets id. - * - * @param id the id - */ - public void setId(Long id) { - this.id = id; - } - - /** - * Id tag. - * - * @param id the id - * @return the tag - */ - public Tag id(Long id) { - this.id = id; - return this; - } - - /** - * Get name - * - * @return name name - */ - @JsonProperty("name") - public String getName() { - return name; - } - - /** - * Sets name. - * - * @param name the name - */ - public void setName(String name) { - this.name = name; - } - - /** - * Name tag. - * - * @param name the name - * @return the tag - */ - public Tag name(String name) { - this.name = name; - return this; - } - - /** - * To string string. - * - * @return the string - */ - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class Tag {\n"); - - sb.append(" id: ").append(toIndentedString(id)).append("\n"); - sb.append(" name: ").append(toIndentedString(name)).append("\n"); - sb.append("}"); - return sb.toString(); - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app2/model/User.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app2/model/User.java deleted file mode 100644 index 0d6a85e03..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app2/model/User.java +++ /dev/null @@ -1,350 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app2.model; - -import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.v3.oas.annotations.media.Schema; - -/** - * The type User. - */ -public class User { - - /** - * The Id. - */ - @Schema(description = "") - private Long id = null; - - /** - * The Username. - */ - @Schema(description = "") - private String username = null; - - /** - * The First name. - */ - @Schema(description = "") - private String firstName = null; - - /** - * The Last name. - */ - @Schema(description = "") - private String lastName = null; - - /** - * The Email. - */ - @Schema(description = "") - private String email = null; - - /** - * The Password. - */ - @Schema(description = "") - private String password = null; - - /** - * The Phone. - */ - @Schema(description = "") - private String phone = null; - - /** - * User Status - */ - private Integer userStatus = null; - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - * @param o the o - * @return the string - */ - private static String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } - - /** - * Get id - * - * @return id id - */ - @JsonProperty("id") - public Long getId() { - return id; - } - - /** - * Sets id. - * - * @param id the id - */ - public void setId(Long id) { - this.id = id; - } - - /** - * Id user. - * - * @param id the id - * @return the user - */ - public User id(Long id) { - this.id = id; - return this; - } - - /** - * Get username - * - * @return username username - */ - @JsonProperty("username") - public String getUsername() { - return username; - } - - /** - * Sets username. - * - * @param username the username - */ - public void setUsername(String username) { - this.username = username; - } - - /** - * Username user. - * - * @param username the username - * @return the user - */ - public User username(String username) { - this.username = username; - return this; - } - - /** - * Get firstName - * - * @return firstName first name - */ - @JsonProperty("firstName") - public String getFirstName() { - return firstName; - } - - /** - * Sets first name. - * - * @param firstName the first name - */ - public void setFirstName(String firstName) { - this.firstName = firstName; - } - - /** - * First name user. - * - * @param firstName the first name - * @return the user - */ - public User firstName(String firstName) { - this.firstName = firstName; - return this; - } - - /** - * Get lastName - * - * @return lastName last name - */ - @JsonProperty("lastName") - public String getLastName() { - return lastName; - } - - /** - * Sets last name. - * - * @param lastName the last name - */ - public void setLastName(String lastName) { - this.lastName = lastName; - } - - /** - * Last name user. - * - * @param lastName the last name - * @return the user - */ - public User lastName(String lastName) { - this.lastName = lastName; - return this; - } - - /** - * Get email - * - * @return email email - */ - @JsonProperty("email") - public String getEmail() { - return email; - } - - /** - * Sets email. - * - * @param email the email - */ - public void setEmail(String email) { - this.email = email; - } - - /** - * Email user. - * - * @param email the email - * @return the user - */ - public User email(String email) { - this.email = email; - return this; - } - - /** - * Get password - * - * @return password password - */ - @JsonProperty("password") - public String getPassword() { - return password; - } - - /** - * Sets password. - * - * @param password the password - */ - public void setPassword(String password) { - this.password = password; - } - - /** - * Password user. - * - * @param password the password - * @return the user - */ - public User password(String password) { - this.password = password; - return this; - } - - /** - * Get phone - * - * @return phone phone - */ - @JsonProperty("phone") - public String getPhone() { - return phone; - } - - /** - * Sets phone. - * - * @param phone the phone - */ - public void setPhone(String phone) { - this.phone = phone; - } - - /** - * Phone user. - * - * @param phone the phone - * @return the user - */ - public User phone(String phone) { - this.phone = phone; - return this; - } - - /** - * User Status - * - * @return userStatus user status - */ - @JsonProperty("userStatus") - public Integer getUserStatus() { - return userStatus; - } - - /** - * Sets user status. - * - * @param userStatus the user status - */ - public void setUserStatus(Integer userStatus) { - this.userStatus = userStatus; - } - - /** - * User status user. - * - * @param userStatus the user status - * @return the user - */ - public User userStatus(Integer userStatus) { - this.userStatus = userStatus; - return this; - } - - /** - * To string string. - * - * @return the string - */ - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class User {\n"); - - sb.append(" id: ").append(toIndentedString(id)).append("\n"); - sb.append(" username: ").append(toIndentedString(username)).append("\n"); - sb.append(" firstName: ").append(toIndentedString(firstName)).append("\n"); - sb.append(" lastName: ").append(toIndentedString(lastName)).append("\n"); - sb.append(" email: ").append(toIndentedString(email)).append("\n"); - sb.append(" password: ").append(toIndentedString(password)).append("\n"); - sb.append(" phone: ").append(toIndentedString(phone)).append("\n"); - sb.append(" userStatus: ").append(toIndentedString(userStatus)).append("\n"); - sb.append("}"); - return sb.toString(); - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app20/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app20/HelloController.java deleted file mode 100644 index a47bf7f0c..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app20/HelloController.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app20; - -import io.swagger.v3.oas.annotations.Hidden; -import jakarta.validation.Valid; -import jakarta.validation.constraints.NotBlank; - -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * The type Hello controller. - */ -@RestController -class HelloController { - - /** - * Persons. - * - * @param name the name - */ - @GetMapping(value = "/persons") - @Hidden - public void persons(@Valid @NotBlank String name) { - - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app20/SpringDocApp20Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app20/SpringDocApp20Test.java deleted file mode 100644 index df7d4359d..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app20/SpringDocApp20Test.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app20; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * The type Spring doc app 20 test. - */ -class SpringDocApp20Test extends AbstractSpringDocTest { - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app21/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app21/HelloController.java deleted file mode 100644 index 0fdd1b83e..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app21/HelloController.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app21; - -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.enums.SecuritySchemeType; -import io.swagger.v3.oas.annotations.security.OAuthFlow; -import io.swagger.v3.oas.annotations.security.OAuthFlows; -import io.swagger.v3.oas.annotations.security.OAuthScope; -import io.swagger.v3.oas.annotations.security.SecurityRequirement; -import io.swagger.v3.oas.annotations.security.SecurityScheme; -import jakarta.validation.Valid; -import jakarta.validation.constraints.NotBlank; - -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * The type Hello controller. - */ -@RestController -@SecurityScheme(name = "personstore_auth", type = SecuritySchemeType.OAUTH2, flows = @OAuthFlows(implicit = @OAuthFlow(authorizationUrl = "${springdoc.oAuthFlow.authorizationUrl}", scopes = { - @OAuthScope(name = "write:persons", description = "modify persons in your account"), - @OAuthScope(name = "read:persons", description = "read your persons") }))) -class HelloController { - - /** - * Persons. - * - * @param name the name - */ - @Operation(summary = "Add a new person to the store", description = "", security = { - @SecurityRequirement(name = "personstore_auth", scopes = { "write:persons", "read:persons" }) }, tags = { - "person" }) - @GetMapping(value = "/persons") - public void persons(@Valid @NotBlank String name) { - - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app21/SpringDocApp21Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app21/SpringDocApp21Test.java deleted file mode 100644 index 9d4cb5a3e..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app21/SpringDocApp21Test.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app21; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.test.context.TestPropertySource; - -/** - * The type Spring doc app 21 test. - */ -@TestPropertySource(properties = "springdoc.oAuthFlow.authorizationUrl=http://personstore.swagger.io/oauth/dialog") -class SpringDocApp21Test extends AbstractSpringDocTest { - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app22/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app22/HelloController.java deleted file mode 100644 index 5a5a01002..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app22/HelloController.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app22; - -import java.util.List; - -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * The type Hello controller. - */ -@RestController -class HelloController { - - - /** - * Do get response entity. - * - * @return the response entity - */ - @GetMapping(value = "/persons") - public ResponseEntity>> doGet() { - return null; - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app22/PersonDTO.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app22/PersonDTO.java deleted file mode 100644 index a0f5932e6..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app22/PersonDTO.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app22; - -/** - * The type Person dto. - */ -class PersonDTO { - /** - * The Email. - */ - private String email; - - /** - * The First name. - */ - private String firstName; - - /** - * The Last name. - */ - private String lastName; - - /** - * Instantiates a new Person dto. - */ - public PersonDTO() { - } - - /** - * Instantiates a new Person dto. - * - * @param email the email - * @param firstName the first name - * @param lastName the last name - */ - public PersonDTO(final String email, final String firstName, final String lastName) { - this.email = email; - this.firstName = firstName; - this.lastName = lastName; - } - - /** - * Gets email. - * - * @return the email - */ - public String getEmail() { - return email; - } - - /** - * Sets email. - * - * @param email the email - */ - public void setEmail(final String email) { - this.email = email; - } - - /** - * Gets first name. - * - * @return the first name - */ - public String getFirstName() { - return firstName; - } - - /** - * Sets first name. - * - * @param firstName the first name - */ - public void setFirstName(final String firstName) { - this.firstName = firstName; - } - - /** - * Gets last name. - * - * @return the last name - */ - public String getLastName() { - return lastName; - } - - /** - * Sets last name. - * - * @param lastName the last name - */ - public void setLastName(final String lastName) { - this.lastName = lastName; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app22/SpringDocApp22Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app22/SpringDocApp22Test.java deleted file mode 100644 index e39d6c820..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app22/SpringDocApp22Test.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app22; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * The type Spring doc app 22 test. - */ -class SpringDocApp22Test extends AbstractSpringDocTest { - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app23/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app23/HelloController.java deleted file mode 100644 index a6cb22640..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app23/HelloController.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app23; - -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.enums.SecuritySchemeIn; -import io.swagger.v3.oas.annotations.enums.SecuritySchemeType; -import io.swagger.v3.oas.annotations.security.SecurityRequirement; -import io.swagger.v3.oas.annotations.security.SecurityScheme; -import jakarta.validation.Valid; -import jakarta.validation.constraints.NotBlank; - -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * The type Hello controller. - */ -@RestController -@SecurityScheme(type = SecuritySchemeType.APIKEY, in = SecuritySchemeIn.HEADER, name = "Authorization", paramName = "JWT", description = "A core-auth Bearer token") -class HelloController { - - /** - * Persons. - * - * @param name the name - */ - @Operation(summary = "Add a new person to the store", description = "", security = { - @SecurityRequirement(name = "Authorization") }) - @GetMapping(value = "/persons") - public void persons(@Valid @NotBlank String name) { - - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app23/SpringDocApp23Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app23/SpringDocApp23Test.java deleted file mode 100644 index d6600286c..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app23/SpringDocApp23Test.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app23; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * The type Spring doc app 23 test. - */ -class SpringDocApp23Test extends AbstractSpringDocTest { - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app24/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app24/HelloController.java deleted file mode 100644 index f5b863c78..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app24/HelloController.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app24; - -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.enums.SecuritySchemeIn; -import io.swagger.v3.oas.annotations.enums.SecuritySchemeType; -import io.swagger.v3.oas.annotations.security.SecurityRequirement; -import io.swagger.v3.oas.annotations.security.SecurityScheme; -import jakarta.validation.Valid; -import jakarta.validation.constraints.NotBlank; - -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * The type Hello controller. - */ -@RestController -@SecurityScheme(type = SecuritySchemeType.APIKEY, in = SecuritySchemeIn.HEADER, name = "Authorization", description = "A core-auth Bearer token") -class HelloController { - - /** - * Persons. - * - * @param name the name - */ - @Operation(summary = "Add a new person to the store", description = "", security = { - @SecurityRequirement(name = "Authorization") }) - @GetMapping(value = "/persons") - public void persons(@Valid @NotBlank String name) { - - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app24/SpringDocApp24Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app24/SpringDocApp24Test.java deleted file mode 100644 index cf24c85eb..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app24/SpringDocApp24Test.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app24; - -import test.org.springdoc.api.AbstractSpringDocTest; - -/** - * The type Spring doc app 24 test. - */ -class SpringDocApp24Test extends AbstractSpringDocTest { - - -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app24/SpringDocTestApp.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app24/SpringDocTestApp.java deleted file mode 100644 index 172d4166a..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app24/SpringDocTestApp.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app24; - -import io.swagger.v3.oas.models.Components; -import io.swagger.v3.oas.models.OpenAPI; -import io.swagger.v3.oas.models.headers.Header; -import io.swagger.v3.oas.models.info.Info; -import io.swagger.v3.oas.models.info.License; -import io.swagger.v3.oas.models.media.StringSchema; -import io.swagger.v3.oas.models.parameters.Parameter; -import io.swagger.v3.oas.models.security.SecurityScheme; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.Bean; - -/** - * The type Spring doc test app. - */ -@SpringBootApplication -class SpringDocTestApp { - - /** - * The entry point of application. - * - * @param args the input arguments - */ - public static void main(String[] args) { - SpringApplication.run(SpringDocTestApp.class, args); - } - - /** - * Custom open api open api. - * - * @return the open api - */ - @Bean - public OpenAPI customOpenAPI() { - return new OpenAPI() - .components(new Components() - .addSecuritySchemes("basicScheme", - new SecurityScheme().type(SecurityScheme.Type.HTTP).scheme("basic")) - .addParameters("myHeader1", - new Parameter().in("header").schema(new StringSchema()).name("myHeader1")) - .addHeaders("myHeader2", - new Header().description("myHeader2 header").schema(new StringSchema()))) - .info(new Info().title("Petstore API").version("v0").description( - "This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.") - .termsOfService("http://swagger.io/terms/") - .license(new License().name("Apache 2.0").url("http://springdoc.org"))); - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app25/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app25/HelloController.java deleted file mode 100644 index a2760a194..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app25/HelloController.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app25; - -import java.time.Instant; - -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.enums.ParameterIn; -import io.swagger.v3.oas.annotations.media.Schema; -import io.swagger.v3.oas.annotations.responses.ApiResponse; - -import org.springframework.http.HttpStatus; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.ResponseStatus; -import org.springframework.web.bind.annotation.RestController; - -/** - * The type Hello controller. - */ -@RestController -class HelloController { - - /** - * Check. - */ - @GetMapping(value = "/check") - @ResponseStatus(HttpStatus.OK) - void check() { - } - - /** - * List. - * - * @param trackerId the tracker id - * @param startDate the start date - * @param endDate the end date - */ - @GetMapping(value = "/list/{trackerId}") - void list( - - @Parameter(name = "trackerId", in = ParameterIn.PATH, required = true, schema = @Schema(type = "string", example = "the-tracker-id")) @PathVariable String trackerId, - @Parameter(name = "start", in = ParameterIn.QUERY, required = false, schema = @Schema(type = "string", format = "date-time", required = false, example = "1970-01-01T00:00:00.000Z")) @RequestParam(value = "start", required = false) Instant startDate, - @Parameter(name = "end", in = ParameterIn.QUERY, required = false, schema = @Schema(type = "string", format = "date-time", required = false, example = "1970-01-01T00:10:00.000Z")) @RequestParam(value = "end", required = false) Instant endDate) { - } - - /** - * Secondlist. - * - * @param trackerId the tracker id - * @param startDate the start date - * @param endDate the end date - */ - @GetMapping(value = "/secondlist/{trackerId}") - void secondlist( - @Parameter(name = "trackerId", in = ParameterIn.PATH, required = true, schema = @Schema(type = "string", example = "the-tracker-id")) @PathVariable String trackerId, - @Parameter(name = "start", in = ParameterIn.QUERY, required = false, schema = @Schema(type = "string", format = "date-time", required = false, example = "1970-01-01T00:00:00.000Z")) @RequestParam(value = "start", required = false) Instant startDate, - @Parameter(name = "end", in = ParameterIn.QUERY, required = false, schema = @Schema(type = "string", format = "date-time", required = false, example = "1970-01-01T00:10:00.000Z")) @RequestParam(value = "end", required = false) Instant endDate) { - - } - - /** - * Third list. - * - * @param trackerId the tracker id - * @param start the start - * @param end the end - * @param limit the limit - */ - @Operation(description = "Get last data from a tracker", parameters = { - @Parameter(name = "trackerId", in = ParameterIn.PATH, required = true, schema = @Schema(type = "string", example = "the-tracker-id")), - @Parameter(name = "start", in = ParameterIn.QUERY, required = false, schema = @Schema(type = "string", format = "date-time", required = false, example = "1970-01-01T00:00:00.000Z")), - @Parameter(name = "end", in = ParameterIn.QUERY, required = false, schema = @Schema(type = "string", format = "date-time", required = false, example = "1970-01-01T00:10:00.000Z")), - @Parameter(name = "limit", in = ParameterIn.QUERY, required = false, schema = @Schema(type = "number", required = false, example = "10")) }, responses = { - @ApiResponse(responseCode = "200") }) - - @GetMapping(value = "/values/{trackerId}/data") - void thirdList(@PathVariable String trackerId, @RequestParam(value = "start", required = false) Instant start, - @RequestParam(value = "end", required = false) Instant end, - @RequestParam(value = "limit", required = false) Integer limit) { - - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app25/SpringDocApp25Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app25/SpringDocApp25Test.java deleted file mode 100644 index f4a12140a..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app25/SpringDocApp25Test.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app25; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * The type Spring doc app 25 test. - */ -class SpringDocApp25Test extends AbstractSpringDocTest { - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app26/Bar.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app26/Bar.java deleted file mode 100644 index 0f0f32164..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app26/Bar.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app26; - -/** - * The type Bar. - */ -class Bar { - /** - * The Bar. - */ - private String bar; - - /** - * Gets bar. - * - * @return the bar - */ - public String getBar() { - return bar; - } - - /** - * Sets bar. - * - * @param bar the bar - */ - public void setBar(String bar) { - this.bar = bar; - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app26/Foo.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app26/Foo.java deleted file mode 100644 index da6b0a2fb..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app26/Foo.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app26; - -/** - * The type Foo. - */ -class Foo { - - /** - * The Foo. - */ - private String foo; - - /** - * Gets foo. - * - * @return the foo - */ - public String getFoo() { - return foo; - } - - /** - * Sets foo. - * - * @param foo the foo - */ - public void setFoo(String foo) { - this.foo = foo; - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app26/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app26/HelloController.java deleted file mode 100644 index 6584e3711..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app26/HelloController.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app26; - -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * The type Hello controller. - */ -@RestController -class HelloController { - - /** - * Persons my model. - * - * @param myModel the my model - * @return the my model - */ - @PostMapping(value = "/persons") - public MyModel persons(MyModel myModel) { - return new MyModel(); - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app26/MyModel.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app26/MyModel.java deleted file mode 100644 index 045de17e0..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app26/MyModel.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app26; - -import io.swagger.v3.oas.annotations.media.Schema; - -/** - * The type My model. - */ -class MyModel { - - /** - * The Thing. - */ - @Schema(description = "Hello", type = "object", oneOf = { Foo.class, Bar.class }) - private Object thing; - - /** - * Gets thing. - * - * @return the thing - */ - public Object getThing() { - return thing; - } - - /** - * Sets thing. - * - * @param thing the thing - */ - public void setThing(Object thing) { - this.thing = thing; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app26/SpringDocApp26Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app26/SpringDocApp26Test.java deleted file mode 100644 index b871ae8a6..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app26/SpringDocApp26Test.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app26; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * The type Spring doc app 26 test. - */ -class SpringDocApp26Test extends AbstractSpringDocTest { - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app27/Advice.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app27/Advice.java deleted file mode 100644 index 6ba5ed55e..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app27/Advice.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app27; - -import io.swagger.v3.oas.annotations.Hidden; - -import org.springframework.http.HttpStatus; -import org.springframework.web.bind.annotation.ExceptionHandler; -import org.springframework.web.bind.annotation.ResponseStatus; -import org.springframework.web.bind.annotation.RestControllerAdvice; -import org.springframework.web.context.request.WebRequest; - -/** - * The type Advice. - */ -@RestControllerAdvice -class Advice { - - /** - * Handle exception foo. - * - * @param ex the ex - * @param request the request - * @return the foo - */ - @ExceptionHandler(Exception.class) - @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR) - public Foo handleException(Exception ex, WebRequest request) { - return new Foo(); - } - - /** - * Handle my exception bar. - * - * @param ex the ex - * @param request the request - * @return the bar - */ - @ExceptionHandler(MyException.class) - @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR) - public Bar handleMyException(MyException ex, WebRequest request) { - return new Bar(); - } - - /** - * Handle my exception 2 bar. - * - * @param ex the ex - * @param request the request - * @return the bar - */ - @Hidden - @ExceptionHandler(Throwable.class) - @ResponseStatus(HttpStatus.NOT_FOUND) - public Bar handleMyException2(MyException ex, WebRequest request) { - return new Bar(); - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app27/Bar.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app27/Bar.java deleted file mode 100644 index dccaf02a8..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app27/Bar.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app27; - -/** - * The type Bar. - */ -class Bar { - /** - * The Bar. - */ - public String bar = "bar"; -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app27/Foo.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app27/Foo.java deleted file mode 100644 index 5e3b5bb0d..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app27/Foo.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app27; - -/** - * The type Foo. - */ -class Foo { - /** - * The Foo. - */ - public String foo = "foo"; -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app27/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app27/HelloController.java deleted file mode 100644 index 3c2742c65..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app27/HelloController.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app27; - -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * The type Hello controller. - */ -@RestController -class HelloController { - - /** - * The Flag. - */ - private boolean flag = false; - - /** - * Index string. - * - * @return the string - */ - @RequestMapping("/") - public String index() { - return ""; - } - - /** - * Test string. - * - * @return the string - */ - @GetMapping("/test") - public String test() { - flag = !flag; - throw flag ? new MyException() : new RuntimeException(); - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app27/MyException.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app27/MyException.java deleted file mode 100644 index f49c3a6e8..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app27/MyException.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app27; - -/** - * The type My exception. - */ -class MyException extends RuntimeException { - - /** - * The constant serialVersionUID. - */ - private static final long serialVersionUID = 1L; - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app27/SpringDocApp27Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app27/SpringDocApp27Test.java deleted file mode 100644 index 9e17ed72b..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app27/SpringDocApp27Test.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app27; - -import org.junit.jupiter.api.Test; -import org.springdoc.core.utils.Constants; -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -import static org.hamcrest.Matchers.containsInAnyOrder; -import static org.hamcrest.Matchers.is; -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; - -/** - * The type Spring doc app 27 test. - */ -class SpringDocApp27Test extends AbstractSpringDocTest { - - /** - * Test app. - * - * @throws Exception the exception - */ - @Test - protected void testApp() throws Exception { - mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL)).andExpect(status().isOk()) - .andExpect(jsonPath("$.openapi", is("3.0.1"))).andExpect(jsonPath("$.paths./test.get.responses.500.content.['*/*'].schema.oneOf").isArray()).andExpect(jsonPath("$.paths./test.get.responses.500.content.['*/*'].schema.oneOf[*].$ref", containsInAnyOrder("#/components/schemas/Bar", - "#/components/schemas/Foo"))); - } - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app28/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app28/HelloController.java deleted file mode 100644 index 30f2c77c6..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app28/HelloController.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app28; - -import org.springframework.http.MediaType; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestPart; -import org.springframework.web.bind.annotation.RestController; -import org.springframework.web.multipart.MultipartFile; - -/** - * The type Hello controller. - */ -@RestController -class HelloController { - - /** - * Upload 2 string. - * - * @param one the one - * @param two the two - * @return the string - */ - @PostMapping(value = "/upload2", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) - public String upload2(@RequestPart("one") MultipartFile one, @RequestPart("two") MultipartFile two) { - return "Ok"; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app28/SpringDocApp28Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app28/SpringDocApp28Test.java deleted file mode 100644 index a3c5fc1e8..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app28/SpringDocApp28Test.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app28; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * The type Spring doc app 28 test. - */ -class SpringDocApp28Test extends AbstractSpringDocTest { - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app29/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app29/HelloController.java deleted file mode 100644 index 5f4f4b6db..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app29/HelloController.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app29; - -import java.util.List; - -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.media.ArraySchema; -import io.swagger.v3.oas.annotations.media.Content; -import io.swagger.v3.oas.annotations.media.Schema; -import io.swagger.v3.oas.annotations.parameters.RequestBody; -import io.swagger.v3.oas.annotations.responses.ApiResponse; - -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * The type Hello controller. - */ -@RestController -class HelloController { - - /** - * Post entity list. - * - * @param postEntity the post entity - * @return the list - */ - @PostMapping(value = "/post-entity") - @Operation(description = "Post entity", - requestBody = @RequestBody(content = @Content(mediaType = "application/json", schema = @Schema(implementation = TrackerData.class))), - responses = - { @ApiResponse(responseCode = "200", content = @Content(mediaType = "application/json", array = @ArraySchema(schema = @Schema(implementation = TrackerData.class)))) }) - List postEntity(@RequestBody TrackerData postEntity) { - return null; - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app29/SpringDocApp29Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app29/SpringDocApp29Test.java deleted file mode 100644 index dca022fc9..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app29/SpringDocApp29Test.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app29; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * The type Spring doc app 29 test. - */ -class SpringDocApp29Test extends AbstractSpringDocTest { - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app29/TrackerData.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app29/TrackerData.java deleted file mode 100644 index 190835bc3..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app29/TrackerData.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app29; - -import java.time.Instant; - -import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.v3.oas.annotations.media.Schema; - -/** - * The type Tracker data. - */ -@Schema(name = "TrackerData") -class TrackerData { - - /** - * The Tracker id. - */ - @Schema(name = "trackerId", type = "string", required = true, example = "the-tracker-id") - @JsonProperty("trackerId") - String trackerId; - - /** - * The Timestamp. - */ - @Schema(name = "timestamp", type = "string", format = "date-time", required = true, example = "2018-01-01T00:00:00Z") - @JsonProperty("timestamp") - Instant timestamp; - - /** - * The Value. - */ - @Schema(name = "value", type = "number", format = "double", description = "The data value", required = true, example = "19.0") - @JsonProperty("value") - Double value; - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app3/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app3/HelloController.java deleted file mode 100644 index 0e3e4e96f..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app3/HelloController.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app3; - -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -/** - * The type Hello controller. - */ -@RestController -class HelloController { - - /** - * Echo playing card. - * - * @param card the card baby - * @param toto the toto baby - * @return the playing card baby - */ - @PostMapping - public PersonDTO echo(@RequestBody PlayingCard card, @RequestParam String toto) { - return null; - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app3/PersonDTO.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app3/PersonDTO.java deleted file mode 100644 index 973c8443b..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app3/PersonDTO.java +++ /dev/null @@ -1,113 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app3; - -/** - * The type Person dto. - */ -class PersonDTO { - - /** - * The email - */ - private String email; - - /** - * The firstName - */ - private String firstName; - - /** - * The lastName - */ - private String lastName; - - /** - * Instantiates a new Person dto. - */ - public PersonDTO() { - } - - /** - * Instantiates a new Person dto. - * - * @param email the email - * @param firstName the first name - * @param lastName the last name - */ - public PersonDTO(final String email, final String firstName, final String lastName) { - this.email = email; - this.firstName = firstName; - this.lastName = lastName; - } - - /** - * Gets email. - * - * @return the email - */ - public String getEmail() { - return email; - } - - /** - * Sets email. - * - * @param email the email - */ - public void setEmail(final String email) { - this.email = email; - } - - /** - * Gets first name. - * - * @return the first name - */ - public String getFirstName() { - return firstName; - } - - /** - * Sets first name. - * - * @param firstName the first name - */ - public void setFirstName(final String firstName) { - this.firstName = firstName; - } - - /** - * Gets last name. - * - * @return the last name - */ - public String getLastName() { - return lastName; - } - - /** - * Sets last name. - * - * @param lastName the last name - */ - public void setLastName(final String lastName) { - this.lastName = lastName; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app3/PlayingCard.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app3/PlayingCard.java deleted file mode 100644 index 747a0c2d4..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app3/PlayingCard.java +++ /dev/null @@ -1,125 +0,0 @@ -package test.org.springdoc.api.app3; - -import java.util.Date; - -import com.fasterxml.jackson.annotation.JsonValue; - -/** - * The type Playing card. - */ -class PlayingCard { - /** - * The Suit. - */ - private Suit suit; - - /** - * The Value. - */ - private Integer value; - - /** - * The Toto. - */ - private Date toto; - - /** - * Gets toto. - * - * @return the toto - */ - public Date getToto() { - return toto; - } - - /** - * Sets toto. - * - * @param toto the toto - */ - public void setToto(Date toto) { - this.toto = toto; - } - - /** - * Gets suit. - * - * @return the suit - */ - public Suit getSuit() { - return suit; - } - - /** - * Sets suit. - * - * @param suit the suit - */ - public void setSuit(Suit suit) { - this.suit = suit; - } - - /** - * Gets value. - * - * @return the value - */ - public Integer getValue() { - return value; - } - - /** - * Sets value. - * - * @param value the value - */ - public void setValue(Integer value) { - this.value = value; - } - - /** - * The enum Suit. - */ - public enum Suit { - /** - *Hearts suit. - */ - HEARTS("Hearts"), - /** - *Diamonds suit. - */ - DIAMONDS("Diamonds"), - /** - *Clubs suit. - */ - CLUBS("Clubs"), - /** - *Spades suit. - */ - SPADES("Spades"); - - /** - * The Json value. - */ - private final String jsonValue; - - /** - * Instantiates a new Suit. - * - * @param jsonValue the json value - */ - Suit(String jsonValue) { - this.jsonValue = jsonValue; - } - - /** - * Gets json value. - * - * @return the json value - */ - @JsonValue - public String getJsonValue() { - return jsonValue; - } - } -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app3/SpringDocApp3Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app3/SpringDocApp3Test.java deleted file mode 100644 index 25467759a..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app3/SpringDocApp3Test.java +++ /dev/null @@ -1,16 +0,0 @@ -package test.org.springdoc.api.app3; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * The type Spring doc app 3 test. - */ -class SpringDocApp3Test extends AbstractSpringDocTest { - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app30/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app30/HelloController.java deleted file mode 100644 index fe0d6daae..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app30/HelloController.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app30; - -import org.springframework.http.MediaType; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -/** - * The type Hello controller. - */ -@RestController -class HelloController { - - /** - * Echo string. - * - * @param text the text - * @return the string - */ - @GetMapping(produces = MediaType.TEXT_PLAIN_VALUE, path = "/test") - public String echo(@RequestParam(name = "text", defaultValue = "Hello, World!") String text) { - return text; - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app30/SpringDocApp30Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app30/SpringDocApp30Test.java deleted file mode 100644 index 9b06f5862..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app30/SpringDocApp30Test.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app30; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * The type Spring doc app 30 test. - */ -class SpringDocApp30Test extends AbstractSpringDocTest { - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app31/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app31/HelloController.java deleted file mode 100644 index 082a24e48..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app31/HelloController.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app31; - -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.callbacks.Callback; -import io.swagger.v3.oas.annotations.enums.ParameterIn; -import io.swagger.v3.oas.annotations.media.Schema; -import io.swagger.v3.oas.annotations.responses.ApiResponse; - -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -/** - * The type Hello controller. - */ -@RestController -class HelloController { - - /** - * Subscribe subscription response. - * - * @param token the token - * @param url the url - * @return the subscription response - */ - @PostMapping("/test") - @Callback(callbackUrlExpression = "http://$request.query.url", name = "subscription", operation = { - @Operation(method = "post", description = "payload data will be sent", parameters = { - @Parameter(in = ParameterIn.PATH, name = "subscriptionId", required = true, schema = @Schema(type = "string", format = "uuid", description = "the generated UUID", accessMode = Schema.AccessMode.READ_ONLY)) }, responses = { - @ApiResponse(responseCode = "200", description = "Return this code if the callback was received and processed successfully"), - @ApiResponse(responseCode = "205", description = "Return this code to unsubscribe from future data updates"), - @ApiResponse(responseCode = "default", description = "All other response codes will disable this callback subscription") }) }) - @Operation(description = "subscribes a client to updates relevant to the requestor's account, as " - + "identified by the input token. The supplied url will be used as the delivery address for response payloads") - public SubscriptionResponse subscribe(@Schema(required = true, description = "the authentication token " - + "provided after initially authenticating to the application") @RequestHeader("x-auth-token") String token, - @Schema(required = true, description = "the URL to call with response " - + "data") @RequestParam("url") String url) { - return null; - } - - /** - * The type Subscription response. - */ - static class SubscriptionResponse { - /** - * The Subscription uuid. - */ - private String subscriptionUuid; - - /** - * Gets subscription uuid. - * - * @return the subscription uuid - */ - public String getSubscriptionUuid() { - return subscriptionUuid; - } - - /** - * Sets subscription uuid. - * - * @param subscriptionUuid the subscription uuid - */ - public void setSubscriptionUuid(String subscriptionUuid) { - this.subscriptionUuid = subscriptionUuid; - } - - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app31/SpringDocApp31Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app31/SpringDocApp31Test.java deleted file mode 100644 index ca0a7ecc4..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app31/SpringDocApp31Test.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app31; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * The type Spring doc app 31 test. - */ -class SpringDocApp31Test extends AbstractSpringDocTest { - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app32/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app32/HelloController.java deleted file mode 100644 index 9da86e547..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app32/HelloController.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app32; - -import io.swagger.v3.oas.annotations.parameters.RequestBody; - -import org.springframework.http.HttpStatus; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.ResponseStatus; -import org.springframework.web.bind.annotation.RestController; - -/** - * The type Hello controller. - */ -@RestController -class HelloController { - - /** - * Filter post string. - * - * @param filter the filter - * @return the string - */ - @RequestMapping(value = "/filter", method = RequestMethod.POST) - @ResponseStatus(value = HttpStatus.OK) - public String filterPost(@RequestBody final MyTestDto filter) { - return "OK"; - } - - /** - * The type My test dto. - */ - class MyTestDto { - /** - * The Object 1. - */ - public String object1; - - /** - * The Object 2. - */ - public String object2; - - /** - * The Object 3. - */ - public String object3; - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app32/SpringDocApp32Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app32/SpringDocApp32Test.java deleted file mode 100644 index 403a3e8be..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app32/SpringDocApp32Test.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app32; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * The type Spring doc app 32 test. - */ -class SpringDocApp32Test extends AbstractSpringDocTest { - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app33/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app33/HelloController.java deleted file mode 100644 index 085dbf071..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app33/HelloController.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app33; - -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.responses.ApiResponse; - -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RestController; - -/** - * The type Hello controller. - * - * @param the type parameter - */ -@RestController -class HelloController { - - /** - * Index t. - * - * @param numTel the num tel - * @param adresse the adresse - * @return the t - */ - @GetMapping(value = "/hello/{numTelco}") - @Operation(summary = "GET Persons", responses = @ApiResponse(responseCode = "418")) - public T index(@PathVariable("numTelco") String numTel, String adresse) { - return null; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app33/SpringDocApp33Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app33/SpringDocApp33Test.java deleted file mode 100644 index 84116c241..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app33/SpringDocApp33Test.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app33; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * The type Spring doc app 33 test. - */ -class SpringDocApp33Test extends AbstractSpringDocTest { - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app34/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app34/HelloController.java deleted file mode 100644 index e192e5093..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app34/HelloController.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app34; - -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.responses.ApiResponse; - -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RestController; - -/** - * The type Hello controller. - * - * @param the type parameter - */ -@RestController -class HelloController { - - /** - * Index t. - * - * @param numTel the num tel - * @param adresse the adresse - * @return the t - */ - @GetMapping(value = "/hello/{numTelco}") - @Operation(summary = "GET Persons", responses = @ApiResponse(responseCode = "418")) - public T index(@PathVariable("numTelco") String numTel, String adresse) { - return null; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app34/MyExceptionHandler.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app34/MyExceptionHandler.java deleted file mode 100644 index f83158ab7..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app34/MyExceptionHandler.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app34; - -import io.swagger.v3.oas.annotations.Hidden; - -import org.springframework.http.HttpStatus; -import org.springframework.web.bind.annotation.ExceptionHandler; -import org.springframework.web.bind.annotation.ResponseStatus; -import org.springframework.web.bind.annotation.RestControllerAdvice; -import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler; - -/** - * The type My exception handler. - */ -@RestControllerAdvice -@Hidden -class MyExceptionHandler extends ResponseEntityExceptionHandler { - /** - * Bad object. - * - * @param e the e - * @return the object - */ - @ExceptionHandler(IllegalArgumentException.class) - @ResponseStatus(HttpStatus.BAD_REQUEST) - public Object bad(IllegalArgumentException e) { - return null; - } - - /** - * Gateway object. - * - * @param e the e - * @return the object - */ - @ExceptionHandler(RuntimeException.class) - @ResponseStatus(HttpStatus.BAD_GATEWAY) - public Object gateway(RuntimeException e) { - return null; - } -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app34/SpringDocApp34Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app34/SpringDocApp34Test.java deleted file mode 100644 index 5d5acccf0..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app34/SpringDocApp34Test.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app34; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * The type Spring doc app 34 test. - */ -class SpringDocApp34Test extends AbstractSpringDocTest { - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app35/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app35/HelloController.java deleted file mode 100644 index 8d2c1dfd7..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app35/HelloController.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app35; - -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.media.Content; -import io.swagger.v3.oas.annotations.media.Schema; -import io.swagger.v3.oas.annotations.responses.ApiResponse; - -import org.springframework.http.ResponseEntity; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; - -/** - * The type Hello controller. - */ -@Controller -@RequestMapping("/api/v1/poc/") -class HelloController { - - /** - * Testme response entity. - * - * @return the response entity - */ - @Operation(summary = "Get thing", responses = { - @ApiResponse(description = "Successful Operation", responseCode = "200", content = @Content(mediaType = "application/json", schema = @Schema(implementation = String.class))), - @ApiResponse(responseCode = "404", description = "Not found", content = @Content), - @ApiResponse(responseCode = "401", description = "Authentication Failure", content = @Content(schema = @Schema(hidden = true))) }) - @RequestMapping(path = "/testme", method = RequestMethod.GET) - ResponseEntity testme() { - return ResponseEntity.ok("Hello"); - } - - /** - * Test response entity. - * - * @return the response entity - */ - @Operation(summary = "Get thing", responses = { - @ApiResponse(description = "Successful Operation", responseCode = "200", content = @Content(mediaType = "application/json", schema = @Schema(implementation = String.class))), - @ApiResponse(responseCode = "404", description = "Not found", content = @Content(schema = @Schema(hidden = true))), - @ApiResponse(responseCode = "401", description = "Authentication Failure", content = @Content(schema = @Schema(hidden = true))) }) - @RequestMapping(path = "/test", method = RequestMethod.GET) - ResponseEntity test() { - return ResponseEntity.ok("Hello"); - } -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app35/SpringDocApp35Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app35/SpringDocApp35Test.java deleted file mode 100644 index 686ba0304..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app35/SpringDocApp35Test.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app35; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -import static org.springdoc.core.utils.SpringDocUtils.getConfig; - -/** - * The type Spring doc app 35 test. - */ -class SpringDocApp35Test extends AbstractSpringDocTest { - - static { - getConfig().addRestControllers(HelloController.class); - } - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app37/Bar.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app37/Bar.java deleted file mode 100644 index 0ef75bedf..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app37/Bar.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app37; - -/** - * The type Bar. - */ -class Bar { - /** - * The Bar. - */ - public String bar = "bar"; -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app37/Car.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app37/Car.java deleted file mode 100644 index 8e8d11c13..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app37/Car.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app37; - -/** - * The type Car. - */ -class Car { - /** - * The Car. - */ - public String car = "car"; - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app37/Foo.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app37/Foo.java deleted file mode 100644 index 85756d914..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app37/Foo.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app37; - -/** - * The type Foo. - */ -class Foo { - /** - * The Foo. - */ - public String foo = "foo"; -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app37/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app37/HelloController.java deleted file mode 100644 index 3df46159a..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app37/HelloController.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app37; - -import io.swagger.v3.oas.annotations.parameters.RequestBody; -import jakarta.validation.Valid; - -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * The type Hello controller. - */ -@RestController("/api") -class HelloController { - - /** - * Process foo. - * - * @param a the a - * @return the foo - */ - @PostMapping(path = "/bar/baz", consumes = "application/x.a+json", produces = MediaType.TEXT_PLAIN_VALUE) - public Foo process(@RequestBody Foo a) { - return a; - } - - /** - * Process bar. - * - * @param b the b - * @return the bar - */ - @PostMapping(path = "/bar/baz", consumes = "application/x.b+json", produces = MediaType.TEXT_PLAIN_VALUE) - public Bar process(@RequestBody Bar b) { - return b; - } - - /** - * Process car. - * - * @param c the c - * @return the car - */ - @PostMapping(path = "/bar/baz", consumes = "application/x.c+json", produces = MediaType.APPLICATION_JSON_VALUE) - public Car process(@RequestBody Car c) { - return c; - } - - - /** - * Pets post response entity. - * - * @param pet the pet - * @return the response entity - */ - @PostMapping(value = "/pets1", consumes = "text/plain") - public ResponseEntity petsPost1(@Valid @RequestBody String pet) { - return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); - } - - /** - * Pets post response entity. - * - * @param pet the pet - * @return the response entity - */ - @PostMapping(value = "/pets2", consumes = "application/json") - public ResponseEntity petsPost2(@Valid @RequestBody Pet pet) { - return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); - } -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app37/Pet.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app37/Pet.java deleted file mode 100644 index dd3446b17..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app37/Pet.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app37; - -/** - * The type Pet. - */ -class Pet { - /** - * The Pet. - */ - public String pet = "pet"; - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app37/SpringDocApp37Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app37/SpringDocApp37Test.java deleted file mode 100644 index 624d08eca..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app37/SpringDocApp37Test.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app37; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * The type Spring doc app 37 test. - */ -class SpringDocApp37Test extends AbstractSpringDocTest { - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app38/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app38/HelloController.java deleted file mode 100644 index 090351308..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app38/HelloController.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app38; - -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RestController; - -/** - * The type Hello controller. - */ -@RestController("/api") -class HelloController { - - /** - * Gets model resource. - * - * @return the model resource - */ - @RequestMapping(value = "/npe_error", method = RequestMethod.GET) - public ResponseEntity getModelResource() { - return new ResponseEntity<>(new byte[0], HttpStatus.OK); - } - -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app38/SpringDocApp38Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app38/SpringDocApp38Test.java deleted file mode 100644 index cf49de2bf..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app38/SpringDocApp38Test.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app38; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * The type Spring doc app 38 test. - */ -class SpringDocApp38Test extends AbstractSpringDocTest { - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app39/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app39/HelloController.java deleted file mode 100644 index 84af2ee98..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app39/HelloController.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app39; - -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.media.Content; -import io.swagger.v3.oas.annotations.media.Schema; -import io.swagger.v3.oas.annotations.parameters.RequestBody; - -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * The type Hello controller. - */ -@RestController -class HelloController { - - /** - * Search employee. - * - * @param test the test - */ - @Operation(summary = "test Request") - @RequestBody(description = "test value", required = true, content = @Content(schema = @Schema(implementation = String.class))) - @PostMapping("/test") - public void searchEmployee(String test) { - } - - /** - * Hello string. - * - * @return the string - */ - @GetMapping("/hello") - public String hello() { - return "hello"; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app39/SpringDocApp39Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app39/SpringDocApp39Test.java deleted file mode 100644 index 03c832a91..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app39/SpringDocApp39Test.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app39; - -import test.org.springdoc.api.AbstractSpringDocTest; - -/** - * The type Spring doc app 39 test. - */ -class SpringDocApp39Test extends AbstractSpringDocTest { - - -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app39/SpringDocTestApp.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app39/SpringDocTestApp.java deleted file mode 100644 index 185111bb0..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app39/SpringDocTestApp.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app39; - -import io.swagger.v3.oas.models.Components; -import io.swagger.v3.oas.models.OpenAPI; -import io.swagger.v3.oas.models.media.StringSchema; -import io.swagger.v3.oas.models.parameters.HeaderParameter; -import org.springdoc.core.customizers.OpenApiCustomizer; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.Bean; - -/** - * The type Spring doc test app. - */ -@SpringBootApplication -class SpringDocTestApp { - - /** - * The entry point of application. - * - * @param args the input arguments - */ - public static void main(String[] args) { - SpringApplication.run(SpringDocTestApp.class, args); - } - - /** - * Custom open api open api. - * - * @return the open api - */ - @Bean - public OpenAPI customOpenAPI() { - StringSchema schema = new StringSchema(); - return new OpenAPI() - .components(new Components().addParameters("myGlobalHeader", new HeaderParameter().required(true).name("My-Global-Header").description("My Global Header").schema(schema))); - } - - /** - * Customer global header open api customiser open api customiser. - * - * @return the open api customiser - */ - @Bean - public OpenApiCustomizer customerGlobalHeaderOpenApiCustomizer() { - return openApi -> openApi.getPaths().values().stream().flatMap(pathItem -> pathItem.readOperations().stream()) - .forEach(operation -> operation.addParametersItem(new HeaderParameter().$ref("#/components/parameters/myGlobalHeader"))); - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app4/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app4/HelloController.java deleted file mode 100644 index f86ea0cca..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app4/HelloController.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app4; - -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * The type Hello controller. - */ -@RestController -class HelloController { - - /** - * List tracker data. - * - * @param toto the toto - * @return the tracker data - */ - @PostMapping(value = "/values/data") - TrackerData list(TrackerData toto) { - return toto; - - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app4/SpringDocApp4Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app4/SpringDocApp4Test.java deleted file mode 100644 index eef0de0a4..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app4/SpringDocApp4Test.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app4; - -import io.swagger.v3.core.jackson.TypeNameResolver; -import org.junit.jupiter.api.AfterAll; -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.test.context.TestPropertySource; - -/** - * The type Spring doc app 4 test. - */ -@TestPropertySource(properties = "springdoc.use-fqn=true") -class SpringDocApp4Test extends AbstractSpringDocTest { - - /** - * Restore. - */ - @AfterAll - static void restore() { - TypeNameResolver.std.setUseFqn(false); - } - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app4/TrackerData.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app4/TrackerData.java deleted file mode 100644 index 19f06fb86..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app4/TrackerData.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app4; - -import java.time.Instant; - -import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.v3.oas.annotations.media.Schema; - -/** - * The type Tracker data. - */ -class TrackerData { - - /** - * The Tracker id. - */ - @Schema(name = "trackerId", type = "string", required = true, example = "the-tracker-id") - @JsonProperty("trackerId") - String trackerId; - - /** - * The Timestamp. - */ - @Schema(name = "timestamp", type = "string", format = "date-time", required = true, example = "2018-01-01T00:00:00Z") - @JsonProperty("timestamp") - Instant timestamp; - - /** - * The Value. - */ - @Schema(name = "value", type = "number", format = "double", description = "The data value", required = true, example = "19.0") - @JsonProperty("value") - Double value; - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app40/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app40/HelloController.java deleted file mode 100644 index 6b88a1d03..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app40/HelloController.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app40; - -import com.fasterxml.jackson.databind.node.ObjectNode; - -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RestController; - -/** - * The type Hello controller. - */ -@RestController("/api") -class HelloController { - - /** - * Gets start form properties. - * - * @return the start form properties - */ - @RequestMapping(value = "/iae_error", method = RequestMethod.GET) - public ObjectNode getStartFormProperties() { - return null; - } -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app40/SpringDocApp40Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app40/SpringDocApp40Test.java deleted file mode 100644 index 6877c71ee..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app40/SpringDocApp40Test.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app40; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * The type Spring doc app 40 test. - */ -class SpringDocApp40Test extends AbstractSpringDocTest { - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app41/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app41/HelloController.java deleted file mode 100644 index c1eae2978..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app41/HelloController.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app41; - -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.media.Content; -import io.swagger.v3.oas.annotations.media.Schema; -import io.swagger.v3.oas.annotations.responses.ApiResponse; -import io.swagger.v3.oas.annotations.responses.ApiResponses; -import jakarta.validation.Valid; -import jakarta.validation.constraints.NotNull; - -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -/** - * The type Hello controller. - */ -@RestController("/api") -class HelloController { - - /** - * Gets file. - * - * @param path the path - * @return the file - */ - @Operation(description = "Download file") - @ApiResponses(value = { - @ApiResponse(responseCode = "200", description = "File resource", content = @Content(schema = @Schema(implementation = java.io.File.class))), - @ApiResponse(responseCode = "400", description = "Wrong request", content = @Content(schema = @Schema(implementation = Error.class))), - @ApiResponse(responseCode = "500", description = "Unexpected error", content = @Content(schema = @Schema(implementation = Error.class))) }) - @GetMapping(value = "/file", produces = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity getFile( - @NotNull @Parameter(description = "File path", required = true) @Valid @RequestParam(value = "path") String path) { - return ResponseEntity.status(HttpStatus.NOT_IMPLEMENTED).build(); - } - -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app41/SpringDocApp411Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app41/SpringDocApp411Test.java deleted file mode 100644 index 19de007a6..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app41/SpringDocApp411Test.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app41; - -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; - -import org.junit.jupiter.api.Test; -import org.springdoc.core.utils.Constants; -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -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; - -/** - * The type Spring doc app 411 test. - */ -class SpringDocApp411Test extends AbstractSpringDocTest { - - /** - * Test app. - * - * @throws Exception the exception - */ - @Test - protected void testApp() throws Exception { - String className = getClass().getSimpleName(); - String testNumber = className.replaceAll("[^0-9]", ""); - MvcResult mockMvcResult = mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL)).andExpect(status().isOk()) - .andExpect(jsonPath("$.openapi", is("3.0.1"))).andReturn(); - // Test result consistency - mockMvcResult = mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL)).andExpect(status().isOk()) - .andExpect(jsonPath("$.openapi", is("3.0.1"))).andReturn(); - String result = mockMvcResult.getResponse().getContentAsString(); - Path path = Paths.get(getClass().getClassLoader().getResource("results/app41.json").toURI()); - byte[] fileBytes = Files.readAllBytes(path); - String expected = new String(fileBytes); - assertEquals(expected, result, false); - } - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} - -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app41/SpringDocApp41Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app41/SpringDocApp41Test.java deleted file mode 100644 index 32892d65e..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app41/SpringDocApp41Test.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app41; - -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; - -import org.junit.jupiter.api.Test; -import org.springdoc.core.utils.Constants; -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -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; - -/** - * The type Spring doc app 41 test. - */ -@TestPropertySource(properties = "springdoc.cache.disabled=true") -class SpringDocApp41Test extends AbstractSpringDocTest { - - /** - * Test app. - * - * @throws Exception the exception - */ - @Test - protected void testApp() throws Exception { - String className = getClass().getSimpleName(); - String testNumber = className.replaceAll("[^0-9]", ""); - MvcResult mockMvcResult = mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL)).andExpect(status().isOk()) - .andExpect(jsonPath("$.openapi", is("3.0.1"))).andReturn(); - // Test result consistency - mockMvcResult = mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL)).andExpect(status().isOk()) - .andExpect(jsonPath("$.openapi", is("3.0.1"))).andReturn(); - String result = mockMvcResult.getResponse().getContentAsString(); - Path path = Paths.get(getClass().getClassLoader().getResource("results/app" + testNumber + ".json").toURI()); - byte[] fileBytes = Files.readAllBytes(path); - String expected = new String(fileBytes); - assertEquals(expected, result, false); - } - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} - -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app42/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app42/HelloController.java deleted file mode 100644 index da264542d..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app42/HelloController.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app42; - -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RestController; - - -/** - * The type Hello controller. - */ -@RestController("/api") -class HelloController { - - /** - * Tweets. - * - * @param id the id - */ - @GetMapping(value = "/tweets/{id}") - public void tweets(@PathVariable TweetId id) { - - } - -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app42/SpringDocApp42Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app42/SpringDocApp42Test.java deleted file mode 100644 index 0c92fc0cd..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app42/SpringDocApp42Test.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app42; - -import io.swagger.v3.oas.models.Components; -import io.swagger.v3.oas.models.OpenAPI; -import io.swagger.v3.oas.models.media.StringSchema; -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.Bean; - -/** - * The type Spring doc app 42 test. - */ -class SpringDocApp42Test extends AbstractSpringDocTest { - - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp { - /** - * Custom open api open api. - * - * @return the open api - */ - @Bean - public OpenAPI customOpenAPI() { - return new OpenAPI().components(new Components().addSchemas("TweetId", new StringSchema())); - } - } -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app42/TweetId.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app42/TweetId.java deleted file mode 100644 index dc34326e0..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app42/TweetId.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app42; - -/** - * The type Tweet id. - */ -class TweetId { - /** - * The Value. - */ - private final String value; - - /** - * Instantiates a new Tweet id. - * - * @param value the value - */ - public TweetId(String value) { - this.value = value; - } - - /** - * Gets value. - * - * @return the value - */ - public String getValue() { - return value; - } -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app43/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app43/HelloController.java deleted file mode 100644 index c99a02e26..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app43/HelloController.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app43; - -import java.util.List; - -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestPart; -import org.springframework.web.bind.annotation.RestController; -import org.springframework.web.multipart.MultipartFile; - -/** - * The type Hello controller. - */ -@RestController -class HelloController { - - /** - * Upload documents response entity. - * - * @param multipartFiles the multipart files - * @return the response entity - */ - @PostMapping(path = "/documents", consumes = "multipart/form-data") - public ResponseEntity uploadDocuments(@RequestPart("doc") List multipartFiles) { - return null; - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app43/SpringDocApp43Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app43/SpringDocApp43Test.java deleted file mode 100644 index 7d6f801d0..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app43/SpringDocApp43Test.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app43; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * The type Spring doc app 43 test. - */ -class SpringDocApp43Test extends AbstractSpringDocTest { - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app44/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app44/HelloController.java deleted file mode 100644 index 6b78db2f1..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app44/HelloController.java +++ /dev/null @@ -1,226 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app44; - -import io.swagger.v3.oas.annotations.media.Content; -import io.swagger.v3.oas.annotations.media.Schema; -import io.swagger.v3.oas.annotations.responses.ApiResponse; -import io.swagger.v3.oas.annotations.responses.ApiResponses; - -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RestController; - -/** - * The type Hello controller. - */ -@RestController("/api") -class HelloController { - - /** - * Hello response entity. - * - * @param request the request - * @return the response entity - */ - @PostMapping(value = "/helloworld", produces = "application/json", consumes = "application/vnd.v1+json") - @ApiResponses({ - @ApiResponse(responseCode = "200", description = "Successful operation", content = @Content(schema = @Schema(implementation = HelloDTO1.class))), - @ApiResponse(responseCode = "400", description = "Bad name", content = @Content(schema = @Schema(implementation = ErrorDTO.class))) }) - public ResponseEntity hello(@RequestBody RequestV1 request) { - final String name = request.getNameV1(); - if ("error".equalsIgnoreCase(name)) { - return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ErrorDTO("invalid name: " + name)); - } - return ResponseEntity.ok(new HelloDTO1("Greetings from Spring Boot v1! " + name)); - } - - /** - * Hello response entity. - * - * @param request the request - * @return the response entity - */ - @PostMapping(value = "/helloworld", produces = "application/json", consumes = "application/vnd.v2+json") - @ApiResponses({ - @ApiResponse(responseCode = "200", description = "Successful operation", content = @Content(schema = @Schema(implementation = HelloDTO2.class))), - @ApiResponse(responseCode = "400", description = "Bad name", content = @Content(schema = @Schema(implementation = ErrorDTO.class))) }) - public ResponseEntity hello(@RequestBody RequestV2 request) { - final String name = request.getNameV2(); - if ("error".equalsIgnoreCase(name)) { - return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ErrorDTO("invalid name: " + name)); - } - return ResponseEntity.ok(new HelloDTO2("Greetings from Spring Boot v2! " + name)); - } - - /** - * The type Request v 1. - */ - static class RequestV1 { - /** - * The Name v 1. - */ - private String nameV1; - - /** - * Instantiates a new Request v 1. - */ - public RequestV1() { - } - - /** - * Gets name v 1. - * - * @return the name v 1 - */ - public String getNameV1() { - return nameV1; - } - - /** - * Sets name v 1. - * - * @param nameV1 the name v 1 - */ - public void setNameV1(String nameV1) { - this.nameV1 = nameV1; - } - } - - /** - * The type Request v 2. - */ - static class RequestV2 { - /** - * The Name v 2. - */ - private String nameV2; - - /** - * Instantiates a new Request v 2. - */ - public RequestV2() { - } - - /** - * Gets name v 2. - * - * @return the name v 2 - */ - public String getNameV2() { - return nameV2; - } - - /** - * Sets name v 2. - * - * @param nameV2 the name v 2 - */ - public void setNameV2(String nameV2) { - this.nameV2 = nameV2; - } - } - - /** - * The type Hello dto 1. - */ - class HelloDTO1 { - /** - * The Message. - */ - private String message; - - /** - * Instantiates a new Hello dto 1. - * - * @param message the message - */ - public HelloDTO1(String message) { - this.message = message; - } - - /** - * Gets message. - * - * @return the message - */ - public String getMessage() { - return message; - } - } - - /** - * The type Hello dto 2. - */ - class HelloDTO2 { - /** - * The Message. - */ - private String message; - - /** - * Instantiates a new Hello dto 2. - * - * @param message the message - */ - public HelloDTO2(String message) { - this.message = message; - } - - /** - * Gets message. - * - * @return the message - */ - public String getMessage() { - return message; - } - } - - /** - * The type Error dto. - */ - class ErrorDTO { - /** - * The Error message. - */ - private String errorMessage; - - /** - * Instantiates a new Error dto. - * - * @param errorMessage the error message - */ - public ErrorDTO(String errorMessage) { - this.errorMessage = errorMessage; - } - - /** - * Gets error message. - * - * @return the error message - */ - public String getErrorMessage() { - return errorMessage; - } - } - -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app44/SpringDocApp44Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app44/SpringDocApp44Test.java deleted file mode 100644 index 52d07050d..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app44/SpringDocApp44Test.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app44; - -import org.junit.jupiter.api.Test; -import org.springdoc.core.utils.Constants; -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -import static org.hamcrest.Matchers.containsInAnyOrder; -import static org.hamcrest.Matchers.is; -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; - -/** - * The type Spring doc app 44 test. - */ -class SpringDocApp44Test extends AbstractSpringDocTest { - - /** - * Test app. - * - * @throws Exception the exception - */ - @Test - protected void testApp() throws Exception { - mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL)).andExpect(status().isOk()) - .andExpect(jsonPath("$.openapi", is("3.0.1"))).andExpect(jsonPath("$.paths./helloworld.post.responses.200.content.['application/json'].schema.oneOf").isArray()).andExpect(jsonPath("$.paths./helloworld.post.responses.200.content.['application/json'].schema.oneOf[*].$ref", containsInAnyOrder("#/components/schemas/HelloDTO2", - "#/components/schemas/HelloDTO1"))) - .andExpect(jsonPath("$.paths./helloworld.post.requestBody.content.['application/vnd.v1+json'].schema.$ref", is("#/components/schemas/RequestV1"))) - .andExpect(jsonPath("$.paths./helloworld.post.requestBody.content.['application/vnd.v2+json'].schema.$ref", is("#/components/schemas/RequestV2"))) - .andExpect(jsonPath("$.paths./helloworld.post.responses.400.content.['application/json'].schema.$ref", is("#/components/schemas/ErrorDTO"))); - - } - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} - -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app45/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app45/HelloController.java deleted file mode 100644 index 55440ef8a..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app45/HelloController.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app45; - -import java.util.Collections; -import java.util.List; - -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.media.ArraySchema; -import io.swagger.v3.oas.annotations.media.Content; -import io.swagger.v3.oas.annotations.media.Schema; -import io.swagger.v3.oas.annotations.responses.ApiResponse; -import io.swagger.v3.oas.annotations.security.SecurityRequirement; -import io.swagger.v3.oas.annotations.tags.Tag; - -import org.springframework.http.MediaType; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - - -/** - * The type Hello controller. - */ -@Tag(name = "People", description = "Use this resource to serve all requests and initiate all operations related to people") -@RestController -@RequestMapping(value = "/v1/people") -class HelloController { - - - /** - * List list. - * - * @return the list - */ - @Operation(description = "List all persons") - @SecurityRequirement(name = "bearer") - @ApiResponse(responseCode = "200", description = "", content = @Content(array = @ArraySchema(schema = @Schema(implementation = PersonDTO.class)))) - @GetMapping(path = "/list", consumes = MediaType.ALL_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) - public List list() { - PersonDTO person = new PersonDTO(); - person.setFirstName("Nass"); - return Collections.singletonList(person); - } - - /** - * List two list. - * - * @return the list - */ - @Operation(description = "List all persons") - @ApiResponse(responseCode = "200", description = "", content = @Content(array = @ArraySchema(schema = @Schema(implementation = PersonDTO.class)))) - @GetMapping(path = "/listTwo", consumes = MediaType.ALL_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) - public List listTwo() { - PersonDTO person = new PersonDTO(); - person.setFirstName("Nass"); - return Collections.singletonList(person); - } - -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app45/HelloController2.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app45/HelloController2.java deleted file mode 100644 index d2bf8df88..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app45/HelloController2.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app45; - -import java.util.Collections; -import java.util.List; - -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.media.ArraySchema; -import io.swagger.v3.oas.annotations.media.Content; -import io.swagger.v3.oas.annotations.media.Schema; -import io.swagger.v3.oas.annotations.responses.ApiResponse; -import io.swagger.v3.oas.annotations.security.SecurityRequirement; -import io.swagger.v3.oas.annotations.tags.Tag; - -import org.springframework.http.MediaType; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - - -/** - * The type Hello controller 2. - */ -@Tag(name = "People", description = "Use this resource to serve all requests and initiate all operations related to people") -@SecurityRequirement(name = "bearer") -@RestController -@RequestMapping(value = "/v1/people2") -class HelloController2 { - - - /** - * List list. - * - * @return the list - */ - @Operation(description = "List all persons") - @ApiResponse(responseCode = "200", description = "", content = @Content(array = @ArraySchema(schema = @Schema(implementation = PersonDTO.class)))) - @GetMapping(path = "/list", consumes = MediaType.ALL_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) - public List list() { - PersonDTO person = new PersonDTO(); - person.setFirstName("Nass"); - return Collections.singletonList(person); - } - - /** - * List two list. - * - * @return the list - */ - @Operation(description = "List all persons") - @ApiResponse(responseCode = "200", description = "", content = @Content(array = @ArraySchema(schema = @Schema(implementation = PersonDTO.class)))) - @GetMapping(path = "/listTwo", consumes = MediaType.ALL_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) - public List listTwo() { - PersonDTO person = new PersonDTO(); - person.setFirstName("Nass"); - return Collections.singletonList(person); - } - -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app45/OpenApiConfig.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app45/OpenApiConfig.java deleted file mode 100644 index de9a8d0e4..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app45/OpenApiConfig.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app45; - -import io.swagger.v3.oas.annotations.OpenAPIDefinition; -import io.swagger.v3.oas.annotations.enums.SecuritySchemeType; -import io.swagger.v3.oas.annotations.info.Info; -import io.swagger.v3.oas.annotations.info.License; -import io.swagger.v3.oas.annotations.security.SecurityScheme; - -/** - * The type Open api config. - */ -@OpenAPIDefinition(info = @Info(title = "My App", description = "Some long and useful description", version = "v1", license = @License(name = "Apache 2.0", url = "https://www.apache.org/licenses/LICENSE-2.0"))) -@SecurityScheme(name = "bearer", type = SecuritySchemeType.HTTP, scheme = "bearer", bearerFormat = "JWT") -class OpenApiConfig { -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app45/PersonDTO.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app45/PersonDTO.java deleted file mode 100644 index 9f2912e80..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app45/PersonDTO.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app45; - -/** - * The type Person dto. - */ -class PersonDTO { - /** - * The Email. - */ - private String email; - - /** - * The First name. - */ - private String firstName; - - /** - * The Last name. - */ - private String lastName; - - /** - * Instantiates a new Person dto. - */ - public PersonDTO() { - } - - /** - * Instantiates a new Person dto. - * - * @param email the email - * @param firstName the first name - * @param lastName the last name - */ - public PersonDTO(final String email, final String firstName, final String lastName) { - this.email = email; - this.firstName = firstName; - this.lastName = lastName; - } - - /** - * Gets email. - * - * @return the email - */ - public String getEmail() { - return email; - } - - /** - * Sets email. - * - * @param email the email - */ - public void setEmail(final String email) { - this.email = email; - } - - /** - * Gets first name. - * - * @return the first name - */ - public String getFirstName() { - return firstName; - } - - /** - * Sets first name. - * - * @param firstName the first name - */ - public void setFirstName(final String firstName) { - this.firstName = firstName; - } - - /** - * Gets last name. - * - * @return the last name - */ - public String getLastName() { - return lastName; - } - - /** - * Sets last name. - * - * @param lastName the last name - */ - public void setLastName(final String lastName) { - this.lastName = lastName; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app45/SpringDocApp45Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app45/SpringDocApp45Test.java deleted file mode 100644 index 762e7ff56..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app45/SpringDocApp45Test.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app45; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * The type Spring doc app 45 test. - */ -class SpringDocApp45Test extends AbstractSpringDocTest { - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app46/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app46/HelloController.java deleted file mode 100644 index 7fb014288..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app46/HelloController.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app46; - -import io.swagger.v3.oas.annotations.ExternalDocumentation; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.enums.ParameterIn; -import io.swagger.v3.oas.annotations.media.Content; -import io.swagger.v3.oas.annotations.media.Schema; -import io.swagger.v3.oas.annotations.responses.ApiResponse; - -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * The type Hello controller. - */ -@RestController -class HelloController { - - /** - * Persons string. - * - * @param subscriptionId the subscription id - * @return the string - */ - @GetMapping("/persons/{subscriptionId}") - @Operation(operationId = "operationId", summary = "Operation Summary", description = "Operation Description", tags = { - "Example Tag" }, externalDocs = @ExternalDocumentation(description = "External documentation description", url = "http://url.com"), parameters = { - @Parameter(in = ParameterIn.PATH, name = "subscriptionId", required = true, description = "parameter description", allowEmptyValue = true, allowReserved = true, schema = @Schema(type = "string", format = "uuid", description = "the generated UUID", accessMode = Schema.AccessMode.READ_ONLY)) }, responses = { - @ApiResponse(responseCode = "200", description = "voila!", content = @Content(mediaType = "application/json", schema = @Schema(implementation = String.class))) }) - public String persons(String subscriptionId) { - return "OK"; - } - -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app46/SpringDocApp46Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app46/SpringDocApp46Test.java deleted file mode 100644 index 8b6eacd97..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app46/SpringDocApp46Test.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app46; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * The type Spring doc app 46 test. - */ -class SpringDocApp46Test extends AbstractSpringDocTest { - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app47/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app47/HelloController.java deleted file mode 100644 index f75afbfc1..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app47/HelloController.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app47; - -import java.util.Locale; - -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.media.Schema; - -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RestController; - -/** - * The type Hello controller. - */ -@RestController -class HelloController { - /** - * Gets documents with locale. - * - * @param locale the locale - * @return the documents with locale - */ - @GetMapping(path = "/documents/{locale}") - public ResponseEntity getDocumentsWithLocale( - @Parameter(schema = @Schema(type = "string")) @PathVariable("locale") Locale locale) { - return null; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app47/SpringDocApp47Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app47/SpringDocApp47Test.java deleted file mode 100644 index bdea686c2..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app47/SpringDocApp47Test.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app47; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * The type Spring doc app 47 test. - */ -class SpringDocApp47Test extends AbstractSpringDocTest { - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app48/AbstractHelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app48/AbstractHelloController.java deleted file mode 100644 index 2f91b87ca..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app48/AbstractHelloController.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app48; - -import io.swagger.v3.oas.annotations.responses.ApiResponse; -import io.swagger.v3.oas.annotations.responses.ApiResponses; - -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.GetMapping; - -/** - * The type Abstract hello controller. - */ -@ApiResponse(responseCode = "410") -@ApiResponses({ - @ApiResponse(responseCode = "411") -}) -class AbstractHelloController { - - /** - * Gets documents. - * - * @return the documents - */ - @GetMapping(path = "/documents/{locale}") - @ApiResponse(responseCode = "412") - @ApiResponses({ - @ApiResponse(responseCode = "413") - }) - public ResponseEntity getDocuments() { - return null; - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app48/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app48/HelloController.java deleted file mode 100644 index efa7bb7f7..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app48/HelloController.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app48; - -import io.swagger.v3.oas.annotations.responses.ApiResponse; -import io.swagger.v3.oas.annotations.responses.ApiResponses; - -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * The type Hello controller. - */ -@RestController - -@ApiResponse(responseCode = "400") -@ApiResponses({ - @ApiResponse(responseCode = "401") -}) -class HelloController extends AbstractHelloController { - - /** - * Gets documents. - * - * @return the documents - */ - @Override - @GetMapping(path = "/documents/{locale}") - @ApiResponse(responseCode = "402") - @ApiResponses({ - @ApiResponse(responseCode = "403") - }) - public ResponseEntity getDocuments() { - return null; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app48/SpringDocApp48Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app48/SpringDocApp48Test.java deleted file mode 100644 index e13b06ee5..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app48/SpringDocApp48Test.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app48; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * The type Spring doc app 48 test. - */ -class SpringDocApp48Test extends AbstractSpringDocTest { - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app49/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app49/HelloController.java deleted file mode 100644 index 7b75fa82a..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app49/HelloController.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app49; - -import java.util.List; - -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.responses.ApiResponse; -import io.swagger.v3.oas.annotations.responses.ApiResponses; - -import org.springframework.http.MediaType; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * The type Hello controller. - */ -@RestController -class HelloController { - - /** - * List list. - * - * @return the list - */ - @Operation(description = "Obtain the list of services available in the system") - @ApiResponses({ @ApiResponse(responseCode = "401", ref = "Unauthorized") }) - @GetMapping(value = "/hello", produces = MediaType.APPLICATION_JSON_VALUE) - List list() { - return null; - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app49/SpringDocApp49Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app49/SpringDocApp49Test.java deleted file mode 100644 index 8a1ac3db3..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app49/SpringDocApp49Test.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app49; - -import test.org.springdoc.api.AbstractSpringDocTest; - -/** - * The type Spring doc app 49 test. - */ -class SpringDocApp49Test extends AbstractSpringDocTest { - - -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app49/SpringDocTestApp.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app49/SpringDocTestApp.java deleted file mode 100644 index 603e563af..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app49/SpringDocTestApp.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app49; - -import io.swagger.v3.oas.models.Components; -import io.swagger.v3.oas.models.OpenAPI; -import io.swagger.v3.oas.models.media.Content; -import io.swagger.v3.oas.models.media.StringSchema; -import io.swagger.v3.oas.models.responses.ApiResponse; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.Bean; -import org.springframework.http.MediaType; - -/** - * The type Spring doc test app. - */ -@SpringBootApplication -class SpringDocTestApp { - - /** - * The entry point of application. - * - * @param args the input arguments - */ - public static void main(String[] args) { - SpringApplication.run(SpringDocTestApp.class, args); - } - - /** - * Define open api open api. - * - * @return the open api - */ - @Bean - public OpenAPI defineOpenApi() { - OpenAPI api = new OpenAPI(); - api.components(new Components().addResponses("Unauthorized", - new ApiResponse().description("Unauthorized") - .content(new Content().addMediaType(MediaType.APPLICATION_JSON_VALUE, - new io.swagger.v3.oas.models.media.MediaType().schema(new StringSchema()))))); - return api; - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app5/CustomOpenAPIConfig.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app5/CustomOpenAPIConfig.java deleted file mode 100644 index b2f659365..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app5/CustomOpenAPIConfig.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app5; - -import io.swagger.v3.oas.models.Components; -import io.swagger.v3.oas.models.OpenAPI; -import io.swagger.v3.oas.models.info.Info; -import io.swagger.v3.oas.models.tags.Tag; - -import org.springframework.context.annotation.Bean; - -/** - * The type Custom open api config. - */ -public class CustomOpenAPIConfig { - /** - * Custom open api open api. - * - * @return the open api - */ - @Bean - public OpenAPI customOpenAPI() { - return new OpenAPI() - .components(new Components()) - .info(new Info().title("Custom API").version("100")).addTagsItem(new Tag().name("mytag")); - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app5/sample/OpenAPIResourceBeanConfigurationComponentsSecuritySchemesTest.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app5/sample/OpenAPIResourceBeanConfigurationComponentsSecuritySchemesTest.java deleted file mode 100644 index f5500c3d7..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app5/sample/OpenAPIResourceBeanConfigurationComponentsSecuritySchemesTest.java +++ /dev/null @@ -1,166 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app5.sample; - -import java.util.ArrayList; - -import io.swagger.v3.oas.models.Components; -import io.swagger.v3.oas.models.OpenAPI; -import io.swagger.v3.oas.models.security.OAuthFlow; -import io.swagger.v3.oas.models.security.OAuthFlows; -import io.swagger.v3.oas.models.security.Scopes; -import io.swagger.v3.oas.models.security.SecurityRequirement; -import io.swagger.v3.oas.models.security.SecurityScheme; -import org.junit.jupiter.api.Test; -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.test.context.TestConfiguration; -import org.springframework.context.annotation.Bean; -import org.springframework.test.context.TestPropertySource; - -import static org.hamcrest.Matchers.is; -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; - -/** - * The type Open api resource bean configuration components security schemes test. - */ -@TestPropertySource(properties = "springdoc.api-docs.path=/api-docs") -class OpenAPIResourceBeanConfigurationComponentsSecuritySchemesTest extends AbstractSpringDocTest { - - /** - * Given: Bean configuration with security scheme http basic (shouldDefineComponentsSecuritySchemesForHttpBasic) - * When: Get api-docs - * Then: Return security definitions http basic - * @throws Exception the exception - */ - @Test - protected void testApp() throws Exception { - mockMvc - .perform(get("/api-docs")) - .andExpect(status().isOk()) - .andExpect(jsonPath("$.security[0].basicScheme", is(new ArrayList()))) - .andExpect(jsonPath("$.components.securitySchemes.basicScheme.type", is("http"))) - .andExpect(jsonPath("$.components.securitySchemes.basicScheme.scheme", is("basic"))) - ; - } - - /** - * Given: Bean configuration with security scheme API key - * When: Get api-docs - * Then: Return security definitions with API key - * @throws Exception the exception - */ - @Test - void shouldDefineComponentsSecuritySchemesForApiKey() throws Exception { - mockMvc - .perform(get("/api-docs")) - .andExpect(status().isOk()) - .andExpect(jsonPath("$.security[1].apiKeyScheme", is(new ArrayList()))) - .andExpect(jsonPath("$.components.securitySchemes.apiKeyScheme.type", is("apiKey"))) - .andExpect(jsonPath("$.components.securitySchemes.apiKeyScheme.in", is("header"))) - ; - } - - /** - * Given: Bean configuration with security scheme OAuth2 - * When: Get api-docs - * Then: Return security definitions with OAuth - * @throws Exception the exception - */ - @Test - void shouldDefineComponentsSecuritySchemesForOAuth2() throws Exception { - mockMvc - .perform(get("/api-docs")) - .andExpect(status().isOk()) - .andExpect(jsonPath("$.security[2].oAuthScheme", is(new ArrayList()))) - .andExpect(jsonPath("$.components.securitySchemes.oAuthScheme.type", is("oauth2"))) - .andExpect(jsonPath("$.components.securitySchemes.oAuthScheme.description", is("This API uses OAuth 2 with the implicit grant flow. [More info](https://api.example.com/docs/auth)"))) - .andExpect(jsonPath("$.components.securitySchemes.oAuthScheme.flows.implicit.authorizationUrl", is("https://api.example.com/oauth2/authorize"))) - .andExpect(jsonPath("$.components.securitySchemes.oAuthScheme.flows.implicit.scopes.read_pets", is("read your pets"))) - .andExpect(jsonPath("$.components.securitySchemes.oAuthScheme.flows.implicit.scopes.write_pets", is("modify pets in your account"))) - ; - } - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} - - /** - * The type Config. - */ - @TestConfiguration - static class Config { - - /** - * Open api open api. - * - * @return the open api - */ - @Bean - public OpenAPI openApi() { - return new OpenAPI() - .components(new Components() - - //HTTP Basic, see: https://swagger.io/docs/specification/authentication/basic-authentication/ - .addSecuritySchemes("basicScheme", new SecurityScheme() - .type(SecurityScheme.Type.HTTP) - .scheme("basic") - ) - - //API Key, see: https://swagger.io/docs/specification/authentication/api-keys/ - .addSecuritySchemes("apiKeyScheme", new SecurityScheme() - .type(SecurityScheme.Type.APIKEY) - .in(SecurityScheme.In.HEADER) - .name("X-API-KEY") - ) - - //OAuth 2.0, see: https://swagger.io/docs/specification/authentication/oauth2/ - .addSecuritySchemes("oAuthScheme", new SecurityScheme() - .type(SecurityScheme.Type.OAUTH2) - .description("This API uses OAuth 2 with the implicit grant flow. [More info](https://api.example.com/docs/auth)") - .flows(new OAuthFlows() - .implicit(new OAuthFlow() - .authorizationUrl("https://api.example.com/oauth2/authorize") - .scopes(new Scopes() - .addString("read_pets", "read your pets") - .addString("write_pets", "modify pets in your account") - ) - ) - ) - ) - ) - .addSecurityItem(new SecurityRequirement() - .addList("basicScheme") - ) - .addSecurityItem(new SecurityRequirement() - .addList("apiKeyScheme") - ) - .addSecurityItem(new SecurityRequirement() - .addList("oAuthScheme") - ) - ; - } - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app5/sample/OpenApiResourceCustomConfigurationTest.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app5/sample/OpenApiResourceCustomConfigurationTest.java deleted file mode 100644 index c354dcd65..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app5/sample/OpenApiResourceCustomConfigurationTest.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app5.sample; - -import org.junit.jupiter.api.Test; -import test.org.springdoc.api.AbstractSpringDocTest; -import test.org.springdoc.api.app5.CustomOpenAPIConfig; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.Import; -import org.springframework.test.context.TestPropertySource; - -import static org.hamcrest.Matchers.is; -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; - -/** - * The type Open api resource custom configuration test. - */ -@Import(CustomOpenAPIConfig.class) -@TestPropertySource(properties = "springdoc.api-docs.path=/api-docs") -class OpenApiResourceCustomConfigurationTest extends AbstractSpringDocTest { - - /** - * givenNoConfiguration_whenGetApiJson_returnsDefaultEmptyDocs - should return - * {"openapi":"3.0.1","info":{"title":"Custom API","version":"100"},"paths":{},"components":{}} - * @throws Exception the exception - */ - @Test - protected void testApp() throws Exception { - mockMvc - .perform(get("/api-docs")) - .andExpect(status().isOk()) - .andExpect(jsonPath("$.openapi", is("3.0.1"))) - .andExpect(jsonPath("$.info.title", is("Custom API"))) - .andExpect(jsonPath("$.info.version", is("100"))) - .andExpect(jsonPath("$.paths").isEmpty()) - .andExpect(jsonPath("$.components").isEmpty()) - .andExpect(jsonPath("$.tags").isNotEmpty()) - .andExpect(jsonPath("$.tags[0].name", is("mytag"))); - } - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app5/sample/OpenApiResourceNoConfigurationTest.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app5/sample/OpenApiResourceNoConfigurationTest.java deleted file mode 100644 index 9e94b8bcb..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app5/sample/OpenApiResourceNoConfigurationTest.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app5.sample; - -import org.junit.jupiter.api.Test; -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.test.context.TestPropertySource; - -import static org.hamcrest.Matchers.is; -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; - -/** - * The type Open api resource no configuration test. - */ -@TestPropertySource(properties = "springdoc.api-docs.path=/api-docs") -class OpenApiResourceNoConfigurationTest extends AbstractSpringDocTest { - - /** - * givenNoConfiguration_whenGetApiJson_returnsDefaultEmptyDocs - should return - * {"openapi":"3.0.1","info":{"title":"OpenAPI definition","version":"v0"},"paths":{},"components":{}} - * @throws Exception the exception - */ - @Test - protected void testApp() throws Exception { - mockMvc - .perform(get("/api-docs")) - .andExpect(status().isOk()) - .andExpect(jsonPath("$.openapi", is("3.0.1"))) - .andExpect(jsonPath("$.info.title", is("OpenAPI definition"))) - .andExpect(jsonPath("$.info.version", is("v0"))) - .andExpect(jsonPath("$.paths").isEmpty()) - .andExpect(jsonPath("$.components").isEmpty()); - } - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app50/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app50/HelloController.java deleted file mode 100644 index d634d8207..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app50/HelloController.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app50; - -import java.util.List; - -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.responses.ApiResponse; - -import org.springframework.http.MediaType; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * The type Hello controller. - */ -@RestController -class HelloController { - - /** - * List list. - * - * @return the list - */ - @Operation(description = "Some operation", responses = { @ApiResponse(responseCode = "401") }) - //@ApiResponse(responseCode = "401", content = @Content()) - @GetMapping(value = "/hello", produces = MediaType.APPLICATION_JSON_VALUE) - List list() { - return null; - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app50/SpringDocApp50Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app50/SpringDocApp50Test.java deleted file mode 100644 index 55c44dc39..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app50/SpringDocApp50Test.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app50; - -import test.org.springdoc.api.AbstractSpringDocTest; - -/** - * The type Spring doc app 50 test. - */ -class SpringDocApp50Test extends AbstractSpringDocTest { - - -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app50/SpringDocTestApp.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app50/SpringDocTestApp.java deleted file mode 100644 index 3d84acfe7..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app50/SpringDocTestApp.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app50; - -import io.swagger.v3.oas.models.Components; -import io.swagger.v3.oas.models.OpenAPI; -import io.swagger.v3.oas.models.media.Content; -import io.swagger.v3.oas.models.media.StringSchema; -import io.swagger.v3.oas.models.responses.ApiResponse; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.Bean; -import org.springframework.http.MediaType; - -/** - * The type Spring doc test app. - */ -@SpringBootApplication -class SpringDocTestApp { - - /** - * The entry point of application. - * - * @param args the input arguments - */ - public static void main(String[] args) { - SpringApplication.run(SpringDocTestApp.class, args); - } - - /** - * Define open api open api. - * - * @return the open api - */ - @Bean - public OpenAPI defineOpenApi() { - OpenAPI api = new OpenAPI(); - api.components(new Components().addResponses("Unauthorized", - new ApiResponse().description("Unauthorized") - .content(new Content().addMediaType(MediaType.APPLICATION_JSON_VALUE, - new io.swagger.v3.oas.models.media.MediaType().schema(new StringSchema()))))); - return api; - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app51/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app51/HelloController.java deleted file mode 100644 index 19bad65da..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app51/HelloController.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app51; - -import java.util.HashMap; -import java.util.Map; - -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.enums.ParameterIn; -import io.swagger.v3.oas.annotations.media.Schema; - -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -/** - * The type Hello controller. - */ -@RestController -class HelloController { - - /** - * Test 1 string. - * - * @return the string - */ - @Operation(parameters = { - @Parameter(in = ParameterIn.HEADER, name = "test_header", required = true, schema = @Schema(type = "string", example = "rherherherherh")) }) - @GetMapping("/test1") - public String test1() { - return "test"; - } - - /** - * Test 2 string. - * - * @param param1 the param 1 - * @return the string - */ - @Operation(parameters = { - @Parameter(in = ParameterIn.HEADER, name = "test_header", required = true, schema = @Schema(type = "string", example = "rherherherherh")) }) - @GetMapping("/test2") - public String test2(@RequestParam(name = "param1") String param1) { - return "test"; - } - - /** - * Test 3 string. - * - * @param param1 the param 1 - * @return the string - */ - @Operation(parameters = { - @Parameter(in = ParameterIn.HEADER, name = "test_header", required = true, schema = @Schema(type = "string", example = "rherherherherh")), - @Parameter(description = "desc1", in = ParameterIn.QUERY, name = "param1", required = true, schema = @Schema(type = "string", example = "something")) }) - @GetMapping("/test3") - public String test3( - @RequestParam(name = "param1") @Parameter(description = "desc2", in = ParameterIn.QUERY) String param1) { - return "test"; - } - - /** - * Get string. - * - * @param path the path - * @param params the params - * @return the string - */ - @GetMapping("/test/{path}") - public String get( - @PathVariable String path, - @RequestParam(required = false) Map params) { - return null; - } - - /** - * Hello response entity. - * - * @param map the map - * @return the response entity - */ - @PostMapping - public ResponseEntity> hello(@RequestBody HashMap map) { - return ResponseEntity.ok(map); - } -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app51/SpringDocApp51Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app51/SpringDocApp51Test.java deleted file mode 100644 index 4a19e4253..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app51/SpringDocApp51Test.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app51; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * The type Spring doc app 51 test. - */ -class SpringDocApp51Test extends AbstractSpringDocTest { - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app52/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app52/HelloController.java deleted file mode 100644 index 4ac240cc1..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app52/HelloController.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app52; - -import java.util.List; - -import org.springframework.http.MediaType; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestPart; -import org.springframework.web.bind.annotation.RestController; -import org.springframework.web.multipart.MultipartFile; - -/** - * The type Hello controller. - */ -@RestController -class HelloController { - - /** - * Create test 1 string. - * - * @param username the username - * @param test the test - * @param imageFile the image file - * @return the string - */ - @PostMapping(value = "/test1/{username}", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) - public String createTest1(@PathVariable String username, @RequestPart("test") MyTestDto test, - @RequestPart("image") MultipartFile imageFile) { - return null; - } - - /** - * Create test 2 string. - * - * @param username the username - * @param imageFile the image file - * @param test the test - * @return the string - */ - @PostMapping(value = "/test2/{username}", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) - public String createTest2(@PathVariable String username, @RequestPart("image") MultipartFile imageFile, - @RequestPart("test") MyTestDto test) { - return null; - } - - /** - * Create test 3 string. - * - * @param test the test - * @param multipartFiles the multipart files - * @return the string - */ - @PostMapping(value = "/test3", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) - public String createTest3(@RequestPart("test") MyTestDto test, - @RequestPart("doc") List multipartFiles) { - return null; - } - - /** - * The type My test dto. - */ - class MyTestDto { - /** - * The Object 1. - */ - public String object1; - - /** - * The Object 2. - */ - public String object2; - - /** - * The Object 3. - */ - public String object3; - } -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app52/SpringDocApp52Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app52/SpringDocApp52Test.java deleted file mode 100644 index be590d244..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app52/SpringDocApp52Test.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app52; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * The type Spring doc app 52 test. - */ -class SpringDocApp52Test extends AbstractSpringDocTest { - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app53/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app53/HelloController.java deleted file mode 100644 index 8da9c35ff..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app53/HelloController.java +++ /dev/null @@ -1,147 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app53; - - -import java.util.List; - -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.responses.ApiResponse; - -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.ResponseStatus; -import org.springframework.web.bind.annotation.RestController; - -/** - * The type Hello controller. - */ -@RestController -class HelloController { - - /** - * List with no api response list. - * - * @return the list - */ - @Operation(description = "Some operation") - @GetMapping(value = "/hello1", produces = MediaType.APPLICATION_JSON_VALUE) - List listWithNoApiResponse() { - return null; - } - - /** - * List with empty api response list. - * - * @return the list - */ - @Operation(description = "Some operation") - @ApiResponse - @GetMapping(value = "/hello2", produces = MediaType.APPLICATION_JSON_VALUE) - List listWithEmptyApiResponse() { - return null; - } - - /** - * List with explicit response status list. - * - * @return the list - */ - @Operation(description = "Some operation") - @GetMapping(value = "/hello3", produces = MediaType.APPLICATION_JSON_VALUE) - @ResponseStatus(HttpStatus.NO_CONTENT) - List listWithExplicitResponseStatus() { - return null; - } - - /** - * Gets dto with explicit response status. - * - * @return the dto with explicit response status - */ - @Operation(description = "Some operation") - @GetMapping(value = "/hello4", produces = MediaType.APPLICATION_JSON_VALUE) - @ResponseStatus(HttpStatus.NO_CONTENT) - HelloDTO1 getDTOWithExplicitResponseStatus() { - return null; - } - - /** - * List with default response status list. - * - * @return the list - */ - @Operation(description = "Some operation") - @GetMapping(value = "/hello5", produces = MediaType.APPLICATION_JSON_VALUE) - List listWithDefaultResponseStatus() { - return null; - } - - /** - * Gets dto with default response status. - * - * @return the dto with default response status - */ - @Operation(description = "Some operation") - @GetMapping(value = "/hello6", produces = MediaType.APPLICATION_JSON_VALUE) - HelloDTO1 getDTOWithDefaultResponseStatus() { - return null; - } - - /** - * Gets nested dto with default response status. - * - * @return the nested dto with default response status - */ - @Operation(description = "Some operation") - @GetMapping(value = "/hello7", produces = MediaType.APPLICATION_JSON_VALUE) - ResponseEntity getNestedDTOWithDefaultResponseStatus() { - return null; - } - - /** - * The type Hello dto 1. - */ - static class HelloDTO1 { - /** - * The Message. - */ - private String message; - - /** - * Instantiates a new Hello dto 1. - * - * @param message the message - */ - public HelloDTO1(String message) { - this.message = message; - } - - /** - * Gets message. - * - * @return the message - */ - public String getMessage() { - return message; - } - } -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app53/HelloControllerWithGlobalApiResponse.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app53/HelloControllerWithGlobalApiResponse.java deleted file mode 100644 index 4aeb6e41e..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app53/HelloControllerWithGlobalApiResponse.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app53; - -import java.util.List; - -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.responses.ApiResponse; - -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.ResponseStatus; -import org.springframework.web.bind.annotation.RestController; - -/** - * The type Hello controller with global api response. - */ -@RestController -@RequestMapping(path = "/global") -class HelloControllerWithGlobalApiResponse { - - /** - * List with no api response list. - * - * @return the list - */ - @Operation(description = "Some operation", responses = { - @ApiResponse(responseCode = "204", description = "Explicit description for this response") }) - @ResponseStatus(HttpStatus.NO_CONTENT) - @GetMapping(value = "/hello1", produces = MediaType.APPLICATION_JSON_VALUE) - List listWithNoApiResponse() { - return null; - } - - /** - * List with default response status list. - * - * @return the list - */ - @Operation(description = "Some operation") - @ApiResponse(responseCode = "200", description = "Explicit description for this response") - @GetMapping(value = "/hello2", produces = MediaType.APPLICATION_JSON_VALUE) - List listWithDefaultResponseStatus() { - return null; - } -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app53/SpringDocApp53Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app53/SpringDocApp53Test.java deleted file mode 100644 index 907519058..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app53/SpringDocApp53Test.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app53; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * The type Spring doc app 53 test. - */ -class SpringDocApp53Test extends AbstractSpringDocTest { - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app54/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app54/HelloController.java deleted file mode 100644 index c62439f8d..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app54/HelloController.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app54; - -import com.fasterxml.jackson.annotation.JsonView; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.parameters.RequestBody; -import io.swagger.v3.oas.annotations.responses.ApiResponse; -import io.swagger.v3.oas.annotations.responses.ApiResponses; - -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * The type Hello controller. - */ -@RestController -class HelloController { - - /** - * Gets meal party. - * - * @param mealPartyId the meal party id - * @return the meal party - */ - @GetMapping(value = "/parties/{id}") - @JsonView(Views.Public.class) - @Operation(summary = "Gets meal party details [Meal party admin restricted]") - @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "Successfully retrieved the meal party") }) - public MealParty getMealParty(@PathVariable("id") long mealPartyId) { - return null; - } - - /** - * Save meal party response entity. - * - * @param p the p - * @return the response entity - */ - @JsonView(Views.MealPartyAdmin.class) - @PostMapping(value = "/parties") - public ResponseEntity saveMealParty(@JsonView(Views.Public.class) @RequestBody MealParty p) { - return null; - } - - /** - * Save meal new party response entity. - * - * @param p the p - * @return the response entity - */ - @JsonView(Views.MealPartyAdmin.class) - @PostMapping(value = "/new-parties") - public ResponseEntity saveMealNewParty(@JsonView(Views.Public.class) @org.springframework.web.bind.annotation.RequestBody MealParty p) { - return null; - } -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app54/MealParty.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app54/MealParty.java deleted file mode 100644 index 5f5f4020f..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app54/MealParty.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app54; - -import java.util.ArrayList; -import java.util.List; - -import com.fasterxml.jackson.annotation.JsonView; - -/** - * The type Meal party. - */ -class MealParty { - /** - * The Name. - */ - @JsonView(Views.Public.class) - private String name; - - /** - * The Members. - */ - @JsonView(Views.MealPartyAdmin.class) - private List members = new ArrayList<>(); -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app54/SpringDocApp54Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app54/SpringDocApp54Test.java deleted file mode 100644 index c01ac10c9..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app54/SpringDocApp54Test.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app54; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * The type Spring doc app 54 test. - */ -class SpringDocApp54Test extends AbstractSpringDocTest { - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app54/Views.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app54/Views.java deleted file mode 100644 index d18177afe..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app54/Views.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app54; - -/** - * The interface Views. - */ -public interface Views { - /** - * The interface Public. - */ - public interface Public { - } - - /** - * The interface Meal party admin. - */ - public interface MealPartyAdmin extends Public { - } -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app55/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app55/HelloController.java deleted file mode 100644 index c1cd59288..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app55/HelloController.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app55; - -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.responses.ApiResponse; -import io.swagger.v3.oas.annotations.responses.ApiResponses; -import io.swagger.v3.oas.annotations.tags.Tag; - -import org.springframework.http.HttpStatus; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.ResponseBody; -import org.springframework.web.bind.annotation.ResponseStatus; - -/** - * The type Hello controller. - */ -@Controller -@Tag(name = "health") -class HelloController { - - /** - * Ping endpoint used for health checks. - * @return the boolean - */ - @RequestMapping(value = "/ping", method = RequestMethod.GET) - @Operation(summary = "Simple health check") - @ApiResponses({ @ApiResponse(responseCode = "200", description = "OK") }) - @ResponseBody - @ResponseStatus(HttpStatus.OK) - public Boolean ping() { - return true; - } -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app55/SpringDocApp55Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app55/SpringDocApp55Test.java deleted file mode 100644 index 949c6cd7e..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app55/SpringDocApp55Test.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app55; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * The type Spring doc app 55 test. - */ -class SpringDocApp55Test extends AbstractSpringDocTest { - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app56/GlobalExceptionHandler.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app56/GlobalExceptionHandler.java deleted file mode 100644 index a9fdfc46d..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app56/GlobalExceptionHandler.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app56; - -import io.swagger.v3.oas.annotations.media.Content; -import io.swagger.v3.oas.annotations.media.Schema; -import io.swagger.v3.oas.annotations.responses.ApiResponse; - -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; -import org.springframework.web.bind.annotation.ExceptionHandler; -import org.springframework.web.bind.annotation.ResponseStatus; -import org.springframework.web.bind.annotation.RestControllerAdvice; - -/** - * The type Global exception handler. - */ -@RestControllerAdvice -class GlobalExceptionHandler { - /** - * Handle unhandled error error dto. - * - * @return the error dto - */ - @ExceptionHandler(Exception.class) - @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR) - @ApiResponse( - responseCode = "500", - description = "Internal server error", - content = @Content( - mediaType = MediaType.APPLICATION_JSON_VALUE, - schema = @Schema(implementation = ErrorDTO.class) - ) - ) - ErrorDTO handleUnhandledError() { - return new ErrorDTO("internal error: "); - } - - /** - * The type Error dto. - */ - class ErrorDTO { - /** - * The Error message. - */ - private String errorMessage; - - /** - * Instantiates a new Error dto. - * - * @param errorMessage the error message - */ - ErrorDTO(String errorMessage) { - this.errorMessage = errorMessage; - } - - /** - * Gets error message. - * - * @return the error message - */ - public String getErrorMessage() { - return errorMessage; - } - } -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app56/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app56/HelloController.java deleted file mode 100644 index f5b696dc2..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app56/HelloController.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app56; - -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * The type Hello controller. - */ -@RestController -class HelloController { - - /** - * Persons string. - * - * @return the string - */ - @GetMapping("/persons") - public String persons() { - return "OK"; - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app56/SpringDocApp56Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app56/SpringDocApp56Test.java deleted file mode 100644 index 6fa54f02e..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app56/SpringDocApp56Test.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app56; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * The type Spring doc app 56 test. - */ -class SpringDocApp56Test extends AbstractSpringDocTest { - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app57/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app57/HelloController.java deleted file mode 100644 index 1e88921ca..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app57/HelloController.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app57; - -import io.swagger.v3.oas.annotations.Parameter; - -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RestController; - -/** - * The type Hello controller. - */ -@RestController -class HelloController { - - /** - * Gets text. - * - * @param name the name - * @return the text - */ - @GetMapping("/{name:.+}") - public ResponseEntity getText(@Parameter(description = "desc", required = true) @PathVariable String name) { - return null; - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app57/SpringDocApp57Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app57/SpringDocApp57Test.java deleted file mode 100644 index 085514048..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app57/SpringDocApp57Test.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app57; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * The type Spring doc app 57 test. - */ -class SpringDocApp57Test extends AbstractSpringDocTest { - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app58/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app58/HelloController.java deleted file mode 100644 index bc90da29c..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app58/HelloController.java +++ /dev/null @@ -1,175 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app58; - -import com.fasterxml.jackson.databind.JsonNode; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.media.Content; -import io.swagger.v3.oas.annotations.media.Schema; - -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -/** - * The type Hello controller. - */ -@RestController -class HelloController { - - /** - * Example object. - * - * @param json the json - * @return the object - */ - @PostMapping("/examplePost") - @Operation(summary = "schema example") - public Object example(@Parameter(schema = @Schema(hidden = true)) JsonNode json) { - return null; - } - - /** - * Test. - * - * @param json the json - */ - @GetMapping("/example") - public void test(@Parameter(schema = @Schema(hidden = true)) JsonNode json) { - } - - /** - * Foobar. - * - * @param bar the bar - */ - @GetMapping(value = "/foo") - public void foobar(@Parameter(description = "User", name = "user", - schema = @Schema(implementation = PersonDTO.class)) @RequestParam("bar") String bar) { - - } - - /** - * Foobar 1. - * - * @param bar the bar - */ - @GetMapping(value = "/foo1") - public void foobar1(@Parameter(description = "User", name = "user", - content = @Content(mediaType = "application/json", - schema = @Schema(implementation = PersonDTO.class))) @RequestParam("bar") String bar) { - - } - - /** - * The type Person dto. - */ - class PersonDTO { - /** - * The Email. - */ - private String email; - - /** - * The First name. - */ - private String firstName; - - /** - * The Last name. - */ - private String lastName; - - /** - * Instantiates a new Person dto. - */ - public PersonDTO() { - } - - /** - * Instantiates a new Person dto. - * - * @param email the email - * @param firstName the first name - * @param lastName the last name - */ - public PersonDTO(final String email, final String firstName, final String lastName) { - this.email = email; - this.firstName = firstName; - this.lastName = lastName; - } - - /** - * Gets email. - * - * @return the email - */ - public String getEmail() { - return email; - } - - /** - * Sets email. - * - * @param email the email - */ - public void setEmail(final String email) { - this.email = email; - } - - /** - * Gets first name. - * - * @return the first name - */ - public String getFirstName() { - return firstName; - } - - /** - * Sets first name. - * - * @param firstName the first name - */ - public void setFirstName(final String firstName) { - this.firstName = firstName; - } - - /** - * Gets last name. - * - * @return the last name - */ - public String getLastName() { - return lastName; - } - - /** - * Sets last name. - * - * @param lastName the last name - */ - public void setLastName(final String lastName) { - this.lastName = lastName; - } - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app58/SpringDocApp58Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app58/SpringDocApp58Test.java deleted file mode 100644 index e9326afa4..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app58/SpringDocApp58Test.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app58; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * The type Spring doc app 58 test. - */ -class SpringDocApp58Test extends AbstractSpringDocTest { - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app59/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app59/HelloController.java deleted file mode 100644 index 45c8db86d..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app59/HelloController.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app59; - -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * The type Hello controller. - */ -@RestController -class HelloController { - /** - * Test. - */ - @Deprecated - @GetMapping("/example") - public void test() { - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app59/SpringDocApp59Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app59/SpringDocApp59Test.java deleted file mode 100644 index 6779a221d..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app59/SpringDocApp59Test.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app59; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * The type Spring doc app 59 test. - */ -class SpringDocApp59Test extends AbstractSpringDocTest { - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app6/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app6/HelloController.java deleted file mode 100644 index a7b5ffdb6..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app6/HelloController.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app6; - -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.media.Content; -import io.swagger.v3.oas.annotations.media.ExampleObject; -import io.swagger.v3.oas.annotations.media.Schema; -import io.swagger.v3.oas.annotations.responses.ApiResponse; - -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * The type Hello controller. - */ -@RestController -class HelloController { - - /** - * Say hello response entity. - * - * @return the response entity - */ - @Operation(summary = "Get Something by key", responses = { - @ApiResponse(description = "Successful Operation", responseCode = "200", content = @Content(mediaType = "application/json", schema = @Schema(oneOf = { - String.class, Integer.class }), examples = { - @ExampleObject(name = "The String example", value = "urgheiurgheirghieurg"), - @ExampleObject(name = "The Integer example", value = "311414") })), - @ApiResponse(responseCode = "404", description = "Thing not found"), - @ApiResponse(responseCode = "401", description = "Authentication Failure") }) - @GetMapping(value = "/hello") - ResponseEntity sayHello() { - return null; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app6/SpringDocApp6Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app6/SpringDocApp6Test.java deleted file mode 100644 index f5e18904b..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app6/SpringDocApp6Test.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app6; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * The type Spring doc app 6 test. - */ -class SpringDocApp6Test extends AbstractSpringDocTest { - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app60/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app60/HelloController.java deleted file mode 100644 index e51a5b071..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app60/HelloController.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app60; - -import java.util.List; - -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.Parameters; - -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * The type Hello controller. - */ -@RestController -class HelloController { - - /** - * List 1 list. - * - * @param page the page - * @param size the size - * @return the list - */ - @GetMapping("/hello1") - @Operation(summary = "summary1") - @Parameters({ - @Parameter(name = "page", description = "The page"), - @Parameter(name = "size", description = "The size") - }) - public List list1(String page, String size) { - return null; - } - - /** - * List 2 list. - * - * @param page the page - * @param size the size - * @param sort the sort - * @return the list - */ - @GetMapping("/hello2") - @Operation(summary = "summary2") - @QuerySort - @QueryPaging - public List list2(String page, String size, String sort) { - return null; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app60/QueryPaging.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app60/QueryPaging.java deleted file mode 100644 index 649ae149a..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app60/QueryPaging.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app60; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.Parameters; - -/** - * The interface Query paging. - */ -@Retention(RetentionPolicy.RUNTIME) -@Target({ ElementType.METHOD }) -@Parameters({ - @Parameter(name = "page", description = "desc page from Annotated interface"), - @Parameter(name = "size", description = "desc page from Annotated interface") -}) -public @interface QueryPaging { -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app60/QuerySort.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app60/QuerySort.java deleted file mode 100644 index da3ac664e..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app60/QuerySort.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app60; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -import io.swagger.v3.oas.annotations.Parameter; - -/** - * The interface Query sort. - */ -@Retention(RetentionPolicy.RUNTIME) -@Target({ ElementType.METHOD }) -@Parameter(name = "sort", description = "desc sort from Annotated interface") -public @interface QuerySort { -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app60/SpringDocApp60Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app60/SpringDocApp60Test.java deleted file mode 100644 index 4e607b47e..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app60/SpringDocApp60Test.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app60; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * The type Spring doc app 60 test. - */ -class SpringDocApp60Test extends AbstractSpringDocTest { - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app61/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app61/HelloController.java deleted file mode 100644 index 970eebc77..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app61/HelloController.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app61; - -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.enums.ParameterIn; -import io.swagger.v3.oas.annotations.media.ArraySchema; -import io.swagger.v3.oas.annotations.media.Content; -import io.swagger.v3.oas.annotations.media.Schema; - -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * The type Hello controller. - */ -@RestController -class HelloController { - - - /** - * Persons string. - * - * @param name the name - * @param phone the phone - * @param createdFrom the created from - * @param createdRange the created range - * @return the string - */ - @Operation(description = "List", parameters = { - @Parameter(description = "Name", name = "name", in = ParameterIn.QUERY), - @Parameter(description = "Phone", name = "phone", in = ParameterIn.QUERY), - @Parameter(description = "createdFrom", name = "createdFrom", in = ParameterIn.QUERY, content = @Content(array = @ArraySchema(schema = @Schema(type = "string")))), - @Parameter(description = "createdRange", name = "createdRange", in = ParameterIn.QUERY, array = @ArraySchema(schema = @Schema(type = "string", format = "date"), minItems = 2, maxItems = 2)) - }) - @GetMapping(value = "/persons-with-user") - public String persons(String name, String phone, String createdFrom, String createdRange) { - return "OK"; - } - -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app61/SpringDocApp61Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app61/SpringDocApp61Test.java deleted file mode 100644 index 050afb6d7..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app61/SpringDocApp61Test.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app61; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * The type Spring doc app 61 test. - */ -class SpringDocApp61Test extends AbstractSpringDocTest { - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app62/BaseController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app62/BaseController.java deleted file mode 100644 index 209ed33af..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app62/BaseController.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app62; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -import org.springframework.core.annotation.AliasFor; -import org.springframework.http.MediaType; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * The interface Base controller. - */ -@Target({ ElementType.METHOD, ElementType.TYPE }) -@Retention(RetentionPolicy.RUNTIME) -@RestController -@RequestMapping -public @interface BaseController { - /** - * Value string [ ]. - * - * @return the string [ ] - */ - @AliasFor(annotation = RequestMapping.class) - String[] value() default {}; - - /** - * Produces string [ ]. - * - * @return the string [ ] - */ - @AliasFor(annotation = RequestMapping.class) - String[] produces() default { MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE }; -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app62/SpringDocApp62Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app62/SpringDocApp62Test.java deleted file mode 100644 index 08f628182..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app62/SpringDocApp62Test.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app62; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * The type Spring doc app 62 test. - */ -class SpringDocApp62Test extends AbstractSpringDocTest { - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app62/TestController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app62/TestController.java deleted file mode 100644 index cc61e35eb..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app62/TestController.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app62; - -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; - -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; - -/** - * The type Test controller. - */ -@BaseController -@Tag(name = "Test Controller") -class TestController { - - /** - * Test string. - * - * @param accept the accept - * @return the string - */ - @RequestMapping(value = "/test", method = RequestMethod.GET) - @Operation(summary = "This is the test endpoint") - public String test(@RequestHeader("Accept") String accept) { - return "This is a test"; - } -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app63/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app63/HelloController.java deleted file mode 100644 index 471f45b20..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app63/HelloController.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app63; - -import java.util.Locale; - -import jakarta.servlet.http.HttpServletRequest; -import jakarta.servlet.http.HttpServletResponse; -import jakarta.servlet.http.HttpSession; - -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * The type Hello controller. - */ -@RestController -class HelloController { - - /** - * Test. - * - * @param header the header - * @param request the request - * @param response the response - * @param locale the locale - * @param hello the hello - */ - @GetMapping("/test") - public void test(HttpSession header, HttpServletRequest request, HttpServletResponse response, Locale locale, - String hello) { - } - -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app63/SpringDocApp63Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app63/SpringDocApp63Test.java deleted file mode 100644 index aa1cf7088..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app63/SpringDocApp63Test.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app63; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.test.context.TestPropertySource; - - -/** - * The type Spring doc app 63 test. - */ -@TestPropertySource(properties = { - "springdoc.packagesToScan=hell,hello1, hello.me", - "springdoc.packagesToExclude=test.org.springdoc.api.app63.65" }) -class SpringDocApp63Test extends AbstractSpringDocTest { - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app64/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app64/HelloController.java deleted file mode 100644 index 758acfb7d..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app64/HelloController.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app64; - -import io.swagger.v3.oas.annotations.Operation; - -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * The type Hello controller. - */ -@RestController -class HelloController { - - /** - * Test 1. - * - * @param hello the hello - */ - @GetMapping("/v1/test") - public void test1(String hello) { - } - - /** - * Test 2 string. - * - * @param from the from - * @return the string - */ - @GetMapping(value = "/api/balance/abcd") - @Operation(summary = "This is the test endpoint") - public String test2(String from) { - return "This is a fake test"; - } - -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app64/SpringDocApp64Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app64/SpringDocApp64Test.java deleted file mode 100644 index 2251b372d..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app64/SpringDocApp64Test.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app64; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.test.context.TestPropertySource; - -/** - * The type Spring doc app 64 test. - */ -@TestPropertySource(properties = "springdoc.paths-to-match=/v1, /api/**") -class SpringDocApp64Test extends AbstractSpringDocTest { - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app65/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app65/HelloController.java deleted file mode 100644 index e479d9e88..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app65/HelloController.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app65; - -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; - -import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * The type Hello controller. - */ -@Tag(name = "Health", description = "Health check / ping API") -@RestController -class HelloController { - - /** - * Ping response entity. - * - * @return the response entity - */ - @Operation(summary = "Check server status", description = "Check server status, will return 200 with simple string if alive. Do nothing else.") - @GetMapping(value = { "/ping", "/health", "/" }, produces = MediaType.TEXT_PLAIN_VALUE) - public ResponseEntity ping() { - return ResponseEntity.ok("Healthy"); - } - -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app65/SpringDocApp65Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app65/SpringDocApp65Test.java deleted file mode 100644 index 102afe729..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app65/SpringDocApp65Test.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app65; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * The type Spring doc app 65 test. - */ -class SpringDocApp65Test extends AbstractSpringDocTest { - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app66/DefaultHealthCheckApi.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app66/DefaultHealthCheckApi.java deleted file mode 100644 index 651299d3b..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app66/DefaultHealthCheckApi.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app66; - -import java.time.LocalDate; - -import io.swagger.v3.oas.annotations.Hidden; - -import org.springframework.format.annotation.DateTimeFormat; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RestController; - - -/** - * The type Default health check api. - */ -@RestController -@Hidden -class DefaultHealthCheckApi { - - /** - * Test date echo string. - * - * @param date the date - * @return the string - */ - @GetMapping("/test/date/echo/{date}") - public String testDateEcho(@DateTimeFormat(pattern = "yyyyMMdd") @PathVariable LocalDate date) { - return date.toString(); - } - -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app66/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app66/HelloController.java deleted file mode 100644 index dc32d1cfa..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app66/HelloController.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app66; - -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.tags.Tag; - -import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * The type Hello controller. - */ -@Tag(name = "Health", description = "Health check / ping API") -@RestController -class HelloController { - - /** - * Ping response entity. - * - * @param possiblyInjectedByAspect the possibly injected by aspect - * @return the response entity - */ - @Operation(summary = "Check server status", description = "Check server status, will return 200 with simple string if alive. Do nothing else.") - @GetMapping(value = { "/ping", "/health", "/" }, produces = MediaType.TEXT_PLAIN_VALUE) - public ResponseEntity ping(UndocumentedClass possiblyInjectedByAspect) { - return ResponseEntity.ok("Healthy"); - } - -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app66/SpringDocApp66Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app66/SpringDocApp66Test.java deleted file mode 100644 index c54781196..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app66/SpringDocApp66Test.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app66; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * The type Spring doc app 66 test. - */ -class SpringDocApp66Test extends AbstractSpringDocTest { - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app66/UndocumentedClass.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app66/UndocumentedClass.java deleted file mode 100644 index 9404d0987..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app66/UndocumentedClass.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app66; - -import io.swagger.v3.oas.annotations.Hidden; - -/** - * The type Undocumented class. - */ -@Hidden -class UndocumentedClass { - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app67/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app67/HelloController.java deleted file mode 100644 index e60ca14cd..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app67/HelloController.java +++ /dev/null @@ -1,133 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app67; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.Parameters; -import io.swagger.v3.oas.annotations.enums.ParameterIn; -import io.swagger.v3.oas.annotations.media.Schema; - -import org.springframework.http.MediaType; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * The type Hello controller. - */ -@RestController -@RequestMapping(path = "/demo", - produces = MediaType.TEXT_PLAIN_VALUE) -class HelloController { - - /** - * Operation 1 string. - * - * @return the string - */ - @GetMapping("operation1") - @Operation(summary = "Operation 1 (expected result - no parameters)") - public String operation1() { - return "operation1"; - } - - /** - * Operation 2 string. - * - * @return the string - */ - @GetMapping("operation2") - @Operation(summary = "Operation 2 (expected result - 3 parameters)", parameters = { - @Parameter(name = "pageNumber", description = "page number", - in = ParameterIn.QUERY, schema = @Schema(type = "integer")), - @Parameter(name = "pageSize", description = "page size", - in = ParameterIn.QUERY, schema = @Schema(type = "integer")), - @Parameter(name = "sort", description = "sort specification", - in = ParameterIn.QUERY, schema = @Schema(type = "string")) - }) - public String operation2() { - return "operation2"; - } - - /** - * Operation 3 string. - * - * @return the string - */ - @GetMapping("operation3") - @Operation(summary = "Operation 3 (expected result - 3 parameters)") - @Parameters({ - @Parameter(name = "pageNumber", description = "page number", - in = ParameterIn.QUERY, schema = @Schema(type = "integer")), - @Parameter(name = "pageSize", description = "page size", - in = ParameterIn.QUERY, schema = @Schema(type = "integer")), - @Parameter(name = "sort", description = "sort specification", - in = ParameterIn.QUERY, schema = @Schema(type = "string")) - }) - public String operation3() { - return "operation3"; - } - - /** - * Operation 4 string. - * - * @return the string - */ - @GetMapping("operation4") - @Operation(summary = "Operation 4 (expected result - 3 parameters)") - @QueryPaging - @QuerySort - public String operation4() { - return "operation4"; - } - - /** - * The interface Query paging. - */ - @Retention(RetentionPolicy.RUNTIME) - @Target({ ElementType.METHOD }) - @Parameters({ - @Parameter(name = "pageNumber", description = "page number", - in = ParameterIn.QUERY, schema = @Schema(type = "integer")), - @Parameter(name = "pageSize", description = "page size", - in = ParameterIn.QUERY, schema = @Schema(type = "integer")) - }) - public @interface QueryPaging { - - } - - /** - * The interface Query sort. - */ - @Retention(RetentionPolicy.RUNTIME) - @Target({ ElementType.METHOD }) - @Parameters({ - @Parameter(name = "sort", description = "sort specification", - in = ParameterIn.QUERY, schema = @Schema(type = "string")) - }) - public @interface QuerySort { - - } -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app67/SpringDocApp67Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app67/SpringDocApp67Test.java deleted file mode 100644 index 01dd40162..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app67/SpringDocApp67Test.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app67; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * The type Spring doc app 67 test. - */ -class SpringDocApp67Test extends AbstractSpringDocTest { - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app69/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app69/HelloController.java deleted file mode 100644 index a9a837cd8..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app69/HelloController.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app69; - -import java.util.concurrent.Callable; - -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RestController; - -/** - * The type Hello controller. - */ -@RestController -class HelloController { - - /** - * Gets tasks. - * - * @param str the str - * @return the tasks - */ - @RequestMapping(value = "/tasks", method = RequestMethod.GET) - private Callable> getTasks(String str) { - return null; - } - -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app69/PersonDTO.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app69/PersonDTO.java deleted file mode 100644 index 614c352d5..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app69/PersonDTO.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app69; - -/** - * The type Person dto. - */ -class PersonDTO { - /** - * The Email. - */ - private String email; - - /** - * The First name. - */ - private String firstName; - - /** - * The Last name. - */ - private String lastName; - - /** - * Instantiates a new Person dto. - */ - public PersonDTO() { - } - - /** - * Instantiates a new Person dto. - * - * @param email the email - * @param firstName the first name - * @param lastName the last name - */ - public PersonDTO(final String email, final String firstName, final String lastName) { - this.email = email; - this.firstName = firstName; - this.lastName = lastName; - } - - /** - * Gets email. - * - * @return the email - */ - public String getEmail() { - return email; - } - - /** - * Sets email. - * - * @param email the email - */ - public void setEmail(final String email) { - this.email = email; - } - - /** - * Gets first name. - * - * @return the first name - */ - public String getFirstName() { - return firstName; - } - - /** - * Sets first name. - * - * @param firstName the first name - */ - public void setFirstName(final String firstName) { - this.firstName = firstName; - } - - /** - * Gets last name. - * - * @return the last name - */ - public String getLastName() { - return lastName; - } - - /** - * Sets last name. - * - * @param lastName the last name - */ - public void setLastName(final String lastName) { - this.lastName = lastName; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app69/SpringDocApp69Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app69/SpringDocApp69Test.java deleted file mode 100644 index 5e2d3632c..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app69/SpringDocApp69Test.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app69; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * The type Spring doc app 69 test. - */ -class SpringDocApp69Test extends AbstractSpringDocTest { - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app7/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app7/HelloController.java deleted file mode 100644 index 926ba4511..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app7/HelloController.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app7; - -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.media.Content; -import io.swagger.v3.oas.annotations.media.Schema; -import io.swagger.v3.oas.annotations.parameters.RequestBody; - -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * The type Hello controller. - */ -@RestController -class HelloController { - - /** - * Search employee. - * - * @param test the test - */ - @Operation(summary = "test Request") - @RequestBody(description = "test value", required = true, content = @Content(schema = @Schema(implementation = String.class))) - @PostMapping("/test") - public void searchEmployee(String test) { - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app7/SpringDocApp7Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app7/SpringDocApp7Test.java deleted file mode 100644 index a6fee1e8d..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app7/SpringDocApp7Test.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app7; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * The type Spring doc app 7 test. - */ -class SpringDocApp7Test extends AbstractSpringDocTest { - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app70/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app70/HelloController.java deleted file mode 100644 index 99bb18f19..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app70/HelloController.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app70; - -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import test.org.springdoc.api.app70.customizer.CustomizedOperation; -import test.org.springdoc.api.app70.customizer.CustomizedParameter; -import test.org.springdoc.api.app70.model.ApiType; - -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RestController; - -/** - * The type Hello controller. - */ -@RestController -class HelloController { - - /** - * Test api type. - * - * @param test the test - * @return the api type - */ - @CustomizedOperation - @Operation(description = "Some operation") - @GetMapping("/example/{test}") - public ApiType test(@PathVariable @CustomizedParameter @Parameter(description = "Parameter description") String test) { - return new ApiType(); - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app70/SpringDocApp70Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app70/SpringDocApp70Test.java deleted file mode 100644 index 1b400bae2..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app70/SpringDocApp70Test.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app70; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * The type Spring doc app 70 test. - */ -class SpringDocApp70Test extends AbstractSpringDocTest { - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app70/customizer/CustomizedOperation.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app70/customizer/CustomizedOperation.java deleted file mode 100644 index 33984147c..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app70/customizer/CustomizedOperation.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app70.customizer; - -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; - -/** - * The interface Customized operation. - */ -@Retention(RetentionPolicy.RUNTIME) -public @interface CustomizedOperation { - /** - * Addition string. - * - * @return the string - */ - String addition() default "customized operation!"; -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app70/customizer/CustomizedParameter.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app70/customizer/CustomizedParameter.java deleted file mode 100644 index 0cf44ca69..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app70/customizer/CustomizedParameter.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app70.customizer; - -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; - -/** - * The interface Customized parameter. - */ -@Retention(RetentionPolicy.RUNTIME) -public @interface CustomizedParameter { - /** - * Addition string. - * - * @return the string - */ - String addition() default "customized parameter!"; -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app70/customizer/CustomizedProperty.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app70/customizer/CustomizedProperty.java deleted file mode 100644 index 1c42e60bd..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app70/customizer/CustomizedProperty.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app70.customizer; - -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; - -/** - * The interface Customized property. - */ -@Retention(RetentionPolicy.RUNTIME) -public @interface CustomizedProperty { - /** - * Addition string. - * - * @return the string - */ - String addition() default "customized property!"; -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app70/customizer/OperationCustomizer.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app70/customizer/OperationCustomizer.java deleted file mode 100644 index ed8d5cf2f..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app70/customizer/OperationCustomizer.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app70.customizer; - -import io.swagger.v3.oas.models.Operation; - -import org.springframework.stereotype.Component; -import org.springframework.web.method.HandlerMethod; - -/** - * The type Operation customizer. - */ -@Component -class OperationCustomizer implements org.springdoc.core.customizers.OperationCustomizer { - /** - * Customize operation. - * - * @param operation the operation - * @param handlerMethod the handler method - * @return the operation - */ - @Override - public Operation customize(Operation operation, HandlerMethod handlerMethod) { - CustomizedOperation annotation = handlerMethod.getMethodAnnotation(CustomizedOperation.class); - if (annotation != null) { - operation.description(operation.getDescription() + ", " + annotation.addition()); - } - return operation; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app70/customizer/ParameterCustomizer.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app70/customizer/ParameterCustomizer.java deleted file mode 100644 index 8611b8c12..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app70/customizer/ParameterCustomizer.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app70.customizer; - -import io.swagger.v3.oas.models.parameters.Parameter; - -import org.springframework.core.MethodParameter; -import org.springframework.stereotype.Component; - -/** - * The type Parameter customizer. - */ -@Component -class ParameterCustomizer implements org.springdoc.core.customizers.ParameterCustomizer { - /** - * Customize parameter. - * - * @param parameterModel the parameter model - * @param methodParameter the method parameter - * @return the parameter - */ - @Override - public Parameter customize(Parameter parameterModel, MethodParameter methodParameter) { - CustomizedParameter annotation = methodParameter.getParameterAnnotation(CustomizedParameter.class); - if (annotation != null) { - parameterModel.description(parameterModel.getDescription() + ", " + annotation.addition()); - } - return parameterModel; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app70/customizer/PropertyCustomizer.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app70/customizer/PropertyCustomizer.java deleted file mode 100644 index 3a71c3dbc..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app70/customizer/PropertyCustomizer.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * - * * - * * * - * * * * - * * * * * 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.app70.customizer; - -import java.lang.annotation.Annotation; -import java.time.Duration; -import java.util.Collections; -import java.util.Optional; -import java.util.stream.Stream; - -import com.fasterxml.jackson.databind.JavaType; -import io.swagger.v3.core.converter.AnnotatedType; -import io.swagger.v3.oas.models.media.Schema; -import io.swagger.v3.oas.models.media.StringSchema; -import org.springdoc.core.providers.ObjectMapperProvider; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -/** - * The type Property customizer. - */ -@Component -class PropertyCustomizer implements org.springdoc.core.customizers.PropertyCustomizer { - - @Autowired - ObjectMapperProvider objectMapperProvider; - - /** - * Customize schema. - * - * @param property the property - * @param type the type - * @return the schema - */ - @Override - public Schema customize(Schema property, AnnotatedType type) { - Annotation[] ctxAnnotations = type.getCtxAnnotations(); - if (ctxAnnotations == null) { - return property; - } - - Optional propertyAnnotation = Stream.of(ctxAnnotations) - .filter(CustomizedProperty.class::isInstance) - .findFirst() - .map(CustomizedProperty.class::cast); - - JavaType javaType = objectMapperProvider.jsonMapper().constructType(type.getType()); - if (javaType.getRawClass().equals(Duration.class)) { - property = new StringSchema().format("duration").properties(Collections.emptyMap()); - } - return property; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app70/model/ApiType.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app70/model/ApiType.java deleted file mode 100644 index c79da0218..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app70/model/ApiType.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app70.model; - -import java.time.Duration; - -import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.v3.oas.annotations.media.Schema; -import test.org.springdoc.api.app70.customizer.CustomizedProperty; - -/** - * The type Api type. - */ -public class ApiType { - /** - * The Some property. - */ - @CustomizedProperty - @Schema(description = "Test description") - @JsonProperty("someProperty") - private Duration someProperty; - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app71/Dog.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app71/Dog.java deleted file mode 100644 index edcf892b4..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app71/Dog.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app71; - -import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.v3.oas.annotations.media.Schema; - - -/** - * The type Dog. - */ -@Schema(name = "Dog") -class Dog { - - /** - * The Display name. - */ - @JsonProperty("display_name") - @Schema( - name = "display_name", - description = "A name given to the Dog", - example = "Fido" - ) - String displayName; - -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app71/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app71/HelloController.java deleted file mode 100644 index 4d1e0c56b..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app71/HelloController.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app71; - -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * The type Hello controller. - */ -@RestController -class HelloController { - - /** - * Persons string. - * - * @param dog the dog - * @return the string - */ - @PostMapping("/persons") - public String persons(Dog dog) { - return null; - } - -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app71/SpringDocApp71Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app71/SpringDocApp71Test.java deleted file mode 100644 index 051921c85..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app71/SpringDocApp71Test.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app71; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * The type Spring doc app 71 test. - */ -class SpringDocApp71Test extends AbstractSpringDocTest { - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app72/BlockingAutoConfigurationTest.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app72/BlockingAutoConfigurationTest.java deleted file mode 100644 index c553ef06b..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app72/BlockingAutoConfigurationTest.java +++ /dev/null @@ -1,122 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app72; - -import org.junit.jupiter.api.Test; -import org.springdoc.core.models.GroupedOpenApi; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.test.context.FilteredClassLoader; -import org.springframework.boot.test.context.runner.ApplicationContextRunner; -import org.springframework.boot.test.context.runner.WebApplicationContextRunner; -import org.springframework.context.annotation.Bean; - -import static org.assertj.core.api.Assertions.assertThat; - -/** - * The type Blocking auto configuration test. - */ -class BlockingAutoConfigurationTest { - - /** - * The Context runner. - */ - private final WebApplicationContextRunner contextRunner = new WebApplicationContextRunner() - .withUserConfiguration(TestApp.class); - - - /** - * Configurations not loaded when application is not web. - */ - @Test - void configurations_not_loaded_when_application_is_not_web() { - new ApplicationContextRunner() - .withUserConfiguration(TestApp.class) - .run(context -> assertThat(context) - .hasNotFailed() - .doesNotHaveBean("openApiResource") - .doesNotHaveBean("actuatorProvider") - .doesNotHaveBean("multipleOpenApiResource") - ); - } - - /** - * Actuator configuration not loaded when not enabled explicitly. - */ - @Test - void actuator_configuration_not_loaded_when_not_enabled_explicitly() { - contextRunner - .run(context -> assertThat(context) - .hasNotFailed() - .hasBean("openApiResource") - .doesNotHaveBean("actuatorPprrovider") - .hasBean("multipleOpenApiResource") - ); - } - - /** - * Configurations not loaded when disabled. - */ - @Test - void configurations_not_loaded_when_disabled() { - contextRunner - .withPropertyValues("springdoc.api-docs.enabled=false") - .run(context -> assertThat(context) - .hasNotFailed() - .doesNotHaveBean("openApiResource") - .doesNotHaveBean("actuatorProvider") - .doesNotHaveBean("multipleOpenApiResource") - ); - } - - /** - * Configurations not loaded when mvc is not on class path. - */ - @Test - void configurations_not_loaded_when_mvc_is_not_on_class_path() { - contextRunner - .withClassLoader(new FilteredClassLoader("org.springframework.web.context.support.GenericWebApplicationContext")) - .run(context -> assertThat(context) - .hasNotFailed() - .doesNotHaveBean("openApiResource") - .doesNotHaveBean("actuatorProvider") - .doesNotHaveBean("multipleOpenApiResource") - ); - - } - - /** - * The type Test app. - */ - @SpringBootApplication - static class TestApp { - /** - * Test grouped open api grouped open api. - * - * @return the grouped open api - */ - @Bean - GroupedOpenApi testGroupedOpenApi() { - return GroupedOpenApi.builder() - .group("test-group") - .packagesToScan("org.test") - .build(); - } - } -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app72/CacheAutoConfigurationTest1.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app72/CacheAutoConfigurationTest1.java deleted file mode 100644 index 01a1c1945..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app72/CacheAutoConfigurationTest1.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app72; - -import org.junit.jupiter.api.Test; - -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.boot.test.context.runner.WebApplicationContextRunner; - -import static org.assertj.core.api.Assertions.assertThat; - -/** - * The type Cache auto configuration test 1. - */ -class CacheAutoConfigurationTest1 { - - /** - * The Context runner. - */ - private final WebApplicationContextRunner contextRunner = new WebApplicationContextRunner() - .withUserConfiguration(TestApp.class); - - /** - * Cache configuration loaded when not disabled explicitly. - */ - @Test - void cache_configuration_loaded_when_not_disabled_explicitly() { - contextRunner - .run(context -> assertThat(context) - .hasNotFailed() - .hasBean("openApiResource") - .doesNotHaveBean("springdocBeanFactoryPostProcessor") - .doesNotHaveBean("multipleOpenApiResource") - ); - } - - /** - * Cache configuration loaded when disabled explicitly. - */ - @Test - void cache_configuration_loaded_when_disabled_explicitly() { - contextRunner - .withPropertyValues("springdoc.cache.disabled=false") - .run(context -> assertThat(context) - .hasNotFailed() - .hasBean("openApiResource") - .doesNotHaveBean("springdocBeanFactoryPostProcessor") - .doesNotHaveBean("multipleOpenApiResource") - ); - } - - /** - * Cache configurations successfully disabled. - */ - @Test - void cache_configurations_successfully_disabled() { - contextRunner - .withPropertyValues("springdoc.cache.disabled=true") - .run(context -> assertThat(context) - .hasNotFailed() - .hasBean("openApiResource") - .hasBean("springdocBeanFactoryPostProcessor") - .doesNotHaveBean("multipleOpenApiResource") - ); - } - - /** - * Group configuration loaded. - */ - @Test - void group_configuration_loaded() { - contextRunner - .withPropertyValues("springdoc.group-configs[0].group=stores", "springdoc.group-configs[0].paths-to-match=/store/**") - .run(context -> assertThat(context) - .hasNotFailed() - .hasBean("openApiResource") - .hasBean("multipleOpenApiResource") - .hasBean("springdocBeanFactoryPostProcessor") - ); - } - - - /** - * The type Test app. - */ - @EnableAutoConfiguration - static class TestApp { - - } -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app72/GroupAutoConfigurationTest.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app72/GroupAutoConfigurationTest.java deleted file mode 100644 index ae17c3212..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app72/GroupAutoConfigurationTest.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app72; - -import org.junit.jupiter.api.Test; -import org.springdoc.core.models.GroupedOpenApi; - -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.boot.test.context.runner.WebApplicationContextRunner; -import org.springframework.context.annotation.Bean; - -import static org.assertj.core.api.Assertions.assertThat; - -/** - * The type Group auto configuration test. - */ -class GroupAutoConfigurationTest { - - /** - * The Context runner. - */ - private final WebApplicationContextRunner contextRunner = new WebApplicationContextRunner() - .withUserConfiguration(TestApp.class); - - /** - * Group configuration loaded. - */ - @Test - void group_configuration_loaded() { - contextRunner - .run(context -> assertThat(context) - .hasNotFailed() - .hasBean("openApiResource") - .hasBean("springdocBeanFactoryPostProcessor") - .hasBean("multipleOpenApiResource") - ); - } - - /** - * The type Test app. - */ - @EnableAutoConfiguration - static class TestApp { - /** - * Test grouped open api grouped open api. - * - * @return the grouped open api - */ - @Bean - GroupedOpenApi testGroupedOpenApi() { - return GroupedOpenApi.builder() - .group("test-group") - .packagesToScan("org.test") - .build(); - } - } -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app73/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app73/HelloController.java deleted file mode 100644 index 66b2debc0..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app73/HelloController.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app73; - -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.enums.ParameterIn; - -import org.springframework.http.HttpStatus; -import org.springframework.web.bind.annotation.DeleteMapping; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.ResponseStatus; -import org.springframework.web.bind.annotation.RestController; - - -/** - * The type Hello controller. - */ -@RestController -@RequestMapping({ "/{country_code}/persons/", "/persons" }) -class HelloController { - - /** - * Delete. - * - * @param countryCode the country code - * @param id the id - */ - @DeleteMapping("/{id}") - @ResponseStatus(HttpStatus.NO_CONTENT) - public void delete(@Parameter(name = "country_code", in = ParameterIn.QUERY) String countryCode, @PathVariable("id") String id) { - - } - - /** - * Get string. - * - * @param countryCode the country code - * @param id the id - * @return the string - */ - @GetMapping("/{id}") - public String get(@Parameter(name = "country_code", in = ParameterIn.QUERY) String countryCode, @PathVariable("id") String id) { - return null; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app73/SpringDocApp73Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app73/SpringDocApp73Test.java deleted file mode 100644 index 330a6ffdf..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app73/SpringDocApp73Test.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app73; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * The type Spring doc app 73 test. - */ -class SpringDocApp73Test extends AbstractSpringDocTest { - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app74/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app74/HelloController.java deleted file mode 100644 index aab5ab2c0..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app74/HelloController.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app74; - -import io.swagger.v3.oas.annotations.media.Content; -import io.swagger.v3.oas.annotations.media.ExampleObject; -import io.swagger.v3.oas.annotations.parameters.RequestBody; - -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RestController; - - -/** - * The type Hello controller. - */ -@RestController -class HelloController { - - /** - * Post my request body string. - * - * @param myRequestBody the my request body - * @return the string - */ - @PostMapping("/test") - @RequestBody( - content = @Content( - examples = @ExampleObject( - value = "sample" - ) - ) - ) - public String postMyRequestBody( - String myRequestBody) { - return null; - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app74/SpringDocApp74Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app74/SpringDocApp74Test.java deleted file mode 100644 index 3006d60e5..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app74/SpringDocApp74Test.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app74; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * The type Spring doc app 74 test. - */ -class SpringDocApp74Test extends AbstractSpringDocTest { - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app75/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app75/HelloController.java deleted file mode 100644 index 5cd7892de..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app75/HelloController.java +++ /dev/null @@ -1,119 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app75; - -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.enums.ParameterIn; -import io.swagger.v3.oas.annotations.media.Content; -import io.swagger.v3.oas.annotations.media.Schema; -import io.swagger.v3.oas.annotations.responses.ApiResponse; -import io.swagger.v3.oas.annotations.responses.ApiResponses; - -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * The type Hello controller. - */ -@RestController -class HelloController { - - /** - * Post my request body 1 string. - * - * @return the string - */ - @PostMapping("/test1/{uuid}") - @Operation(summary = "Example api that realize an ECHO operation", - description = "The result of the echo is the input value of the api", - parameters = { @Parameter(in = ParameterIn.PATH, - name = "uuid", - required = true, - description = "Is the identification of the document", - schema = @Schema(type = "string", - example = "uuid")) } - - - ) - @ApiResponses(value = { - @ApiResponse(description = "Successful Operation", - responseCode = "200", - content = @Content(mediaType = "application/json", - schema = @Schema(implementation = PersonDTO.class))), - @ApiResponse(responseCode = "201", - description = "other possible response") - }) - public String postMyRequestBody1() { - return null; - } - - /** - * Post my request body 2 string. - * - * @return the string - */ - @PostMapping("/test2/{uuid}") - @Operation(summary = "Example api that realize an ECHO operation", - description = "The result of the echo is the input value of the api", - responses = { - @ApiResponse(description = "Successful Operation", - responseCode = "200", - content = @Content(mediaType = "application/json", - schema = @Schema(implementation = PersonDTO.class))), - @ApiResponse(responseCode = "201", - description = "other possible response") - }, - parameters = { @Parameter(in = ParameterIn.PATH, - name = "uuid", - required = true, - description = "Is the identification of the document", - schema = @Schema(type = "string", - example = "uuid")) } - - - ) - public String postMyRequestBody2() { - return null; - } - - /** - * Post my request body 3 string. - * - * @return the string - */ - @PostMapping("/test3/{uuid}") - @Operation(summary = "Example api that realize an ECHO operation", - description = "The result of the echo is the input value of the api", - parameters = { @Parameter(in = ParameterIn.PATH, - name = "uuid", - required = true, - description = "Is the identification of the document", - schema = @Schema(type = "string", - example = "uuid")) } - - - ) - @ApiResponse(responseCode = "201", - description = "other possible response") - public String postMyRequestBody3() { - return null; - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app75/PersonDTO.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app75/PersonDTO.java deleted file mode 100644 index e07dbfcea..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app75/PersonDTO.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app75; - -/** - * The type Person dto. - */ -class PersonDTO { - /** - * The Email. - */ - private String email; - - /** - * The First name. - */ - private String firstName; - - /** - * The Last name. - */ - private String lastName; - - /** - * Instantiates a new Person dto. - */ - public PersonDTO() { - } - - /** - * Instantiates a new Person dto. - * - * @param email the email - * @param firstName the first name - * @param lastName the last name - */ - public PersonDTO(final String email, final String firstName, final String lastName) { - this.email = email; - this.firstName = firstName; - this.lastName = lastName; - } - - /** - * Gets email. - * - * @return the email - */ - public String getEmail() { - return email; - } - - /** - * Sets email. - * - * @param email the email - */ - public void setEmail(final String email) { - this.email = email; - } - - /** - * Gets first name. - * - * @return the first name - */ - public String getFirstName() { - return firstName; - } - - /** - * Sets first name. - * - * @param firstName the first name - */ - public void setFirstName(final String firstName) { - this.firstName = firstName; - } - - /** - * Gets last name. - * - * @return the last name - */ - public String getLastName() { - return lastName; - } - - /** - * Sets last name. - * - * @param lastName the last name - */ - public void setLastName(final String lastName) { - this.lastName = lastName; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app75/RestResponseEntityExceptionHandler.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app75/RestResponseEntityExceptionHandler.java deleted file mode 100644 index 4d0feeddb..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app75/RestResponseEntityExceptionHandler.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app75; - -import java.util.List; - -import jakarta.servlet.http.HttpServletRequest; - -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.ControllerAdvice; -import org.springframework.web.bind.annotation.ExceptionHandler; -import org.springframework.web.bind.annotation.ResponseStatus; -import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler; - -/** - * The type Rest response entity exception handler. - */ -@ControllerAdvice -class RestResponseEntityExceptionHandler - extends ResponseEntityExceptionHandler { - /** - * Bad request response entity. - * - * @param req the req - * @param exception the exception - * @return the response entity - */ - @ResponseStatus(value = HttpStatus.OK) - @ExceptionHandler({ Exception.class }) - public ResponseEntity> badRequest(HttpServletRequest req, Exception exception) { - return null; - } -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app75/SpringDocApp75Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app75/SpringDocApp75Test.java deleted file mode 100644 index 5dbd1acc9..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app75/SpringDocApp75Test.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app75; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * The type Spring doc app 75 test. - */ -class SpringDocApp75Test extends AbstractSpringDocTest { - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp { - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app76/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app76/HelloController.java deleted file mode 100644 index fb8df1e31..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app76/HelloController.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app76; - -import io.swagger.v3.oas.annotations.security.SecurityRequirements; - -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.ResponseBody; -import org.springframework.web.bind.annotation.RestController; - - -/** - * The type Hello controller. - */ -@RestController -class HelloController { - - /** - * Secured string. - * - * @return the string - */ - @GetMapping("/secure") - @ResponseBody - public String secured() { - return "It works!"; - } - - /** - * Open string. - * - * @return the string - */ - @GetMapping("/open") - @ResponseBody - @SecurityRequirements - public String open() { - return "It works!"; - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app76/SpringDocApp76Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app76/SpringDocApp76Test.java deleted file mode 100644 index 422cb11fb..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app76/SpringDocApp76Test.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app76; - -import java.util.Arrays; - -import io.swagger.v3.oas.models.Components; -import io.swagger.v3.oas.models.OpenAPI; -import io.swagger.v3.oas.models.security.SecurityRequirement; -import io.swagger.v3.oas.models.security.SecurityScheme; -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.Bean; - -/** - * The type Spring doc app 76 test. - */ -class SpringDocApp76Test extends AbstractSpringDocTest { - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp { - /** - * Open api open api. - * - * @return the open api - */ - @Bean - public OpenAPI openAPI() { - return new OpenAPI() - .components(new Components().addSecuritySchemes("bearer-jwt", - new SecurityScheme() - .type(SecurityScheme.Type.HTTP) - .scheme("bearer") - .bearerFormat("JWT")) - ) - .addSecurityItem( - new SecurityRequirement().addList("bearer-jwt", Arrays.asList("read", "write"))); - } - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app77/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app77/HelloController.java deleted file mode 100644 index 6eb96004e..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app77/HelloController.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app77; - -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.extensions.Extension; -import io.swagger.v3.oas.annotations.extensions.ExtensionProperty; -import io.swagger.v3.oas.annotations.media.Content; -import io.swagger.v3.oas.annotations.media.Schema; -import io.swagger.v3.oas.annotations.responses.ApiResponse; -import jakarta.validation.Valid; -import org.hibernate.validator.constraints.NotBlank; - -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - - -/** - * The type Hello controller. - */ -@RestController -class HelloController { - - /** - * Persons. - * - * @param name the name - */ - @ApiResponse(content = @Content(schema = @Schema(type = "string")), extensions = @Extension(properties = @ExtensionProperty(name = "x-is-file", value = "true"))) - @GetMapping(value = "/persons") - public void persons(@Valid @NotBlank String name) { - - } - - - /** - * Persons 2. - * - * @param name the name - */ - @Operation(responses = @ApiResponse(content = @Content(schema = @Schema(type = "string")), extensions = @Extension(properties = @ExtensionProperty(name = "x-is-file", value = "true")))) - @GetMapping(value = "/persons2") - public void persons2(@Valid @NotBlank String name) { - - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app77/SpringDocApp77Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app77/SpringDocApp77Test.java deleted file mode 100644 index af48953bf..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app77/SpringDocApp77Test.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app77; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * The type Spring doc app 77 test. - */ -class SpringDocApp77Test extends AbstractSpringDocTest { - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app78/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app78/HelloController.java deleted file mode 100644 index a7099fc40..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app78/HelloController.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app78; - -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.CompletionStage; - -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RestController; - -/** - * The type Hello controller. - */ -@RestController -class HelloController { - - /** - * Gets person 1. - * - * @param str the str - * @return the person 1 - */ - @RequestMapping(value = "/person1", method = RequestMethod.GET) - private CompletionStage> getPerson1(String str) { - return null; - } - - /** - * Gets person 2. - * - * @param str the str - * @return the person 2 - */ - @RequestMapping(value = "/person2", method = RequestMethod.GET) - private CompletableFuture getPerson2(String str) { - return null; - } - -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app78/PersonDTO.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app78/PersonDTO.java deleted file mode 100644 index ab764145b..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app78/PersonDTO.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app78; - -/** - * The type Person dto. - */ -class PersonDTO { - /** - * The Email. - */ - private String email; - - /** - * The First name. - */ - private String firstName; - - /** - * The Last name. - */ - private String lastName; - - /** - * Instantiates a new Person dto. - */ - public PersonDTO() { - } - - /** - * Instantiates a new Person dto. - * - * @param email the email - * @param firstName the first name - * @param lastName the last name - */ - public PersonDTO(final String email, final String firstName, final String lastName) { - this.email = email; - this.firstName = firstName; - this.lastName = lastName; - } - - /** - * Gets email. - * - * @return the email - */ - public String getEmail() { - return email; - } - - /** - * Sets email. - * - * @param email the email - */ - public void setEmail(final String email) { - this.email = email; - } - - /** - * Gets first name. - * - * @return the first name - */ - public String getFirstName() { - return firstName; - } - - /** - * Sets first name. - * - * @param firstName the first name - */ - public void setFirstName(final String firstName) { - this.firstName = firstName; - } - - /** - * Gets last name. - * - * @return the last name - */ - public String getLastName() { - return lastName; - } - - /** - * Sets last name. - * - * @param lastName the last name - */ - public void setLastName(final String lastName) { - this.lastName = lastName; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app78/SpringDocApp78Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app78/SpringDocApp78Test.java deleted file mode 100644 index e16cd0967..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app78/SpringDocApp78Test.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app78; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * The type Spring doc app 78 test. - */ -class SpringDocApp78Test extends AbstractSpringDocTest { - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app79/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app79/HelloController.java deleted file mode 100644 index fb6f299bd..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app79/HelloController.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app79; - -import java.util.Optional; - -import org.springframework.http.MediaType; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -/** - * The type Hello controller. - */ -@RestController -class HelloController { - - /** - * Echo string. - * - * @param text the text - * @return the string - */ - @GetMapping(produces = MediaType.TEXT_PLAIN_VALUE, path = "/test") - public String echo(@RequestParam Optional text) { - return text.orElse("not-specified"); - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app79/SpringDocApp79Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app79/SpringDocApp79Test.java deleted file mode 100644 index 131461c13..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app79/SpringDocApp79Test.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app79; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - - -/** - * The type Spring doc app 79 test. - */ -class SpringDocApp79Test extends AbstractSpringDocTest { - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app8/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app8/HelloController.java deleted file mode 100644 index bcb51786d..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app8/HelloController.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app8; - -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * The type Hello controller. - */ -@RestController -class HelloController { - - /** - * Test. - * - * @param hello the hello - */ - @GetMapping("/test") - public void test(String hello) { - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app8/SpringDocApp8Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app8/SpringDocApp8Test.java deleted file mode 100644 index 9b42f39b0..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app8/SpringDocApp8Test.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app8; - -import org.junit.jupiter.api.Test; -import org.springdoc.core.utils.Constants; -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; - - -/** - * The type Spring doc app 8 test. - */ -class SpringDocApp8Test extends AbstractSpringDocTest { - - /** - * Test app. - * - * @throws Exception the exception - */ - @Test - protected void testApp() throws Exception { - mockMvc.perform(get("/myapp" + Constants.DEFAULT_API_DOCS_URL).contextPath("/myapp")) - .andExpect(status().isOk()); - } - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app80/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app80/HelloController.java deleted file mode 100644 index d7f13a317..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app80/HelloController.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app80; - -import java.net.URISyntaxException; - -import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RestController; - -/** - * The type Hello controller. - */ -@RestController -@RequestMapping("/api") -class HelloController { - - - /** - * Testpost 1 response entity. - * - * @param dto the dto - * @return the response entity - * @throws URISyntaxException the uri syntax exception - */ - @RequestMapping(value = "/testpost1", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity testpost1(@RequestBody TestObject dto) throws URISyntaxException { - return ResponseEntity.ok(dto); - } - - /** - * Testpost 2 response entity. - * - * @param dto the dto - * @return the response entity - * @throws URISyntaxException the uri syntax exception - */ - @RequestMapping(value = "/testpost2", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity testpost2(@RequestBody TestObject dto) throws URISyntaxException { - return ResponseEntity.ok(dto); - } - - /** - * Hello response entity. - * - * @return the response entity - * @throws URISyntaxException the uri syntax exception - */ - @RequestMapping(value = "/hello", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) - public ResponseEntity hello() throws URISyntaxException { - return ResponseEntity.ok("Hello World"); - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app80/SpringDocApp80Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app80/SpringDocApp80Test.java deleted file mode 100644 index dcb068d88..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app80/SpringDocApp80Test.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app80; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.test.context.ActiveProfiles; - -/** - * The type Spring doc app 80 test. - */ -@ActiveProfiles("80") -class SpringDocApp80Test extends AbstractSpringDocTest { - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app80/TestObject.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app80/TestObject.java deleted file mode 100644 index cc6a2182b..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app80/TestObject.java +++ /dev/null @@ -1,54 +0,0 @@ -package test.org.springdoc.api.app80; - -import java.time.LocalDateTime; - -/** - * The type Test object. - */ -class TestObject { - /** - * The String value. - */ - public String stringValue; - - /** - * The Local date time. - */ - public LocalDateTime localDateTime; - - /** - * Gets string value. - * - * @return the string value - */ - public String getStringValue() { - return stringValue; - } - - /** - * Sets string value. - * - * @param stringValue the string value - */ - public void setStringValue(String stringValue) { - this.stringValue = stringValue; - } - - /** - * Gets local date time. - * - * @return the local date time - */ - public LocalDateTime getLocalDateTime() { - return localDateTime; - } - - /** - * Sets local date time. - * - * @param localDateTime the local date time - */ - public void setLocalDateTime(LocalDateTime localDateTime) { - this.localDateTime = localDateTime; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app81/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app81/HelloController.java deleted file mode 100644 index ddd00b1ac..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app81/HelloController.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app81; - -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * The type Hello controller. - */ -@RestController -@RequestMapping("/api") -class HelloController { - - /** - * Test string. - * - * @return the string - */ - @RequestMapping - public String test() { - return "ok"; - } - -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app81/SpringDocApp81Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app81/SpringDocApp81Test.java deleted file mode 100644 index ac273d741..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app81/SpringDocApp81Test.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app81; - -import org.junit.jupiter.api.Test; -import org.springdoc.core.utils.Constants; -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -import static org.hamcrest.Matchers.containsString; -import static org.hamcrest.Matchers.is; -import static org.hamcrest.Matchers.startsWith; -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; - -/** - * The type Spring doc app 81 test. - */ -class SpringDocApp81Test extends AbstractSpringDocTest { - - /** - * Test app. - * - * @throws Exception the exception - */ - @Test - protected void testApp() throws Exception { - mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL)).andExpect(status().isOk()) - .andExpect(jsonPath("$.openapi", is("3.0.1"))) - .andExpect(jsonPath("$.paths./api.get.tags[0]", containsString("hello-controller"))) - .andExpect(jsonPath("$.paths./api.get.operationId", startsWith("test"))) - .andExpect(jsonPath("$.paths./api.get.responses.200.content.['*/*'].schema.type", is("string"))) - .andExpect(jsonPath("$.paths./api.post.tags[0]", containsString("hello-controller"))) - .andExpect(jsonPath("$.paths./api.post.operationId", startsWith("test"))) - .andExpect(jsonPath("$.paths./api.post.responses.200.content.['*/*'].schema.type", is("string"))) - .andExpect(jsonPath("$.paths./api.put.tags[0]", containsString("hello-controller"))) - .andExpect(jsonPath("$.paths./api.put.operationId", startsWith("test"))) - .andExpect(jsonPath("$.paths./api.put.responses.200.content.['*/*'].schema.type", is("string"))) - .andExpect(jsonPath("$.paths./api.patch.tags[0]", containsString("hello-controller"))) - .andExpect(jsonPath("$.paths./api.patch.operationId", startsWith("test"))) - .andExpect(jsonPath("$.paths./api.patch.responses.200.content.['*/*'].schema.type", is("string"))) - .andExpect(jsonPath("$.paths./api.delete.tags[0]", containsString("hello-controller"))) - .andExpect(jsonPath("$.paths./api.delete.operationId", startsWith("test"))) - .andExpect(jsonPath("$.paths./api.delete.responses.200.content.['*/*'].schema.type", is("string"))) - .andExpect(jsonPath("$.paths./api.options.tags[0]", containsString("hello-controller"))) - .andExpect(jsonPath("$.paths./api.options.operationId", startsWith("test"))) - .andExpect(jsonPath("$.paths./api.options.responses.200.content.['*/*'].schema.type", is("string"))) - .andExpect(jsonPath("$.paths./api.head.tags[0]", containsString("hello-controller"))) - .andExpect(jsonPath("$.paths./api.head.operationId", startsWith("test"))) - .andExpect(jsonPath("$.paths./api.head.responses.200.content.['*/*'].schema.type", is("string"))); - } - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app82/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app82/HelloController.java deleted file mode 100644 index 9e1496699..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app82/HelloController.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app82; - -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * The type Hello controller. - */ -@RestController -class HelloController { - - - /** - * Put response entity. - * - * @param configuration the configuration - * @param second the second - * @param personDTO the person dto - * @return the response entity - */ - @PutMapping(value = "/test") - public ResponseEntity put( - String configuration, - String second, PersonDTO personDTO) { - return null; - } - -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app82/PersonDTO.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app82/PersonDTO.java deleted file mode 100644 index 5cdfbce51..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app82/PersonDTO.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app82; - -/** - * The type Person dto. - */ -class PersonDTO { - /** - * The Email. - */ - private String email; - - /** - * The First name. - */ - private String firstName; - - /** - * The Last name. - */ - private String lastName; - - /** - * Instantiates a new Person dto. - */ - public PersonDTO() { - } - - /** - * Instantiates a new Person dto. - * - * @param email the email - * @param firstName the first name - * @param lastName the last name - */ - public PersonDTO(final String email, final String firstName, final String lastName) { - this.email = email; - this.firstName = firstName; - this.lastName = lastName; - } - - /** - * Gets email. - * - * @return the email - */ - public String getEmail() { - return email; - } - - /** - * Sets email. - * - * @param email the email - */ - public void setEmail(final String email) { - this.email = email; - } - - /** - * Gets first name. - * - * @return the first name - */ - public String getFirstName() { - return firstName; - } - - /** - * Sets first name. - * - * @param firstName the first name - */ - public void setFirstName(final String firstName) { - this.firstName = firstName; - } - - /** - * Gets last name. - * - * @return the last name - */ - public String getLastName() { - return lastName; - } - - /** - * Sets last name. - * - * @param lastName the last name - */ - public void setLastName(final String lastName) { - this.lastName = lastName; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app82/SpringDocApp82Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app82/SpringDocApp82Test.java deleted file mode 100644 index ce42a3b2a..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app82/SpringDocApp82Test.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app82; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * The type Spring doc app 82 test. - */ -class SpringDocApp82Test extends AbstractSpringDocTest { - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app83/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app83/HelloController.java deleted file mode 100644 index df5fd5935..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app83/HelloController.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app83; - -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.media.Schema; - -import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestPart; -import org.springframework.web.bind.annotation.RestController; -import org.springframework.web.multipart.MultipartFile; - -/** - * The type Hello controller. - */ -@RestController -class HelloController { - - - /** - * Put response entity. - * - * @param config the config - * @param configuration the configuration - * @param aFile the a file - * @return the response entity - */ - @RequestMapping(value = "/{config}", - method = RequestMethod.PUT, - consumes = { MediaType.MULTIPART_FORM_DATA_VALUE }, - produces = { MediaType.APPLICATION_JSON_VALUE } - ) - public ResponseEntity put( - @PathVariable("config") final String config, - @Parameter(name = "configuration", schema = @Schema(name = "configuration", type = "string", format = "binary")) @RequestPart(value = "configuration") final PersonDTO configuration, - @RequestPart(value = "file") final MultipartFile aFile) { - return null; - } - -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app83/PersonDTO.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app83/PersonDTO.java deleted file mode 100644 index 82b3d6afc..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app83/PersonDTO.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app83; - -/** - * The type Person dto. - */ -class PersonDTO { - /** - * The Email. - */ - private String email; - - /** - * The First name. - */ - private String firstName; - - /** - * The Last name. - */ - private String lastName; - - /** - * Instantiates a new Person dto. - */ - public PersonDTO() { - } - - /** - * Instantiates a new Person dto. - * - * @param email the email - * @param firstName the first name - * @param lastName the last name - */ - public PersonDTO(final String email, final String firstName, final String lastName) { - this.email = email; - this.firstName = firstName; - this.lastName = lastName; - } - - /** - * Gets email. - * - * @return the email - */ - public String getEmail() { - return email; - } - - /** - * Sets email. - * - * @param email the email - */ - public void setEmail(final String email) { - this.email = email; - } - - /** - * Gets first name. - * - * @return the first name - */ - public String getFirstName() { - return firstName; - } - - /** - * Sets first name. - * - * @param firstName the first name - */ - public void setFirstName(final String firstName) { - this.firstName = firstName; - } - - /** - * Gets last name. - * - * @return the last name - */ - public String getLastName() { - return lastName; - } - - /** - * Sets last name. - * - * @param lastName the last name - */ - public void setLastName(final String lastName) { - this.lastName = lastName; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app83/SpringDocApp83Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app83/SpringDocApp83Test.java deleted file mode 100644 index 8088cb240..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app83/SpringDocApp83Test.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app83; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * The type Spring doc app 83 test. - */ -class SpringDocApp83Test extends AbstractSpringDocTest { - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app84/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app84/HelloController.java deleted file mode 100644 index 1e7476764..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app84/HelloController.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app84; - -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * The type Hello controller. - */ -@RestController -@RequestMapping("/api") -class HelloController { - - /** - * Persons string. - * - * @return the string - */ - @GetMapping("/persons") - public String persons() { - return "OK"; - } - - /** - * Persons string. - * - * @param toto the toto - * @return the string - */ - @GetMapping("/persons1") - public String persons(String toto) { - return "OK"; - } - -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app84/SpringDocApp84Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app84/SpringDocApp84Test.java deleted file mode 100644 index c48dcf3df..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app84/SpringDocApp84Test.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app84; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * The type Spring doc app 84 test. - */ -class SpringDocApp84Test extends AbstractSpringDocTest { - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app85/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app85/HelloController.java deleted file mode 100644 index 8579bcf0a..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app85/HelloController.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app85; - -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; - -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * The type Hello controller. - */ -@RestController -@RequestMapping("/api") -class HelloController { - - /** - * Testme. - * - * @param id the id - */ - @PostMapping("/test/{id}") - @Operation( - parameters = { - @Parameter(ref = "#/components/parameters/paramA"), - @Parameter(ref = "#/components/parameters/paramB") - } - ) - public void testme(@PathVariable("id") String id) { - } -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app85/SpringDocApp85Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app85/SpringDocApp85Test.java deleted file mode 100644 index 7ec0b689b..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app85/SpringDocApp85Test.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app85; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * The type Spring doc app 85 test. - */ -class SpringDocApp85Test extends AbstractSpringDocTest { - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app86/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app86/HelloController.java deleted file mode 100644 index 0a4158c98..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app86/HelloController.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app86; - -import java.util.Locale; - -import jakarta.servlet.http.HttpServletRequest; -import jakarta.servlet.http.HttpServletResponse; -import jakarta.servlet.http.HttpSession; - -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * The type Hello controller. - */ -@RestController -class HelloController { - - /** - * Test. - * - * @param header the header - * @param request the request - * @param response the response - * @param locale the locale - * @param hello the hello - */ - @GetMapping("/test") - public void test(HttpSession header, HttpServletRequest request, HttpServletResponse response, Locale locale, - String hello) { - } - -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app86/SpringDocApp86Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app86/SpringDocApp86Test.java deleted file mode 100644 index a9ab50eb9..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app86/SpringDocApp86Test.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app86; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.test.context.TestPropertySource; - -/** - * The type Spring doc app 86 test. - */ -@TestPropertySource(properties = { - "springdoc.packagesToScan=test.org.springdoc.api.app86", - "springdoc.packagesToExclude=test.org.springdoc.api.app86.test" }) -class SpringDocApp86Test extends AbstractSpringDocTest { - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app86/test/HelloController2.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app86/test/HelloController2.java deleted file mode 100644 index d90c176c3..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app86/test/HelloController2.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app86.test; - -import java.util.Locale; - -import jakarta.servlet.http.HttpServletRequest; -import jakarta.servlet.http.HttpServletResponse; -import jakarta.servlet.http.HttpSession; - -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * The type Hello controller 2. - */ -@RestController -class HelloController2 { - - /** - * Test. - * - * @param header the header - * @param request the request - * @param response the response - * @param locale the locale - * @param hello the hello - */ - @GetMapping("/test2") - public void test(HttpSession header, HttpServletRequest request, HttpServletResponse response, Locale locale, - String hello) { - } - -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app87/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app87/HelloController.java deleted file mode 100644 index 54f05e75a..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app87/HelloController.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app87; - -import java.util.UUID; - -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.parameters.RequestBody; - -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.CookieValue; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.RestController; - - -/** - * The type Hello controller. - */ -@RestController("cookie") -class HelloController { - - /** - * Put item response entity. - * - * @param cookie the cookie - * @param itemId the item id - * @param item the item - * @return the response entity - */ - @PutMapping("/{itemId}") - @Operation - public ResponseEntity putItem( - @CookieValue( - name = "cookie" - ) String cookie, - @PathVariable UUID itemId, - @RequestBody Item item - ) { - return ResponseEntity.ok(item); - } - - /** - * The type Item. - */ - public static class Item { - } -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app87/SpringDocApp87Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app87/SpringDocApp87Test.java deleted file mode 100644 index 4e42c27a7..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app87/SpringDocApp87Test.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app87; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * The type Spring doc app 87 test. - */ -class SpringDocApp87Test extends AbstractSpringDocTest { - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app88/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app88/HelloController.java deleted file mode 100644 index 7f0d0755a..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app88/HelloController.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app88; - -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * The type Hello controller. - */ -@RestController -class HelloController { - - /** - * Persons string. - * - * @return the string - */ - @GetMapping(value = "/persons") - public String persons() { - return null; - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app88/SpringDocApp88Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app88/SpringDocApp88Test.java deleted file mode 100644 index a9a47dc5c..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app88/SpringDocApp88Test.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app88; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.test.context.TestPropertySource; - -/** - * The type Spring doc app 88 test. - */ -@TestPropertySource(properties = "springdoc.auto-tag-classes=false") -class SpringDocApp88Test extends AbstractSpringDocTest { - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app89/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app89/HelloController.java deleted file mode 100644 index 4f882cc2d..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app89/HelloController.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app89; - -import io.swagger.v3.oas.annotations.Operation; - -import org.springframework.http.MediaType; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RestController; -import org.springframework.web.servlet.ModelAndView; - -/** - * The type Hello controller. - */ -@RestController -class HelloController { - - /** - * Gets address. - * - * @param id the id - * @return the address - */ - @Operation(summary = "Get Status") - @GetMapping(value = "/status/{id}", produces = MediaType.TEXT_HTML_VALUE) - public ModelAndView getAddress(@PathVariable String id) { - return null; - } -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app89/SpringDocApp89Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app89/SpringDocApp89Test.java deleted file mode 100644 index cc124b074..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app89/SpringDocApp89Test.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app89; - - -import io.swagger.v3.oas.models.media.ObjectSchema; -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.test.context.TestPropertySource; -import org.springframework.web.servlet.ModelAndView; - -import static org.springdoc.core.utils.SpringDocUtils.getConfig; - -/** - * The type Spring doc app 89 test. - */ -@TestPropertySource(properties = "springdoc.model-and-view-allowed=true") -class SpringDocApp89Test extends AbstractSpringDocTest { - - static { - getConfig().replaceWithSchema(ModelAndView.class, new ObjectSchema()); - } - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app9/MyApi.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app9/MyApi.java deleted file mode 100644 index 2ac9f7a3d..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app9/MyApi.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app9; - -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.enums.ParameterIn; - -import org.springframework.http.HttpHeaders; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestMapping; - -/** - * The interface My api. - */ -@RequestMapping("/myapi") -public interface MyApi { - - /** - * Get string. - * - * @param language the language - * @return the string - */ - @Operation(description = "Annotations from interfaces test") - @GetMapping - String get( - @Parameter(hidden = true, in = ParameterIn.HEADER, name = HttpHeaders.ACCEPT_LANGUAGE) @RequestHeader(value = HttpHeaders.ACCEPT_LANGUAGE, required = false) String language); -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app9/MyApiController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app9/MyApiController.java deleted file mode 100644 index 304ec0fbb..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app9/MyApiController.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app9; - -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; - -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * The type My api controller. - */ -@RestController -class MyApiController implements MyApi { - /** - * Get string. - * - * @param language the language - * @return the string - */ - public String get(String language) { - return language; - } - - - /** - * Gets code. - * - * @param code the code - * @return the code - */ - @Operation(description = "Annotations from class with hidden parameter code") - @GetMapping("/getCode") - public String getCode(@Parameter(hidden = true) String code) { - return code; - } -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app9/SpringDocApp9Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app9/SpringDocApp9Test.java deleted file mode 100644 index 743b3482a..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app9/SpringDocApp9Test.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app9; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * The type Spring doc app 9 test. - */ -class SpringDocApp9Test extends AbstractSpringDocTest { - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app90/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app90/HelloController.java deleted file mode 100644 index ee39766e1..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app90/HelloController.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app90; - -import io.swagger.v3.oas.annotations.media.Content; -import io.swagger.v3.oas.annotations.media.ExampleObject; -import io.swagger.v3.oas.annotations.media.Schema; -import io.swagger.v3.oas.annotations.parameters.RequestBody; -import io.swagger.v3.oas.annotations.responses.ApiResponse; -import io.swagger.v3.oas.annotations.responses.ApiResponses; - -import org.springframework.http.MediaType; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * The type Hello controller. - */ -@RestController -class HelloController { - - /** - * Test 1. - * - * @param hello the hello - */ - @GetMapping("/test") - @ApiResponses(value = { @ApiResponse(description = "successful operation", content = { @Content(examples = @ExampleObject(name = "500", ref = "#/components/examples/http500Example"), mediaType = "application/json", schema = @Schema(implementation = User.class)), @Content(mediaType = "application/xml", schema = @Schema(implementation = User.class)) }) }) - public void test1(String hello) { - } - - /** - * Test 2. - * - * @param hello the hello - */ - @PostMapping("/test2") - @RequestBody( - description = "Details of the Item to be created", - required = true, - content = @Content( - schema = @Schema(implementation = User.class), - mediaType = MediaType.APPLICATION_JSON_VALUE, - examples = { - @ExampleObject( - name = "An example request with the minimum required fields to create.", - value = "min", - summary = "Minimal request"), - @ExampleObject( - name = "An example request with all fields provided with example values.", - value = "full", - summary = "Full request") })) - public void test2(String hello) { - } - -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app90/SpringDocApp90Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app90/SpringDocApp90Test.java deleted file mode 100644 index 08ea75648..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app90/SpringDocApp90Test.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app90; - - -import test.org.springdoc.api.AbstractSpringDocTest; - -/** - * The type Spring doc app 90 test. - */ -class SpringDocApp90Test extends AbstractSpringDocTest { - -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app90/SpringDocTestApp.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app90/SpringDocTestApp.java deleted file mode 100644 index 36dc05d61..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app90/SpringDocTestApp.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app90; - -import java.io.IOException; -import java.io.InputStreamReader; -import java.io.Reader; -import java.io.UncheckedIOException; -import java.util.AbstractMap; -import java.util.Collection; -import java.util.Map.Entry; - -import io.swagger.v3.oas.models.examples.Example; -import org.springdoc.core.customizers.OpenApiCustomizer; - -import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.Bean; -import org.springframework.core.io.Resource; -import org.springframework.util.FileCopyUtils; - -/** - * The type Spring doc test app. - */ -@SpringBootApplication -class SpringDocTestApp { - - /** - * The Http 500 example resource. - */ - @Value("classpath:/500-90.txt") - private Resource http500ExampleResource; - - /** - * As string string. - * - * @param resource the resource - * @return the string - */ - public static String asString(Resource resource) { - try (Reader reader = new InputStreamReader(resource.getInputStream())) { - return FileCopyUtils.copyToString(reader); - } - catch (IOException e) { - throw new UncheckedIOException(e); - } - } - - /** - * Open api customiser open api customiser. - * - * @param examples the examples - * @return the open api customiser - */ - @Bean - public OpenApiCustomizer openApiCustomizer(Collection> examples) { - return openAPI -> { - examples.forEach(example -> { - openAPI.getComponents().addExamples(example.getKey(), example.getValue()); - }); - }; - } - - /** - * Http 500 example entry. - * - * @return the entry - */ - @Bean - public Entry http500Example() { - Example http500Example = new Example(); - Entry entry = new AbstractMap.SimpleEntry("http500Example", http500Example); - http500Example.setSummary("HTTP 500 JSON Body response example"); - http500Example.setDescription( - "An example of HTTP response in case an error occurs on server side. instance attribute reference a traceId to ease server side analysis."); - http500Example.setValue(asString(http500ExampleResource)); - return entry; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app90/User.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app90/User.java deleted file mode 100644 index 49a51389f..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app90/User.java +++ /dev/null @@ -1,440 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app90; - -import java.util.Objects; - -import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.v3.oas.annotations.media.Schema; - -/** - * User - */ -@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen", date = "2019-11-30T09:49:26.034469-01:00[Atlantic/Azores]") - - -class User { - - /** - * The Id. - */ - @JsonProperty("id") - - private Long id; - - - /** - * The Username. - */ - @JsonProperty("username") - - private String username; - - - /** - * The First name. - */ - @JsonProperty("firstName") - - private String firstName; - - - /** - * The Last name. - */ - @JsonProperty("lastName") - - private String lastName; - - - /** - * The Email. - */ - @JsonProperty("email") - - private String email; - - - /** - * The Password. - */ - @JsonProperty("password") - - private String password; - - - /** - * The Phone. - */ - @JsonProperty("phone") - - private String phone; - - - /** - * The User status. - */ - @JsonProperty("userStatus") - - private Integer userStatus; - - - /** - * Id user. - * - * @param id the id - * @return the user - */ - public User id(Long id) { - this.id = id; - return this; - } - - - /** - * Get id - * - * @return id id - */ - @Schema(example = "10", description = "") - - - public Long getId() { - return id; - } - - /** - * Sets id. - * - * @param id the id - */ - public void setId(Long id) { - this.id = id; - } - - - /** - * Username user. - * - * @param username the username - * @return the user - */ - public User username(String username) { - this.username = username; - return this; - } - - - /** - * Get username - * - * @return username username - */ - @Schema(example = "theUser", description = "") - - - public String getUsername() { - return username; - } - - /** - * Sets username. - * - * @param username the username - */ - public void setUsername(String username) { - this.username = username; - } - - - /** - * First name user. - * - * @param firstName the first name - * @return the user - */ - public User firstName(String firstName) { - this.firstName = firstName; - return this; - } - - - /** - * Get firstName - * - * @return firstName first name - */ - @Schema(example = "John", description = "") - - - public String getFirstName() { - return firstName; - } - - /** - * Sets first name. - * - * @param firstName the first name - */ - public void setFirstName(String firstName) { - this.firstName = firstName; - } - - - /** - * Last name user. - * - * @param lastName the last name - * @return the user - */ - public User lastName(String lastName) { - this.lastName = lastName; - return this; - } - - - /** - * Get lastName - * - * @return lastName last name - */ - @Schema(example = "James", description = "") - - - public String getLastName() { - return lastName; - } - - /** - * Sets last name. - * - * @param lastName the last name - */ - public void setLastName(String lastName) { - this.lastName = lastName; - } - - - /** - * Email user. - * - * @param email the email - * @return the user - */ - public User email(String email) { - this.email = email; - return this; - } - - - /** - * Get email - * - * @return email email - */ - @Schema(example = "john@email.com", description = "") - - - public String getEmail() { - return email; - } - - /** - * Sets email. - * - * @param email the email - */ - public void setEmail(String email) { - this.email = email; - } - - - /** - * Password user. - * - * @param password the password - * @return the user - */ - public User password(String password) { - this.password = password; - return this; - } - - - /** - * Get password - * - * @return password password - */ - @Schema(example = "12345", description = "") - - - public String getPassword() { - return password; - } - - /** - * Sets password. - * - * @param password the password - */ - public void setPassword(String password) { - this.password = password; - } - - - /** - * Phone user. - * - * @param phone the phone - * @return the user - */ - public User phone(String phone) { - this.phone = phone; - return this; - } - - - /** - * Get phone - * - * @return phone phone - */ - @Schema(example = "12345", description = "") - - - public String getPhone() { - return phone; - } - - /** - * Sets phone. - * - * @param phone the phone - */ - public void setPhone(String phone) { - this.phone = phone; - } - - - /** - * User status user. - * - * @param userStatus the user status - * @return the user - */ - public User userStatus(Integer userStatus) { - this.userStatus = userStatus; - return this; - } - - - /** - * User Status - * - * @return userStatus user status - */ - @Schema(example = "1", description = "User Status") - - - public Integer getUserStatus() { - return userStatus; - } - - /** - * Sets user status. - * - * @param userStatus the user status - */ - public void setUserStatus(Integer userStatus) { - this.userStatus = userStatus; - } - - - /** - * Equals boolean. - * - * @param o the o - * @return the boolean - */ - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - User user = (User) o; - return Objects.equals(this.id, user.id) && - Objects.equals(this.username, user.username) && - Objects.equals(this.firstName, user.firstName) && - Objects.equals(this.lastName, user.lastName) && - Objects.equals(this.email, user.email) && - Objects.equals(this.password, user.password) && - Objects.equals(this.phone, user.phone) && - Objects.equals(this.userStatus, user.userStatus); - } - - /** - * Hash code int. - * - * @return the int - */ - @Override - public int hashCode() { - return Objects.hash(id, username, firstName, lastName, email, password, phone, userStatus); - } - - /** - * To string string. - * - * @return the string - */ - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class User {\n"); - - sb.append(" id: ").append(toIndentedString(id)).append("\n"); - sb.append(" username: ").append(toIndentedString(username)).append("\n"); - sb.append(" firstName: ").append(toIndentedString(firstName)).append("\n"); - sb.append(" lastName: ").append(toIndentedString(lastName)).append("\n"); - sb.append(" email: ").append(toIndentedString(email)).append("\n"); - sb.append(" password: ").append(toIndentedString(password)).append("\n"); - sb.append(" phone: ").append(toIndentedString(phone)).append("\n"); - sb.append(" userStatus: ").append(toIndentedString(userStatus)).append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces - * (except the first line). - * @param o the o - * @return the string - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } -} - diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app91/Advice.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app91/Advice.java deleted file mode 100644 index fb5baf5cc..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app91/Advice.java +++ /dev/null @@ -1,84 +0,0 @@ -package test.org.springdoc.api.app91; - -import io.swagger.v3.oas.annotations.media.Content; -import io.swagger.v3.oas.annotations.media.ExampleObject; -import io.swagger.v3.oas.annotations.media.Schema; -import io.swagger.v3.oas.annotations.responses.ApiResponse; -import jakarta.servlet.http.HttpServletRequest; - -import org.springframework.beans.TypeMismatchException; -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.ExceptionHandler; -import org.springframework.web.bind.annotation.ResponseStatus; -import org.springframework.web.bind.annotation.RestControllerAdvice; - -/** - * The type Advice. - */ -@RestControllerAdvice -class Advice { - - /** - * Bad request response entity. - * - * @param req the req - * @param exception the exception - * @return the response entity - */ - @ExceptionHandler(TypeMismatchException.class) - @ResponseStatus(HttpStatus.BAD_REQUEST) - @ApiResponse( - responseCode = "400", - description = "Bad Request", - content = - @Content( - mediaType = MediaType.APPLICATION_JSON_VALUE, - schema = @Schema(implementation = ApiError.class), - examples = { - @ExampleObject( - name = "Service-400", - summary = "400 from the service directly", - value = - "{\"status\": 400," - + "\"errorCode\": \"ERROR_001\"," - + "\"message\": \"An example message...\"" - + "}") - })) - public ResponseEntity badRequest(HttpServletRequest req, Exception exception) { - ApiError erroObj = new ApiError(400, "A code", "A message"); - return new ResponseEntity<>(erroObj, HttpStatus.BAD_REQUEST); - } - - /** - * Internal server error response entity. - * - * @param req the req - * @param exception the exception - * @return the response entity - */ - @ExceptionHandler(Exception.class) - @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR) - @ApiResponse( - responseCode = "500", - description = "Internal Server Error", - content = - @Content( - mediaType = MediaType.APPLICATION_JSON_VALUE, - schema = @Schema(implementation = ApiError.class), - examples = { - @ExampleObject( - name = "Service-500", - summary = "500 from the service directly", - value = - "{\"status\": 500," - + "\"errorCode\": \"ERROR_002\"," - + "\"message\": \"Another example message...\"" - + "}") - })) - public ResponseEntity internalServerError(HttpServletRequest req, Exception exception) { - ApiError erroObj = new ApiError(500, "A different code", "A different message"); - return new ResponseEntity<>(erroObj, HttpStatus.INTERNAL_SERVER_ERROR); - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app91/ApiError.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app91/ApiError.java deleted file mode 100644 index 4cf6bdcb3..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app91/ApiError.java +++ /dev/null @@ -1,53 +0,0 @@ -package test.org.springdoc.api.app91; - -import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.v3.oas.annotations.media.Schema; - -/** - * The type Api error. - */ -@Schema( - type = "object", - name = "ApiError", - title = "ApiError", - description = "A consistent response object for sending errors over the wire.") -class ApiError { - - /** - * The Status. - */ - @Schema(name = "status", description = "The Http Status value", type = "int", nullable = true) - @JsonProperty("status") - private int status; - - /** - * The Error code. - */ - @Schema( - name = "errorCode", - description = "An Error Code which can help with identifying issues.", - type = "string", - nullable = true) - @JsonProperty("errorCode") - private String errorCode; - - /** - * The Message. - */ - @Schema(name = "message", description = "The Error Message.", type = "string", nullable = false) - @JsonProperty("message") - private String message; - - /** - * Instantiates a new Api error. - * - * @param status the status - * @param errorCode the error code - * @param message the message - */ - public ApiError(int status, String errorCode, String message) { - this.status = status; - this.errorCode = errorCode; - this.message = message; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app91/Greeting.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app91/Greeting.java deleted file mode 100644 index fb37663f6..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app91/Greeting.java +++ /dev/null @@ -1,37 +0,0 @@ -package test.org.springdoc.api.app91; - -import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.v3.oas.annotations.media.Schema; - -/** - * The type Greeting. - */ -@Schema( - type = "object", - name = "Greeting", - title = "Greeting", - description = "An object containing a greeting message") -class Greeting { - - - /** - * The Payload. - */ - @Schema( - name = "payload", - description = "The greeting value", - type = "string", - nullable = false, - example = "sdfsdfs") - @JsonProperty("payload") - private String payload; - - /** - * Instantiates a new Greeting. - * - * @param payload the payload - */ - public Greeting(String payload) { - this.payload = payload; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app91/GreetingController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app91/GreetingController.java deleted file mode 100644 index edb144c15..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app91/GreetingController.java +++ /dev/null @@ -1,46 +0,0 @@ -package test.org.springdoc.api.app91; - -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.responses.ApiResponse; -import io.swagger.v3.oas.annotations.responses.ApiResponses; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.apache.commons.lang3.RandomStringUtils; - -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE; - -/** - * The type Greeting controller. - */ -@RestController -@Tag(name = "Demo", description = "The Demo API") -class GreetingController { - - /** - * Say hello response entity. - * - * @return the response entity - */ - @GetMapping(produces = APPLICATION_JSON_VALUE) - @Operation(summary = "This API will return a random greeting.") - public ResponseEntity sayHello() { - return ResponseEntity.ok(new Greeting(RandomStringUtils.randomAlphanumeric(10))); - } - - /** - * Say hello 2 response entity. - * - * @return the response entity - */ - @GetMapping("/test") - @ApiResponses(value = { @ApiResponse(responseCode = "201", description = "item created"), - @ApiResponse(responseCode = "400", description = "invalid input, object invalid"), - @ApiResponse(responseCode = "409", description = "an existing item already exists") }) - public ResponseEntity sayHello2() { - return ResponseEntity.ok(new Greeting(RandomStringUtils.randomAlphanumeric(10))); - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app91/SpringDocApp91Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app91/SpringDocApp91Test.java deleted file mode 100644 index 23a390257..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app91/SpringDocApp91Test.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app91; - - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.test.context.TestPropertySource; - -/** - * The type Spring doc app 91 test. - */ -@TestPropertySource(properties = "springdoc.override-with-generic-response=false") -class SpringDocApp91Test extends AbstractSpringDocTest { - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} - -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app92/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app92/HelloController.java deleted file mode 100644 index 5c9ce3272..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app92/HelloController.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app92; - -import jakarta.validation.constraints.NotNull; - -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * The type Hello controller. - */ -@RestController -@RequestMapping("/test") -class HelloController { - - /** - * Index string. - * - * @param test the test - * @return the string - */ - @GetMapping - String index(@NotNull String test) { - return null; - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app92/ParameterCustomizer.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app92/ParameterCustomizer.java deleted file mode 100644 index 351251c49..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app92/ParameterCustomizer.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app92; - -import io.swagger.v3.oas.models.parameters.Parameter; -import jakarta.validation.constraints.NotNull; - -import org.springframework.core.MethodParameter; -import org.springframework.stereotype.Component; - -/** - * The type Parameter customizer. - */ -@Component -class ParameterCustomizer implements org.springdoc.core.customizers.ParameterCustomizer { - /** - * Customize parameter. - * - * @param parameterModel the parameter model - * @param methodParameter the method parameter - * @return the parameter - */ - @Override - public Parameter customize(Parameter parameterModel, MethodParameter methodParameter) { - NotNull annotation = methodParameter.getParameterAnnotation(NotNull.class); - if (annotation != null) { - parameterModel.required(false); - } - return parameterModel; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app92/SpringDocApp92Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app92/SpringDocApp92Test.java deleted file mode 100644 index dbfbf1657..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app92/SpringDocApp92Test.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app92; - - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * The type Spring doc app 92 test. - */ -class SpringDocApp92Test extends AbstractSpringDocTest { - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} - -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app93/BaseClientModel.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app93/BaseClientModel.java deleted file mode 100644 index 22be1373e..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app93/BaseClientModel.java +++ /dev/null @@ -1,14 +0,0 @@ -package test.org.springdoc.api.app93; - -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * The type Base client model. - */ -public abstract class BaseClientModel { - /** - * The Id. - */ - @JsonProperty("id") - int id; -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app93/BaseController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app93/BaseController.java deleted file mode 100644 index bb0b57e46..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app93/BaseController.java +++ /dev/null @@ -1,24 +0,0 @@ -package test.org.springdoc.api.app93; - -import io.swagger.v3.oas.annotations.Operation; - -import org.springframework.web.bind.annotation.GetMapping; - -/** - * The type Base controller. - * - * @param the type parameter - */ -public abstract class BaseController { - /** - * Get t client model. - * - * @param param the param - * @return the t client model - */ - @Operation - @GetMapping - TClientModel get(TClientModel param) { - return null; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app93/SpecificClientModel.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app93/SpecificClientModel.java deleted file mode 100644 index 591bc5804..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app93/SpecificClientModel.java +++ /dev/null @@ -1,14 +0,0 @@ -package test.org.springdoc.api.app93; - -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * The type Specific client model. - */ -class SpecificClientModel extends BaseClientModel { - /** - * The Name. - */ - @JsonProperty("name") - String name; -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app93/SpecificController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app93/SpecificController.java deleted file mode 100644 index 8c45f0910..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app93/SpecificController.java +++ /dev/null @@ -1,9 +0,0 @@ -package test.org.springdoc.api.app93; - -import org.springframework.web.bind.annotation.RestController; - -/** - * The type Specific controller. - */ -@RestController -class SpecificController extends BaseController {} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app93/SpringDocApp93Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app93/SpringDocApp93Test.java deleted file mode 100644 index 40f48fb16..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app93/SpringDocApp93Test.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app93; - - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * The type Spring doc app 93 test. - */ -class SpringDocApp93Test extends AbstractSpringDocTest { - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} - -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app94/Greeting.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app94/Greeting.java deleted file mode 100644 index 1cfca3a7a..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app94/Greeting.java +++ /dev/null @@ -1,37 +0,0 @@ -package test.org.springdoc.api.app94; - -import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.v3.oas.annotations.media.Schema; - -/** - * The type Greeting. - */ -@Schema( - type = "object", - name = "Greeting", - title = "Greeting", - description = "An object containing a greeting message") -class Greeting { - - - /** - * The Payload. - */ - @Schema( - name = "payload", - description = "The greeting value", - type = "string", - nullable = false, - example = "sdfsdfs") - @JsonProperty("payload") - private String payload; - - /** - * Instantiates a new Greeting. - * - * @param payload the payload - */ - public Greeting(String payload) { - this.payload = payload; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app94/SpringDocApp94Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app94/SpringDocApp94Test.java deleted file mode 100644 index dad845771..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app94/SpringDocApp94Test.java +++ /dev/null @@ -1,178 +0,0 @@ -package test.org.springdoc.api.app94; - -/* - * - * * Copyright 2019-2020 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. - * - */ - -import java.util.Collections; - -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.responses.ApiResponse; -import io.swagger.v3.oas.annotations.responses.ApiResponses; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.apache.commons.lang3.RandomStringUtils; -import org.springdoc.core.customizers.OpenApiBuilderCustomizer; -import org.springdoc.core.customizers.SpringDocCustomizers; -import org.springdoc.core.properties.SpringDocConfigProperties; -import org.springdoc.core.providers.SpringDocProviders; -import org.springdoc.core.service.AbstractRequestService; -import org.springdoc.core.service.GenericResponseService; -import org.springdoc.core.service.OpenAPIService; -import org.springdoc.core.service.OperationService; -import org.springdoc.webmvc.api.OpenApiWebMvcResource; -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.beans.BeansException; -import org.springframework.beans.factory.ObjectFactory; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.ApplicationContext; -import org.springframework.context.ApplicationContextAware; -import org.springframework.context.annotation.Bean; -import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; -import org.springframework.test.context.TestPropertySource; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.ResponseBody; -import org.springframework.web.servlet.mvc.method.RequestMappingInfo; -import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping; - -import static org.springdoc.core.utils.Constants.DEFAULT_GROUP_NAME; -import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE; - -/** - * The type Spring doc app 94 test. - */ -@TestPropertySource(properties = "springdoc.default-produces-media-type=application/json") -class SpringDocApp94Test extends AbstractSpringDocTest { - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp implements ApplicationContextAware { - - /** - * The Application context. - */ - private ApplicationContext applicationContext; - - /** - * Greeting controller greeting controller. - * - * @return the greeting controller - */ - @Bean - public GreetingController greetingController() { - return new GreetingController(); - } - - /** - * Custom open api open api builder customizer. - * - * @return the open api builder customizer - */ - @Bean - public OpenApiBuilderCustomizer customOpenAPI() { - return openApiBuilder -> openApiBuilder.addMappings(Collections.singletonMap("greetingController", new GreetingController())); - } - - /** - * Default test handler mapping request mapping handler mapping. - * - * @param greetingController the greeting controller - * @return the request mapping handler mapping - * @throws NoSuchMethodException the no such method exception - */ - @Bean - public RequestMappingHandlerMapping defaultTestHandlerMapping(GreetingController greetingController) throws NoSuchMethodException { - RequestMappingHandlerMapping result = new RequestMappingHandlerMapping(); - RequestMappingInfo requestMappingInfo = - RequestMappingInfo.paths("/test").methods(RequestMethod.GET).produces(MediaType.APPLICATION_JSON_VALUE).build(); - - result.setApplicationContext(this.applicationContext); - result.registerMapping(requestMappingInfo, "greetingController", GreetingController.class.getDeclaredMethod("sayHello2")); - //result.handlerme - return result; - } - - /** - * Open api resource open api web mvc resource. - * - * @param openAPIBuilderObjectFactory the open api builder object factory - * @param requestBuilder the request builder - * @param responseBuilder the response builder - * @param operationParser the operation parser - * @param springDocConfigProperties the spring doc config properties - * @param springDocProviders the spring doc providers - * @param springDocCustomizers the spring doc customizers - * @return the open api web mvc resource - */ - @Bean(name = "openApiResource") - public OpenApiWebMvcResource openApiResource(ObjectFactory openAPIBuilderObjectFactory, AbstractRequestService requestBuilder, GenericResponseService responseBuilder, - OperationService operationParser, - SpringDocConfigProperties springDocConfigProperties, - SpringDocProviders springDocProviders, SpringDocCustomizers springDocCustomizers) { - return new OpenApiWebMvcResource(DEFAULT_GROUP_NAME, openAPIBuilderObjectFactory, requestBuilder, responseBuilder, operationParser, - springDocConfigProperties, springDocProviders, springDocCustomizers); - } - - /** - * Sets application context. - * - * @param applicationContext the application context - * @throws BeansException the beans exception - */ - @Override - public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { - this.applicationContext = applicationContext; - } - } - - /** - * The type Greeting controller. - */ - @ResponseBody - @Tag(name = "Demo", description = "The Demo API") - public static class GreetingController { - - /** - * Say hello response entity. - * - * @return the response entity - */ - @GetMapping(produces = APPLICATION_JSON_VALUE) - @Operation(summary = "This API will return a random greeting.") - public ResponseEntity sayHello() { - return ResponseEntity.ok(new Greeting(RandomStringUtils.randomAlphanumeric(10))); - } - - /** - * Say hello 2 response entity. - * - * @return the response entity - */ - @GetMapping("/test") - @ApiResponses(value = { @ApiResponse(responseCode = "201", description = "item created"), - @ApiResponse(responseCode = "400", description = "invalid input, object invalid"), - @ApiResponse(responseCode = "409", description = "an existing item already exists") }) - public ResponseEntity sayHello2() { - return ResponseEntity.ok(new Greeting(RandomStringUtils.randomAlphanumeric(10))); - } - - } -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app95/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app95/HelloController.java deleted file mode 100644 index 9e6bc3a9b..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app95/HelloController.java +++ /dev/null @@ -1,29 +0,0 @@ -package test.org.springdoc.api.app95; - -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; - -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * The type Hello controller. - */ -@RestController -@RequestMapping("/persons") -class HelloController { - - /** - * Persons. - * - * @param name the name - */ - @GetMapping - @Operation(summary = "${test.app95.operation.persons.summary}", - description = "${test.app95.operation.persons.description}") - public void persons(@Parameter(description = "${test.app95.param.name.description}") String name) { - - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app95/SpringDocApp95Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app95/SpringDocApp95Test.java deleted file mode 100644 index 8f197c9c9..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app95/SpringDocApp95Test.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app95; - - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.test.context.ActiveProfiles; - -/** - * The type Spring doc app 95 test. - */ -@ActiveProfiles("95") -class SpringDocApp95Test extends AbstractSpringDocTest { - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} - -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app96/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app96/HelloController.java deleted file mode 100644 index 25c658079..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app96/HelloController.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app96; - -import jakarta.validation.constraints.Min; -import jakarta.validation.constraints.NotNull; - -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RestController; - -/** - * The type Hello controller. - */ -@RestController -class HelloController { - - - /** - * Test 1 string. - * - * @param test the test - * @return the string - */ - @PostMapping("/api1") - String test1(@RequestBody @Min(2) int test) { - return null; - } - - /** - * Test 2 string. - * - * @param test the test - * @return the string - */ - @PostMapping("/api2") - String test2(@RequestBody String test) { - return null; - } - - /** - * Test 3 string. - * - * @param test the test - * @return the string - */ - @PostMapping("/api3") - String test3(@NotNull String test) { - return null; - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app96/SpringDocApp96Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app96/SpringDocApp96Test.java deleted file mode 100644 index eb13e5e75..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app96/SpringDocApp96Test.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app96; - - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * The type Spring doc app 96 test. - */ -class SpringDocApp96Test extends AbstractSpringDocTest { - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} - -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app97/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app97/HelloController.java deleted file mode 100644 index 65986b5e0..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app97/HelloController.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app97; - -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * The type Hello controller. - */ -@RestController -@RequestMapping("/api") -class HelloController { - - /** - * Header v 1 student v 1. - * - * @return the student v 1 - */ - @GetMapping(value = "/student/header1", headers = "X-API-VERSION=1") - public StudentV1 headerV1() { - return new StudentV1("Bob Charlie"); - } - - /** - * Header v 2 student v 2. - * - * @return the student v 2 - */ - @GetMapping(value = "/student/header2", headers = "X-API-VERSION=2") - public StudentV2 headerV2() { - return new StudentV2("Charlie"); - } - - /** - * Header v 3 student v 3. - * - * @return the student v 3 - */ - @GetMapping(value = "/student/header3", headers = "X-API-VERSION") - public StudentV3 headerV3() { - return new StudentV3("Tom Charlie"); - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app97/SpringDocApp97Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app97/SpringDocApp97Test.java deleted file mode 100644 index 1340c442d..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app97/SpringDocApp97Test.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app97; - - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * The type Spring doc app 97 test. - */ -class SpringDocApp97Test extends AbstractSpringDocTest { - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} - -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app97/StudentV1.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app97/StudentV1.java deleted file mode 100644 index 5a6a5ae2d..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app97/StudentV1.java +++ /dev/null @@ -1,24 +0,0 @@ -package test.org.springdoc.api.app97; - -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * The type Student v 1. - */ -class StudentV1 { - - /** - * The Name. - */ - @JsonProperty("name") - private String name; - - /** - * Instantiates a new Student v 1. - * - * @param name the name - */ - public StudentV1(String name) { - this.name = name; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app97/StudentV2.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app97/StudentV2.java deleted file mode 100644 index e76f0cb46..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app97/StudentV2.java +++ /dev/null @@ -1,24 +0,0 @@ -package test.org.springdoc.api.app97; - -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * The type Student v 2. - */ -class StudentV2 { - - /** - * The Name. - */ - @JsonProperty("bb") - private String name; - - /** - * Instantiates a new Student v 2. - * - * @param name the name - */ - public StudentV2(String name) { - this.name = name; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app97/StudentV3.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app97/StudentV3.java deleted file mode 100644 index 9907b8544..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app97/StudentV3.java +++ /dev/null @@ -1,24 +0,0 @@ -package test.org.springdoc.api.app97; - -import com.fasterxml.jackson.annotation.JsonProperty; - -/** - * The type Student v 3. - */ -class StudentV3 { - - /** - * The Name. - */ - @JsonProperty("name") - private String name; - - /** - * Instantiates a new Student v 3. - * - * @param name the name - */ - public StudentV3(String name) { - this.name = name; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app98/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app98/HelloController.java deleted file mode 100644 index b5becd942..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app98/HelloController.java +++ /dev/null @@ -1,22 +0,0 @@ -package test.org.springdoc.api.app98; - -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * The type Hello controller. - */ -@RestController -class HelloController { - - /** - * Persons. - * - * @param name the name - */ - @GetMapping("/persons") - public void persons(@IgnoredAnnotationParameter String name) { - - } - -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app98/IgnoredAnnotationParameter.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app98/IgnoredAnnotationParameter.java deleted file mode 100644 index 5e53ba7de..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app98/IgnoredAnnotationParameter.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app98; - -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; - -/** - * The interface Ignored annotation parameter. - */ -@Retention(RetentionPolicy.RUNTIME) -public @interface IgnoredAnnotationParameter { - /** - * Addition string. - * - * @return the string - */ - String addition() default "customized parameter!"; -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app98/SpringDocApp98Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app98/SpringDocApp98Test.java deleted file mode 100644 index cacfce2ac..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app98/SpringDocApp98Test.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app98; - - -import org.springdoc.core.utils.SpringDocUtils; -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -/** - * The type Spring doc app 98 test. - */ -class SpringDocApp98Test extends AbstractSpringDocTest { - - static { - SpringDocUtils.getConfig().addAnnotationsToIgnore(IgnoredAnnotationParameter.class); - } - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app99/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app99/HelloController.java deleted file mode 100644 index 5980368b2..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app99/HelloController.java +++ /dev/null @@ -1,28 +0,0 @@ -package test.org.springdoc.api.app99; - -import io.swagger.v3.oas.annotations.responses.ApiResponse; -import io.swagger.v3.oas.annotations.responses.ApiResponses; - -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * The type Hello controller. - */ -@RestController -@RequestMapping("/persons") -class HelloController { - - /** - * Persons. - */ - @GetMapping - @ApiResponses({ - @ApiResponse(responseCode = "202", description = "${test.app99.operation.persons.response.202.description}") - }) - public void persons() { - - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app99/SpringDocApp99Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app99/SpringDocApp99Test.java deleted file mode 100644 index f7639bf8a..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/app99/SpringDocApp99Test.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app99; - - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.test.context.ActiveProfiles; - -/** - * The type Spring doc app 99 test. - */ -@ActiveProfiles("99") -class SpringDocApp99Test extends AbstractSpringDocTest { - - /** - * The type Spring doc test app. - */ - @SpringBootApplication - static class SpringDocTestApp {} - -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/AbstractSpringDocTest.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/AbstractSpringDocTest.java new file mode 100644 index 000000000..4c3990c94 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/AbstractSpringDocTest.java @@ -0,0 +1,104 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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; + +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; + +import org.junit.jupiter.api.Test; +import org.springdoc.core.utils.Constants; + +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.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; + +/** + * The type Abstract spring doc test. + */ +@ActiveProfiles("test") +@SpringBootTest +@AutoConfigureMockMvc +@TestPropertySource(properties = "springdoc.api-docs.version=openapi_3_0" ) +public abstract class AbstractSpringDocTest { + + /** + * The constant className. + */ + public static String className; + + /** + * The Mock mvc. + */ + @Autowired + protected MockMvc mockMvc; + + /** + * Gets content. + * + * @param fileName the file name + * @return the content + * @throws Exception the exception + */ + public static String getContent(String fileName) throws Exception { + try { + Path path = Paths.get(AbstractSpringDocTest.class.getClassLoader().getResource(fileName).toURI()); + byte[] fileBytes = Files.readAllBytes(path); + return new String(fileBytes, StandardCharsets.UTF_8); + } + catch (Exception e) { + throw new RuntimeException("Failed to read file: " + fileName, e); + } + } + + /** + * Test app. + * + * @throws Exception the exception + */ + @Test + protected void testApp() throws Exception { + className = getClass().getSimpleName(); + String testNumber = className.replaceAll("[^0-9]", ""); + MvcResult mockMvcResult = mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL)).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 + ".json"); + assertEquals(expected, result, true); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app1/ApiException.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app1/ApiException.java new file mode 100644 index 000000000..0145e3e9d --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app1/ApiException.java @@ -0,0 +1,56 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app1; + +/** + * The type Api exception. + */ +public final class ApiException extends Exception { + + /** + * The constant serialVersionUID. + */ + private static final long serialVersionUID = 1L; + + /** + * The Code. + */ + @SuppressWarnings("unused") + + private final int code; + + /** + * Instantiates a new Api exception. + * + * @param code the code + * @param msg the msg + */ + public ApiException(int code, String msg) { + super(msg); + this.code = code; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app1/ApiOriginFilter.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app1/ApiOriginFilter.java new file mode 100644 index 000000000..cd5a1f1f2 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app1/ApiOriginFilter.java @@ -0,0 +1,77 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app1; + +import java.io.IOException; + +import jakarta.servlet.FilterChain; +import jakarta.servlet.FilterConfig; +import jakarta.servlet.ServletException; +import jakarta.servlet.ServletRequest; +import jakarta.servlet.ServletResponse; +import jakarta.servlet.http.HttpServletResponse; + +/** + * The type Api origin filter. + */ +class ApiOriginFilter implements jakarta.servlet.Filter { + /** + * Do filter. + * + * @param request the request + * @param response the response + * @param chain the chain + * @throws IOException the io exception + * @throws ServletException the servlet exception + */ + @Override + public void doFilter(ServletRequest request, ServletResponse response, + FilterChain chain) throws IOException, ServletException { + HttpServletResponse res = (HttpServletResponse) response; + res.addHeader("Access-Control-Allow-Origin", "*"); + res.addHeader("Access-Control-Allow-Methods", "GET, POST, DELETE, PUT"); + res.addHeader("Access-Control-Allow-Headers", "Content-Type"); + chain.doFilter(request, response); + } + + /** + * Destroy. + */ + @Override + public void destroy() { + } + + /** + * Init. + * + * @param filterConfig the filter config + * @throws ServletException the servlet exception + */ + @Override + public void init(FilterConfig filterConfig) throws ServletException { + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app1/ApiResponseMessage.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app1/ApiResponseMessage.java new file mode 100644 index 000000000..e1d3d09e6 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app1/ApiResponseMessage.java @@ -0,0 +1,168 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app1; + +import jakarta.xml.bind.annotation.XmlTransient; + +/** + * The type Api response message. + */ +@jakarta.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2019-07-08T09:37:36.546Z[GMT]") +@jakarta.xml.bind.annotation.XmlRootElement +class ApiResponseMessage { + /** + * The constant ERROR. + */ + public static final int ERROR = 1; + + /** + * The constant WARNING. + */ + public static final int WARNING = 2; + + /** + * The constant INFO. + */ + public static final int INFO = 3; + + /** + * The constant OK. + */ + public static final int OK = 4; + + /** + * The constant TOO_BUSY. + */ + public static final int TOO_BUSY = 5; + + /** + * The Code. + */ + int code; + + /** + * The Type. + */ + String type; + + /** + * The Message. + */ + String message; + + /** + * Instantiates a new Api response message. + */ + public ApiResponseMessage() { + } + + /** + * Instantiates a new Api response message. + * + * @param code the code + * @param message the message + */ + public ApiResponseMessage(int code, String message) { + this.code = code; + switch (code) { + case ERROR: + setType("error"); + break; + case WARNING: + setType("warning"); + break; + case INFO: + setType("info"); + break; + case OK: + setType("ok"); + break; + case TOO_BUSY: + setType("too busy"); + break; + default: + setType("unknown"); + break; + } + this.message = message; + } + + /** + * Gets code. + * + * @return the code + */ + @XmlTransient + public int getCode() { + return code; + } + + /** + * Sets code. + * + * @param code the code + */ + public void setCode(int code) { + this.code = code; + } + + /** + * Gets type. + * + * @return the type + */ + public String getType() { + return type; + } + + /** + * Sets type. + * + * @param type the type + */ + public void setType(String type) { + this.type = type; + } + + /** + * Gets message. + * + * @return the message + */ + public String getMessage() { + return message; + } + + /** + * Sets message. + * + * @param message the message + */ + public void setMessage(String message) { + this.message = message; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app1/ErrorMessage.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app1/ErrorMessage.java new file mode 100644 index 000000000..98c03b30b --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app1/ErrorMessage.java @@ -0,0 +1,91 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app1; + +/** + * The type Error message. + */ +class ErrorMessage { + + /** + * The Id. + */ + private String id; + + /** + * The Message. + */ + private String message; + + /** + * Instantiates a new Error message. + * + * @param id the id + * @param message2 the message 2 + */ + public ErrorMessage(String id, String message2) { + this.id = id; + this.message = message2; + } + + /** + * Gets id. + * + * @return the id + */ + public String getId() { + return id; + } + + /** + * Sets id. + * + * @param id the id + */ + public void setId(String id) { + this.id = id; + } + + /** + * Gets message. + * + * @return the message + */ + public String getMessage() { + return message; + } + + /** + * Sets message. + * + * @param message the message + */ + public void setMessage(String message) { + this.message = message; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app1/ExceptionTranslator.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app1/ExceptionTranslator.java new file mode 100644 index 000000000..0da4240d2 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app1/ExceptionTranslator.java @@ -0,0 +1,75 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app1; + +import java.util.UUID; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.ControllerAdvice; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.ResponseStatus; + +/** + * The type Exception translator. + */ +@ControllerAdvice +class ExceptionTranslator { + + /** + * The constant LOGGER. + */ + private static final Logger LOGGER = LoggerFactory.getLogger(ExceptionTranslator.class); + + /** + * Handle run time exception response entity. + * + * @param e the e + * @return the response entity + */ + @ExceptionHandler({ RuntimeException.class }) + @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR) + public ResponseEntity handleRunTimeException(RuntimeException e) { + return error(HttpStatus.INTERNAL_SERVER_ERROR, e); + } + + + /** + * Error response entity. + * + * @param status the status + * @param e the e + * @return the response entity + */ + private ResponseEntity error(HttpStatus status, Exception e) { + LOGGER.error("Exception : ", e); + return ResponseEntity.status(status).body(new ErrorMessage(UUID.randomUUID().toString(), e.getMessage())); + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app1/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app1/HelloController.java new file mode 100644 index 000000000..68475fe16 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app1/HelloController.java @@ -0,0 +1,58 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app1; + + +import io.swagger.v3.oas.annotations.tags.Tag; + +import org.springframework.http.HttpStatus; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.ResponseStatus; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * Index string. + * + * @param numTel the num tel + * @param adresse the adresse + * @return the string + */ + @GetMapping(value = "/hello/{numTelco}") + @ResponseStatus(HttpStatus.I_AM_A_TEAPOT) + @Tag(name = "tea") + public String index(@PathVariable("numTelco") String numTel, String adresse) { + return "Greetings from Spring Boot!"; + } + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app1/HomeController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app1/HomeController.java new file mode 100644 index 000000000..9b6bbeb6d --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app1/HomeController.java @@ -0,0 +1,58 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app1; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.GetMapping; + +import static org.springdoc.core.utils.Constants.SWAGGER_UI_PATH; +import static org.springframework.util.AntPathMatcher.DEFAULT_PATH_SEPARATOR; +import static org.springframework.web.servlet.view.UrlBasedViewResolver.REDIRECT_URL_PREFIX; + +/** + * Home redirection to swagger api documentation + */ +@Controller +class HomeController { + + /** + * The Swagger ui path. + */ + @Value(SWAGGER_UI_PATH) + private String swaggerUiPath; + + /** + * Index string. + * + * @return the string + */ + @GetMapping(DEFAULT_PATH_SEPARATOR) + public String index() { + return REDIRECT_URL_PREFIX + swaggerUiPath; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app1/InventoryApi.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app1/InventoryApi.java new file mode 100644 index 000000000..5a4c4938e --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app1/InventoryApi.java @@ -0,0 +1,92 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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. + * * * * * + * * * * + * * * + * * + * + */ + +/** + * NOTE: This class is auto generated by the swagger code generator program (3.0.8). + * https://github.com/swagger-api/swagger-codegen + * Do not edit the class manually. + */ +package test.org.springdoc.api.v30.app1; + +import java.util.List; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.validation.Valid; +import jakarta.validation.constraints.Max; +import jakarta.validation.constraints.Min; + +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestParam; + +/** + * The interface Inventory api. + */ +@jakarta.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2019-07-08T09:37:36.546Z[GMT]") +@Tag(name = "inventory") +public interface InventoryApi { + + /** + * Add inventory response entity. + * + * @param body the body + * @return the response entity + */ + @Operation(description = "adds an inventory item", operationId = "addInventory", summary = "Adds an item to the system", tags = { + "admins", }) + @ApiResponses(value = { @ApiResponse(responseCode = "201", description = "item created"), + @ApiResponse(responseCode = "400", description = "invalid input, object invalid"), + @ApiResponse(responseCode = "409", description = "an existing item already exists") }) + @PostMapping(value = "/inventory", consumes = { "application/json" }) + ResponseEntity addInventory( + @io.swagger.v3.oas.annotations.parameters.RequestBody(description = "Inventory item to do") @Valid @RequestBody InventoryItem body); + + /** + * Search inventory response entity. + * + * @param searchString the search string + * @param skip the skip + * @param limit the limit + * @return the response entity + */ + @Operation(description = "searches inventory", operationId = "searchInventory", summary = "By passing in the appropriate options, you can search for available inventory in the system ", tags = { + "developers", }, parameters = { + @Parameter(description = "pass an optional search string for looking up inventory", name = "searchString") }) + @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "search results matching criteria"), + @ApiResponse(responseCode = "400", description = "bad input parameter") }) + @GetMapping(value = "/inventory", produces = { "application/json" }) + ResponseEntity> searchInventory( + @Valid @RequestParam(value = "searchString", required = false) String searchString, + @Min(0) @Parameter(description = "number of records to skip for pagination") @Valid @RequestParam(value = "skip", required = true) Integer skip, + @Min(0) @Max(50) @Parameter(description = "maximum number of records to return") @Valid @RequestParam(value = "limit", required = true) Integer limit); + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app1/InventoryApiController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app1/InventoryApiController.java new file mode 100644 index 000000000..b9972fb9f --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app1/InventoryApiController.java @@ -0,0 +1,115 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app1; + +import java.util.List; + +import com.fasterxml.jackson.databind.ObjectMapper; +import io.swagger.v3.oas.annotations.Parameter; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.validation.Valid; +import jakarta.validation.constraints.Max; +import jakarta.validation.constraints.Min; + +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Inventory api controller. + */ +@jakarta.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2019-07-08T09:37:36.546Z[GMT]") +@RestController +class InventoryApiController implements InventoryApi { + + + /** + * The Object mapper. + */ + @SuppressWarnings("unused") + private final ObjectMapper objectMapper; + + /** + * The Request. + */ + private final HttpServletRequest request; + + /** + * Instantiates a new Inventory api controller. + * + * @param objectMapper the object mapper + * @param request the request + */ + @org.springframework.beans.factory.annotation.Autowired + public InventoryApiController(ObjectMapper objectMapper, HttpServletRequest request) { + this.objectMapper = objectMapper; + this.request = request; + } + + /** + * Add inventory response entity. + * + * @param body the body + * @return the response entity + */ + public ResponseEntity addInventory( + @io.swagger.v3.oas.annotations.parameters.RequestBody(description = "Inventory item to add") @Valid @RequestBody InventoryItem body) { + @SuppressWarnings("unused") + String accept = request.getHeader("Accept"); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); + } + + /** + * Search inventory response entity. + * + * @param searchString the search string + * @param skip the skip + * @param limit the limit + * @return the response entity + */ + public ResponseEntity> searchInventory( + @Parameter(description = "pass an optional search string for looking up inventory") @Valid @RequestParam(value = "searchString", required = false) String searchString, + @Min(0) @Parameter(description = "number of records to skip for pagination") @Valid @RequestParam(value = "skip", required = true) Integer skip, + @Min(0) @Max(50) @Parameter(description = "maximum number of records to return") @Valid @RequestParam(value = "limit", required = true) Integer limit) { + @SuppressWarnings("unused") + String accept = request.getHeader("Accept"); + return new ResponseEntity>(HttpStatus.NOT_IMPLEMENTED); + } + + /** + * Gets . + * + * @param language the language + * @return the + */ + public String getme(String language) { + return language; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app1/InventoryItem.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app1/InventoryItem.java new file mode 100644 index 000000000..e6b02165b --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app1/InventoryItem.java @@ -0,0 +1,261 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app1; + +import java.util.Objects; +import java.util.UUID; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.Valid; +import jakarta.validation.constraints.NotNull; + +import org.springframework.validation.annotation.Validated; + +/** + * InventoryItem + */ +@Validated +@jakarta.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2019-07-08T09:37:36.546Z[GMT]") +class InventoryItem { + /** + * The Id. + */ + @JsonProperty("id") + private UUID id = null; + + /** + * The Name. + */ + @JsonProperty("name") + private String name = null; + + /** + * The Release date. + */ + @JsonProperty("releaseDate") + private String releaseDate = null; + + /** + * The Manufacturer. + */ + @JsonProperty("manufacturer") + private Manufacturer manufacturer = null; + + /** + * Id inventory item. + * + * @param id the id + * @return the inventory item + */ + public InventoryItem id(UUID id) { + this.id = id; + return this; + } + + /** + * Get id + * + * @return id id + */ + @Schema(example = "d290f1ee-6c54-4b01-90e6-d701748f0851", required = true) + @NotNull + + @Valid + public UUID getId() { + return id; + } + + /** + * Sets id. + * + * @param id the id + */ + public void setId(UUID id) { + this.id = id; + } + + /** + * Name inventory item. + * + * @param name the name + * @return the inventory item + */ + public InventoryItem name(String name) { + this.name = name; + return this; + } + + /** + * Get name + * + * @return name name + */ + @Schema(example = "Widget Adapter", required = true) + @NotNull + + public String getName() { + return name; + } + + /** + * Sets name. + * + * @param name the name + */ + public void setName(String name) { + this.name = name; + } + + /** + * Release date inventory item. + * + * @param releaseDate the release date + * @return the inventory item + */ + public InventoryItem releaseDate(String releaseDate) { + this.releaseDate = releaseDate; + return this; + } + + /** + * Get releaseDate + * + * @return releaseDate release date + */ + @Schema(example = "2016-08-29T09:12:33.001Z", required = true) + @NotNull + + public String getReleaseDate() { + return releaseDate; + } + + /** + * Sets release date. + * + * @param releaseDate the release date + */ + public void setReleaseDate(String releaseDate) { + this.releaseDate = releaseDate; + } + + /** + * Manufacturer inventory item. + * + * @param manufacturer the manufacturer + * @return the inventory item + */ + public InventoryItem manufacturer(Manufacturer manufacturer) { + this.manufacturer = manufacturer; + return this; + } + + /** + * Get manufacturer + * + * @return manufacturer manufacturer + */ + @Schema(required = true) + @NotNull + + @Valid + public Manufacturer getManufacturer() { + return manufacturer; + } + + /** + * Sets manufacturer. + * + * @param manufacturer the manufacturer + */ + public void setManufacturer(Manufacturer manufacturer) { + this.manufacturer = manufacturer; + } + + + /** + * Equals boolean. + * + * @param o the o + * @return the boolean + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + InventoryItem inventoryItem = (InventoryItem) o; + return Objects.equals(this.id, inventoryItem.id) && + Objects.equals(this.name, inventoryItem.name) && + Objects.equals(this.releaseDate, inventoryItem.releaseDate) && + Objects.equals(this.manufacturer, inventoryItem.manufacturer); + } + + /** + * Hash code int. + * + * @return the int + */ + @Override + public int hashCode() { + return Objects.hash(id, name, releaseDate, manufacturer); + } + + /** + * To string string. + * + * @return the string + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class InventoryItem {\n"); + + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" releaseDate: ").append(toIndentedString(releaseDate)).append("\n"); + sb.append(" manufacturer: ").append(toIndentedString(manufacturer)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + * @param o the o + * @return the string + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app1/ItemController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app1/ItemController.java new file mode 100644 index 000000000..ecc120f11 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app1/ItemController.java @@ -0,0 +1,89 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app1; + +import java.net.URI; +import java.time.Instant; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; + +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.enums.Explode; +import io.swagger.v3.oas.annotations.enums.ParameterIn; +import io.swagger.v3.oas.annotations.media.ArraySchema; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.validation.Valid; +import jakarta.validation.constraints.Size; + +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.servlet.support.ServletUriComponentsBuilder; + +/** + * The type Item controller. + */ +@RestController +@Tag(name = "items") +class ItemController { + + /** + * Show items list. + * + * @param customerID the customer id + * @param toto the toto + * @param startDate the start date + * @param filterIds the filter ids + * @return the list + */ + @GetMapping("/items") + public List showItems(@RequestParam("cusID") @Size(min = 4, max = 6) final String customerID, + @Size(min = 4, max = 6) int toto, + @Parameter(name = "start", in = ParameterIn.QUERY, required = false, schema = @Schema(type = "string", format = "date-time", required = false, example = "1970-01-01T00:00:00.000Z")) @RequestParam(value = "start", required = false) Instant startDate, + @Parameter(name = "filterIds", in = ParameterIn.QUERY, array = @ArraySchema(schema = @Schema(type = "string")), explode = Explode.FALSE) @RequestParam(required = false) List filterIds) { + return new ArrayList(); + } + + /** + * Add item response entity. + * + * @param itemDTO the item dto + * @return the response entity + */ + @PostMapping("/items") + public ResponseEntity addItem(@Valid @RequestBody final ItemLightDTO itemDTO) { + final URI location = ServletUriComponentsBuilder.fromCurrentRequest().path("/{id}") + .buildAndExpand(UUID.randomUUID()).toUri(); + return ResponseEntity.created(location).build(); + } + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app1/ItemDTO.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app1/ItemDTO.java new file mode 100644 index 000000000..8e427e0b4 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app1/ItemDTO.java @@ -0,0 +1,164 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app1; + +import java.io.Serializable; + +/** + * The type Item dto. + * @author bnasslahsen + */ +class ItemDTO implements Serializable { + + /** + * serialVersionUID of type long + */ + private static final long serialVersionUID = 1L; + + /** + * itemID of type String + */ + private String itemID; + + /** + * description of type String + */ + private String description; + + /** + * price of type int + */ + private int price; + + /** + * The Deprecated price. + */ + @Deprecated + private int deprecatedPrice; + + /** + * Instantiates a new Item dto. + */ + public ItemDTO() { + } + + /** + * Instantiates a new Item dto. + * + * @param description description + * @param price price + */ + public ItemDTO(final String description, final int price) { + this.description = description; + this.price = price; + } + + /** + * Instantiates a new Item dto. + * + * @param itemID itemID + * @param description description + * @param price price + */ + public ItemDTO(final String itemID, final String description, final int price) { + this.itemID = itemID; + this.description = description; + this.price = price; + } + + /** + * Gets description. + * + * @return description description + */ + public String getDescription() { + return description; + } + + /** + * Sets description. + * + * @param description description + */ + public void setDescription(final String description) { + this.description = description; + } + + /** + * Gets item id. + * + * @return item id + */ + public String getItemID() { + return itemID; + } + + /** + * Sets item id. + * + * @param itemID itemID + */ + public void setItemID(final String itemID) { + this.itemID = itemID; + } + + /** + * Gets price. + * + * @return price price + */ + public int getPrice() { + return price; + } + + /** + * Sets price. + * + * @param price price + */ + public void setPrice(final int price) { + this.price = price; + } + + /** + * Gets deprecated price. + * + * @return the deprecated price + */ + public int getDeprecatedPrice() { + return deprecatedPrice; + } + + /** + * Sets deprecated price. + * + * @param deprecatedPrice the deprecated price + */ + public void setDeprecatedPrice(int deprecatedPrice) { + this.deprecatedPrice = deprecatedPrice; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app1/ItemLightDTO.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app1/ItemLightDTO.java new file mode 100644 index 000000000..7f557efb6 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app1/ItemLightDTO.java @@ -0,0 +1,129 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app1; + +import java.io.Serializable; + +/** + * The type Item light dto. + * @author bnasslahsen + */ +class ItemLightDTO implements Serializable { + + /** + * serialVersionUID of type long + */ + private static final long serialVersionUID = 1L; + + /** + * description of type String + */ + private String description; + + /** + * price of type int + */ + private int price; + + /** + * The Deprecated price. + */ + @Deprecated + private int deprecatedPrice; + + /** + * Instantiates a new Item light dto. + */ + public ItemLightDTO() { + } + + /** + * Instantiates a new Item light dto. + * + * @param description the description + * @param price the price + */ + public ItemLightDTO(String description, int price) { + super(); + this.description = description; + this.price = price; + } + + /** + * Gets description. + * + * @return description description + */ + public String getDescription() { + return description; + } + + /** + * Sets description. + * + * @param description description + */ + public void setDescription(final String description) { + this.description = description; + } + + /** + * Gets price. + * + * @return price price + */ + public int getPrice() { + return price; + } + + /** + * Sets price. + * + * @param price price + */ + public void setPrice(final int price) { + this.price = price; + } + + /** + * Gets deprecated price. + * + * @return the deprecated price + */ + public int getDeprecatedPrice() { + return deprecatedPrice; + } + + /** + * Sets deprecated price. + * + * @param deprecatedPrice the deprecated price + */ + public void setDeprecatedPrice(int deprecatedPrice) { + this.deprecatedPrice = deprecatedPrice; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app1/Manufacturer.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app1/Manufacturer.java new file mode 100644 index 000000000..db8eb7732 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app1/Manufacturer.java @@ -0,0 +1,215 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app1; + +import java.util.Objects; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotNull; + +import org.springframework.validation.annotation.Validated; + + +/** + * Manufacturer + */ +@Validated +@jakarta.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2019-07-08T09:37:36.546Z[GMT]") +class Manufacturer { + /** + * The Name. + */ + @JsonProperty("name") + private String name = null; + + /** + * The Home page. + */ + @JsonProperty("homePage") + private String homePage = null; + + /** + * The Phone. + */ + @JsonProperty("phone") + private String phone = null; + + /** + * Name manufacturer. + * + * @param name the name + * @return the manufacturer + */ + public Manufacturer name(String name) { + this.name = name; + return this; + } + + /** + * Get name + * + * @return name name + */ + @Schema(example = "ACME Corporation", required = true) + @NotNull + + public String getName() { + return name; + } + + /** + * Sets name. + * + * @param name the name + */ + public void setName(String name) { + this.name = name; + } + + /** + * Home page manufacturer. + * + * @param homePage the home page + * @return the manufacturer + */ + public Manufacturer homePage(String homePage) { + this.homePage = homePage; + return this; + } + + /** + * Get homePage + * + * @return homePage home page + */ + @Schema(example = "https://www.acme-corp.com") + + public String getHomePage() { + return homePage; + } + + /** + * Sets home page. + * + * @param homePage the home page + */ + public void setHomePage(String homePage) { + this.homePage = homePage; + } + + /** + * Phone manufacturer. + * + * @param phone the phone + * @return the manufacturer + */ + public Manufacturer phone(String phone) { + this.phone = phone; + return this; + } + + /** + * Get phone + * + * @return phone phone + */ + @Schema(example = "408-867-5309") + public String getPhone() { + return phone; + } + + /** + * Sets phone. + * + * @param phone the phone + */ + public void setPhone(String phone) { + this.phone = phone; + } + + + /** + * Equals boolean. + * + * @param o the o + * @return the boolean + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Manufacturer manufacturer = (Manufacturer) o; + return Objects.equals(this.name, manufacturer.name) && + Objects.equals(this.homePage, manufacturer.homePage) && + Objects.equals(this.phone, manufacturer.phone); + } + + /** + * Hash code int. + * + * @return the int + */ + @Override + public int hashCode() { + return Objects.hash(name, homePage, phone); + } + + /** + * To string string. + * + * @return the string + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Manufacturer {\n"); + + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" homePage: ").append(toIndentedString(homePage)).append("\n"); + sb.append(" phone: ").append(toIndentedString(phone)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + * @param o the o + * @return the string + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app1/PeopleRestService.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app1/PeopleRestService.java new file mode 100644 index 000000000..742e97f54 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app1/PeopleRestService.java @@ -0,0 +1,146 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app1; + +import java.net.URI; +import java.util.Collection; +import java.util.Map; +import java.util.UUID; +import java.util.concurrent.ConcurrentHashMap; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.headers.Header; +import io.swagger.v3.oas.annotations.media.ArraySchema; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.tags.Tag; + +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.servlet.support.ServletUriComponentsBuilder; + +/** + * The type People rest service. + */ +@RestController +@Tag(name = "people") +class PeopleRestService { + /** + * The People. + */ + private Map people = new ConcurrentHashMap<>(); + + /** + * Gets people. + * + * @return the people + */ + @GetMapping(value = "/people", produces = MediaType.APPLICATION_JSON_VALUE) + @Operation(description = "List all people", responses = { + @ApiResponse(content = @Content(array = @ArraySchema(schema = @Schema(implementation = PersonDTO.class))), responseCode = "200") }) + public Collection getPeople() { + return people.values(); + } + + /** + * Find person person dto. + * + * @param email the email + * @return the person dto + */ + @Operation(description = "Find person by e-mail", responses = { + @ApiResponse(content = @Content(schema = @Schema(implementation = PersonDTO.class)), responseCode = "200"), + @ApiResponse(responseCode = "404", description = "Person with such e-mail doesn't exists") }) + @GetMapping(value = "/{email}", produces = MediaType.APPLICATION_JSON_VALUE) + public PersonDTO findPerson( + @Parameter(description = "E-Mail address to lookup for", required = true) @PathVariable("email") final String email) { + + final PersonDTO person = people.get(email); + + if (person == null) { + throw new RuntimeException("Person with such e-mail doesn't exists"); + } + + return person; + } + + /** + * Add person response entity. + * + * @param email the email + * @param firstName the first name + * @param lastName the last name + * @return the response entity + */ + @PostMapping(value = "/{email}", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) + @Operation(description = "Create new person", responses = { + @ApiResponse(content = @Content(schema = @Schema(implementation = PersonDTO.class), mediaType = MediaType.APPLICATION_JSON_VALUE), headers = @Header(name = "Location"), responseCode = "201"), + @ApiResponse(responseCode = "409", description = "Person with such e-mail already exists") }) + public ResponseEntity addPerson( + @Parameter(description = "E-Mail", required = true) @PathVariable("email") final String email, + @Parameter(description = "First Name", required = true) @RequestParam("firstName") final String firstName, + @Parameter(description = "Last Name", required = true) @RequestParam("lastName") final String lastName) { + + final PersonDTO person = people.get(email); + + if (person != null) { + return ResponseEntity.status(HttpStatus.CONFLICT).body("Person with such e-mail already exists"); + } + + people.put(email, new PersonDTO(email, firstName, lastName)); + final URI location = ServletUriComponentsBuilder.fromCurrentRequest().path("/{id}") + .buildAndExpand(UUID.randomUUID()).toUri(); + return ResponseEntity.created(location).build(); + } + + /** + * Delete person response entity. + * + * @param email the email + * @return the response entity + */ + @DeleteMapping(value = "/{email}") + @Operation(description = "Delete existing person", responses = { + @ApiResponse(responseCode = "204", description = "Person has been deleted"), + @ApiResponse(responseCode = "404", description = "Person with such e-mail doesn't exists") }) + public ResponseEntity deletePerson( + @Parameter(description = "E-Mail address to lookup for", required = true) @PathVariable("email") final String email) { + if (people.remove(email) == null) { + throw new RuntimeException("Person with such e-mail doesn't exists"); + } + return ResponseEntity.noContent().build(); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app1/PersonDTO.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app1/PersonDTO.java new file mode 100644 index 000000000..de48411cb --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app1/PersonDTO.java @@ -0,0 +1,120 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app1; + +/** + * The type Person dto. + */ +class PersonDTO { + /** + * The Email. + */ + private String email; + + /** + * The First name. + */ + private String firstName; + + /** + * The Last name. + */ + private String lastName; + + /** + * Instantiates a new Person dto. + */ + public PersonDTO() { + } + + /** + * Instantiates a new Person dto. + * + * @param email the email + * @param firstName the first name + * @param lastName the last name + */ + public PersonDTO(final String email, final String firstName, final String lastName) { + this.email = email; + this.firstName = firstName; + this.lastName = lastName; + } + + /** + * Gets email. + * + * @return the email + */ + public String getEmail() { + return email; + } + + /** + * Sets email. + * + * @param email the email + */ + public void setEmail(final String email) { + this.email = email; + } + + /** + * Gets first name. + * + * @return the first name + */ + public String getFirstName() { + return firstName; + } + + /** + * Sets first name. + * + * @param firstName the first name + */ + public void setFirstName(final String firstName) { + this.firstName = firstName; + } + + /** + * Gets last name. + * + * @return the last name + */ + public String getLastName() { + return lastName; + } + + /** + * Sets last name. + * + * @param lastName the last name + */ + public void setLastName(final String lastName) { + this.lastName = lastName; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app1/SpringDocApp1Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app1/SpringDocApp1Test.java new file mode 100644 index 000000000..80d44a073 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app1/SpringDocApp1Test.java @@ -0,0 +1,65 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app1; + +import io.swagger.v3.oas.models.Components; +import io.swagger.v3.oas.models.OpenAPI; +import io.swagger.v3.oas.models.info.Info; +import io.swagger.v3.oas.models.info.License; +import io.swagger.v3.oas.models.security.SecurityScheme; +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; +import org.springframework.test.context.TestPropertySource; + +/** + * The type Spring doc app 1 test. + */ +@TestPropertySource(properties = "springdoc.default-produces-media-type=application/json") +class SpringDocApp1Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp { + /** + * Custom open api open api. + * + * @return the open api + */ + @Bean + public OpenAPI customOpenAPI() { + return new OpenAPI() + .components(new Components().addSecuritySchemes("basicScheme", + new SecurityScheme().type(SecurityScheme.Type.HTTP).scheme("basic"))) + .info(new Info().title("SpringShop API").version("v0") + .license(new License().name("Apache 2.0").url("http://springdoc.org"))); + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app10/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app10/HelloController.java new file mode 100644 index 000000000..8655b18b9 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app10/HelloController.java @@ -0,0 +1,69 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app10; + +import java.util.Locale; + +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; +import jakarta.servlet.http.HttpSession; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestAttribute; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * Test. + * + * @param header the header + * @param request the request + * @param response the response + * @param locale the locale + * @param hello the hello + */ + @GetMapping("/test") + public void test(HttpSession header, HttpServletRequest request, HttpServletResponse response, Locale locale, + String hello) { + } + + /** + * Test request attribute. + * + * @param sample the sample + * @param s the s + */ + @GetMapping("/testreq") + public void testRequestAttribute(@RequestAttribute String sample, String s) { + + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app10/SpringDocApp10Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app10/SpringDocApp10Test.java new file mode 100644 index 000000000..90606fa9c --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app10/SpringDocApp10Test.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app10; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 10 test. + */ +class SpringDocApp10Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app100/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app100/HelloController.java new file mode 100644 index 000000000..0c938edd0 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app100/HelloController.java @@ -0,0 +1,55 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app100; + +import io.swagger.v3.oas.annotations.tags.Tag; +import io.swagger.v3.oas.annotations.tags.Tags; +import jakarta.validation.constraints.NotNull; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +@Tags(value = @Tag(name = "hello-ap1")) +class HelloController { + + /** + * Gets all pets. + * + * @param toto the toto + * @return the all pets + */ + @GetMapping(value = "/search", produces = { "application/xml", "application/json" }) + @Tags(value = @Tag(name = "hello-ap2")) + public PersonDTO getAllPets(@NotNull String toto) { + return null; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app100/PersonDTO.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app100/PersonDTO.java new file mode 100644 index 000000000..3b7f6a394 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app100/PersonDTO.java @@ -0,0 +1,123 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app100; + +import io.swagger.v3.oas.annotations.media.Schema; + +/** + * The type Person dto. + */ +@Schema +class PersonDTO { + /** + * The Email. + */ + private String email; + + /** + * The First name. + */ + private String firstName; + + /** + * The Last name. + */ + private String lastName; + + /** + * Instantiates a new Person dto. + */ + public PersonDTO() { + } + + /** + * Instantiates a new Person dto. + * + * @param email the email + * @param firstName the first name + * @param lastName the last name + */ + public PersonDTO(final String email, final String firstName, final String lastName) { + this.email = email; + this.firstName = firstName; + this.lastName = lastName; + } + + /** + * Gets email. + * + * @return the email + */ + public String getEmail() { + return email; + } + + /** + * Sets email. + * + * @param email the email + */ + public void setEmail(final String email) { + this.email = email; + } + + /** + * Gets first name. + * + * @return the first name + */ + public String getFirstName() { + return firstName; + } + + /** + * Sets first name. + * + * @param firstName the first name + */ + public void setFirstName(final String firstName) { + this.firstName = firstName; + } + + /** + * Gets last name. + * + * @return the last name + */ + public String getLastName() { + return lastName; + } + + /** + * Sets last name. + * + * @param lastName the last name + */ + public void setLastName(final String lastName) { + this.lastName = lastName; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app100/SpringDocApp100Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app100/SpringDocApp100Test.java new file mode 100644 index 000000000..761338601 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app100/SpringDocApp100Test.java @@ -0,0 +1,45 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app100; + + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 100 test. + */ +class SpringDocApp100Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app101/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app101/HelloController.java new file mode 100644 index 000000000..12f76bfd5 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app101/HelloController.java @@ -0,0 +1,57 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app101; + +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +@RequestMapping("/hello") +class HelloController { + + /** + * Hello hello dto. + * + * @return the hello dto + */ + @GetMapping + @ApiResponse(content = @Content(schema = @Schema( + description = "${test.app101.operation.hello.response.schema.description}", + implementation = HelloDTO.class))) + public HelloDTO hello() { + return new HelloDTO(); + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app101/HelloDTO.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app101/HelloDTO.java new file mode 100644 index 000000000..d6732e42d --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app101/HelloDTO.java @@ -0,0 +1,63 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app101; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.v3.oas.annotations.media.Schema; + +/** + * The type Hello dto. + */ +@Schema(description = "${test.app101.schema.hello.description}") +class HelloDTO { + + /** + * The Id. + */ + @Schema(description = "${test.app101.schema.hello.param.id.description}") + private String id; + + /** + * Gets id. + * + * @return the id + */ + @JsonProperty("id") + public String getId() { + return id; + } + + /** + * Sets id. + * + * @param id the id + */ + public void setId(String id) { + this.id = id; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app101/SpringDocApp101Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app101/SpringDocApp101Test.java new file mode 100644 index 000000000..41d339064 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app101/SpringDocApp101Test.java @@ -0,0 +1,47 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app101; + + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.test.context.ActiveProfiles; + +/** + * The type Spring doc app 101 test. + */ +@ActiveProfiles("101") +class SpringDocApp101Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app102/InheritedRequestParams.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app102/InheritedRequestParams.java new file mode 100644 index 000000000..a12a5f23d --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app102/InheritedRequestParams.java @@ -0,0 +1,60 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app102; + +import io.swagger.v3.oas.annotations.Parameter; +import jakarta.validation.constraints.NotBlank; + +/** + * The type Inherited request params. + */ +class InheritedRequestParams extends RequestParams { + /** + * The Child param. + */ + @Parameter(description = "parameter from child of RequestParams") + @NotBlank + private String childParam; + + /** + * Gets child param. + * + * @return the child param + */ + public String getChildParam() { + return childParam; + } + + /** + * Sets child param. + * + * @param childParam the child param + */ + public void setChildParam(String childParam) { + this.childParam = childParam; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app102/RequestParams.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app102/RequestParams.java new file mode 100644 index 000000000..90563e969 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app102/RequestParams.java @@ -0,0 +1,284 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app102; + +import java.math.BigInteger; +import java.util.List; +import java.util.Optional; + +import io.swagger.v3.oas.annotations.Parameter; + +import org.springframework.lang.Nullable; + +/** + * The type Request params. + */ +class RequestParams { + + /** + * The String param. + */ + @Parameter(description = "string parameter") + private String stringParam; + + /** + * The String param 1. + */ + @Deprecated + private String stringParam1; + + /** + * The String param 2. + */ + @Parameter(description = "string parameter2", required = true) + private String stringParam2; + + /** + * The Int param. + */ + @Parameter(description = "int parameter") + private int intParam; + + /** + * The Int param 2. + */ + private Optional intParam2; + + /** + * The Int param 3. + */ + @Nullable + private String intParam3; + + /** + * The Nested. + */ + private Nested nested; + + /** + * The Nested list. + */ + private List nestedList; + + /** + * Gets string param. + * + * @return the string param + */ + public String getStringParam() { + return stringParam; + } + + /** + * Sets string param. + * + * @param stringParam the string param + */ + public void setStringParam(String stringParam) { + this.stringParam = stringParam; + } + + /** + * Gets int param. + * + * @return the int param + */ + public int getIntParam() { + return intParam; + } + + /** + * Sets int param. + * + * @param intParam the int param + */ + public void setIntParam(int intParam) { + this.intParam = intParam; + } + + /** + * Gets int param 2. + * + * @return the int param 2 + */ + public Optional getIntParam2() { + return intParam2; + } + + /** + * Sets int param 2. + * + * @param intParam2 the int param 2 + */ + public void setIntParam2(Optional intParam2) { + this.intParam2 = intParam2; + } + + /** + * Gets int param 3. + * + * @return the int param 3 + */ + @Nullable + public String getIntParam3() { + return intParam3; + } + + /** + * Sets int param 3. + * + * @param intParam3 the int param 3 + */ + public void setIntParam3(@Nullable String intParam3) { + this.intParam3 = intParam3; + } + + /** + * Gets string param 1. + * + * @return the string param 1 + */ + public String getStringParam1() { + return stringParam1; + } + + /** + * Sets string param 1. + * + * @param stringParam1 the string param 1 + */ + public void setStringParam1(String stringParam1) { + this.stringParam1 = stringParam1; + } + + /** + * Gets string param 2. + * + * @return the string param 2 + */ + public String getStringParam2() { + return stringParam2; + } + + /** + * Sets string param 2. + * + * @param stringParam2 the string param 2 + */ + public void setStringParam2(String stringParam2) { + this.stringParam2 = stringParam2; + } + + /** + * Gets nested. + * + * @return the nested + */ + public Nested getNested() { + return nested; + } + + /** + * Sets nested. + * + * @param nested the nested + */ + public void setNested(Nested nested) { + this.nested = nested; + } + + /** + * Gets nested list. + * + * @return the nested list + */ + public List getNestedList() { + return nestedList; + } + + /** + * Sets nested list. + * + * @param nestedList the nested list + */ + public void setNestedList(List nestedList) { + this.nestedList = nestedList; + } + + /** + * The type Nested. + */ + public static class Nested { + /** + * The Param 1. + */ + private String param1; + + /** + * The Param 2. + */ + private BigInteger param2; + + /** + * Gets param 1. + * + * @return the param 1 + */ + @Parameter(description = "nested string parameter") + public String getParam1() { + return param1; + } + + /** + * Sets param 1. + * + * @param param1 the param 1 + */ + public void setParam1(String param1) { + this.param1 = param1; + } + + /** + * Gets param 2. + * + * @return the param 2 + */ + @Parameter(description = "nested BigInteger parameter") + public BigInteger getParam2() { + return param2; + } + + /** + * Sets param 2. + * + * @param param2 the param 2 + */ + public void setParam2(BigInteger param2) { + this.param2 = param2; + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app102/SpringDocApp102Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app102/SpringDocApp102Test.java new file mode 100644 index 000000000..ea42b187b --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app102/SpringDocApp102Test.java @@ -0,0 +1,42 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app102; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 102 test. + */ +class SpringDocApp102Test extends AbstractSpringDocTest { + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app102/TestController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app102/TestController.java new file mode 100644 index 000000000..e987fb7aa --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app102/TestController.java @@ -0,0 +1,50 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app102; + +import org.springdoc.core.annotations.ParameterObject; + +import org.springframework.lang.Nullable; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Test controller. + */ +@RestController +class TestController { + /** + * Gets test. + * + * @param param the param + * @param requestParams the request params + */ + @GetMapping("test") + public void getTest(@RequestParam @Nullable String param, @ParameterObject InheritedRequestParams requestParams) { + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app103/ExampleBody.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app103/ExampleBody.java new file mode 100644 index 000000000..8cbc2e1ac --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app103/ExampleBody.java @@ -0,0 +1,78 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app103; + +/** + * The type Example body. + */ +class ExampleBody { + /** + * The String param. + */ + private String stringParam; + + /** + * The Int param. + */ + private int intParam; + + /** + * Gets string param. + * + * @return the string param + */ + public String getStringParam() { + return stringParam; + } + + /** + * Sets string param. + * + * @param stringParam the string param + */ + public void setStringParam(String stringParam) { + this.stringParam = stringParam; + } + + /** + * Gets int param. + * + * @return the int param + */ + public int getIntParam() { + return intParam; + } + + /** + * Sets int param. + * + * @param intParam the int param + */ + public void setIntParam(int intParam) { + this.intParam = intParam; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app103/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app103/HelloController.java new file mode 100644 index 000000000..c94308c19 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app103/HelloController.java @@ -0,0 +1,69 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app103; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Encoding; +import io.swagger.v3.oas.annotations.parameters.RequestBody; + +import org.springframework.http.MediaType; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.multipart.MultipartFile; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * Post my request body string. + * + * @param body the body + * @param file the file + * @return the string + */ + @PostMapping(value = "/test/103", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) + @Operation( + requestBody = @RequestBody( + content = @Content( + encoding = @Encoding(name = "body", contentType = "application/json") + ) + ) + ) + public String postMyRequestBody( + @RequestPart("body") ExampleBody body, + @RequestParam("file") MultipartFile file + ) { + return null; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app103/SpringDocApp103Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app103/SpringDocApp103Test.java new file mode 100644 index 000000000..b607f58b0 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app103/SpringDocApp103Test.java @@ -0,0 +1,42 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app103; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 103 test. + */ +class SpringDocApp103Test extends AbstractSpringDocTest { + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app104/CrudController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app104/CrudController.java new file mode 100644 index 000000000..ff8a6a701 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app104/CrudController.java @@ -0,0 +1,73 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app104; + +import java.util.List; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.ResponseBody; + +/** + * The type Crud controller. + * + * @param the type parameter + */ +@Controller +@SuppressWarnings("rawtypes") +public abstract class CrudController { + + /** + * Get t. + * + * @param id the id + * @return the t + */ + @GetMapping(path = "{id}") + @ResponseBody + @Operation(description = "Get single object") + public T get( // + @Parameter(description = "The id to get.", required = true) @PathVariable("id") int id) { + return null; + } + + /** + * List list. + * + * @return the list + */ + @GetMapping(path = "") + @ResponseBody + @Operation(description = "Receive a list of objects") + public List list() { + return null; + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app104/Design.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app104/Design.java new file mode 100644 index 000000000..c6b846d0f --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app104/Design.java @@ -0,0 +1,33 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app104; + +/** + * The type Design. + */ +class Design extends HavingPK { +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app104/DesignController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app104/DesignController.java new file mode 100644 index 000000000..b540e8753 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app104/DesignController.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app104; + +import io.swagger.v3.oas.annotations.tags.Tag; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; + +/** + * The type Design controller. + */ +@Tag(name = "design") +@Controller +@RequestMapping("/design") +class DesignController extends CrudController { + + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app104/HavingPK.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app104/HavingPK.java new file mode 100644 index 000000000..c2869a01d --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app104/HavingPK.java @@ -0,0 +1,33 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app104; + +/** + * The type Having pk. + */ +class HavingPK { +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app104/SpringDocApp104Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app104/SpringDocApp104Test.java new file mode 100644 index 000000000..f24f696c2 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app104/SpringDocApp104Test.java @@ -0,0 +1,42 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app104; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 104 test. + */ +class SpringDocApp104Test extends AbstractSpringDocTest { + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app105/SpringDocApp105Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app105/SpringDocApp105Test.java new file mode 100644 index 000000000..4b90155b9 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app105/SpringDocApp105Test.java @@ -0,0 +1,144 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app105; + +import io.swagger.v3.oas.models.Components; +import io.swagger.v3.oas.models.OpenAPI; +import io.swagger.v3.oas.models.info.Info; +import io.swagger.v3.oas.models.info.License; +import io.swagger.v3.oas.models.security.SecurityScheme; +import org.junit.jupiter.api.Test; +import org.springdoc.core.utils.Constants; +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; +import org.springframework.test.context.TestPropertySource; + +import static org.hamcrest.Matchers.is; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + +/** + * The type Spring doc app 105 test. + */ +@TestPropertySource(properties = { + "springdoc.group-configs[0].group=stores", + "springdoc.group-configs[0].paths-to-match=/store/**", + "springdoc.group-configs[1].group=users", + "springdoc.group-configs[1].packages-to-scan=test.org.springdoc.api.v30.app105.api.user", + "springdoc.group-configs[2].group=pets", + "springdoc.group-configs[2].paths-to-match=/pet/**", + "springdoc.group-configs[3].group=groups test", + "springdoc.group-configs[3].paths-to-match=/v1/**", + "springdoc.group-configs[3].paths-to-exclude=/v1/users", + "springdoc.group-configs[3].packages-to-scan=test.org.springdoc.api.v30.app105.api.user,test.org.springdoc.api.v30.app105.api.store", +}) +class SpringDocApp105Test extends AbstractSpringDocTest { + + /** + * The constant className. + */ + public static String className; + + /** + * Test app. + * + * @throws Exception the exception + */ + @Test + protected void testApp() throws Exception { + mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL + "/stores")) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.openapi", is("3.0.1"))) + .andExpect(content().json(getContent("results/3.0.1/app105-1.json"), true)); + } + + /** + * Test app 2. + * + * @throws Exception the exception + */ + @Test + void testApp2() throws Exception { + mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL + "/users")) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.openapi", is("3.0.1"))) + .andExpect(content().json(getContent("results/3.0.1/app105-2.json"), true)); + } + + /** + * Test app 3. + * + * @throws Exception the exception + */ + @Test + void testApp3() throws Exception { + mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL + "/pets")) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.openapi", is("3.0.1"))) + .andExpect(content().json(getContent("results/3.0.1/app105-3.json"), true)); + } + + /** + * Test app 4. + * + * @throws Exception the exception + */ + @Test + void testApp4() throws Exception { + mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL + "/groups test")) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.openapi", is("3.0.1"))) + .andExpect(content().json(getContent("results/3.0.1/app105-4.json"), true)); + } + + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp { + /** + * Custom open api open api. + * + * @return the open api + */ + @Bean + public OpenAPI customOpenAPI() { + return new OpenAPI() + .components(new Components().addSecuritySchemes("basicScheme", + new SecurityScheme().type(SecurityScheme.Type.HTTP).scheme("basic"))) + .info(new Info().title("Petstore API").version("v0").description( + "This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.") + .termsOfService("http://swagger.io/terms/") + .license(new License().name("Apache 2.0").url("http://springdoc.org"))); + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app105/api/ApiUtil.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app105/api/ApiUtil.java new file mode 100644 index 000000000..0f4d89b78 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app105/api/ApiUtil.java @@ -0,0 +1,69 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app105.api; + +import java.io.IOException; + +import jakarta.servlet.http.HttpServletResponse; + +import org.springframework.http.HttpStatus; +import org.springframework.web.context.request.NativeWebRequest; +import org.springframework.web.server.ResponseStatusException; + +/** + * The type Api util. + */ +public class ApiUtil { + + /** + * Sets example response. + * + * @param req the req + * @param contentType the content type + * @param example the example + */ + public static void setExampleResponse(NativeWebRequest req, String contentType, String example) { + try { + req.getNativeResponse(HttpServletResponse.class).addHeader("Content-Type", contentType); + req.getNativeResponse(HttpServletResponse.class).getOutputStream().print(example); + } + catch (IOException e) { + throw new RuntimeException(e); + } + } + + /** + * Check api key. + * + * @param req the req + */ + public static void checkApiKey(NativeWebRequest req) { + if (!"1".equals(System.getenv("DISABLE_API_KEY")) && !"special-key".equals(req.getHeader("api_key"))) { + throw new ResponseStatusException(HttpStatus.UNAUTHORIZED, "Missing API key!"); + } + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app105/api/ExceptionTranslator.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app105/api/ExceptionTranslator.java new file mode 100644 index 000000000..99d109db6 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app105/api/ExceptionTranslator.java @@ -0,0 +1,74 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app105.api; + +import java.util.Map; + +import jakarta.validation.ConstraintViolationException; + +import org.springframework.boot.web.error.ErrorAttributeOptions; +import org.springframework.boot.web.servlet.error.ErrorAttributes; +import org.springframework.http.HttpStatus; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.ResponseStatus; +import org.springframework.web.bind.annotation.RestControllerAdvice; +import org.springframework.web.context.request.RequestAttributes; +import org.springframework.web.context.request.WebRequest; + +/** + * The type Exception translator. + */ +@RestControllerAdvice +class ExceptionTranslator { + + /** + * The Error attributes. + */ + private final ErrorAttributes errorAttributes; + + /** + * Instantiates a new Exception translator. + * + * @param errorAttributes the error attributes + */ + public ExceptionTranslator(ErrorAttributes errorAttributes) { + this.errorAttributes = errorAttributes; + } + + /** + * Process constraint violation exception map. + * + * @param request the request + * @return the map + */ + @ExceptionHandler(ConstraintViolationException.class) + @ResponseStatus(HttpStatus.BAD_REQUEST) + public Map processConstraintViolationException(WebRequest request) { + request.setAttribute("jakarta.servlet.error.status_code", HttpStatus.BAD_REQUEST.value(), RequestAttributes.SCOPE_REQUEST); + return errorAttributes.getErrorAttributes(request, ErrorAttributeOptions.defaults()); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app105/api/HomeController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app105/api/HomeController.java new file mode 100644 index 000000000..f1f293b9f --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app105/api/HomeController.java @@ -0,0 +1,58 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app105.api; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.GetMapping; + +import static org.springdoc.core.utils.Constants.SWAGGER_UI_PATH; +import static org.springframework.util.AntPathMatcher.DEFAULT_PATH_SEPARATOR; +import static org.springframework.web.servlet.view.UrlBasedViewResolver.REDIRECT_URL_PREFIX; + +/** + * Home redirection to swagger api documentation + */ +@Controller +class HomeController { + + /** + * The Swagger ui path. + */ + @Value(SWAGGER_UI_PATH) + private String swaggerUiPath; + + /** + * Index string. + * + * @return the string + */ + @GetMapping(DEFAULT_PATH_SEPARATOR) + public String index() { + return REDIRECT_URL_PREFIX + swaggerUiPath; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app105/api/pet/PetApi.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app105/api/pet/PetApi.java new file mode 100644 index 000000000..58dbc0872 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app105/api/pet/PetApi.java @@ -0,0 +1,227 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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. + * * * * * + * * * * + * * * + * * + * + */ + +/** + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (3.0.0). + * https://openapi-generator.tech + * Do not edit the class manually. + */ +package test.org.springdoc.api.v30.app105.api.pet; + +import java.util.List; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.enums.SecuritySchemeType; +import io.swagger.v3.oas.annotations.media.ArraySchema; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; +import io.swagger.v3.oas.annotations.security.OAuthFlow; +import io.swagger.v3.oas.annotations.security.OAuthFlows; +import io.swagger.v3.oas.annotations.security.OAuthScope; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.security.SecurityScheme; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.validation.Valid; +import jakarta.validation.constraints.NotNull; +import test.org.springdoc.api.v30.app105.model.ModelApiResponse; +import test.org.springdoc.api.v30.app105.model.Pet; + +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestHeader; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.multipart.MultipartFile; + +/** + * The interface Pet api. + */ +@SecurityScheme(name = "petstore_auth", type = SecuritySchemeType.OAUTH2, flows = @OAuthFlows(implicit = @OAuthFlow(authorizationUrl = "http://petstore.swagger.io/oauth/dialog", scopes = { + @OAuthScope(name = "write:pets", description = "modify pets in your account"), + @OAuthScope(name = "read:pets", description = "read your pets") }))) +@Tag(name = "pet", description = "the pet API") +public interface PetApi { + + /** + * Gets delegate. + * + * @return the delegate + */ + default PetApiDelegate getDelegate() { + return new PetApiDelegate() { + }; + } + + /** + * Add pet. + * + * @param pet the pet + */ + @Operation(summary = "Add a new pet to the store", description = "", security = { + @SecurityRequirement(name = "petstore_auth", scopes = { "write:pets", "read:pets" }) }, tags = { "pet" }) + @ApiResponses(value = { @ApiResponse(responseCode = "405", description = "Invalid input") }) + @PostMapping(value = "/pet", consumes = { "application/json", "application/xml" }) + default void addPet( + @io.swagger.v3.oas.annotations.parameters.RequestBody(description = "Pet object that needs to be added to the store", required = true) @Valid @RequestBody Pet pet) { + // return getDelegate().addPet(pet); + } + + /** + * Delete pet response entity. + * + * @param petId the pet id + * @param apiKey the api key + * @return the response entity + */ + @Operation(summary = "Deletes a pet", description = "", security = { + @SecurityRequirement(name = "petstore_auth", scopes = { "write:pets", "read:pets" }) }, tags = { "pet" }) + @ApiResponses(value = { @ApiResponse(responseCode = "400", description = "Invalid ID supplied"), + @ApiResponse(responseCode = "404", description = "Pet not found") }) + @DeleteMapping(value = "/pet/{petId}") + default ResponseEntity deletePet( + @Parameter(description = "Pet id to delete", required = true) @PathVariable("petId") Long petId, + @Parameter(description = "") @RequestHeader(value = "api_key", required = false) String apiKey) { + return getDelegate().deletePet(petId, apiKey); + } + + /** + * Find pets by status response entity. + * + * @param status the status + * @return the response entity + */ + @Operation(summary = "Finds Pets by status", description = "Multiple status values can be provided with comma separated strings", security = { + @SecurityRequirement(name = "petstore_auth", scopes = { "write:pets", "read:pets" }) }, tags = { "pet" }) + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(array = @ArraySchema(schema = @Schema(implementation = Pet.class)))), + @ApiResponse(responseCode = "400", description = "Invalid status value") }) + @GetMapping(value = "/pet/findByStatus", produces = { "application/xml", "application/json" }) + default ResponseEntity> findPetsByStatus( + @NotNull @Parameter(description = "Status values that need to be considered for filter", required = true) @Valid @RequestParam(value = "status", required = true) List status) { + return getDelegate().findPetsByStatus(status); + } + + /** + * Find pets by tags response entity. + * + * @param tags the tags + * @return the response entity + */ + @Operation(summary = "Finds Pets by tags", description = "Muliple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.", security = { + @SecurityRequirement(name = "petstore_auth", scopes = { "write:pets", "read:pets" }) }, tags = { "pet" }) + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(array = @ArraySchema(schema = @Schema(implementation = Pet.class)))), + @ApiResponse(responseCode = "400", description = "Invalid tag value") }) + @GetMapping(value = "/pet/findByTags", produces = { "application/xml", "application/json" }) + default ResponseEntity> findPetsByTags( + @NotNull @Parameter(description = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) List tags) { + return getDelegate().findPetsByTags(tags); + } + + /** + * Gets pet by id. + * + * @param petId the pet id + * @return the pet by id + */ + @Operation(summary = "Find pet by ID", description = "Returns a single pet", security = { + @SecurityRequirement(name = "api_key") }, tags = { "pet" }) + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(schema = @Schema(implementation = Pet.class))), + @ApiResponse(responseCode = "400", description = "Invalid ID supplied"), + @ApiResponse(responseCode = "404", description = "Pet not found") }) + @GetMapping(value = "/pet/{petId}", produces = { "application/xml", "application/json" }) + default ResponseEntity getPetById( + @Parameter(description = "ID of pet to return", required = true) @PathVariable("petId") Long petId) { + return getDelegate().getPetById(petId); + } + + /** + * Update pet response entity. + * + * @param pet the pet + * @return the response entity + */ + @Operation(summary = "Update an existing pet", description = "", security = { + @SecurityRequirement(name = "petstore_auth", scopes = { "write:pets", "read:pets" }) }, tags = { "pet" }) + @ApiResponses(value = { @ApiResponse(responseCode = "400", description = "Invalid ID supplied"), + @ApiResponse(responseCode = "404", description = "Pet not found"), + @ApiResponse(responseCode = "405", description = "Validation exception") }) + @PutMapping(value = "/pet", consumes = { "application/json", "application/xml" }) + default ResponseEntity updatePet( + @io.swagger.v3.oas.annotations.parameters.RequestBody(description = "Pet object that needs to be added to the store", required = true) @Valid @RequestBody Pet pet) { + return getDelegate().updatePet(pet); + } + + /** + * Update pet with form response entity. + * + * @param petId the pet id + * @param name the name + * @param status the status + * @return the response entity + */ + @Operation(summary = "Updates a pet in the store with form data", description = "", security = { + @SecurityRequirement(name = "petstore_auth", scopes = { "write:pets", "read:pets" }) }, tags = { "pet" }) + @ApiResponses(value = { @ApiResponse(responseCode = "405", description = "Invalid input") }) + @PostMapping(value = "/pet/{petId}", consumes = { "application/x-www-form-urlencoded" }) + default ResponseEntity updatePetWithForm( + @Parameter(description = "ID of pet that needs to be updated", required = true) @PathVariable("petId") Long petId, + @Parameter(description = "Updated name of the pet") @RequestParam(value = "name", required = false) String name, + @Parameter(description = "Updated status of the pet") @RequestParam(value = "status", required = false) String status) { + return getDelegate().updatePetWithForm(petId, name, status); + } + + /** + * Upload file response entity. + * + * @param petId the pet id + * @param additionalMetadata the additional metadata + * @param file the file + * @return the response entity + */ + @Operation(summary = "uploads an image", description = "", security = { + @SecurityRequirement(name = "petstore_auth", scopes = { "write:pets", "read:pets" }) }, tags = { "pet" }) + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(schema = @Schema(implementation = ModelApiResponse.class))) }) + @PostMapping(value = "/pet/{petId}/uploadImage", produces = { "application/json" }, consumes = { + "multipart/form-data" }) + default ResponseEntity uploadFile( + @Parameter(description = "ID of pet to update", required = true) @PathVariable("petId") Long petId, + @Parameter(description = "Additional data to pass to server") @RequestParam(value = "additionalMetadata", required = false) String additionalMetadata, + @Parameter(description = "file detail") @Valid @RequestPart("file") MultipartFile file) { + return getDelegate().uploadFile(petId, additionalMetadata, file); + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app105/api/pet/PetApiController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app105/api/pet/PetApiController.java new file mode 100644 index 000000000..f20e6d307 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app105/api/pet/PetApiController.java @@ -0,0 +1,68 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app105.api.pet; + +import java.util.Optional; + +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Pet api controller. + */ +@jakarta.annotation.Generated(value = "org.springdoc.demo.app2.codegen.languages.SpringCodegen", date = "2019-07-11T00:09:29.839+02:00[Europe/Paris]") + +@RestController +@RequestMapping("${openapi.openAPIPetstore.base-path:/}") +class PetApiController implements PetApi { + + /** + * The Delegate. + */ + private final PetApiDelegate delegate; + + /** + * Instantiates a new Pet api controller. + * + * @param delegate the delegate + */ + public PetApiController(@org.springframework.beans.factory.annotation.Autowired(required = false) PetApiDelegate delegate) { + this.delegate = Optional.ofNullable(delegate).orElse(new PetApiDelegate() { + }); + } + + /** + * Gets delegate. + * + * @return the delegate + */ + @Override + public PetApiDelegate getDelegate() { + return delegate; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app105/api/pet/PetApiDelegate.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app105/api/pet/PetApiDelegate.java new file mode 100644 index 000000000..8c4c79157 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app105/api/pet/PetApiDelegate.java @@ -0,0 +1,193 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app105.api.pet; + +import java.util.List; +import java.util.Optional; + +import jakarta.validation.Valid; +import test.org.springdoc.api.v30.app105.api.ApiUtil; +import test.org.springdoc.api.v30.app105.model.ModelApiResponse; +import test.org.springdoc.api.v30.app105.model.Pet; + +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.web.context.request.NativeWebRequest; +import org.springframework.web.multipart.MultipartFile; + +/** + * A delegate to be called by the {@link PetApiController}}. + * Implement this interface with a {@link org.springframework.stereotype.Service} annotated class. + */ +@jakarta.annotation.Generated(value = "org.springdoc.demo.app2.codegen.languages.SpringCodegen", date = "2019-07-11T00:09:29.839+02:00[Europe/Paris]") + +public interface PetApiDelegate { + + /** + * Gets request. + * + * @return the request + */ + default Optional getRequest() { + return Optional.empty(); + } + + /** + * Add pet. + * + * @param pet the pet + * @see PetApi#addPet PetApi#addPet + */ + default void addPet(Pet pet) { + + } + + /** + * Delete pet response entity. + * + * @param petId the pet id + * @param apiKey the api key + * @return the response entity + * @see PetApi#deletePet PetApi#deletePet + */ + default ResponseEntity deletePet(Long petId, + String apiKey) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * Find pets by status response entity. + * + * @param status the status + * @return the response entity + * @see PetApi#findPetsByStatus PetApi#findPetsByStatus + */ + default ResponseEntity> findPetsByStatus(List status) { + extract(); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * Extract. + */ + default void extract() { + getRequest().ifPresent(request -> { + for (MediaType mediaType : MediaType.parseMediaTypes(request.getHeader("Accept"))) { + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + ApiUtil.setExampleResponse(request, "application/json", "{ \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\"}"); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/xml"))) { + ApiUtil.setExampleResponse(request, "application/xml", " 123456789 doggie aeiou aeiou"); + break; + } + } + }); + } + + /** + * Find pets by tags response entity. + * + * @param tags the tags + * @return the response entity + * @see PetApi#findPetsByTags PetApi#findPetsByTags + */ + default ResponseEntity> findPetsByTags(List tags) { + extract(); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * Gets pet by id. + * + * @param petId the pet id + * @return the pet by id + * @see PetApi#getPetById PetApi#getPetById + */ + default ResponseEntity getPetById(Long petId) { + extract(); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * Update pet response entity. + * + * @param pet the pet + * @return the response entity + * @see PetApi#updatePet PetApi#updatePet + */ + default ResponseEntity updatePet(Pet pet) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * Update pet with form response entity. + * + * @param petId the pet id + * @param name the name + * @param status the status + * @return the response entity + * @see PetApi#updatePetWithForm PetApi#updatePetWithForm + */ + default ResponseEntity updatePetWithForm(Long petId, + String name, + String status) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * Upload file response entity. + * + * @param petId the pet id + * @param additionalMetadata the additional metadata + * @param file the file + * @return the response entity + * @see PetApi#uploadFile PetApi#uploadFile + */ + default ResponseEntity uploadFile(Long petId, + String additionalMetadata, + @Valid MultipartFile file) { + getRequest().ifPresent(request -> { + for (MediaType mediaType : MediaType.parseMediaTypes(request.getHeader("Accept"))) { + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + ApiUtil.setExampleResponse(request, "application/json", "{ \"code\" : 0, \"type\" : \"type\", \"message\" : \"message\"}"); + break; + } + } + }); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app105/api/pet/PetApiDelegateImpl.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app105/api/pet/PetApiDelegateImpl.java new file mode 100644 index 000000000..88c50c130 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app105/api/pet/PetApiDelegateImpl.java @@ -0,0 +1,38 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app105.api.pet; + +import org.springframework.stereotype.Service; + +/** + * The type Pet api delegate. + */ +@Service +class PetApiDelegateImpl implements PetApiDelegate { + + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app105/api/store/StoreApi.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app105/api/store/StoreApi.java new file mode 100644 index 000000000..9f80a2b02 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app105/api/store/StoreApi.java @@ -0,0 +1,148 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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. + * * * * * + * * * * + * * * + * * + * + */ + +/** + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (3.0.0). + * https://openapi-generator.tech + * Do not edit the class manually. + */ +package test.org.springdoc.api.v30.app105.api.store; + +import java.util.Map; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.media.ArraySchema; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.validation.Valid; +import jakarta.validation.constraints.Max; +import jakarta.validation.constraints.Min; +import jakarta.validation.constraints.NotBlank; +import test.org.springdoc.api.v30.app105.model.Order; + +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; + +/** + * The interface Store api. + */ +@jakarta.annotation.Generated(value = "org.springdoc.demo.app2.codegen.languages.SpringCodegen", date = "2019-07-11T00:09:29.839+02:00[Europe/Paris]") + +@Tag(name = "store", description = "the store API") +public interface StoreApi { + + /** + * Gets delegate. + * + * @return the delegate + */ + default StoreApiDelegate getDelegate() { + return new StoreApiDelegate() { + }; + } + + /** + * Delete order response entity. + * + * @param orderId the order id + * @return the response entity + */ + @Operation(summary = "Delete purchase order by ID", tags = { "store" }) + @ApiResponses(value = { @ApiResponse(responseCode = "400", description = "Invalid ID supplied"), + @ApiResponse(responseCode = "404", description = "Order not found") }) + @DeleteMapping(value = "/store/order/{orderId}") + default ResponseEntity deleteOrder( + @Parameter(description = "ID of the order that needs to be deleted", required = true) @PathVariable("orderId") String orderId) { + return getDelegate().deleteOrder(orderId); + } + + /** + * Gets inventory. + * + * @return the inventory + */ + @Operation(summary = "Returns pet inventories by status", description = "Returns a map of status codes to quantities", security = { + @SecurityRequirement(name = "api_key") }, tags = { "store" }) + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(array = @ArraySchema(schema = @Schema(implementation = Map.class)))) }) + @GetMapping(value = "/store/inventory", produces = { "application/json" }) + default ResponseEntity> getInventory() { + return getDelegate().getInventory(); + } + + /** + * Gets order by id. + * + * @param orderId the order id + * @return the order by id + */ + @Operation(summary = "Find purchase order by ID", tags = { "store" }) + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(schema = @Schema(implementation = Order.class))), + @ApiResponse(responseCode = "400", description = "Invalid ID supplied"), + @ApiResponse(responseCode = "404", description = "Order not found") }) + @GetMapping(value = "/store/order/{orderId}", produces = { "application/xml", "application/json" }) + default ResponseEntity getOrderById( + @Min(1L) @Max(5L) @Parameter(description = "ID of pet that needs to be fetched", required = true) @PathVariable("orderId") Long orderId) { + return getDelegate().getOrderById(orderId); + } + + /** + * Place order response entity. + * + * @param order the order + * @return the response entity + */ + @Operation(summary = "Place an order for a pet", tags = { "store" }) + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(schema = @Schema(implementation = Order.class))), + @ApiResponse(responseCode = "400", description = "Invalid Order") }) + @PostMapping(value = "/store/order", produces = { "application/xml", "application/json" }, consumes = { + "application/json" }) + default ResponseEntity placeOrder( + @Parameter(description = "order placed for purchasing the pet", required = true) @Valid @RequestBody Order order) { + return getDelegate().placeOrder(order); + } + + /** + * Stores. + * + * @param name the name + */ + @GetMapping(value = "/v1/stores") + default void stores(@Valid @NotBlank String name) { + + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app105/api/store/StoreApiController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app105/api/store/StoreApiController.java new file mode 100644 index 000000000..86454ab89 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app105/api/store/StoreApiController.java @@ -0,0 +1,68 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app105.api.store; + +import java.util.Optional; + +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Store api controller. + */ +@jakarta.annotation.Generated(value = "org.springdoc.demo.app2.codegen.languages.SpringCodegen", date = "2019-07-11T00:09:29.839+02:00[Europe/Paris]") + +@RestController +@RequestMapping("${openapi.openAPIPetstore.base-path:/}") +class StoreApiController implements StoreApi { + + /** + * The Delegate. + */ + private final StoreApiDelegate delegate; + + /** + * Instantiates a new Store api controller. + * + * @param delegate the delegate + */ + public StoreApiController(@org.springframework.beans.factory.annotation.Autowired(required = false) StoreApiDelegate delegate) { + this.delegate = Optional.ofNullable(delegate).orElse(new StoreApiDelegate() { + }); + } + + /** + * Gets delegate. + * + * @return the delegate + */ + @Override + public StoreApiDelegate getDelegate() { + return delegate; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app105/api/store/StoreApiDelegate.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app105/api/store/StoreApiDelegate.java new file mode 100644 index 000000000..99e159a0d --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app105/api/store/StoreApiDelegate.java @@ -0,0 +1,124 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app105.api.store; + +import java.util.Map; +import java.util.Optional; + +import test.org.springdoc.api.v30.app105.api.ApiUtil; +import test.org.springdoc.api.v30.app105.model.Order; + +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.web.context.request.NativeWebRequest; + +/** + * A delegate to be called by the {@link StoreApiController}}. + * Implement this interface with a {@link org.springframework.stereotype.Service} annotated class. + */ +@jakarta.annotation.Generated(value = "org.springdoc.demo.app2.codegen.languages.SpringCodegen", date = "2019-07-11T00:09:29.839+02:00[Europe/Paris]") + +public interface StoreApiDelegate { + + /** + * Gets request. + * + * @return the request + */ + default Optional getRequest() { + return Optional.empty(); + } + + /** + * Delete order response entity. + * + * @param orderId the order id + * @return the response entity + * @see StoreApi#deleteOrder StoreApi#deleteOrder + */ + default ResponseEntity deleteOrder(String orderId) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * Gets inventory. + * + * @return the inventory + * @see StoreApi#getInventory StoreApi#getInventory + */ + default ResponseEntity> getInventory() { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * Gets order by id. + * + * @param orderId the order id + * @return the order by id + * @see StoreApi#getOrderById StoreApi#getOrderById + */ + default ResponseEntity getOrderById(Long orderId) { + extract(); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * Extract. + */ + default void extract() { + getRequest().ifPresent(request -> { + for (MediaType mediaType : MediaType.parseMediaTypes(request.getHeader("Accept"))) { + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + ApiUtil.setExampleResponse(request, "application/json", "{ \"petId\" : 6, \"quantity\" : 1, \"id\" : 0, \"shipDate\" : \"2000-01-23T04:56:07.000+00:00\", \"complete\" : false, \"status\" : \"placed\"}"); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/xml"))) { + ApiUtil.setExampleResponse(request, "application/xml", " 123456789 123456789 123 2000-01-23T04:56:07.000Z aeiou true"); + break; + } + } + }); + } + + /** + * Place order response entity. + * + * @param order the order + * @return the response entity + * @see StoreApi#placeOrder StoreApi#placeOrder + */ + default ResponseEntity placeOrder(Order order) { + extract(); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app105/api/store/StoreApiDelegateImpl.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app105/api/store/StoreApiDelegateImpl.java new file mode 100644 index 000000000..c100604bd --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app105/api/store/StoreApiDelegateImpl.java @@ -0,0 +1,38 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app105.api.store; + +import org.springframework.stereotype.Service; + +/** + * The type Store api delegate. + */ +@Service +class StoreApiDelegateImpl implements StoreApiDelegate { + + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app105/api/user/UserApi.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app105/api/user/UserApi.java new file mode 100644 index 000000000..5c3223f05 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app105/api/user/UserApi.java @@ -0,0 +1,197 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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. + * * * * * + * * * * + * * * + * * + * + */ + +/** + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (3.0.0). + * https://openapi-generator.tech + * Do not edit the class manually. + */ +package test.org.springdoc.api.v30.app105.api.user; + +import java.util.List; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.validation.Valid; +import jakarta.validation.constraints.NotNull; +import test.org.springdoc.api.v30.app105.model.User; + +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestParam; + +/** + * The interface User api. + */ +@jakarta.annotation.Generated(value = "org.springdoc.demo.app2.codegen.languages.SpringCodegen", date = "2019-07-11T00:09:29.839+02:00[Europe/Paris]") + +@Tag(name = "user", description = "the user API") +public interface UserApi { + + /** + * Gets delegate. + * + * @return the delegate + */ + default UserApiDelegate getDelegate() { + return new UserApiDelegate() { + }; + } + + /** + * Create user response entity. + * + * @param user the user + * @return the response entity + */ + @Operation(summary = "Create user", tags = { "user" }) + @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "successful operation") }) + @PostMapping(value = "/user", consumes = { "application/json" }) + default ResponseEntity createUser( + @io.swagger.v3.oas.annotations.parameters.RequestBody(description = "Created user object", required = true) @Valid @RequestBody User user) { + return getDelegate().createUser(user); + } + + /** + * Create users with array input response entity. + * + * @param user the user + * @return the response entity + */ + @Operation(summary = "Creates list of users with given input array", tags = { "user" }) + @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "successful operation") }) + + @PostMapping(value = "/user/createWithArray", consumes = { "application/json" }) + default ResponseEntity createUsersWithArrayInput( + @io.swagger.v3.oas.annotations.parameters.RequestBody(description = "List of user object", required = true) @Valid @RequestBody List user) { + return getDelegate().createUsersWithArrayInput(user); + } + + /** + * Create users with list input response entity. + * + * @param user the user + * @return the response entity + */ + @Operation(summary = "Creates list of users with given input array", tags = { "user" }) + @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "successful operation") }) + @PostMapping(value = "/user/createWithList", consumes = { "application/json" }) + default ResponseEntity createUsersWithListInput( + @io.swagger.v3.oas.annotations.parameters.RequestBody(description = "List of user object", required = true) @Valid @RequestBody List user) { + return getDelegate().createUsersWithListInput(user); + } + + /** + * Delete user response entity. + * + * @param username the username + * @return the response entity + */ + @Operation(summary = "Creates list of users with given input array", tags = { "user" }) + @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "successful operation") }) + + @DeleteMapping(value = "/user/{username}") + default ResponseEntity deleteUser( + @io.swagger.v3.oas.annotations.parameters.RequestBody(description = "The name that needs to be deleted", required = true) @PathVariable("username") String username) { + return getDelegate().deleteUser(username); + } + + /** + * Gets user by name. + * + * @param username the username + * @return the user by name + */ + @Operation(summary = "Get user by user name", tags = { "user" }) + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(schema = @Schema(implementation = User.class))), + @ApiResponse(responseCode = "400", description = "Invalid username supplied"), + @ApiResponse(responseCode = "404", description = "User not found") }) + + @GetMapping(value = "/user/{username}", produces = { "application/xml", "application/json" }) + default ResponseEntity getUserByName( + @Parameter(description = "The name that needs to be fetched. Use user1 for testing.", required = true) @PathVariable("username") String username) { + return getDelegate().getUserByName(username); + } + + /** + * Login user response entity. + * + * @param username the username + * @param password the password + * @return the response entity + */ + @Operation(summary = "Logs user into the system", tags = { "user" }) + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(schema = @Schema(implementation = String.class))), + @ApiResponse(responseCode = "400", description = "Invalid username/password supplied") }) + @GetMapping(value = "/user/login", produces = { "application/xml", "application/json" }) + default ResponseEntity loginUser( + @NotNull @Parameter(description = "The user name for login", required = true) @Valid @RequestParam(value = "username", required = true) String username, + @NotNull @Parameter(description = "The password for login in clear text", required = true) @Valid @RequestParam(value = "password", required = true) String password) { + return getDelegate().loginUser(username, password); + } + + /** + * Logout user response entity. + * + * @return the response entity + */ + @Operation(summary = "Logs out current logged in user session", tags = { "user" }) + @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "successful operation") }) + @GetMapping(value = "/user/logout") + default ResponseEntity logoutUser() { + return getDelegate().logoutUser(); + } + + /** + * Update user response entity. + * + * @param username the username + * @param user the user + * @return the response entity + */ + @Operation(summary = "Updated user", tags = { "user" }) + @ApiResponses(value = { @ApiResponse(responseCode = "400", description = "Invalid user supplied"), + @ApiResponse(responseCode = "404", description = "User not found") }) + @PutMapping(value = "/user/{username}", consumes = { "application/json" }) + default ResponseEntity updateUser( + @Parameter(description = "name that need to be deleted", required = true) @PathVariable("username") String username, + @io.swagger.v3.oas.annotations.parameters.RequestBody(description = "Updated user object", required = true) @Valid @RequestBody User user) { + return getDelegate().updateUser(username, user); + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app105/api/user/UserApiController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app105/api/user/UserApiController.java new file mode 100644 index 000000000..c36144b9d --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app105/api/user/UserApiController.java @@ -0,0 +1,68 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app105.api.user; + +import java.util.Optional; + +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type User api controller. + */ +@jakarta.annotation.Generated(value = "org.springdoc.demo.app2.codegen.languages.SpringCodegen", date = "2019-07-11T00:09:29.839+02:00[Europe/Paris]") + +@RestController +@RequestMapping("${openapi.openAPIPetstore.base-path:/}") +class UserApiController implements UserApi { + + /** + * The Delegate. + */ + private final UserApiDelegate delegate; + + /** + * Instantiates a new User api controller. + * + * @param delegate the delegate + */ + public UserApiController(@org.springframework.beans.factory.annotation.Autowired(required = false) UserApiDelegate delegate) { + this.delegate = Optional.ofNullable(delegate).orElse(new UserApiDelegate() { + }); + } + + /** + * Gets delegate. + * + * @return the delegate + */ + @Override + public UserApiDelegate getDelegate() { + return delegate; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app105/api/user/UserApiDelegate.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app105/api/user/UserApiDelegate.java new file mode 100644 index 000000000..6b27efa02 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app105/api/user/UserApiDelegate.java @@ -0,0 +1,168 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app105.api.user; + +import java.util.List; +import java.util.Optional; + +import test.org.springdoc.api.v30.app105.api.ApiUtil; +import test.org.springdoc.api.v30.app105.model.User; + +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.web.context.request.NativeWebRequest; + +/** + * A delegate to be called by the {@link UserApiController}}. + * Implement this interface with a {@link org.springframework.stereotype.Service} annotated class. + */ +@jakarta.annotation.Generated(value = "org.springdoc.demo.app2.codegen.languages.SpringCodegen", date = "2019-07-11T00:09:29.839+02:00[Europe/Paris]") + +public interface UserApiDelegate { + + /** + * Gets request. + * + * @return the request + */ + default Optional getRequest() { + return Optional.empty(); + } + + /** + * Create user response entity. + * + * @param user the user + * @return the response entity + * @see UserApi#createUser UserApi#createUser + */ + default ResponseEntity createUser(User user) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * Create users with array input response entity. + * + * @param user the user + * @return the response entity + * @see UserApi#createUsersWithArrayInput UserApi#createUsersWithArrayInput + */ + default ResponseEntity createUsersWithArrayInput(List user) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * Create users with list input response entity. + * + * @param user the user + * @return the response entity + * @see UserApi#createUsersWithListInput UserApi#createUsersWithListInput + */ + default ResponseEntity createUsersWithListInput(List user) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * Delete user response entity. + * + * @param username the username + * @return the response entity + * @see UserApi#deleteUser UserApi#deleteUser + */ + default ResponseEntity deleteUser(String username) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * Gets user by name. + * + * @param username the username + * @return the user by name + * @see UserApi#getUserByName UserApi#getUserByName + */ + default ResponseEntity getUserByName(String username) { + getRequest().ifPresent(request -> { + for (MediaType mediaType : MediaType.parseMediaTypes(request.getHeader("Accept"))) { + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + ApiUtil.setExampleResponse(request, "application/json", "{ \"firstName\" : \"firstName\", \"lastName\" : \"lastName\", \"password\" : \"password\", \"userStatus\" : 6, \"phone\" : \"phone\", \"id\" : 0, \"email\" : \"email\", \"username\" : \"username\"}"); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/xml"))) { + ApiUtil.setExampleResponse(request, "application/xml", " 123456789 aeiou aeiou aeiou aeiou aeiou aeiou 123"); + break; + } + } + }); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * Login user response entity. + * + * @param username the username + * @param password the password + * @return the response entity + * @see UserApi#loginUser UserApi#loginUser + */ + default ResponseEntity loginUser(String username, + String password) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * Logout user response entity. + * + * @return the response entity + * @see UserApi#logoutUser UserApi#logoutUser + */ + default ResponseEntity logoutUser() { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * Update user response entity. + * + * @param username the username + * @param user the user + * @return the response entity + * @see UserApi#updateUser UserApi#updateUser + */ + default ResponseEntity updateUser(String username, + User user) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app105/api/user/UserApiDelegateImpl.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app105/api/user/UserApiDelegateImpl.java new file mode 100644 index 000000000..3490a2665 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app105/api/user/UserApiDelegateImpl.java @@ -0,0 +1,38 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app105.api.user; + +import org.springframework.stereotype.Service; + +/** + * The type User api delegate. + */ +@Service +class UserApiDelegateImpl implements UserApiDelegate { + + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app105/model/Category.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app105/model/Category.java new file mode 100644 index 000000000..81e44e96d --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app105/model/Category.java @@ -0,0 +1,137 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app105.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.v3.oas.annotations.media.Schema; + +/** + * The type Category. + */ +class Category { + + /** + * The Id. + */ + @Schema(description = "") + private Long id = null; + + /** + * The Name. + */ + @Schema(description = "") + private String name = null; + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + * @param o the o + * @return the string + */ + private static String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Get id + * + * @return id id + */ + @JsonProperty("id") + public Long getId() { + return id; + } + + /** + * Sets id. + * + * @param id the id + */ + public void setId(Long id) { + this.id = id; + } + + /** + * Id category. + * + * @param id the id + * @return the category + */ + public Category id(Long id) { + this.id = id; + return this; + } + + /** + * Get name + * + * @return name name + */ + @JsonProperty("name") + public String getName() { + return name; + } + + /** + * Sets name. + * + * @param name the name + */ + public void setName(String name) { + this.name = name; + } + + /** + * Name category. + * + * @param name the name + * @return the category + */ + public Category name(String name) { + this.name = name; + return this; + } + + /** + * To string string. + * + * @return the string + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Category {\n"); + + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append("}"); + return sb.toString(); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app105/model/ModelApiResponse.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app105/model/ModelApiResponse.java new file mode 100644 index 000000000..931c735c7 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app105/model/ModelApiResponse.java @@ -0,0 +1,174 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app105.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.v3.oas.annotations.media.Schema; + +/** + * The type Model api response. + */ +public class ModelApiResponse { + + /** + * The Code. + */ + @Schema(description = "") + private Integer code = null; + + /** + * The Type. + */ + @Schema(description = "") + private String type = null; + + /** + * The Message. + */ + @Schema(description = "") + private String message = null; + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + * @param o the o + * @return the string + */ + private static String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Get code + * + * @return code code + */ + @JsonProperty("code") + public Integer getCode() { + return code; + } + + /** + * Sets code. + * + * @param code the code + */ + public void setCode(Integer code) { + this.code = code; + } + + /** + * Code model api response. + * + * @param code the code + * @return the model api response + */ + public ModelApiResponse code(Integer code) { + this.code = code; + return this; + } + + /** + * Get type + * + * @return type type + */ + @JsonProperty("type") + public String getType() { + return type; + } + + /** + * Sets type. + * + * @param type the type + */ + public void setType(String type) { + this.type = type; + } + + /** + * Type model api response. + * + * @param type the type + * @return the model api response + */ + public ModelApiResponse type(String type) { + this.type = type; + return this; + } + + /** + * Get message + * + * @return message message + */ + @JsonProperty("message") + public String getMessage() { + return message; + } + + /** + * Sets message. + * + * @param message the message + */ + public void setMessage(String message) { + this.message = message; + } + + /** + * Message model api response. + * + * @param message the message + * @return the model api response + */ + public ModelApiResponse message(String message) { + this.message = message; + return this; + } + + /** + * To string string. + * + * @return the string + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ModelApiResponse {\n"); + + sb.append(" code: ").append(toIndentedString(code)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" message: ").append(toIndentedString(message)).append("\n"); + sb.append("}"); + return sb.toString(); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app105/model/Order.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app105/model/Order.java new file mode 100644 index 000000000..f0d175f07 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app105/model/Order.java @@ -0,0 +1,364 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app105.model; + +import java.util.Date; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.v3.oas.annotations.media.Schema; + +/** + * The type Order. + */ +public class Order { + + /** + * The Id. + */ + @Schema(description = "") + private Long id = null; + + /** + * The Pet id. + */ + @Schema(description = "") + private Long petId = null; + + /** + * The Quantity. + */ + @Schema(description = "") + private Integer quantity = null; + + /** + * The Ship date. + */ + @Schema(description = "") + private Date shipDate = null; + + /** + * The Status. + */ + @Schema(description = "Order Status") + /** + * Order Status + **/ + private StatusEnum status = null; + + /** + * The Complete. + */ + @Schema(description = "") + private Boolean complete = false; + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + * @param o the o + * @return the string + */ + private static String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Get id + * + * @return id id + */ + @JsonProperty("id") + public Long getId() { + return id; + } + + /** + * Sets id. + * + * @param id the id + */ + public void setId(Long id) { + this.id = id; + } + + /** + * Id order. + * + * @param id the id + * @return the order + */ + public Order id(Long id) { + this.id = id; + return this; + } + + /** + * Get petId + * + * @return petId pet id + */ + @JsonProperty("petId") + public Long getPetId() { + return petId; + } + + /** + * Sets pet id. + * + * @param petId the pet id + */ + public void setPetId(Long petId) { + this.petId = petId; + } + + /** + * Pet id order. + * + * @param petId the pet id + * @return the order + */ + public Order petId(Long petId) { + this.petId = petId; + return this; + } + + /** + * Get quantity + * + * @return quantity quantity + */ + @JsonProperty("quantity") + public Integer getQuantity() { + return quantity; + } + + /** + * Sets quantity. + * + * @param quantity the quantity + */ + public void setQuantity(Integer quantity) { + this.quantity = quantity; + } + + /** + * Quantity order. + * + * @param quantity the quantity + * @return the order + */ + public Order quantity(Integer quantity) { + this.quantity = quantity; + return this; + } + + /** + * Get shipDate + * + * @return shipDate ship date + */ + @JsonProperty("shipDate") + public Date getShipDate() { + return shipDate; + } + + /** + * Sets ship date. + * + * @param shipDate the ship date + */ + public void setShipDate(Date shipDate) { + this.shipDate = shipDate; + } + + /** + * Ship date order. + * + * @param shipDate the ship date + * @return the order + */ + public Order shipDate(Date shipDate) { + this.shipDate = shipDate; + return this; + } + + /** + * Order Status + * + * @return status status + */ + @JsonProperty("status") + public String getStatus() { + if (status == null) { + return null; + } + return status.getValue(); + } + + /** + * Sets status. + * + * @param status the status + */ + public void setStatus(StatusEnum status) { + this.status = status; + } + + /** + * Status order. + * + * @param status the status + * @return the order + */ + public Order status(StatusEnum status) { + this.status = status; + return this; + } + + /** + * Get complete + * + * @return complete boolean + */ + @JsonProperty("complete") + public Boolean isisComplete() { + return complete; + } + + /** + * Sets complete. + * + * @param complete the complete + */ + public void setComplete(Boolean complete) { + this.complete = complete; + } + + /** + * Complete order. + * + * @param complete the complete + * @return the order + */ + public Order complete(Boolean complete) { + this.complete = complete; + return this; + } + + + /** + * To string string. + * + * @return the string + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Order {\n"); + + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" petId: ").append(toIndentedString(petId)).append("\n"); + sb.append(" quantity: ").append(toIndentedString(quantity)).append("\n"); + sb.append(" shipDate: ").append(toIndentedString(shipDate)).append("\n"); + sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append(" complete: ").append(toIndentedString(complete)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * The enum Status enum. + */ + public enum StatusEnum { + /** + *Placed status enum. + */ + PLACED("placed"), + /** + *Approved status enum. + */ + APPROVED("approved"), + /** + *Delivered status enum. + */ + DELIVERED("delivered"); + + /** + * The Value. + */ + private String value; + + /** + * Instantiates a new Status enum. + * + * @param value the value + */ + StatusEnum(String value) { + this.value = value; + } + + /** + * From value status enum. + * + * @param text the text + * @return the status enum + */ + @JsonCreator + public static StatusEnum fromValue(String text) { + for (StatusEnum b : StatusEnum.values()) { + if (String.valueOf(b.value).equals(text)) { + return b; + } + } + return null; + } + + /** + * Gets value. + * + * @return the value + */ + @JsonValue + public String getValue() { + return value; + } + + /** + * To string string. + * + * @return the string + */ + @Override + public String toString() { + return String.valueOf(value); + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app105/model/Pet.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app105/model/Pet.java new file mode 100644 index 000000000..80cb02aef --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app105/model/Pet.java @@ -0,0 +1,392 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app105.model; + +import java.util.ArrayList; +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotNull; + +/** + * The type Pet. + */ +public class Pet { + + /** + * The Id. + */ + @Schema(description = "") + private Long id = null; + + /** + * The Category. + */ + @Schema(description = "") + private Category category = null; + + /** + * The Name. + */ + @Schema(example = "doggie", required = true, description = "") + private String name = null; + + /** + * The Photo urls. + */ + @Schema(required = true, description = "") + private List photoUrls = new ArrayList(); + + /** + * The Tags. + */ + @Schema(description = "") + private List tags = null; + + /** + * The Status. + */ + @Schema(description = "pet status in the store") + /** + * pet status in the store + **/ + private StatusEnum status = null; + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + * @param o the o + * @return the string + */ + private static String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Get id + * + * @return id id + */ + @JsonProperty("id") + public Long getId() { + return id; + } + + /** + * Sets id. + * + * @param id the id + */ + public void setId(Long id) { + this.id = id; + } + + /** + * Id pet. + * + * @param id the id + * @return the pet + */ + public Pet id(Long id) { + this.id = id; + return this; + } + + /** + * Get category + * + * @return category category + */ + @JsonProperty("category") + public Category getCategory() { + return category; + } + + /** + * Sets category. + * + * @param category the category + */ + public void setCategory(Category category) { + this.category = category; + } + + /** + * Category pet. + * + * @param category the category + * @return the pet + */ + public Pet category(Category category) { + this.category = category; + return this; + } + + /** + * Get name + * + * @return name name + */ + @JsonProperty("name") + @NotNull + public String getName() { + return name; + } + + /** + * Sets name. + * + * @param name the name + */ + public void setName(String name) { + this.name = name; + } + + /** + * Name pet. + * + * @param name the name + * @return the pet + */ + public Pet name(String name) { + this.name = name; + return this; + } + + /** + * Get photoUrls + * + * @return photoUrls photo urls + */ + @JsonProperty("photoUrls") + @NotNull + public List getPhotoUrls() { + return photoUrls; + } + + /** + * Sets photo urls. + * + * @param photoUrls the photo urls + */ + public void setPhotoUrls(List photoUrls) { + this.photoUrls = photoUrls; + } + + /** + * Photo urls pet. + * + * @param photoUrls the photo urls + * @return the pet + */ + public Pet photoUrls(List photoUrls) { + this.photoUrls = photoUrls; + return this; + } + + /** + * Add photo urls item pet. + * + * @param photoUrlsItem the photo urls item + * @return the pet + */ + public Pet addPhotoUrlsItem(String photoUrlsItem) { + this.photoUrls.add(photoUrlsItem); + return this; + } + + /** + * Get tags + * + * @return tags tags + */ + @JsonProperty("tags") + public List getTags() { + return tags; + } + + /** + * Sets tags. + * + * @param tags the tags + */ + public void setTags(List tags) { + this.tags = tags; + } + + /** + * Tags pet. + * + * @param tags the tags + * @return the pet + */ + public Pet tags(List tags) { + this.tags = tags; + return this; + } + + /** + * Add tags item pet. + * + * @param tagsItem the tags item + * @return the pet + */ + public Pet addTagsItem(Tag tagsItem) { + if (this.tags == null) { + this.tags = new ArrayList<>(); + } + this.tags.add(tagsItem); + return this; + } + + /** + * pet status in the store + * + * @return status status + */ + @JsonProperty("status") + public StatusEnum getStatus() { + if (status == null) { + return null; + } + return status; + } + + /** + * Sets status. + * + * @param status the status + */ + public void setStatus(StatusEnum status) { + this.status = status; + } + + /** + * Status pet. + * + * @param status the status + * @return the pet + */ + public Pet status(StatusEnum status) { + this.status = status; + return this; + } + + /** + * To string string. + * + * @return the string + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Pet {\n"); + + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" category: ").append(toIndentedString(category)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" photoUrls: ").append(toIndentedString(photoUrls)).append("\n"); + sb.append(" tags: ").append(toIndentedString(tags)).append("\n"); + sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * The enum Status enum. + */ + public enum StatusEnum { + /** + *Available status enum. + */ + AVAILABLE("available"), + /** + *Pending status enum. + */ + PENDING("pending"), + /** + *Sold status enum. + */ + SOLD("sold"); + + /** + * The Value. + */ + private String value; + + /** + * Instantiates a new Status enum. + * + * @param value the value + */ + StatusEnum(String value) { + this.value = value; + } + + /** + * From value status enum. + * + * @param text the text + * @return the status enum + */ + @JsonCreator + public static StatusEnum fromValue(String text) { + for (StatusEnum b : StatusEnum.values()) { + if (String.valueOf(b.value).equals(text)) { + return b; + } + } + return null; + } + + /** + * Gets value. + * + * @return the value + */ + @JsonValue + public String getValue() { + return value; + } + + /** + * To string string. + * + * @return the string + */ + @Override + public String toString() { + return String.valueOf(value); + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app105/model/Tag.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app105/model/Tag.java new file mode 100644 index 000000000..9c7ba4a06 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app105/model/Tag.java @@ -0,0 +1,137 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app105.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.v3.oas.annotations.media.Schema; + +/** + * The type Tag. + */ +class Tag { + + /** + * The Id. + */ + @Schema(description = "") + private Long id = null; + + /** + * The Name. + */ + @Schema(description = "") + private String name = null; + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + * @param o the o + * @return the string + */ + private static String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Get id + * + * @return id id + */ + @JsonProperty("id") + public Long getId() { + return id; + } + + /** + * Sets id. + * + * @param id the id + */ + public void setId(Long id) { + this.id = id; + } + + /** + * Id tag. + * + * @param id the id + * @return the tag + */ + public Tag id(Long id) { + this.id = id; + return this; + } + + /** + * Get name + * + * @return name name + */ + @JsonProperty("name") + public String getName() { + return name; + } + + /** + * Sets name. + * + * @param name the name + */ + public void setName(String name) { + this.name = name; + } + + /** + * Name tag. + * + * @param name the name + * @return the tag + */ + public Tag name(String name) { + this.name = name; + return this; + } + + /** + * To string string. + * + * @return the string + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Tag {\n"); + + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append("}"); + return sb.toString(); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app105/model/User.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app105/model/User.java new file mode 100644 index 000000000..3e09cc23c --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app105/model/User.java @@ -0,0 +1,362 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app105.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.v3.oas.annotations.media.Schema; + +/** + * The type User. + */ +public class User { + + /** + * The Id. + */ + @Schema(description = "") + private Long id = null; + + /** + * The Username. + */ + @Schema(description = "") + private String username = null; + + /** + * The First name. + */ + @Schema(description = "") + private String firstName = null; + + /** + * The Last name. + */ + @Schema(description = "") + private String lastName = null; + + /** + * The Email. + */ + @Schema(description = "") + private String email = null; + + /** + * The Password. + */ + @Schema(description = "") + private String password = null; + + /** + * The Phone. + */ + @Schema(description = "") + private String phone = null; + + /** + * The User status. + */ + @Schema(description = "User Status") + /** + * User Status + **/ + private Integer userStatus = null; + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + * @param o the o + * @return the string + */ + private static String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Get id + * + * @return id id + */ + @JsonProperty("id") + public Long getId() { + return id; + } + + /** + * Sets id. + * + * @param id the id + */ + public void setId(Long id) { + this.id = id; + } + + /** + * Id user. + * + * @param id the id + * @return the user + */ + public User id(Long id) { + this.id = id; + return this; + } + + /** + * Get username + * + * @return username username + */ + @JsonProperty("username") + public String getUsername() { + return username; + } + + /** + * Sets username. + * + * @param username the username + */ + public void setUsername(String username) { + this.username = username; + } + + /** + * Username user. + * + * @param username the username + * @return the user + */ + public User username(String username) { + this.username = username; + return this; + } + + /** + * Get firstName + * + * @return firstName first name + */ + @JsonProperty("firstName") + public String getFirstName() { + return firstName; + } + + /** + * Sets first name. + * + * @param firstName the first name + */ + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + /** + * First name user. + * + * @param firstName the first name + * @return the user + */ + public User firstName(String firstName) { + this.firstName = firstName; + return this; + } + + /** + * Get lastName + * + * @return lastName last name + */ + @JsonProperty("lastName") + public String getLastName() { + return lastName; + } + + /** + * Sets last name. + * + * @param lastName the last name + */ + public void setLastName(String lastName) { + this.lastName = lastName; + } + + /** + * Last name user. + * + * @param lastName the last name + * @return the user + */ + public User lastName(String lastName) { + this.lastName = lastName; + return this; + } + + /** + * Get email + * + * @return email email + */ + @JsonProperty("email") + public String getEmail() { + return email; + } + + /** + * Sets email. + * + * @param email the email + */ + public void setEmail(String email) { + this.email = email; + } + + /** + * Email user. + * + * @param email the email + * @return the user + */ + public User email(String email) { + this.email = email; + return this; + } + + /** + * Get password + * + * @return password password + */ + @JsonProperty("password") + public String getPassword() { + return password; + } + + /** + * Sets password. + * + * @param password the password + */ + public void setPassword(String password) { + this.password = password; + } + + /** + * Password user. + * + * @param password the password + * @return the user + */ + public User password(String password) { + this.password = password; + return this; + } + + /** + * Get phone + * + * @return phone phone + */ + @JsonProperty("phone") + public String getPhone() { + return phone; + } + + /** + * Sets phone. + * + * @param phone the phone + */ + public void setPhone(String phone) { + this.phone = phone; + } + + /** + * Phone user. + * + * @param phone the phone + * @return the user + */ + public User phone(String phone) { + this.phone = phone; + return this; + } + + /** + * User Status + * + * @return userStatus user status + */ + @JsonProperty("userStatus") + public Integer getUserStatus() { + return userStatus; + } + + /** + * Sets user status. + * + * @param userStatus the user status + */ + public void setUserStatus(Integer userStatus) { + this.userStatus = userStatus; + } + + /** + * User status user. + * + * @param userStatus the user status + * @return the user + */ + public User userStatus(Integer userStatus) { + this.userStatus = userStatus; + return this; + } + + /** + * To string string. + * + * @return the string + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class User {\n"); + + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" username: ").append(toIndentedString(username)).append("\n"); + sb.append(" firstName: ").append(toIndentedString(firstName)).append("\n"); + sb.append(" lastName: ").append(toIndentedString(lastName)).append("\n"); + sb.append(" email: ").append(toIndentedString(email)).append("\n"); + sb.append(" password: ").append(toIndentedString(password)).append("\n"); + sb.append(" phone: ").append(toIndentedString(phone)).append("\n"); + sb.append(" userStatus: ").append(toIndentedString(userStatus)).append("\n"); + sb.append("}"); + return sb.toString(); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app106/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app106/HelloController.java new file mode 100644 index 000000000..4ec9507e7 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app106/HelloController.java @@ -0,0 +1,66 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app106; + +import java.time.Instant; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.enums.ParameterIn; +import io.swagger.v3.oas.annotations.media.Schema; + +import org.springframework.http.HttpHeaders; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestHeader; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * Find articles response entity. + * + * @param modifiedSince the modified since + * @return the response entity + */ + @Operation(summary = "find-articles") + @GetMapping + @Parameter(name = HttpHeaders.IF_MODIFIED_SINCE, + description = "DateTime", + in = ParameterIn.HEADER, + schema = @Schema(type = "string", format = "date-time"), + example = "2020-01-01T00:00:00.000Z" + ) + public ResponseEntity findArticles(@RequestHeader(value = HttpHeaders.IF_MODIFIED_SINCE, required = false) Instant modifiedSince) { + return null; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app106/SpringDocApp106Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app106/SpringDocApp106Test.java new file mode 100644 index 000000000..1378b6d31 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app106/SpringDocApp106Test.java @@ -0,0 +1,42 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app106; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 106 test. + */ +class SpringDocApp106Test extends AbstractSpringDocTest { + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app107/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app107/HelloController.java new file mode 100644 index 000000000..6bc235c9c --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app107/HelloController.java @@ -0,0 +1,85 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app107; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.v3.oas.annotations.media.Schema; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * Gets entity b. + * + * @return the entity b + */ + @GetMapping(path = "/entity-b", produces = { "application/json", "application/xml" }) + public EntityB getEntityB() { + return new EntityB(); + } + + /** + * The type Entity b. + */ + class EntityB { + + /** + * The Field b. + */ + @Schema(required = true) + @JsonProperty("fieldB") + private String fieldB; + + /** + * The Entity a. + */ + @Schema(required = true) + @JsonProperty("entityA") + private EntityA entityA; + //Getters and setters... + } + + /** + * The type Entity a. + */ + class EntityA { + /** + * The Field a. + */ + @Schema(required = true) + @JsonProperty("fieldA") + private String fieldA; + //Getters and setters... + } +} + diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app107/SpringDocApp107Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app107/SpringDocApp107Test.java new file mode 100644 index 000000000..a3d4aa53d --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app107/SpringDocApp107Test.java @@ -0,0 +1,42 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app107; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 107 test. + */ +class SpringDocApp107Test extends AbstractSpringDocTest { + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app108/ActionResult.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app108/ActionResult.java new file mode 100644 index 000000000..621700d17 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app108/ActionResult.java @@ -0,0 +1,173 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app108; + +/** + * The type Action result. + * + * @param the type parameter + */ +class ActionResult { + + /** + * The Value. + */ + protected T value; + + /** + * The Success. + */ + protected boolean success; + + /** + * The Error code. + */ + protected String errorCode; + + /** + * The Message. + */ + protected String message; + + /** + * The Error value. + */ + protected Object errorValue; + + /** + * The Target url. + */ + protected String targetUrl; + + /** + * Gets value. + * + * @return the value + */ + public T getValue() { + return value; + } + + /** + * Sets value. + * + * @param value the value + */ + public void setValue(T value) { + this.value = value; + } + + /** + * Is success boolean. + * + * @return the boolean + */ + public boolean isSuccess() { + return success; + } + + /** + * Sets success. + * + * @param success the success + */ + public void setSuccess(boolean success) { + this.success = success; + } + + /** + * Gets error code. + * + * @return the error code + */ + public String getErrorCode() { + return errorCode; + } + + /** + * Sets error code. + * + * @param errorCode the error code + */ + public void setErrorCode(String errorCode) { + this.errorCode = errorCode; + } + + /** + * Gets message. + * + * @return the message + */ + public String getMessage() { + return message; + } + + /** + * Sets message. + * + * @param message the message + */ + public void setMessage(String message) { + this.message = message; + } + + /** + * Gets error value. + * + * @return the error value + */ + public Object getErrorValue() { + return errorValue; + } + + /** + * Sets error value. + * + * @param errorValue the error value + */ + public void setErrorValue(Object errorValue) { + this.errorValue = errorValue; + } + + /** + * Gets target url. + * + * @return the target url + */ + public String getTargetUrl() { + return targetUrl; + } + + /** + * Sets target url. + * + * @param targetUrl the target url + */ + public void setTargetUrl(String targetUrl) { + this.targetUrl = targetUrl; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app108/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app108/HelloController.java new file mode 100644 index 000000000..d92664602 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app108/HelloController.java @@ -0,0 +1,49 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app108; + +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * Update action result. + * + * @param toto the toto + * @return the action result + */ + @PostMapping + public ActionResult update(String toto) { + return null; + } +} + diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app108/SpringDocApp108Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app108/SpringDocApp108Test.java new file mode 100644 index 000000000..8ae0b068e --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app108/SpringDocApp108Test.java @@ -0,0 +1,42 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app108; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 108 test. + */ +class SpringDocApp108Test extends AbstractSpringDocTest { + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app109/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app109/HelloController.java new file mode 100644 index 000000000..032efdb4c --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app109/HelloController.java @@ -0,0 +1,64 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app109; + +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; + +import org.springframework.core.io.ByteArrayResource; +import org.springframework.core.io.Resource; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * Gets resource. + * + * @return the resource + */ + @GetMapping("/api/v1/resource") + public Resource getResource() { + return new ByteArrayResource(new byte[] {}); + } + + /** + * Get byte array byte [ ]. + * + * @return the byte [ ] + */ + @GetMapping("/api/v1/bytearray") + @ApiResponse(content = @Content(schema = @Schema(type = "string", format = "binary"))) + public byte[] getByteArray() { + return new byte[] {}; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app109/SpringDocApp109Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app109/SpringDocApp109Test.java new file mode 100644 index 000000000..c43cc5f83 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app109/SpringDocApp109Test.java @@ -0,0 +1,42 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app109; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 109 test. + */ +class SpringDocApp109Test extends AbstractSpringDocTest { + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app11/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app11/HelloController.java new file mode 100644 index 000000000..8099afd0b --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app11/HelloController.java @@ -0,0 +1,71 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app11; + +import java.util.List; + +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.multipart.MultipartFile; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * Upload documents response entity. + * + * @param multipartFiles the multipart files + * @return the response entity + */ + @PostMapping(path = "/documents", consumes = "multipart/form-data") + public ResponseEntity uploadDocuments(@RequestPart("doc") List multipartFiles) { + return null; + } + + /** + * Post track string. + * + * @param file the file + * @return the string + */ + @RequestMapping(value = "/tracks", method = RequestMethod.POST, consumes = { MediaType.MULTIPART_FORM_DATA_VALUE }) + public @ResponseBody + String postTrack(@RequestParam("file") MultipartFile file) { + return "redirect:/"; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app11/SpringDocApp11Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app11/SpringDocApp11Test.java new file mode 100644 index 000000000..a6355d729 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app11/SpringDocApp11Test.java @@ -0,0 +1,44 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app11; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 11 test. + */ +class SpringDocApp11Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app110/ErrorMessage.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app110/ErrorMessage.java new file mode 100644 index 000000000..cd99880b8 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app110/ErrorMessage.java @@ -0,0 +1,94 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app110; + +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + + +/** + * The type Error message. + */ +class ErrorMessage { + + /** + * The Errors. + */ + private List errors; + + /** + * Instantiates a new Error message. + */ + public ErrorMessage() { + } + + /** + * Instantiates a new Error message. + * + * @param errors the errors + */ + public ErrorMessage(List errors) { + this.errors = errors; + } + + /** + * Instantiates a new Error message. + * + * @param error the error + */ + public ErrorMessage(String error) { + this(Collections.singletonList(error)); + } + + /** + * Instantiates a new Error message. + * + * @param errors the errors + */ + public ErrorMessage(String... errors) { + this(Arrays.asList(errors)); + } + + /** + * Gets errors. + * + * @return the errors + */ + public List getErrors() { + return errors; + } + + /** + * Sets errors. + * + * @param errors the errors + */ + public void setErrors(List errors) { + this.errors = errors; + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app110/GlobalControllerAdvice.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app110/GlobalControllerAdvice.java new file mode 100644 index 000000000..2e7ecc91f --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app110/GlobalControllerAdvice.java @@ -0,0 +1,192 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app110; + +import java.util.ArrayList; +import java.util.List; +import java.util.Set; +import java.util.UUID; + +import jakarta.validation.ConstraintViolation; +import jakarta.validation.ConstraintViolationException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.http.converter.HttpMessageNotReadableException; +import org.springframework.validation.FieldError; +import org.springframework.validation.ObjectError; +import org.springframework.web.HttpMediaTypeNotSupportedException; +import org.springframework.web.bind.MethodArgumentNotValidException; +import org.springframework.web.bind.MissingServletRequestParameterException; +import org.springframework.web.bind.annotation.ControllerAdvice; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.ResponseStatus; + + +/** + * The type Global controller advice. + */ +@ControllerAdvice(assignableTypes = PersonController.class) +class GlobalControllerAdvice //extends ResponseEntityExceptionHandler +{ + /** + * Note use base class if you wish to leverage its handling. + * Some code will need changing. + */ + private static final Logger logger = LoggerFactory.getLogger(GlobalControllerAdvice.class); + + /** + * Problem response entity. + * + * @param e the e + * @return the response entity + */ + @ExceptionHandler(Throwable.class) + @ResponseStatus(code = HttpStatus.INTERNAL_SERVER_ERROR) + public ResponseEntity problem(final Throwable e) { + String message = "Problem occured"; + UUID uuid = UUID.randomUUID(); + String logRef = uuid.toString(); + logger.error("logRef=" + logRef, message, e); + return new ResponseEntity(new Problem(logRef, message), HttpStatus.INTERNAL_SERVER_ERROR); + } + + + /** + * Handle method argument not valid response entity. + * + * @param ex the ex + * @return the response entity + */ + @ExceptionHandler(MethodArgumentNotValidException.class) + @ResponseStatus(code = HttpStatus.BAD_REQUEST) + public ResponseEntity handleMethodArgumentNotValid(MethodArgumentNotValidException ex + ) { + List fieldErrors = ex.getBindingResult().getFieldErrors(); + List globalErrors = ex.getBindingResult().getGlobalErrors(); + List errors = new ArrayList<>(fieldErrors.size() + globalErrors.size()); + String error; + for (FieldError fieldError : fieldErrors) { + error = fieldError.getField() + ", " + fieldError.getDefaultMessage(); + errors.add(error); + } + for (ObjectError objectError : globalErrors) { + error = objectError.getObjectName() + ", " + objectError.getDefaultMessage(); + errors.add(error); + } + ErrorMessage errorMessage = new ErrorMessage(errors); + + //Object result=ex.getBindingResult();//instead of above can allso pass the more detailed bindingResult + return new ResponseEntity(errorMessage, HttpStatus.BAD_REQUEST); + } + + /** + * Handle constraint violated exception response entity. + * + * @param ex the ex + * @return the response entity + */ + @ExceptionHandler(ConstraintViolationException.class) + @ResponseStatus(code = HttpStatus.BAD_REQUEST) + public ResponseEntity handleConstraintViolatedException(ConstraintViolationException ex + ) { + Set> constraintViolations = ex.getConstraintViolations(); + + + List errors = new ArrayList<>(constraintViolations.size()); + String error; + for (ConstraintViolation constraintViolation : constraintViolations) { + + error = constraintViolation.getMessage(); + errors.add(error); + } + + ErrorMessage errorMessage = new ErrorMessage(errors); + return new ResponseEntity(errorMessage, HttpStatus.BAD_REQUEST); + } + + /** + * Handle missing servlet request parameter exception response entity. + * + * @param ex the ex + * @return the response entity + */ + @ExceptionHandler(MissingServletRequestParameterException.class) + @ResponseStatus(code = HttpStatus.BAD_REQUEST) + public ResponseEntity handleMissingServletRequestParameterException(MissingServletRequestParameterException ex + ) { + + List errors = new ArrayList<>(); + String error = ex.getParameterName() + ", " + ex.getMessage(); + errors.add(error); + ErrorMessage errorMessage = new ErrorMessage(errors); + return new ResponseEntity(errorMessage, HttpStatus.BAD_REQUEST); + } + + + /** + * Handle http media type not supported response entity. + * + * @param ex the ex + * @return the response entity + */ + @ExceptionHandler(HttpMediaTypeNotSupportedException.class) + @ResponseStatus(code = HttpStatus.UNSUPPORTED_MEDIA_TYPE) + public ResponseEntity handleHttpMediaTypeNotSupported(HttpMediaTypeNotSupportedException ex + ) { + String unsupported = "Unsupported content type: " + ex.getContentType(); + String supported = "Supported content types: " + MediaType.toString(ex.getSupportedMediaTypes()); + ErrorMessage errorMessage = new ErrorMessage(unsupported, supported); + return new ResponseEntity(errorMessage, HttpStatus.UNSUPPORTED_MEDIA_TYPE); + } + + /** + * Handle http message not readable response entity. + * + * @param ex the ex + * @return the response entity + */ + @ExceptionHandler(HttpMessageNotReadableException.class) + @ResponseStatus(code = HttpStatus.BAD_REQUEST) + public ResponseEntity handleHttpMessageNotReadable(HttpMessageNotReadableException ex) { + Throwable mostSpecificCause = ex.getMostSpecificCause(); + ErrorMessage errorMessage; + if (mostSpecificCause != null) { + String exceptionName = mostSpecificCause.getClass().getName(); + String message = mostSpecificCause.getMessage(); + errorMessage = new ErrorMessage(exceptionName, message); + } + else { + errorMessage = new ErrorMessage(ex.getMessage()); + } + return new ResponseEntity(errorMessage, HttpStatus.BAD_REQUEST); + } + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app110/Person.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app110/Person.java new file mode 100644 index 000000000..c28859044 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app110/Person.java @@ -0,0 +1,212 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app110; + +import jakarta.validation.constraints.Email; +import jakarta.validation.constraints.Max; +import jakarta.validation.constraints.Min; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; +import jakarta.validation.constraints.Pattern; +import jakarta.validation.constraints.Size; +import org.hibernate.validator.constraints.CreditCardNumber; + + +/** + * The type Person. + */ +class Person { + /** + * The Id. + */ + private long id; + + /** + * The First name. + */ + private String firstName; + + /** + * The Last name. + */ + @NotNull + @NotBlank + @Size(max = 10) + private String lastName; + + /** + * The Email. + */ + @Pattern(regexp = ".+@.+\\..+", message = "Please provide a valid email address") + private String email; + + /** + * The Email 1. + */ + @Email() + private String email1; + + /** + * The Age. + */ + @Min(18) + @Max(30) + private int age; + + /** + * The Credit card number. + */ + @CreditCardNumber + private String creditCardNumber; + + /** + * Gets credit card number. + * + * @return the credit card number + */ + public String getCreditCardNumber() { + return creditCardNumber; + } + + /** + * Sets credit card number. + * + * @param creditCardNumber the credit card number + */ + public void setCreditCardNumber(String creditCardNumber) { + this.creditCardNumber = creditCardNumber; + } + + /** + * Gets id. + * + * @return the id + */ + public long getId() { + return id; + } + + /** + * Sets id. + * + * @param id the id + */ + public void setId(long id) { + this.id = id; + } + + /** + * Gets email 1. + * + * @return the email 1 + */ + public String getEmail1() { + return email1; + } + + /** + * Sets email 1. + * + * @param email1 the email 1 + */ + public void setEmail1(String email1) { + this.email1 = email1; + } + + /** + * Gets first name. + * + * @return the first name + */ + @Size(min = 2) + public String getFirstName() { + return firstName; + } + + /** + * Sets first name. + * + * @param firstName the first name + */ + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + /** + * Gets last name. + * + * @return the last name + */ + public String getLastName() { + return lastName; + } + + /** + * Sets last name. + * + * @param lastName the last name + */ + public void setLastName(String lastName) { + this.lastName = lastName; + } + + /** + * Gets email. + * + * @return the email + */ + public String getEmail() { + return email; + } + + /** + * Sets email. + * + * @param email the email + */ + public void setEmail(String email) { + this.email = email; + } + + /** + * Gets age. + * + * @return the age + */ + public int getAge() { + return age; + } + + /** + * Sets age. + * + * @param age the age + */ + public void setAge(int age) { + this.age = age; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app110/PersonController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app110/PersonController.java new file mode 100644 index 000000000..61255bb4a --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app110/PersonController.java @@ -0,0 +1,96 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app110; + +import java.util.ArrayList; +import java.util.List; +import java.util.Random; + +import jakarta.validation.Valid; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; +import jakarta.validation.constraints.Size; + +import org.springframework.validation.annotation.Validated; +import org.springframework.web.HttpMediaTypeNotSupportedException; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Person controller. + */ +@RestController +@Validated +class PersonController { + /** + * The Ran. + */ + private Random ran = new Random(); + + /** + * Person person. + * + * @param person the person + * @return the person + */ + @RequestMapping(path = "/person", method = RequestMethod.POST) + public Person person(@Valid @RequestBody Person person) throws HttpMediaTypeNotSupportedException { + + int nxt = ran.nextInt(10); + if (nxt >= 5) { + throw new RuntimeException("Breaking logic"); + } + return person; + } + + /** + * Find by last name list. + * + * @param lastName the last name + * @return the list + */ + @RequestMapping(path = "/personByLastName", method = RequestMethod.GET) + public List findByLastName(@RequestParam(name = "lastName", required = true) @NotNull + @NotBlank + @Size(max = 10) String lastName) throws HttpMediaTypeNotSupportedException { + List hardCoded = new ArrayList<>(); + Person person = new Person(); + person.setAge(20); + person.setCreditCardNumber("4111111111111111"); + person.setEmail("abc@abc.com"); + person.setEmail1("abc1@abc.com"); + person.setFirstName("Somefirstname"); + person.setLastName(lastName); + person.setId(1); + hardCoded.add(person); + return hardCoded; + + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app110/PersonController2.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app110/PersonController2.java new file mode 100644 index 000000000..5f5f465d6 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app110/PersonController2.java @@ -0,0 +1,95 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app110; + +import java.util.ArrayList; +import java.util.List; +import java.util.Random; + +import jakarta.validation.Valid; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; +import jakarta.validation.constraints.Size; + +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Person controller 2. + */ +@RestController +@Validated +class PersonController2 { + /** + * The Ran. + */ + private Random ran = new Random(); + + /** + * Person person. + * + * @param person the person + * @return the person + */ + @RequestMapping(path = "/person2", method = RequestMethod.POST) + public Person person(@Valid @RequestBody Person person) { + + int nxt = ran.nextInt(10); + if (nxt >= 5) { + throw new RuntimeException("Breaking logic"); + } + return person; + } + + /** + * Find by last name list. + * + * @param lastName the last name + * @return the list + */ + @RequestMapping(path = "/personByLastName2", method = RequestMethod.GET) + public List findByLastName(@RequestParam(name = "lastName", required = true) @NotNull + @NotBlank + @Size(max = 10) String lastName) { + List hardCoded = new ArrayList<>(); + Person person = new Person(); + person.setAge(20); + person.setCreditCardNumber("4111111111111111"); + person.setEmail("abc@abc.com"); + person.setEmail1("abc1@abc.com"); + person.setFirstName("Somefirstname"); + person.setLastName(lastName); + person.setId(1); + hardCoded.add(person); + return hardCoded; + + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app110/Problem.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app110/Problem.java new file mode 100644 index 000000000..249b9761a --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app110/Problem.java @@ -0,0 +1,99 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app110; + +/** + * The type Problem. + */ +class Problem { + + /** + * The Log ref. + */ + private String logRef; + + /** + * The Message. + */ + private String message; + + /** + * Instantiates a new Problem. + * + * @param logRef the log ref + * @param message the message + */ + public Problem(String logRef, String message) { + super(); + this.logRef = logRef; + this.message = message; + } + + /** + * Instantiates a new Problem. + */ + public Problem() { + super(); + + } + + /** + * Gets log ref. + * + * @return the log ref + */ + public String getLogRef() { + return logRef; + } + + /** + * Sets log ref. + * + * @param logRef the log ref + */ + public void setLogRef(String logRef) { + this.logRef = logRef; + } + + /** + * Gets message. + * + * @return the message + */ + public String getMessage() { + return message; + } + + /** + * Sets message. + * + * @param message the message + */ + public void setMessage(String message) { + this.message = message; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app110/SpringDocApp110Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app110/SpringDocApp110Test.java new file mode 100644 index 000000000..c277bc3ad --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app110/SpringDocApp110Test.java @@ -0,0 +1,72 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app110; + +import io.swagger.v3.oas.models.OpenAPI; +import io.swagger.v3.oas.models.info.Info; +import io.swagger.v3.oas.models.info.License; +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; +import org.springframework.test.context.TestPropertySource; + +/** + * The type Spring doc app 110 test. + */ +@TestPropertySource(properties = { + "application-description=description", + "application-version=v1" }) +class SpringDocApp110Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp { + + /** + * Custom open api open api. + * + * @param appDesciption the app desciption + * @param appVersion the app version + * @return the open api + */ + @Bean + public OpenAPI customOpenAPI(@Value("${application-description}") String appDesciption, @Value("${application-version}") String appVersion) { + + return new OpenAPI() + .info(new Info() + .title("sample application API") + .version(appVersion) + .description(appDesciption) + .termsOfService("http://swagger.io/terms/") + .license(new License().name("Apache 2.0").url("http://springdoc.org"))); + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app111/ErrorMessage.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app111/ErrorMessage.java new file mode 100644 index 000000000..3d38bb18f --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app111/ErrorMessage.java @@ -0,0 +1,94 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app111; + +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + + +/** + * The type Error message. + */ +class ErrorMessage { + + /** + * The Errors. + */ + private List errors; + + /** + * Instantiates a new Error message. + */ + public ErrorMessage() { + } + + /** + * Instantiates a new Error message. + * + * @param errors the errors + */ + public ErrorMessage(List errors) { + this.errors = errors; + } + + /** + * Instantiates a new Error message. + * + * @param error the error + */ + public ErrorMessage(String error) { + this(Collections.singletonList(error)); + } + + /** + * Instantiates a new Error message. + * + * @param errors the errors + */ + public ErrorMessage(String... errors) { + this(Arrays.asList(errors)); + } + + /** + * Gets errors. + * + * @return the errors + */ + public List getErrors() { + return errors; + } + + /** + * Sets errors. + * + * @param errors the errors + */ + public void setErrors(List errors) { + this.errors = errors; + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app111/GlobalControllerAdvice.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app111/GlobalControllerAdvice.java new file mode 100644 index 000000000..88fd3dc62 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app111/GlobalControllerAdvice.java @@ -0,0 +1,192 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app111; + +import java.util.ArrayList; +import java.util.List; +import java.util.Set; +import java.util.UUID; + +import jakarta.validation.ConstraintViolation; +import jakarta.validation.ConstraintViolationException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.http.converter.HttpMessageNotReadableException; +import org.springframework.validation.FieldError; +import org.springframework.validation.ObjectError; +import org.springframework.web.HttpMediaTypeNotSupportedException; +import org.springframework.web.bind.MethodArgumentNotValidException; +import org.springframework.web.bind.MissingServletRequestParameterException; +import org.springframework.web.bind.annotation.ControllerAdvice; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.ResponseStatus; + + +/** + * The type Global controller advice. + */ +@ControllerAdvice(basePackages = "test.org.springdoc.api.appzzz") +class GlobalControllerAdvice //extends ResponseEntityExceptionHandler +{ + /** + * Note use base class if you wish to leverage its handling. + * Some code will need changing. + */ + private static final Logger logger = LoggerFactory.getLogger(GlobalControllerAdvice.class); + + /** + * Problem response entity. + * + * @param e the e + * @return the response entity + */ + @ExceptionHandler(Throwable.class) + @ResponseStatus(code = HttpStatus.INTERNAL_SERVER_ERROR) + public ResponseEntity problem(final Throwable e) { + String message = "Problem occured"; + UUID uuid = UUID.randomUUID(); + String logRef = uuid.toString(); + logger.error("logRef=" + logRef, message, e); + return new ResponseEntity(new Problem(logRef, message), HttpStatus.INTERNAL_SERVER_ERROR); + } + + + /** + * Handle method argument not valid response entity. + * + * @param ex the ex + * @return the response entity + */ + @ExceptionHandler(MethodArgumentNotValidException.class) + @ResponseStatus(code = HttpStatus.BAD_REQUEST) + public ResponseEntity handleMethodArgumentNotValid(MethodArgumentNotValidException ex + ) { + List fieldErrors = ex.getBindingResult().getFieldErrors(); + List globalErrors = ex.getBindingResult().getGlobalErrors(); + List errors = new ArrayList<>(fieldErrors.size() + globalErrors.size()); + String error; + for (FieldError fieldError : fieldErrors) { + error = fieldError.getField() + ", " + fieldError.getDefaultMessage(); + errors.add(error); + } + for (ObjectError objectError : globalErrors) { + error = objectError.getObjectName() + ", " + objectError.getDefaultMessage(); + errors.add(error); + } + ErrorMessage errorMessage = new ErrorMessage(errors); + + //Object result=ex.getBindingResult();//instead of above can allso pass the more detailed bindingResult + return new ResponseEntity(errorMessage, HttpStatus.BAD_REQUEST); + } + + /** + * Handle constraint violated exception response entity. + * + * @param ex the ex + * @return the response entity + */ + @ExceptionHandler(ConstraintViolationException.class) + @ResponseStatus(code = HttpStatus.BAD_REQUEST) + public ResponseEntity handleConstraintViolatedException(ConstraintViolationException ex + ) { + Set> constraintViolations = ex.getConstraintViolations(); + + + List errors = new ArrayList<>(constraintViolations.size()); + String error; + for (ConstraintViolation constraintViolation : constraintViolations) { + + error = constraintViolation.getMessage(); + errors.add(error); + } + + ErrorMessage errorMessage = new ErrorMessage(errors); + return new ResponseEntity(errorMessage, HttpStatus.BAD_REQUEST); + } + + /** + * Handle missing servlet request parameter exception response entity. + * + * @param ex the ex + * @return the response entity + */ + @ExceptionHandler(MissingServletRequestParameterException.class) + @ResponseStatus(code = HttpStatus.BAD_REQUEST) + public ResponseEntity handleMissingServletRequestParameterException(MissingServletRequestParameterException ex + ) { + + List errors = new ArrayList<>(); + String error = ex.getParameterName() + ", " + ex.getMessage(); + errors.add(error); + ErrorMessage errorMessage = new ErrorMessage(errors); + return new ResponseEntity(errorMessage, HttpStatus.BAD_REQUEST); + } + + + /** + * Handle http media type not supported response entity. + * + * @param ex the ex + * @return the response entity + */ + @ExceptionHandler(HttpMediaTypeNotSupportedException.class) + @ResponseStatus(code = HttpStatus.UNSUPPORTED_MEDIA_TYPE) + public ResponseEntity handleHttpMediaTypeNotSupported(HttpMediaTypeNotSupportedException ex + ) { + String unsupported = "Unsupported content type: " + ex.getContentType(); + String supported = "Supported content types: " + MediaType.toString(ex.getSupportedMediaTypes()); + ErrorMessage errorMessage = new ErrorMessage(unsupported, supported); + return new ResponseEntity(errorMessage, HttpStatus.UNSUPPORTED_MEDIA_TYPE); + } + + /** + * Handle http message not readable response entity. + * + * @param ex the ex + * @return the response entity + */ + @ExceptionHandler(HttpMessageNotReadableException.class) + @ResponseStatus(code = HttpStatus.BAD_REQUEST) + public ResponseEntity handleHttpMessageNotReadable(HttpMessageNotReadableException ex) { + Throwable mostSpecificCause = ex.getMostSpecificCause(); + ErrorMessage errorMessage; + if (mostSpecificCause != null) { + String exceptionName = mostSpecificCause.getClass().getName(); + String message = mostSpecificCause.getMessage(); + errorMessage = new ErrorMessage(exceptionName, message); + } + else { + errorMessage = new ErrorMessage(ex.getMessage()); + } + return new ResponseEntity(errorMessage, HttpStatus.BAD_REQUEST); + } + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app111/Person.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app111/Person.java new file mode 100644 index 000000000..1e2e1cb0f --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app111/Person.java @@ -0,0 +1,212 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app111; + +import jakarta.validation.constraints.Email; +import jakarta.validation.constraints.Max; +import jakarta.validation.constraints.Min; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; +import jakarta.validation.constraints.Pattern; +import jakarta.validation.constraints.Size; +import org.hibernate.validator.constraints.CreditCardNumber; + + +/** + * The type Person. + */ +class Person { + /** + * The Id. + */ + private long id; + + /** + * The First name. + */ + private String firstName; + + /** + * The Last name. + */ + @NotNull + @NotBlank + @Size(max = 10) + private String lastName; + + /** + * The Email. + */ + @Pattern(regexp = ".+@.+\\..+", message = "Please provide a valid email address") + private String email; + + /** + * The Email 1. + */ + @Email() + private String email1; + + /** + * The Age. + */ + @Min(18) + @Max(30) + private int age; + + /** + * The Credit card number. + */ + @CreditCardNumber + private String creditCardNumber; + + /** + * Gets credit card number. + * + * @return the credit card number + */ + public String getCreditCardNumber() { + return creditCardNumber; + } + + /** + * Sets credit card number. + * + * @param creditCardNumber the credit card number + */ + public void setCreditCardNumber(String creditCardNumber) { + this.creditCardNumber = creditCardNumber; + } + + /** + * Gets id. + * + * @return the id + */ + public long getId() { + return id; + } + + /** + * Sets id. + * + * @param id the id + */ + public void setId(long id) { + this.id = id; + } + + /** + * Gets email 1. + * + * @return the email 1 + */ + public String getEmail1() { + return email1; + } + + /** + * Sets email 1. + * + * @param email1 the email 1 + */ + public void setEmail1(String email1) { + this.email1 = email1; + } + + /** + * Gets first name. + * + * @return the first name + */ + @Size(min = 2) + public String getFirstName() { + return firstName; + } + + /** + * Sets first name. + * + * @param firstName the first name + */ + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + /** + * Gets last name. + * + * @return the last name + */ + public String getLastName() { + return lastName; + } + + /** + * Sets last name. + * + * @param lastName the last name + */ + public void setLastName(String lastName) { + this.lastName = lastName; + } + + /** + * Gets email. + * + * @return the email + */ + public String getEmail() { + return email; + } + + /** + * Sets email. + * + * @param email the email + */ + public void setEmail(String email) { + this.email = email; + } + + /** + * Gets age. + * + * @return the age + */ + public int getAge() { + return age; + } + + /** + * Sets age. + * + * @param age the age + */ + public void setAge(int age) { + this.age = age; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app111/PersonController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app111/PersonController.java new file mode 100644 index 000000000..c0f489c55 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app111/PersonController.java @@ -0,0 +1,95 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app111; + +import java.util.ArrayList; +import java.util.List; +import java.util.Random; + +import jakarta.validation.Valid; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; +import jakarta.validation.constraints.Size; + +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Person controller. + */ +@RestController +@Validated +class PersonController { + /** + * The Ran. + */ + private Random ran = new Random(); + + /** + * Person person. + * + * @param person the person + * @return the person + */ + @RequestMapping(path = "/person", method = RequestMethod.POST) + public Person person(@Valid @RequestBody Person person) { + + int nxt = ran.nextInt(10); + if (nxt >= 5) { + throw new RuntimeException("Breaking logic"); + } + return person; + } + + /** + * Find by last name list. + * + * @param lastName the last name + * @return the list + */ + @RequestMapping(path = "/personByLastName", method = RequestMethod.GET) + public List findByLastName(@RequestParam(name = "lastName", required = true) @NotNull + @NotBlank + @Size(max = 10) String lastName) { + List hardCoded = new ArrayList<>(); + Person person = new Person(); + person.setAge(20); + person.setCreditCardNumber("4111111111111111"); + person.setEmail("abc@abc.com"); + person.setEmail1("abc1@abc.com"); + person.setFirstName("Somefirstname"); + person.setLastName(lastName); + person.setId(1); + hardCoded.add(person); + return hardCoded; + + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app111/PersonController2.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app111/PersonController2.java new file mode 100644 index 000000000..bde6f8b4e --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app111/PersonController2.java @@ -0,0 +1,95 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app111; + +import java.util.ArrayList; +import java.util.List; +import java.util.Random; + +import jakarta.validation.Valid; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; +import jakarta.validation.constraints.Size; + +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Person controller 2. + */ +@RestController +@Validated +class PersonController2 { + /** + * The Ran. + */ + private Random ran = new Random(); + + /** + * Person person. + * + * @param person the person + * @return the person + */ + @RequestMapping(path = "/person2", method = RequestMethod.POST) + public Person person(@Valid @RequestBody Person person) { + + int nxt = ran.nextInt(10); + if (nxt >= 5) { + throw new RuntimeException("Breaking logic"); + } + return person; + } + + /** + * Find by last name list. + * + * @param lastName the last name + * @return the list + */ + @RequestMapping(path = "/personByLastName2", method = RequestMethod.GET) + public List findByLastName(@RequestParam(name = "lastName", required = true) @NotNull + @NotBlank + @Size(max = 10) String lastName) { + List hardCoded = new ArrayList<>(); + Person person = new Person(); + person.setAge(20); + person.setCreditCardNumber("4111111111111111"); + person.setEmail("abc@abc.com"); + person.setEmail1("abc1@abc.com"); + person.setFirstName("Somefirstname"); + person.setLastName(lastName); + person.setId(1); + hardCoded.add(person); + return hardCoded; + + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app111/Problem.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app111/Problem.java new file mode 100644 index 000000000..367112b14 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app111/Problem.java @@ -0,0 +1,99 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app111; + +/** + * The type Problem. + */ +class Problem { + + /** + * The Log ref. + */ + private String logRef; + + /** + * The Message. + */ + private String message; + + /** + * Instantiates a new Problem. + * + * @param logRef the log ref + * @param message the message + */ + public Problem(String logRef, String message) { + super(); + this.logRef = logRef; + this.message = message; + } + + /** + * Instantiates a new Problem. + */ + public Problem() { + super(); + + } + + /** + * Gets log ref. + * + * @return the log ref + */ + public String getLogRef() { + return logRef; + } + + /** + * Sets log ref. + * + * @param logRef the log ref + */ + public void setLogRef(String logRef) { + this.logRef = logRef; + } + + /** + * Gets message. + * + * @return the message + */ + public String getMessage() { + return message; + } + + /** + * Sets message. + * + * @param message the message + */ + public void setMessage(String message) { + this.message = message; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app111/SpringDocApp111Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app111/SpringDocApp111Test.java new file mode 100644 index 000000000..d15a8d576 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app111/SpringDocApp111Test.java @@ -0,0 +1,71 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app111; + +import io.swagger.v3.oas.models.OpenAPI; +import io.swagger.v3.oas.models.info.Info; +import io.swagger.v3.oas.models.info.License; +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; +import org.springframework.test.context.TestPropertySource; + +/** + * The type Spring doc app 111 test. + */ +@TestPropertySource(properties = { + "application-description=description", + "application-version=v1" }) +class SpringDocApp111Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp { + + /** + * Custom open api open api. + * + * @param appDesciption the app desciption + * @param appVersion the app version + * @return the open api + */ + @Bean + public OpenAPI customOpenAPI(@Value("${application-description}") String appDesciption, @Value("${application-version}") String appVersion) { + return new OpenAPI() + .info(new Info() + .title("sample application API") + .version(appVersion) + .description(appDesciption) + .termsOfService("http://swagger.io/terms/") + .license(new License().name("Apache 2.0").url("http://springdoc.org"))); + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app112/ErrorMessage.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app112/ErrorMessage.java new file mode 100644 index 000000000..d4d6a2493 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app112/ErrorMessage.java @@ -0,0 +1,94 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app112; + +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + + +/** + * The type Error message. + */ +class ErrorMessage { + + /** + * The Errors. + */ + private List errors; + + /** + * Instantiates a new Error message. + */ + public ErrorMessage() { + } + + /** + * Instantiates a new Error message. + * + * @param errors the errors + */ + public ErrorMessage(List errors) { + this.errors = errors; + } + + /** + * Instantiates a new Error message. + * + * @param error the error + */ + public ErrorMessage(String error) { + this(Collections.singletonList(error)); + } + + /** + * Instantiates a new Error message. + * + * @param errors the errors + */ + public ErrorMessage(String... errors) { + this(Arrays.asList(errors)); + } + + /** + * Gets errors. + * + * @return the errors + */ + public List getErrors() { + return errors; + } + + /** + * Sets errors. + * + * @param errors the errors + */ + public void setErrors(List errors) { + this.errors = errors; + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app112/GlobalControllerAdvice.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app112/GlobalControllerAdvice.java new file mode 100644 index 000000000..2fab5b148 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app112/GlobalControllerAdvice.java @@ -0,0 +1,192 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app112; + +import java.util.ArrayList; +import java.util.List; +import java.util.Set; +import java.util.UUID; + +import jakarta.validation.ConstraintViolation; +import jakarta.validation.ConstraintViolationException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.http.converter.HttpMessageNotReadableException; +import org.springframework.validation.FieldError; +import org.springframework.validation.ObjectError; +import org.springframework.web.HttpMediaTypeNotSupportedException; +import org.springframework.web.bind.MethodArgumentNotValidException; +import org.springframework.web.bind.MissingServletRequestParameterException; +import org.springframework.web.bind.annotation.ControllerAdvice; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.ResponseStatus; + + +/** + * The type Global controller advice. + */ +@ControllerAdvice(basePackages = "test.org.springdoc.api.v30.app112.sample") +class GlobalControllerAdvice //extends ResponseEntityExceptionHandler +{ + /** + * Note use base class if you wish to leverage its handling. + * Some code will need changing. + */ + private static final Logger logger = LoggerFactory.getLogger(GlobalControllerAdvice.class); + + /** + * Problem response entity. + * + * @param e the e + * @return the response entity + */ + @ExceptionHandler(Throwable.class) + @ResponseStatus(code = HttpStatus.INTERNAL_SERVER_ERROR) + public ResponseEntity problem(final Throwable e) { + String message = "Problem occured"; + UUID uuid = UUID.randomUUID(); + String logRef = uuid.toString(); + logger.error("logRef=" + logRef, message, e); + return new ResponseEntity(new Problem(logRef, message), HttpStatus.INTERNAL_SERVER_ERROR); + } + + + /** + * Handle method argument not valid response entity. + * + * @param ex the ex + * @return the response entity + */ + @ExceptionHandler(MethodArgumentNotValidException.class) + @ResponseStatus(code = HttpStatus.BAD_REQUEST) + public ResponseEntity handleMethodArgumentNotValid(MethodArgumentNotValidException ex + ) { + List fieldErrors = ex.getBindingResult().getFieldErrors(); + List globalErrors = ex.getBindingResult().getGlobalErrors(); + List errors = new ArrayList<>(fieldErrors.size() + globalErrors.size()); + String error; + for (FieldError fieldError : fieldErrors) { + error = fieldError.getField() + ", " + fieldError.getDefaultMessage(); + errors.add(error); + } + for (ObjectError objectError : globalErrors) { + error = objectError.getObjectName() + ", " + objectError.getDefaultMessage(); + errors.add(error); + } + ErrorMessage errorMessage = new ErrorMessage(errors); + + //Object result=ex.getBindingResult();//instead of above can allso pass the more detailed bindingResult + return new ResponseEntity(errorMessage, HttpStatus.BAD_REQUEST); + } + + /** + * Handle constraint violated exception response entity. + * + * @param ex the ex + * @return the response entity + */ + @ExceptionHandler(ConstraintViolationException.class) + @ResponseStatus(code = HttpStatus.BAD_REQUEST) + public ResponseEntity handleConstraintViolatedException(ConstraintViolationException ex + ) { + Set> constraintViolations = ex.getConstraintViolations(); + + + List errors = new ArrayList<>(constraintViolations.size()); + String error; + for (ConstraintViolation constraintViolation : constraintViolations) { + + error = constraintViolation.getMessage(); + errors.add(error); + } + + ErrorMessage errorMessage = new ErrorMessage(errors); + return new ResponseEntity(errorMessage, HttpStatus.BAD_REQUEST); + } + + /** + * Handle missing servlet request parameter exception response entity. + * + * @param ex the ex + * @return the response entity + */ + @ExceptionHandler(MissingServletRequestParameterException.class) + @ResponseStatus(code = HttpStatus.BAD_REQUEST) + public ResponseEntity handleMissingServletRequestParameterException(MissingServletRequestParameterException ex + ) { + + List errors = new ArrayList<>(); + String error = ex.getParameterName() + ", " + ex.getMessage(); + errors.add(error); + ErrorMessage errorMessage = new ErrorMessage(errors); + return new ResponseEntity(errorMessage, HttpStatus.BAD_REQUEST); + } + + + /** + * Handle http media type not supported response entity. + * + * @param ex the ex + * @return the response entity + */ + @ExceptionHandler(HttpMediaTypeNotSupportedException.class) + @ResponseStatus(code = HttpStatus.UNSUPPORTED_MEDIA_TYPE) + public ResponseEntity handleHttpMediaTypeNotSupported(HttpMediaTypeNotSupportedException ex + ) { + String unsupported = "Unsupported content type: " + ex.getContentType(); + String supported = "Supported content types: " + MediaType.toString(ex.getSupportedMediaTypes()); + ErrorMessage errorMessage = new ErrorMessage(unsupported, supported); + return new ResponseEntity(errorMessage, HttpStatus.UNSUPPORTED_MEDIA_TYPE); + } + + /** + * Handle http message not readable response entity. + * + * @param ex the ex + * @return the response entity + */ + @ExceptionHandler(HttpMessageNotReadableException.class) + @ResponseStatus(code = HttpStatus.BAD_REQUEST) + public ResponseEntity handleHttpMessageNotReadable(HttpMessageNotReadableException ex) { + Throwable mostSpecificCause = ex.getMostSpecificCause(); + ErrorMessage errorMessage; + if (mostSpecificCause != null) { + String exceptionName = mostSpecificCause.getClass().getName(); + String message = mostSpecificCause.getMessage(); + errorMessage = new ErrorMessage(exceptionName, message); + } + else { + errorMessage = new ErrorMessage(ex.getMessage()); + } + return new ResponseEntity(errorMessage, HttpStatus.BAD_REQUEST); + } + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app112/Person.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app112/Person.java new file mode 100644 index 000000000..e60ad3ab5 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app112/Person.java @@ -0,0 +1,212 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app112; + +import jakarta.validation.constraints.Email; +import jakarta.validation.constraints.Max; +import jakarta.validation.constraints.Min; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; +import jakarta.validation.constraints.Pattern; +import jakarta.validation.constraints.Size; +import org.hibernate.validator.constraints.CreditCardNumber; + + +/** + * The type Person. + */ +public class Person { + /** + * The Id. + */ + private long id; + + /** + * The First name. + */ + private String firstName; + + /** + * The Last name. + */ + @NotNull + @NotBlank + @Size(max = 10) + private String lastName; + + /** + * The Email. + */ + @Pattern(regexp = ".+@.+\\..+", message = "Please provide a valid email address") + private String email; + + /** + * The Email 1. + */ + @Email() + private String email1; + + /** + * The Age. + */ + @Min(18) + @Max(30) + private int age; + + /** + * The Credit card number. + */ + @CreditCardNumber + private String creditCardNumber; + + /** + * Gets credit card number. + * + * @return the credit card number + */ + public String getCreditCardNumber() { + return creditCardNumber; + } + + /** + * Sets credit card number. + * + * @param creditCardNumber the credit card number + */ + public void setCreditCardNumber(String creditCardNumber) { + this.creditCardNumber = creditCardNumber; + } + + /** + * Gets id. + * + * @return the id + */ + public long getId() { + return id; + } + + /** + * Sets id. + * + * @param id the id + */ + public void setId(long id) { + this.id = id; + } + + /** + * Gets email 1. + * + * @return the email 1 + */ + public String getEmail1() { + return email1; + } + + /** + * Sets email 1. + * + * @param email1 the email 1 + */ + public void setEmail1(String email1) { + this.email1 = email1; + } + + /** + * Gets first name. + * + * @return the first name + */ + @Size(min = 2) + public String getFirstName() { + return firstName; + } + + /** + * Sets first name. + * + * @param firstName the first name + */ + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + /** + * Gets last name. + * + * @return the last name + */ + public String getLastName() { + return lastName; + } + + /** + * Sets last name. + * + * @param lastName the last name + */ + public void setLastName(String lastName) { + this.lastName = lastName; + } + + /** + * Gets email. + * + * @return the email + */ + public String getEmail() { + return email; + } + + /** + * Sets email. + * + * @param email the email + */ + public void setEmail(String email) { + this.email = email; + } + + /** + * Gets age. + * + * @return the age + */ + public int getAge() { + return age; + } + + /** + * Sets age. + * + * @param age the age + */ + public void setAge(int age) { + this.age = age; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app112/PersonController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app112/PersonController.java new file mode 100644 index 000000000..207725f6d --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app112/PersonController.java @@ -0,0 +1,95 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app112; + +import java.util.ArrayList; +import java.util.List; +import java.util.Random; + +import jakarta.validation.Valid; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; +import jakarta.validation.constraints.Size; + +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Person controller. + */ +@RestController +@Validated +class PersonController { + /** + * The Ran. + */ + private Random ran = new Random(); + + /** + * Person person. + * + * @param person the person + * @return the person + */ + @RequestMapping(path = "/person", method = RequestMethod.POST) + public Person person(@Valid @RequestBody Person person) { + + int nxt = ran.nextInt(10); + if (nxt >= 5) { + throw new RuntimeException("Breaking logic"); + } + return person; + } + + /** + * Find by last name list. + * + * @param lastName the last name + * @return the list + */ + @RequestMapping(path = "/personByLastName", method = RequestMethod.GET) + public List findByLastName(@RequestParam(name = "lastName", required = true) @NotNull + @NotBlank + @Size(max = 10) String lastName) { + List hardCoded = new ArrayList<>(); + Person person = new Person(); + person.setAge(20); + person.setCreditCardNumber("4111111111111111"); + person.setEmail("abc@abc.com"); + person.setEmail1("abc1@abc.com"); + person.setFirstName("Somefirstname"); + person.setLastName(lastName); + person.setId(1); + hardCoded.add(person); + return hardCoded; + + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app112/Problem.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app112/Problem.java new file mode 100644 index 000000000..db231b4ac --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app112/Problem.java @@ -0,0 +1,99 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app112; + +/** + * The type Problem. + */ +class Problem { + + /** + * The Log ref. + */ + private String logRef; + + /** + * The Message. + */ + private String message; + + /** + * Instantiates a new Problem. + * + * @param logRef the log ref + * @param message the message + */ + public Problem(String logRef, String message) { + super(); + this.logRef = logRef; + this.message = message; + } + + /** + * Instantiates a new Problem. + */ + public Problem() { + super(); + + } + + /** + * Gets log ref. + * + * @return the log ref + */ + public String getLogRef() { + return logRef; + } + + /** + * Sets log ref. + * + * @param logRef the log ref + */ + public void setLogRef(String logRef) { + this.logRef = logRef; + } + + /** + * Gets message. + * + * @return the message + */ + public String getMessage() { + return message; + } + + /** + * Sets message. + * + * @param message the message + */ + public void setMessage(String message) { + this.message = message; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app112/SpringDocApp112Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app112/SpringDocApp112Test.java new file mode 100644 index 000000000..3b9019c72 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app112/SpringDocApp112Test.java @@ -0,0 +1,71 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app112; + +import io.swagger.v3.oas.models.OpenAPI; +import io.swagger.v3.oas.models.info.Info; +import io.swagger.v3.oas.models.info.License; +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; +import org.springframework.test.context.TestPropertySource; + +/** + * The type Spring doc app 112 test. + */ +@TestPropertySource(properties = { + "application-description=description", + "application-version=v1" }) +class SpringDocApp112Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp { + + /** + * Custom open api open api. + * + * @param appDesciption the app desciption + * @param appVersion the app version + * @return the open api + */ + @Bean + public OpenAPI customOpenAPI(@Value("${application-description}") String appDesciption, @Value("${application-version}") String appVersion) { + return new OpenAPI() + .info(new Info() + .title("sample application API") + .version(appVersion) + .description(appDesciption) + .termsOfService("http://swagger.io/terms/") + .license(new License().name("Apache 2.0").url("http://springdoc.org"))); + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app112/sample/PersonController2.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app112/sample/PersonController2.java new file mode 100644 index 000000000..c3db8f1ec --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app112/sample/PersonController2.java @@ -0,0 +1,97 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app112.sample; + +import java.util.ArrayList; +import java.util.List; +import java.util.Random; + +import jakarta.validation.Valid; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; +import jakarta.validation.constraints.Size; +import test.org.springdoc.api.v30.app112.Person; + +import org.springframework.validation.annotation.Validated; +import org.springframework.web.HttpMediaTypeNotSupportedException; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Person controller 2. + */ +@RestController +@Validated +class PersonController2 { + /** + * The Ran. + */ + private Random ran = new Random(); + + /** + * Person person. + * + * @param person the person + * @return the person + */ + @RequestMapping(path = "/person2", method = RequestMethod.POST) + public Person person(@Valid @RequestBody Person person) throws HttpMediaTypeNotSupportedException { + + int nxt = ran.nextInt(10); + if (nxt >= 5) { + throw new RuntimeException("Breaking logic"); + } + return person; + } + + /** + * Find by last name list. + * + * @param lastName the last name + * @return the list + */ + @RequestMapping(path = "/personByLastName2", method = RequestMethod.GET) + public List findByLastName(@RequestParam(name = "lastName", required = true) @NotNull + @NotBlank + @Size(max = 10) String lastName) throws HttpMediaTypeNotSupportedException { + List hardCoded = new ArrayList<>(); + Person person = new Person(); + person.setAge(20); + person.setCreditCardNumber("4111111111111111"); + person.setEmail("abc@abc.com"); + person.setEmail1("abc1@abc.com"); + person.setFirstName("Somefirstname"); + person.setLastName(lastName); + person.setId(1); + hardCoded.add(person); + return hardCoded; + + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app113/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app113/HelloController.java new file mode 100644 index 000000000..486593c47 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app113/HelloController.java @@ -0,0 +1,68 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app113; + +import java.util.Optional; + +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * Test. + * + * @param body the body + */ + @PostMapping("/lol") + public void test(@RequestBody(required = false) Body body) { + } + + /** + * Test 2. + * + * @param body the body + */ + @PostMapping("/lol2") + public void test2(@RequestBody Optional body) { + } + + /** + * The type Body. + */ + class Body { + /** + * The Field. + */ + public String field; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app113/SpringDocApp113Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app113/SpringDocApp113Test.java new file mode 100644 index 000000000..a5b645bbb --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app113/SpringDocApp113Test.java @@ -0,0 +1,44 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app113; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + + +/** + * The type Spring doc app 113 test. + */ +class SpringDocApp113Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app114/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app114/HelloController.java new file mode 100644 index 000000000..27ff46f0b --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app114/HelloController.java @@ -0,0 +1,66 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app114; + +import javax.money.MonetaryAmount; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import org.springframework.http.MediaType; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * Gets currency. + * + * @param carDTO the car dto + * @return the currency + */ + @PostMapping(value = "/foos1", consumes = MediaType.APPLICATION_JSON_VALUE) + MonetaryAmount getCurrency(@RequestBody CarDTO carDTO) { + return carDTO.price; + } + + /** + * The type Car dto. + */ + class CarDTO { + /** + * The Price. + */ + @JsonProperty("price") + MonetaryAmount price; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app114/SpringDocApp114Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app114/SpringDocApp114Test.java new file mode 100644 index 000000000..e9ce9538c --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app114/SpringDocApp114Test.java @@ -0,0 +1,51 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app114; + +import javax.money.MonetaryAmount; + +import org.springdoc.core.utils.SpringDocUtils; +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + + +/** + * The type Spring doc app 114 test. + */ +class SpringDocApp114Test extends AbstractSpringDocTest { + + static { + SpringDocUtils.getConfig().replaceWithClass(MonetaryAmount.class, org.springdoc.core.converters.models.MonetaryAmount.class); + } + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app115/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app115/HelloController.java new file mode 100644 index 000000000..9630be358 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app115/HelloController.java @@ -0,0 +1,53 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app115; + +import java.time.Duration; + +import org.springframework.http.MediaType; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * Timeouts duration. + * + * @return the duration + */ + @GetMapping(value = "/api/v2/timeout", + consumes = { MediaType.ALL_VALUE }, + produces = { MediaType.APPLICATION_JSON_VALUE }) + public Duration timeouts() { + return Duration.ofSeconds(5); + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app115/JavaTimeOperationCustomizer.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app115/JavaTimeOperationCustomizer.java new file mode 100644 index 000000000..95b38bea7 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app115/JavaTimeOperationCustomizer.java @@ -0,0 +1,68 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app115; + +import java.time.Duration; +import java.util.Map; + +import io.swagger.v3.oas.models.Operation; +import io.swagger.v3.oas.models.media.Content; +import io.swagger.v3.oas.models.media.Schema; +import org.springdoc.core.customizers.OperationCustomizer; + +import org.springframework.http.MediaType; +import org.springframework.stereotype.Component; +import org.springframework.web.method.HandlerMethod; + +/** + * The type Java time operation customizer. + */ +@Component +class JavaTimeOperationCustomizer implements OperationCustomizer { + /** + * Customize operation. + * + * @param operation the operation + * @param handlerMethod the handler method + * @return the operation + */ + @Override + public Operation customize(Operation operation, HandlerMethod handlerMethod) { + if (handlerMethod.getReturnType().getParameterType().isAssignableFrom(Duration.class)) { + for (Map.Entry entry : operation.getResponses().entrySet()) { + io.swagger.v3.oas.models.responses.ApiResponse response = entry.getValue(); + Content content = response.getContent(); + if (content.containsKey(MediaType.APPLICATION_JSON_VALUE)) { + Schema schema = content.get(MediaType.APPLICATION_JSON_VALUE).getSchema(); + schema.getProperties().clear(); + schema.setType("string"); + } + } + } + return operation; + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app115/SpringDocApp115Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app115/SpringDocApp115Test.java new file mode 100644 index 000000000..49347f219 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app115/SpringDocApp115Test.java @@ -0,0 +1,45 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app115; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + + +/** + * The type Spring doc app 115 test. + */ +class SpringDocApp115Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app116/FooErrorHandler.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app116/FooErrorHandler.java new file mode 100644 index 000000000..f82f1df68 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app116/FooErrorHandler.java @@ -0,0 +1,50 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app116; + +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.ControllerAdvice; +import org.springframework.web.bind.annotation.ExceptionHandler; + +/** + * The type Foo error handler. + */ +@ControllerAdvice(assignableTypes = HelloController.class) +class FooErrorHandler { + + /** + * Store assignment publishing error response entity. + * + * @param e the e + * @return the response entity + */ + @ExceptionHandler + public ResponseEntity storeAssignmentPublishingError(Exception e) { + return new ResponseEntity<>("foo", HttpStatus.INTERNAL_SERVER_ERROR); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app116/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app116/HelloController.java new file mode 100644 index 000000000..e883e84f3 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app116/HelloController.java @@ -0,0 +1,58 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app116; + +import io.swagger.v3.oas.annotations.OpenAPIDefinition; +import io.swagger.v3.oas.annotations.info.Info; +import io.swagger.v3.oas.annotations.tags.Tag; + +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +@RequestMapping("/api") +@OpenAPIDefinition(info = @Info(title = "API Examples", version = "1.0"), tags = @Tag(name = "Operations")) +class HelloController { + + /** + * Create string. + * + * @param foo the foo + * @return the string + */ + @PostMapping("/foo") + public String create(@RequestBody String foo) { + return "foo"; + } +} + + diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app116/SpringDocApp116Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app116/SpringDocApp116Test.java new file mode 100644 index 000000000..b810d3fe7 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app116/SpringDocApp116Test.java @@ -0,0 +1,45 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app116; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + + +/** + * The type Spring doc app 116 test. + */ +class SpringDocApp116Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app117/HelloApplication.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app117/HelloApplication.java new file mode 100644 index 000000000..e757a9093 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app117/HelloApplication.java @@ -0,0 +1,304 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app117; + +import java.io.IOException; +import java.net.URI; +import java.util.HashSet; +import java.util.Set; +import java.util.concurrent.atomic.AtomicLong; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.enums.ParameterIn; +import jakarta.servlet.FilterChain; +import jakarta.servlet.GenericFilter; +import jakarta.servlet.ServletException; +import jakarta.servlet.ServletRequest; +import jakarta.servlet.ServletResponse; +import org.springdoc.core.annotations.RouterOperation; +import org.springdoc.core.annotations.RouterOperations; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.stereotype.Component; +import org.springframework.stereotype.Service; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.servlet.function.RouterFunction; +import org.springframework.web.servlet.function.ServerRequest; +import org.springframework.web.servlet.function.ServerResponse; + +import static org.springframework.web.servlet.function.RouterFunctions.route; +import static org.springframework.web.servlet.function.ServerResponse.ok; + +/** + * The type Hello application. + */ +@Configuration +class HelloApplication { + + /** + * Routes router function. + * + * @param ph the ph + * @return the router function + */ + @Bean + @RouterOperations({ @RouterOperation(path = "/people", method = RequestMethod.GET, beanClass = PersonService.class, beanMethod = "all"), + @RouterOperation(path = "/people/{id}", beanClass = PersonService.class, beanMethod = "byId"), + @RouterOperation(path = "/people", method = RequestMethod.POST, beanClass = PersonService.class, beanMethod = "save") }) + RouterFunction routes(PersonHandler ph) { + String root = ""; + return route() + .GET(root + "/people", ph::handleGetAllPeople) + .GET(root + "/people/{id}", ph::handleGetPersonById) + .POST(root + "/people", ph::handlePostPerson) + .filter((serverRequest, handlerFunction) -> { + return handlerFunction.handle(serverRequest); + }) + .build(); + } +} + +/** + * The type Simple filter. + */ +@Component +class SimpleFilter extends GenericFilter { + + /** + * Do filter. + * + * @param req the req + * @param res the res + * @param filterChain the filter chain + * @throws IOException the io exception + * @throws ServletException the servlet exception + */ + @Override + public void doFilter(ServletRequest req, ServletResponse res, + FilterChain filterChain) throws IOException, ServletException { + filterChain.doFilter(req, res); + } +} + +/** + * The type Person handler. + */ +@Component +class PersonHandler { + + /** + * The Person service. + */ + private final PersonService personService; + + /** + * Instantiates a new Person handler. + * + * @param personService the person service + */ + PersonHandler(PersonService personService) { + this.personService = personService; + } + + /** + * Handle get all people server response. + * + * @param serverRequest the server request + * @return the server response + */ + ServerResponse handleGetAllPeople(ServerRequest serverRequest) { + return ok().body(personService.all()); + } + + /** + * Handle post person server response. + * + * @param r the r + * @return the server response + * @throws ServletException the servlet exception + * @throws IOException the io exception + */ + ServerResponse handlePostPerson(ServerRequest r) throws ServletException, IOException { + Person result = personService.save(new Person(null, r.body(Person.class).getName())); + URI uri = URI.create("/people/" + result.getId()); + return ServerResponse.created(uri).body(result); + } + + /** + * Handle get person by id server response. + * + * @param r the r + * @return the server response + */ + ServerResponse handleGetPersonById(ServerRequest r) { + return ok().body(personService.byId(Long.parseLong(r.pathVariable("id")))); + } +} + +/** + * The type Greetings rest controller. + */ +@RestController +class GreetingsRestController { + + /** + * Greet string. + * + * @param name the name + * @return the string + */ + @GetMapping("/greet/{name}") + String greet(@PathVariable String name) { + return "hello " + name + "!"; + } +} + +/** + * The type Person service. + */ +@Service +class PersonService { + + /** + * The Counter. + */ + private final AtomicLong counter = new AtomicLong(); + + /** + * The People. + */ + private final Set people = Stream.of( + new Person(counter.incrementAndGet(), "Jane"), + new Person(counter.incrementAndGet(), "Josh"), + new Person(counter.incrementAndGet(), "Gordon")) + .collect(Collectors.toCollection(HashSet::new)); + + + /** + * Save person. + * + * @param p the p + * @return the person + */ + Person save(Person p) { + Person person = new Person(counter.incrementAndGet(), p.getName()); + this.people.add(person); + return person; + } + + /** + * All set. + * + * @return the set + */ + Set all() { + return this.people; + } + + /** + * By id person. + * + * @param id the id + * @return the person + */ + Person byId(@Parameter(in = ParameterIn.PATH) Long id) { + return this.people.stream() + .filter(p -> p.getId().equals(id)) + .findFirst() + .orElseThrow(() -> new IllegalArgumentException("no " + Person.class.getName() + " with that ID found!")); + } + +} + +/** + * The type Person. + */ +class Person { + + /** + * The Id. + */ + private Long id; + + /** + * The Name. + */ + private String name; + + /** + * Instantiates a new Person. + * + * @param id the id + * @param name the name + */ + public Person(Long id, String name) { + this.id = id; + this.name = name; + } + + /** + * Gets id. + * + * @return the id + */ + public Long getId() { + return id; + } + + /** + * Sets id. + * + * @param id the id + */ + public void setId(Long id) { + this.id = id; + } + + /** + * Gets name. + * + * @return the name + */ + public String getName() { + return name; + } + + /** + * Sets name. + * + * @param name the name + */ + public void setName(String name) { + this.name = name; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app117/SpringDocApp117Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app117/SpringDocApp117Test.java new file mode 100644 index 000000000..6ebd6ee2e --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app117/SpringDocApp117Test.java @@ -0,0 +1,44 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app117; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + + +/** + * The type Spring doc app 117 test. + */ +class SpringDocApp117Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app118/AbstractParent.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app118/AbstractParent.java new file mode 100644 index 000000000..b743b09f0 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app118/AbstractParent.java @@ -0,0 +1,121 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app118; + +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonSubTypes.Type; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeInfo.Id; + +/** + * The type Abstract parent. + */ +@JsonTypeInfo(use = Id.NAME, property = "type") +@JsonSubTypes({ + @Type(ChildOfAbstract1.class), + @Type(ChildOfAbstract2.class) +}) +public abstract class AbstractParent { + /** + * The Id. + */ + private int id; + + /** + * Gets id. + * + * @return the id + */ + public int getId() { + return id; + } + + /** + * Sets id. + * + * @param id the id + */ + public void setId(int id) { + this.id = id; + } +} + +/** + * The type Child of abstract 1. + */ +class ChildOfAbstract1 extends AbstractParent { + /** + * The Abstrach child 1 param. + */ + private String abstrachChild1Param; + + /** + * Gets abstrach child 1 param. + * + * @return the abstrach child 1 param + */ + public String getAbstrachChild1Param() { + return abstrachChild1Param; + } + + /** + * Sets abstrach child 1 param. + * + * @param abstrachChild1Param the abstrach child 1 param + */ + public void setAbstrachChild1Param(String abstrachChild1Param) { + this.abstrachChild1Param = abstrachChild1Param; + } +} + +/** + * The type Child of abstract 2. + */ +class ChildOfAbstract2 extends AbstractParent { + /** + * The Abstract child 2 param. + */ + private String abstractChild2Param; + + /** + * Gets abstract child 2 param. + * + * @return the abstract child 2 param + */ + public String getAbstractChild2Param() { + return abstractChild2Param; + } + + /** + * Sets abstract child 2 param. + * + * @param abstractChild2Param the abstract child 2 param + */ + public void setAbstractChild2Param(String abstractChild2Param) { + this.abstractChild2Param = abstractChild2Param; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app118/ConcreteParent.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app118/ConcreteParent.java new file mode 100644 index 000000000..a4ff5a45c --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app118/ConcreteParent.java @@ -0,0 +1,121 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app118; + +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonSubTypes.Type; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeInfo.Id; + +/** + * The type Concrete parent. + */ +@JsonTypeInfo(use = Id.NAME, property = "type") +@JsonSubTypes({ + @Type(ChildOfConcrete1.class), + @Type(ChildOfConcrete2.class) +}) +class ConcreteParent { + /** + * The Id. + */ + private int id; + + /** + * Gets id. + * + * @return the id + */ + public int getId() { + return id; + } + + /** + * Sets id. + * + * @param id the id + */ + public void setId(int id) { + this.id = id; + } +} + +/** + * The type Child of concrete 1. + */ +class ChildOfConcrete1 extends ConcreteParent { + /** + * The Concrete child 1 param. + */ + private String concreteChild1Param; + + /** + * Gets concrete child 1 param. + * + * @return the concrete child 1 param + */ + public String getConcreteChild1Param() { + return concreteChild1Param; + } + + /** + * Sets concrete child 1 param. + * + * @param concreteChild1Param the concrete child 1 param + */ + public void setConcreteChild1Param(String concreteChild1Param) { + this.concreteChild1Param = concreteChild1Param; + } +} + +/** + * The type Child of concrete 2. + */ +class ChildOfConcrete2 extends ConcreteParent { + /** + * The Concrete child 2 param. + */ + private String concreteChild2Param; + + /** + * Gets concrete child 2 param. + * + * @return the concrete child 2 param + */ + public String getConcreteChild2Param() { + return concreteChild2Param; + } + + /** + * Sets concrete child 2 param. + * + * @param concreteChild2Param the concrete child 2 param + */ + public void setConcreteChild2Param(String concreteChild2Param) { + this.concreteChild2Param = concreteChild2Param; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app118/Controller.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app118/Controller.java new file mode 100644 index 000000000..029111a1b --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app118/Controller.java @@ -0,0 +1,114 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app118; + +import java.util.List; + +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Controller. + */ +@RestController +@RequestMapping("class-hierarchy") +class Controller { + /** + * Abstract parent response. + * + * @param payload the payload + * @return the response + */ + @PostMapping("abstract-parent") + public Response abstractParent(@RequestBody AbstractParent payload) { + return null; + } + + /** + * Concrete parent response. + * + * @param payload the payload + * @return the response + */ + @PostMapping("concrete-parent") + public Response concreteParent(@RequestBody ConcreteParent payload) { + return null; + } +} + +/** + * The type Response. + */ +class Response { + /** + * The Abstract parent. + */ + AbstractParent abstractParent; + + /** + * The Concrete parents. + */ + List concreteParents; + + /** + * Gets abstract parent. + * + * @return the abstract parent + */ + public AbstractParent getAbstractParent() { + return abstractParent; + } + + /** + * Sets abstract parent. + * + * @param abstractParent the abstract parent + */ + public void setAbstractParent(AbstractParent abstractParent) { + this.abstractParent = abstractParent; + } + + /** + * Gets concrete parents. + * + * @return the concrete parents + */ + public List getConcreteParents() { + return concreteParents; + } + + /** + * Sets concrete parents. + * + * @param concreteParents the concrete parents + */ + public void setConcreteParents(List concreteParents) { + this.concreteParents = concreteParents; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app118/SpringDocApp118Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app118/SpringDocApp118Test.java new file mode 100644 index 000000000..5ccae9c57 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app118/SpringDocApp118Test.java @@ -0,0 +1,44 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app118; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + + +/** + * The type Spring doc app 118 test. + */ +class SpringDocApp118Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app119/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app119/HelloController.java new file mode 100644 index 000000000..5cf238164 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app119/HelloController.java @@ -0,0 +1,67 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app119; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.media.Content; + +import org.springframework.http.MediaType; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.multipart.MultipartFile; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * Multi files in multi part string. + * + * @param jsonRequest the json request + * @param file1 the file 1 + * @param file2 the file 2 + * @return the string + */ + @Operation(summary = "Multiple files and JSON payloads as multi part request") + @PostMapping( + value = "multi", + consumes = MediaType.MULTIPART_FORM_DATA_VALUE, + produces = MediaType.TEXT_PLAIN_VALUE) + public String multiFilesInMultiPart( + @RequestPart("params") + @Parameter( + description = "This is the configuration", + content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE)) final JsonRequest jsonRequest, + @RequestPart(value = "file1", required = false) @Parameter(description = "This is file1") final MultipartFile file1, + @RequestPart(value = "file2", required = false) @Parameter(description = "This is file2") final MultipartFile file2) { + return "Hello World " + jsonRequest.getName(); + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app119/JsonRequest.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app119/JsonRequest.java new file mode 100644 index 000000000..1035fa3e5 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app119/JsonRequest.java @@ -0,0 +1,56 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app119; + +/** + * The type Json request. + */ +class JsonRequest { + + /** + * The Name. + */ + private String name; + + /** + * Gets name. + * + * @return the name + */ + public String getName() { + return name; + } + + /** + * Sets name. + * + * @param name the name + */ + public void setName(String name) { + this.name = name; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app119/SpringDocApp119Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app119/SpringDocApp119Test.java new file mode 100644 index 000000000..d8817f321 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app119/SpringDocApp119Test.java @@ -0,0 +1,44 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app119; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + + +/** + * The type Spring doc app 119 test. + */ +class SpringDocApp119Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app12/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app12/HelloController.java new file mode 100644 index 000000000..7cf3dc686 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app12/HelloController.java @@ -0,0 +1,55 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app12; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.enums.ParameterIn; +import io.swagger.v3.oas.annotations.media.Schema; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * Persons string. + * + * @return the string + */ + @GetMapping(value = "/persons") + @Operation(parameters = { + @Parameter(name = "name", in = ParameterIn.QUERY, schema = @Schema(implementation = String.class)) }) + public String persons() { + return "OK"; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app12/SpringDocApp12Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app12/SpringDocApp12Test.java new file mode 100644 index 000000000..5f09e4fc9 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app12/SpringDocApp12Test.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app12; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 12 test. + */ +class SpringDocApp12Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app120/AccountId.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app120/AccountId.java new file mode 100644 index 000000000..7a033e132 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app120/AccountId.java @@ -0,0 +1,81 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app120; + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.enums.ParameterIn; +import io.swagger.v3.oas.annotations.media.Schema; + +import org.springframework.core.annotation.AliasFor; + +import static java.lang.annotation.ElementType.ANNOTATION_TYPE; +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.ElementType.PARAMETER; + +/** + * The interface Account id. + */ +@Target({ PARAMETER, METHOD, ANNOTATION_TYPE }) +@Retention(RetentionPolicy.RUNTIME) +@Parameter(description = "non alias description") +public @interface AccountId { + + /** + * Name string. + * + * @return the string + */ + @AliasFor(annotation = Parameter.class, value = "name") + String name() default ""; + + /** + * Example string. + * + * @return the string + */ + @AliasFor(annotation = Parameter.class, value = "example") + String example() default "123456"; + + /** + * In parameter in. + * + * @return the parameter in + */ + @AliasFor(annotation = Parameter.class, value = "in") + ParameterIn in() default ParameterIn.DEFAULT; + + /** + * Schema schema. + * + * @return the schema + */ + @AliasFor(annotation = Parameter.class, value = "schema") + Schema schema() default @Schema(); +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app120/MetaAnnotationController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app120/MetaAnnotationController.java new file mode 100644 index 000000000..ae3d50648 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app120/MetaAnnotationController.java @@ -0,0 +1,301 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app120; + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.enums.Explode; +import io.swagger.v3.oas.annotations.enums.ParameterIn; +import io.swagger.v3.oas.annotations.enums.ParameterStyle; +import io.swagger.v3.oas.annotations.extensions.Extension; +import io.swagger.v3.oas.annotations.media.ArraySchema; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.ExampleObject; +import io.swagger.v3.oas.annotations.media.Schema; + +import org.springframework.core.annotation.AliasFor; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import static java.lang.annotation.ElementType.ANNOTATION_TYPE; +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.ElementType.PARAMETER; + +/** + * The type Meta annotation controller. + */ +@RestController +class MetaAnnotationController { + + /** + * Simple test string. + * + * @param accountId the account id + * @return the string + */ + @GetMapping(value = "/simpleTest/{accountId}") + String simpleTest(@PathVariable @AccountId String accountId) { + return accountId; + } + + /** + * When there is a top level {@code @Parameter} annotation it has precedence over the meta-annotation + * So the id parameter should have all the defaults, with a name of "id" + * @param accountId the account id + * @return the string + */ + @GetMapping(value = "/testTopLevelParamAnnotationOverrides/{id}") + String testTopLevelParamAnnotationOverrides(@PathVariable @AccountId @Parameter(name = "id") String accountId) { + return accountId; + } + + /** + * Test query param string. + * + * @param accountId the account id + * @return the string + */ + @GetMapping(value = "/testQueryParam") + String testQueryParam(@RequestParam @AccountId String accountId) { + return accountId; + } + + /** + * {@code @AliasFor} in the {@code @AccountId} annotation allows us to override the default it provides. + * @param accountId the account id + * @return the string + */ + @GetMapping(value = "/testAliasFor") + String testAliasFor(@RequestParam @AccountId(example = "OVERRIDDEN EXAMPLE") String accountId) { + return accountId; + } + + /** + * Test meta meta annotation string. + * + * @param queryAccountId the query account id + * @param accountId the account id + * @return the string + */ + @GetMapping(value = "/testMetaMetaAnnotation/{accountId}") + String testMetaMetaAnnotation( + @RequestParam @QueryAccountId String queryAccountId, + @PathVariable @AccountId String accountId) { + return accountId; + } + + /** + * Test all attributes as alias string. + * + * @param name the name + * @return the string + */ + @GetMapping(value = "/testAllAttributesAsAlias/") + String testAllAttributesAsAlias( + @RequestParam @TestAllAttributesAsAlias String name) { + return name; + } + + /** + * Test no alias fors string. + * + * @param name the name + * @return the string + */ + @GetMapping(value = "/testNoAliasFors/") + String testNoAliasFors( + @RequestParam @TestAllAttributesAsAlias String name) { + return name; + } + + /** + * This should inherent all the attributes of {@code @AccountId}, but give it a different name + */ + @Target({ PARAMETER, METHOD, ANNOTATION_TYPE }) + @Retention(RetentionPolicy.RUNTIME) + @AccountId(name = "queryAccountId") + @interface QueryAccountId { + } + + /** + * The interface Test all attributes as alias. + */ + @Target({ PARAMETER, METHOD, ANNOTATION_TYPE }) + @Retention(RetentionPolicy.RUNTIME) + @Parameter + @interface TestAllAttributesAsAlias { + + /** + * Name string. + * + * @return the string + */ + @AliasFor(annotation = Parameter.class, attribute = "name") + String name() default "name"; + + /** + * In parameter in. + * + * @return the parameter in + */ + @AliasFor(annotation = Parameter.class, attribute = "in") + ParameterIn in() default ParameterIn.QUERY; + + /** + * Description string. + * + * @return the string + */ + @AliasFor(annotation = Parameter.class, attribute = "description") + String description() default "desc"; + + /** + * Required boolean. + * + * @return the boolean + */ + @AliasFor(annotation = Parameter.class, attribute = "required") + boolean required() default true; + + /** + * Deprecated boolean. + * + * @return the boolean + */ + @AliasFor(annotation = Parameter.class, attribute = "deprecated") + boolean deprecated() default true; + + /** + * Allow empty value boolean. + * + * @return the boolean + */ + @AliasFor(annotation = Parameter.class, attribute = "allowEmptyValue") + boolean allowEmptyValue() default true; + + /** + * Style parameter style. + * + * @return the parameter style + */ + @AliasFor(annotation = Parameter.class, attribute = "style") + ParameterStyle style() default ParameterStyle.DEEPOBJECT; + + /** + * Explode explode. + * + * @return the explode + */ + @AliasFor(annotation = Parameter.class, attribute = "explode") + Explode explode() default Explode.TRUE; + + /** + * Allow reserved boolean. + * + * @return the boolean + */ + @AliasFor(annotation = Parameter.class, attribute = "allowReserved") + boolean allowReserved() default true; + + /** + * Schema schema. + * + * @return the schema + */ + @AliasFor(annotation = Parameter.class, attribute = "schema") + Schema schema() default @Schema(name = "special schema", implementation = Boolean.class); + + /** + * Array array schema. + * + * @return the array schema + */ + @AliasFor(annotation = Parameter.class, attribute = "array") + ArraySchema array() default @ArraySchema(); + + /** + * Content content [ ]. + * + * @return the content [ ] + */ + @AliasFor(annotation = Parameter.class, attribute = "content") + Content[] content() default {}; + + /** + * Hidden boolean. + * + * @return the boolean + */ + @AliasFor(annotation = Parameter.class, attribute = "hidden") + boolean hidden() default false; + + /** + * Examples example object [ ]. + * + * @return the example object [ ] + */ + @AliasFor(annotation = Parameter.class, attribute = "examples") + ExampleObject[] examples() default {}; + + /** + * Example string. + * + * @return the string + */ + @AliasFor(annotation = Parameter.class, attribute = "example") + String example() default "1234"; + + /** + * Extensions extension [ ]. + * + * @return the extension [ ] + */ + @AliasFor(annotation = Parameter.class, attribute = "extensions") + Extension[] extensions() default {}; + + /** + * Ref string. + * + * @return the string + */ + @AliasFor(annotation = Parameter.class, attribute = "ref") + String ref() default ""; + } + + /** + * The interface Test no alias fors. + */ + @Target({ PARAMETER, METHOD, ANNOTATION_TYPE }) + @Retention(RetentionPolicy.RUNTIME) + @Parameter(name = "name", description = "desc", schema = @Schema(implementation = Boolean.class)) + @interface TestNoAliasFors { + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app120/SpringDocApp120Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app120/SpringDocApp120Test.java new file mode 100644 index 000000000..66a1bdc49 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app120/SpringDocApp120Test.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app120; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + + +/** + * Tests Spring meta-annotations as method parameters + */ +class SpringDocApp120Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app121/InheritedRequestParams.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app121/InheritedRequestParams.java new file mode 100644 index 000000000..e1e9ef1c4 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app121/InheritedRequestParams.java @@ -0,0 +1,59 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app121; + +import jakarta.validation.constraints.NotBlank; + +/** + * The type Inherited request params. + */ +class InheritedRequestParams extends RequestParams { + + /** + * parameter from child of RequestParams + */ + @NotBlank + private String childParam; + + /** + * Gets child param. + * + * @return the child param + */ + public String getChildParam() { + return childParam; + } + + /** + * Sets child param. + * + * @param childParam the child param + */ + public void setChildParam(String childParam) { + this.childParam = childParam; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app121/RequestParams.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app121/RequestParams.java new file mode 100644 index 000000000..eb02770ce --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app121/RequestParams.java @@ -0,0 +1,281 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app121; + +import java.math.BigInteger; +import java.util.List; +import java.util.Optional; + +import io.swagger.v3.oas.annotations.Parameter; + + +/** + * The type Request params. + */ +class RequestParams { + + /** + * The String param. + */ + @Parameter(description = "string parameter") + private String stringParam; + + /** + * The String param 1. + */ + @Deprecated + private String stringParam1; + + /** + * The String param 2. + */ + @Parameter(description = "string parameter2", required = true) + private String stringParam2; + + /** + * The Int param. + */ + @Parameter(description = "int parameter") + private int intParam; + + /** + * The Int param 2. + */ + private Optional intParam2; + + /** + * The Int param 3. + */ + private String intParam3; + + /** + * The Nested. + */ + private Nested nested; + + /** + * The Nested list. + */ + private List nestedList; + + /** + * Gets string param. + * + * @return the string param + */ + public String getStringParam() { + return stringParam; + } + + /** + * Sets string param. + * + * @param stringParam the string param + */ + public void setStringParam(String stringParam) { + this.stringParam = stringParam; + } + + /** + * Gets int param. + * + * @return the int param + */ + public int getIntParam() { + return intParam; + } + + /** + * Sets int param. + * + * @param intParam the int param + */ + public void setIntParam(int intParam) { + this.intParam = intParam; + } + + /** + * Gets int param 2. + * + * @return the int param 2 + */ + public Optional getIntParam2() { + return intParam2; + } + + /** + * Sets int param 2. + * + * @param intParam2 the int param 2 + */ + public void setIntParam2(Optional intParam2) { + this.intParam2 = intParam2; + } + + /** + * Gets int param 3. + * + * @return the int param 3 + */ + public String getIntParam3() { + return intParam3; + } + + /** + * Sets int param 3. + * + * @param intParam3 the int param 3 + */ + public void setIntParam3(String intParam3) { + this.intParam3 = intParam3; + } + + /** + * Gets string param 1. + * + * @return the string param 1 + */ + public String getStringParam1() { + return stringParam1; + } + + /** + * Sets string param 1. + * + * @param stringParam1 the string param 1 + */ + public void setStringParam1(String stringParam1) { + this.stringParam1 = stringParam1; + } + + /** + * Gets string param 2. + * + * @return the string param 2 + */ + public String getStringParam2() { + return stringParam2; + } + + /** + * Sets string param 2. + * + * @param stringParam2 the string param 2 + */ + public void setStringParam2(String stringParam2) { + this.stringParam2 = stringParam2; + } + + /** + * Gets nested. + * + * @return the nested + */ + public Nested getNested() { + return nested; + } + + /** + * Sets nested. + * + * @param nested the nested + */ + public void setNested(Nested nested) { + this.nested = nested; + } + + /** + * Gets nested list. + * + * @return the nested list + */ + public List getNestedList() { + return nestedList; + } + + /** + * Sets nested list. + * + * @param nestedList the nested list + */ + public void setNestedList(List nestedList) { + this.nestedList = nestedList; + } + + /** + * The type Nested. + */ + public static class Nested { + /** + * The Param 1. + */ + private String param1; + + /** + * The Param 2. + */ + private BigInteger param2; + + /** + * Gets param 1. + * + * @return the param 1 + */ + @Parameter(description = "nested string parameter") + public String getParam1() { + return param1; + } + + /** + * Sets param 1. + * + * @param param1 the param 1 + */ + public void setParam1(String param1) { + this.param1 = param1; + } + + /** + * Gets param 2. + * + * @return the param 2 + */ + @Parameter(description = "nested BigInteger parameter") + public BigInteger getParam2() { + return param2; + } + + /** + * Sets param 2. + * + * @param param2 the param 2 + */ + public void setParam2(BigInteger param2) { + this.param2 = param2; + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app121/SpringDocApp121Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app121/SpringDocApp121Test.java new file mode 100644 index 000000000..450aa34ec --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app121/SpringDocApp121Test.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app121; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + + +/** + * Tests Spring meta-annotations as method parameters + */ +class SpringDocApp121Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app121/TestController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app121/TestController.java new file mode 100644 index 000000000..b02ab3f72 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app121/TestController.java @@ -0,0 +1,52 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app121; + +import org.springdoc.core.annotations.ParameterObject; + +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Test controller. + */ +@RestController +class TestController { + + /** + * Gets test. + * + * @param param the param + * @param requestParams the request params + * @return the test + */ + @PostMapping("test") + public InheritedRequestParams getTest(@RequestParam String param, @ParameterObject InheritedRequestParams requestParams) { + return requestParams; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app122/BaseController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app122/BaseController.java new file mode 100644 index 000000000..515a3552b --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app122/BaseController.java @@ -0,0 +1,55 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app122; + +import io.swagger.v3.oas.annotations.Operation; + +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Base controller. + * + * @param the type parameter + */ +@RestController +public abstract class BaseController { + + /** + * Create response entity. + * + * @param payload the payload + * @return the response entity + */ + @PostMapping + @Operation(summary = "create") + public ResponseEntity create(@RequestBody Wrapper payload) { + return null; + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app122/BaseObject.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app122/BaseObject.java new file mode 100644 index 000000000..da1c562da --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app122/BaseObject.java @@ -0,0 +1,41 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app122; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The type Base object. + */ +class BaseObject { + + /** + * The Base str. + */ + @JsonProperty("baseStr") + private String baseStr; +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app122/CustomerDto.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app122/CustomerDto.java new file mode 100644 index 000000000..d042236bf --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app122/CustomerDto.java @@ -0,0 +1,41 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app122; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The type Customer dto. + */ +class CustomerDto extends BaseObject { + + /** + * The Customer name. + */ + @JsonProperty("customerName") + private String customerName; +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app122/FirstController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app122/FirstController.java new file mode 100644 index 000000000..3187d72a2 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app122/FirstController.java @@ -0,0 +1,40 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app122; + +import io.swagger.v3.oas.annotations.tags.Tag; + +import org.springframework.web.bind.annotation.RestController; + +/** + * The type First controller. + */ +@RestController +@Tag(name = "example") +class FirstController extends BaseController { + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app122/SpringDocApp122Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app122/SpringDocApp122Test.java new file mode 100644 index 000000000..2c7ccd1a3 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app122/SpringDocApp122Test.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app122; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + + +/** + * Tests Spring meta-annotations as method parameters + */ +class SpringDocApp122Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app122/Wrapper.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app122/Wrapper.java new file mode 100644 index 000000000..ddddd1e8f --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app122/Wrapper.java @@ -0,0 +1,45 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app122; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The type Wrapper. + * + * @param the type parameter + */ +class Wrapper { + + + /** + * The Wrapper. + */ + @JsonProperty("wrapper") + private String wrapper; + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app123/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app123/HelloController.java new file mode 100644 index 000000000..12f9c8fb6 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app123/HelloController.java @@ -0,0 +1,56 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app123; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.responses.ApiResponse; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + * + * @param the type parameter + */ +@RestController +class HelloController { + + /** + * Index t. + * + * @param numTel the num tel + * @param adresse the adresse + * @return the t + */ + @GetMapping(value = "/hello/{numTelco}") + @Operation(summary = "GET Persons", responses = @ApiResponse(responseCode = "418")) + public T index(@PathVariable("numTelco") String numTel, String adresse) { + return null; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app123/MyExceptionHandler.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app123/MyExceptionHandler.java new file mode 100644 index 000000000..fec1616b0 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app123/MyExceptionHandler.java @@ -0,0 +1,66 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app123; + +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.responses.ApiResponse; + +import org.springframework.http.HttpStatus; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.ResponseStatus; +import org.springframework.web.bind.annotation.RestControllerAdvice; + +/** + * The type My exception handler. + */ +@RestControllerAdvice +class MyExceptionHandler { + + /** + * Bad. + * + * @param e the e + */ + @ExceptionHandler(IllegalArgumentException.class) + @ApiResponse(responseCode = "404", description = "Not here", content = @Content) + @ResponseStatus(HttpStatus.NOT_FOUND) + public void bad(IllegalArgumentException e) { + + } + + /** + * Gateway object. + * + * @param e the e + * @return the object + */ + @ExceptionHandler(RuntimeException.class) + @ResponseStatus(HttpStatus.BAD_GATEWAY) + public Object gateway(RuntimeException e) { + return null; + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app123/SpringDocApp123Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app123/SpringDocApp123Test.java new file mode 100644 index 000000000..15165d794 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app123/SpringDocApp123Test.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app123; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + + +/** + * Tests Spring meta-annotations as method parameters + */ +class SpringDocApp123Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app124/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app124/HelloController.java new file mode 100644 index 000000000..c43bb6b70 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app124/HelloController.java @@ -0,0 +1,73 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app124; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.responses.ApiResponse; + +import org.springframework.http.HttpStatus; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.ResponseStatus; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + * + * @param the type parameter + */ +@RestController +class HelloController { + + /** + * Bad. + * + * @param e the e + */ + @ExceptionHandler(IllegalArgumentException.class) + @ApiResponse(responseCode = "404", description = "Not here", content = @Content) + @ResponseStatus(HttpStatus.NOT_FOUND) + public void bad(IllegalArgumentException e) { + + } + + /** + * Index t. + * + * @param numTel the num tel + * @param adresse the adresse + * @return the t + */ + @GetMapping(value = "/hello/{numTelco}") + @Operation(summary = "GET Persons", responses = @ApiResponse(responseCode = "418")) + public T index(@PathVariable("numTelco") String numTel, String adresse) { + throw new IllegalArgumentException(); + + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app124/MyExceptionHandler.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app124/MyExceptionHandler.java new file mode 100644 index 000000000..f16e08bb9 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app124/MyExceptionHandler.java @@ -0,0 +1,51 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app124; + +import org.springframework.http.HttpStatus; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.ResponseStatus; +import org.springframework.web.bind.annotation.RestControllerAdvice; + +/** + * The type My exception handler. + */ +@RestControllerAdvice +class MyExceptionHandler { + + /** + * Gateway object. + * + * @param e the e + * @return the object + */ + @ExceptionHandler(RuntimeException.class) + @ResponseStatus(HttpStatus.BAD_GATEWAY) + public Object gateway(RuntimeException e) { + return null; + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app124/SpringDocApp124Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app124/SpringDocApp124Test.java new file mode 100644 index 000000000..358871337 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app124/SpringDocApp124Test.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app124; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + + +/** + * Tests Spring meta-annotations as method parameters + */ +class SpringDocApp124Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app125/DeprecatedEntity.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app125/DeprecatedEntity.java new file mode 100644 index 000000000..493ed26ea --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app125/DeprecatedEntity.java @@ -0,0 +1,86 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app125; + +import io.swagger.v3.oas.annotations.media.Schema; + +/** + * The type Deprecated entity. + * @author bnasslahsen + */ +class DeprecatedEntity { + /** + * The My non deprecated field. + */ + @Schema(deprecated = false) + private String myNonDeprecatedField; + + /** + * The Mydeprecated field. + */ + @Schema(deprecated = true) + private String mydeprecatedField; + + /** + * Gets my non deprecated field. + * + * @return the my non deprecated field + */ + public String getMyNonDeprecatedField() { + return myNonDeprecatedField; + } + + /** + * Sets my non deprecated field. + * + * @param myNonDeprecatedField the my non deprecated field + * @return the my non deprecated field + */ + @Deprecated + public DeprecatedEntity setMyNonDeprecatedField(String myNonDeprecatedField) { + this.myNonDeprecatedField = myNonDeprecatedField; + return this; + } + + /** + * Gets mydeprecated field. + * + * @return the mydeprecated field + */ + public String getMydeprecatedField() { + return mydeprecatedField; + } + + /** + * Sets mydeprecated field. + * + * @param mydeprecatedField the mydeprecated field + */ + public void setMydeprecatedField(String mydeprecatedField) { + this.mydeprecatedField = mydeprecatedField; + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app125/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app125/HelloController.java new file mode 100644 index 000000000..b2a0042ea --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app125/HelloController.java @@ -0,0 +1,52 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app125; + +import jakarta.validation.constraints.NotNull; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + * @author bnasslahsen + */ +@RestController +class HelloController { + + /** + * Gets all pets. + * + * @param toto the toto + * @return the all pets + */ + @GetMapping(value = "/search", produces = { "application/xml", "application/json" }) + public DeprecatedEntity getAllPets(@NotNull String toto) { + return null; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app125/SpringDocApp125Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app125/SpringDocApp125Test.java new file mode 100644 index 000000000..4babed24f --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app125/SpringDocApp125Test.java @@ -0,0 +1,58 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app125; + +import java.util.Optional; + +import io.swagger.v3.core.converter.ModelConverter; +import io.swagger.v3.core.converter.ModelConverters; +import org.springdoc.core.converters.SchemaPropertyDeprecatingConverter; +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.test.context.TestPropertySource; + + +/** + * Tests Spring meta-annotations as method parameters + */ +@TestPropertySource(properties = "springdoc.model-converters.deprecating-converter.enabled=false") +class SpringDocApp125Test extends AbstractSpringDocTest { + + static { + Optional deprecatingConverterOptional = + ModelConverters.getInstance().getConverters() + .stream().filter(modelConverter -> modelConverter instanceof SchemaPropertyDeprecatingConverter).findAny(); + deprecatingConverterOptional.ifPresent(ModelConverters.getInstance()::removeConverter); + } + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app126/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app126/HelloController.java new file mode 100644 index 000000000..602d5a8ec --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app126/HelloController.java @@ -0,0 +1,80 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app126; + +import java.util.ArrayList; +import java.util.Collection; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; + +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +import static org.springframework.http.ResponseEntity.ok; + +/** + * The type Hello controller. + * + * @param the type parameter + */ +@RestController +@ApiResponses(value = { + @ApiResponse(responseCode = "401", ref = SecurityProblemResponsesConfiguration.UNAUTHORIZED_401_NO_TOKEN_RESPONSE_REF), + @ApiResponse(responseCode = "401", ref = SecurityProblemResponsesConfiguration.UNAUTHORIZED_401_BAD_TOKEN_RESPONSE_REF), + @ApiResponse(responseCode = "403", ref = SecurityProblemResponsesConfiguration.FORBIDDEN_403_RESPONSE_REF) }) +//@ApiResponses(value = { +// @ApiResponse(responseCode = "401", description = "Invalid authentication.", content = {@Content(schema = @Schema(implementation = Problem.class), mediaType = APPLICATION_PROBLEM_JSON_VALUE)}), +// @ApiResponse(responseCode = "401", description = "Invalid authentication.",content = {@Content(schema = @Schema(implementation = Problem.class), mediaType = APPLICATION_PROBLEM_JSON_VALUE)}), +// @ApiResponse(responseCode = "403", description = "Missing authorities.",content = {@Content(schema = @Schema(implementation = Problem.class), mediaType = APPLICATION_PROBLEM_JSON_VALUE)}) }) +class HelloController { + + /** + * The constant CURRENCIES. + */ + private static final Collection CURRENCIES = new ArrayList<>(); + + static { + CURRENCIES.add("EUR"); + CURRENCIES.add("USD"); + } + + /** + * Gets all currencies. + * + * @return the all currencies + */ + @GetMapping + @Operation(description = "Get all currencies", summary = "getAllCurrencies") + @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "All currencies returned") }) + public ResponseEntity> getAllCurrencies() { + return ok(CURRENCIES); + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app126/Problem.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app126/Problem.java new file mode 100644 index 000000000..bbd682e8d --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app126/Problem.java @@ -0,0 +1,105 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app126; + +import java.net.URI; +import java.util.Collections; +import java.util.Map; + +/** + * The interface Problem. + */ +public interface Problem { + + /** + * The constant DEFAULT_TYPE. + */ + URI DEFAULT_TYPE = URI.create("about:blank"); + + /** + * An absolute URI that identifies the problem type. When dereferenced, + * it SHOULD provide human-readable documentation for the problem type + * (e.g., using HTML). When this member is not present, its value is + * assumed to be "about:blank". + * + * @return an absolute URI that identifies this problem's type + */ + default URI getType() { + return DEFAULT_TYPE; + } + + /** + * A short, human-readable summary of the problem type. It SHOULD NOT + * change from occurrence to occurrence of the problem, except for + * purposes of localisation. + * + * @return a short, human-readable summary of this problem + */ + default String getTitle() { + return null; + } + + /** + * The HTTP status code generated by the origin server for this + * occurrence of the problem. + * + * @return the HTTP status code + */ + default Integer getStatus() { + return null; + } + + /** + * A human readable explanation specific to this occurrence of the problem. + * + * @return A human readable explaination of this problem + */ + default String getDetail() { + return null; + } + + /** + * An absolute URI that identifies the specific occurrence of the problem. + * It may or may not yield further information if dereferenced. + * + * @return an absolute URI that identifies this specific problem + */ + default URI getInstance() { + return null; + } + + /** + * Optional, additional attributes of the problem. Implementations can choose to ignore this in favor of concrete, + * typed fields. + * + * @return additional parameters + */ + default Map getParameters() { + return Collections.emptyMap(); + } + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app126/SecurityProblemResponsesConfiguration.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app126/SecurityProblemResponsesConfiguration.java new file mode 100644 index 000000000..ee41e82af --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app126/SecurityProblemResponsesConfiguration.java @@ -0,0 +1,129 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app126; + +import java.io.IOException; +import java.util.AbstractMap; +import java.util.Map; + +import io.swagger.v3.oas.models.media.Content; +import io.swagger.v3.oas.models.media.MediaType; +import io.swagger.v3.oas.models.media.Schema; +import io.swagger.v3.oas.models.responses.ApiResponse; + +import org.springframework.beans.factory.parsing.Problem; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +import static org.springframework.http.MediaType.APPLICATION_PROBLEM_JSON_VALUE; + +/** + * Configuration class defining standard OpenAPI Specification for operations + */ +@Configuration +class SecurityProblemResponsesConfiguration { + + /** + * The constant HTTP_401_NO_TOKEN. + */ + private static final String HTTP_401_NO_TOKEN = "http401NoToken"; + + /** + * The constant UNAUTHORIZED_401_NO_TOKEN_RESPONSE_REF. + */ + public static final String UNAUTHORIZED_401_NO_TOKEN_RESPONSE_REF = "#/components/responses/" + HTTP_401_NO_TOKEN; + + /** + * The constant HTTP_401_BAD_TOKEN. + */ + private static final String HTTP_401_BAD_TOKEN = "http401BadToken"; + + /** + * The constant UNAUTHORIZED_401_BAD_TOKEN_RESPONSE_REF. + */ + public static final String UNAUTHORIZED_401_BAD_TOKEN_RESPONSE_REF = "#/components/responses/" + HTTP_401_BAD_TOKEN; + + /** + * The constant HTTP_403. + */ + private static final String HTTP_403 = "http403"; + + /** + * The constant FORBIDDEN_403_RESPONSE_REF. + */ + public static final String FORBIDDEN_403_RESPONSE_REF = "#/components/responses/" + HTTP_403; + + /** + * Http 401 no token response map . entry. + * + * @return the map . entry + * @throws IOException the io exception + */ + @Bean + public Map.Entry http401NoTokenResponse() throws IOException { + return simpleResponse(HTTP_401_NO_TOKEN, "Invalid authentication."); + } + + /** + * Http 401 bad token response map . entry. + * + * @return the map . entry + * @throws IOException the io exception + */ + @Bean + public Map.Entry http401BadTokenResponse() throws IOException { + return simpleResponse(HTTP_401_BAD_TOKEN, "Invalid authentication."); + } + + /** + * Http 403 example map . entry. + * + * @return the map . entry + * @throws IOException the io exception + */ + @Bean + public Map.Entry http403Example() throws IOException { + return simpleResponse(HTTP_403, "Missing authorities."); + } + + /** + * Simple response map . entry. + * + * @param code the code + * @param description the description + * @return the map . entry + * @throws IOException the io exception + */ + private Map.Entry simpleResponse(String code, String description) throws IOException { + ApiResponse response = new ApiResponse().description(description).content(new Content().addMediaType( + APPLICATION_PROBLEM_JSON_VALUE, + new MediaType() + .schema(new Schema().$ref("#/components/schemas/Problem")))); + return new AbstractMap.SimpleEntry<>(code, response); + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app126/SpringDocApp126Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app126/SpringDocApp126Test.java new file mode 100644 index 000000000..04883012b --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app126/SpringDocApp126Test.java @@ -0,0 +1,70 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app126; + +import java.util.List; +import java.util.Map; + +import io.swagger.v3.core.converter.AnnotatedType; +import io.swagger.v3.core.converter.ModelConverters; +import io.swagger.v3.core.converter.ResolvedSchema; +import io.swagger.v3.oas.models.responses.ApiResponse; +import org.springdoc.core.customizers.OpenApiCustomizer; +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; + + +/** + * Tests Spring meta-annotations as method parameters + */ +class SpringDocApp126Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp { + + /** + * Response registration customizer open api customiser. + * + * @param responsesToRegister the responses to register + * @return the open api customiser + */ + @Bean + public OpenApiCustomizer responseRegistrationCustomizer(List> responsesToRegister) { + ResolvedSchema resolvedSchema = ModelConverters.getInstance() + .resolveAsResolvedSchema(new AnnotatedType(Problem.class)); + return openApi -> { + openApi.getComponents().addSchemas("Problem", resolvedSchema.schema); + responsesToRegister.forEach(entry -> openApi.getComponents().addResponses(entry.getKey(), entry.getValue())); + }; + } + + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app127/AbstractObject.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app127/AbstractObject.java new file mode 100644 index 000000000..22b6ae542 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app127/AbstractObject.java @@ -0,0 +1,83 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app127; + +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; + +/** + * The type Abstract object. + */ +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, + include = JsonTypeInfo.As.EXISTING_PROPERTY, + property = "type", + visible = true +) +@JsonSubTypes({ + @JsonSubTypes.Type(value = ConcreteObjectA.class, name = "Type A") +}) +public abstract class AbstractObject { + + /** + * The Type. + */ + private final ConcreteType type; + + /** + * The Name. + */ + private final String name; + + /** + * Instantiates a new Abstract object. + * + * @param type the type + * @param name the name + */ + protected AbstractObject(ConcreteType type, String name) { + this.type = type; + this.name = name; + } + + /** + * Gets type. + * + * @return the type + */ + public ConcreteType getType() { + return type; + } + + /** + * Gets name. + * + * @return the name + */ + public String getName() { + return name; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app127/ConcreteObjectA.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app127/ConcreteObjectA.java new file mode 100644 index 000000000..9edecf656 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app127/ConcreteObjectA.java @@ -0,0 +1,58 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app127; + +/** + * The type Concrete object a. + */ +class ConcreteObjectA extends AbstractObject { + + /** + * The Description. + */ + private final String description; + + /** + * Instantiates a new Concrete object a. + * + * @param name the name + * @param description the description + */ + public ConcreteObjectA(String name, String description) { + super(ConcreteType.TYPE_A, name); + this.description = description; + } + + /** + * Gets description. + * + * @return the description + */ + public String getDescription() { + return description; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app127/ConcreteType.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app127/ConcreteType.java new file mode 100644 index 000000000..523129008 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app127/ConcreteType.java @@ -0,0 +1,64 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app127; + +/** + * The enum Concrete type. + */ +public enum ConcreteType { + /** + * The Type a. + */ + TYPE_A("Type A"), + /** + * The Type b. + */ + TYPE_B("Type B"); + + /** + * The Name. + */ + private final String name; + + /** + * Instantiates a new Concrete type. + * + * @param name the name + */ + ConcreteType(String name) { + this.name = name; + } + + /** + * Gets name. + * + * @return the name + */ + public String getName() { + return name; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app127/Controller.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app127/Controller.java new file mode 100644 index 000000000..ffb95b6c7 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app127/Controller.java @@ -0,0 +1,62 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app127; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.ExampleObject; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; + +import org.springframework.http.MediaType; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Controller. + */ +@RestController +class Controller { + + /** + * Bug umbrella. + * + * @return the umbrella + */ + @Operation(summary = "Test Bug", responses = { + @ApiResponse(responseCode = "200", description = "OK", + content = @Content( + schema = @Schema(implementation = Umbrella.class), + examples = @ExampleObject(ref = "#/components/examples/umbrellaExample", name = "Example with weird YAML tag") + ) + ) + }) + @GetMapping(value = "/bug", produces = MediaType.APPLICATION_JSON_VALUE) + public Umbrella bug() { + return new Umbrella(new ConcreteObjectA("a", "b")); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app127/SpringDocApp127Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app127/SpringDocApp127Test.java new file mode 100644 index 000000000..c604724b2 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app127/SpringDocApp127Test.java @@ -0,0 +1,64 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app127; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.springdoc.core.utils.Constants; +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.test.web.servlet.MvcResult; + +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + + +/** + * Tests Spring meta-annotations as method parameters + */ +class SpringDocApp127Test extends AbstractSpringDocTest { + + /** + * Test app. + * + * @throws Exception the exception + */ + @Test + protected void testApp() throws Exception { + className = getClass().getSimpleName(); + String testNumber = className.replaceAll("[^0-9]", ""); + MvcResult mockMvcResult = mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL + ".yaml")).andExpect(status().isOk()).andReturn(); + String result = mockMvcResult.getResponse().getContentAsString(); + Assertions.assertTrue(!result.contains("!")); + } + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app127/Umbrella.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app127/Umbrella.java new file mode 100644 index 000000000..26e71caa7 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app127/Umbrella.java @@ -0,0 +1,59 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app127; + +import io.swagger.v3.oas.annotations.media.Schema; + +/** + * The type Umbrella. + */ +class Umbrella { + + /** + * The Object. + */ + @Schema(description = "This reference to abstract class causes weird YAML tag to be added", anyOf = ConcreteObjectA.class) + private final AbstractObject object; + + /** + * Instantiates a new Umbrella. + * + * @param object the object + */ + public Umbrella(AbstractObject object) { + this.object = object; + } + + /** + * Gets object. + * + * @return the object + */ + public AbstractObject getObject() { + return object; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app129/ActualReturnedEntity.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app129/ActualReturnedEntity.java new file mode 100644 index 000000000..868c443ab --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app129/ActualReturnedEntity.java @@ -0,0 +1,42 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app129; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The type Actual returned entity. + */ +class ActualReturnedEntity { + + /** + * The Result. + */ + @JsonProperty + String result; + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app129/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app129/HelloController.java new file mode 100644 index 000000000..655b9a1bb --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app129/HelloController.java @@ -0,0 +1,58 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app129; + +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; + +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.context.request.async.DeferredResult; + +/** + * The type Hello controller. + */ +@RestController +@RequestMapping(path = "/api", headers = { "userId", "registrationId" }) +class HelloController { + + /** + * Update deferred result. + * + * @param entity the entity + * @return the deferred result + * @throws Exception the exception + */ + @PostMapping("/test") + @ApiResponses({ @ApiResponse(responseCode = "200") }) + public DeferredResult> update( + @RequestBody ActualReturnedEntity entity) throws Exception { + return null; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app129/OperationResponse.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app129/OperationResponse.java new file mode 100644 index 000000000..302a84818 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app129/OperationResponse.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app129; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The type Operation response. + * + * @param the type parameter + */ +class OperationResponse { + + /** + * The Operation result. + */ + @JsonProperty + String operationResult; +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app129/SpringDocApp129Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app129/SpringDocApp129Test.java new file mode 100644 index 000000000..91f0e1020 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app129/SpringDocApp129Test.java @@ -0,0 +1,44 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app129; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + + +/** + * Tests Spring meta-annotations as method parameters + */ +class SpringDocApp129Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app13/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app13/HelloController.java new file mode 100644 index 000000000..337197b9c --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app13/HelloController.java @@ -0,0 +1,49 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app13; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * Persons string. + * + * @param dto the dto + * @return the string + */ + @GetMapping(value = "/persons") + public String persons(final PersonDTO dto) { + return "OK"; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app13/PersonDTO.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app13/PersonDTO.java new file mode 100644 index 000000000..5d318b4b2 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app13/PersonDTO.java @@ -0,0 +1,124 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app13; + +import com.fasterxml.jackson.databind.PropertyNamingStrategies; +import com.fasterxml.jackson.databind.annotation.JsonNaming; + +/** + * The type Person dto. + */ +@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) +class PersonDTO { + /** + * The Email. + */ + private String email; + + /** + * The First name. + */ + private String firstName; + + /** + * The Last name. + */ + private String lastName; + + /** + * Instantiates a new Person dto. + */ + public PersonDTO() { + } + + /** + * Instantiates a new Person dto. + * + * @param email the email + * @param firstName the first name + * @param lastName the last name + */ + public PersonDTO(final String email, final String firstName, final String lastName) { + this.email = email; + this.firstName = firstName; + this.lastName = lastName; + } + + /** + * Gets email. + * + * @return the email + */ + public String getEmail() { + return email; + } + + /** + * Sets email. + * + * @param email the email + */ + public void setEmail(final String email) { + this.email = email; + } + + /** + * Gets first name. + * + * @return the first name + */ + public String getFirstName() { + return firstName; + } + + /** + * Sets first name. + * + * @param firstName the first name + */ + public void setFirstName(final String firstName) { + this.firstName = firstName; + } + + /** + * Gets last name. + * + * @return the last name + */ + public String getLastName() { + return lastName; + } + + /** + * Sets last name. + * + * @param lastName the last name + */ + public void setLastName(final String lastName) { + this.lastName = lastName; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app13/SpringDocApp13Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app13/SpringDocApp13Test.java new file mode 100644 index 000000000..e930103d3 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app13/SpringDocApp13Test.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app13; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 13 test. + */ +class SpringDocApp13Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app130/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app130/HelloController.java new file mode 100644 index 000000000..b4d9d0fdd --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app130/HelloController.java @@ -0,0 +1,60 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app130; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * List tracker data. + * + * @param toto the toto + * @return the tracker data + */ + @PostMapping(value = "/values/data") + TrackerData list(TrackerData toto) { + return toto; + } + + /** + * Get tracker data. + * + * @param toto the toto + * @return the tracker data + */ + @GetMapping(value = "/values/datakk") + TrackerData get(TrackerData toto) { + return toto; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app130/SpringDocApp130Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app130/SpringDocApp130Test.java new file mode 100644 index 000000000..887f9fc25 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app130/SpringDocApp130Test.java @@ -0,0 +1,44 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app130; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + + +/** + * Tests Spring meta-annotations as method parameters + */ +class SpringDocApp130Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app130/TrackerData.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app130/TrackerData.java new file mode 100644 index 000000000..3f78002e8 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app130/TrackerData.java @@ -0,0 +1,61 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app130; + +import java.time.Instant; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.v3.oas.annotations.Hidden; +import io.swagger.v3.oas.annotations.media.Schema; + +/** + * The type Tracker data. + */ +@Hidden +class TrackerData { + + /** + * The Tracker id. + */ + @JsonProperty("trackerId") + String trackerId; + + /** + * The Timestamp. + */ + @Schema(name = "timestamp", type = "string", format = "date-time", required = true, example = "2018-01-01T00:00:00Z") + @JsonProperty("timestamp") + Instant timestamp; + + /** + * The Value. + */ + @Schema(name = "value", type = "number", format = "double", description = "The data value", required = true, example = "19.0") + @JsonProperty("value") + Double value; + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app131/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app131/HelloController.java new file mode 100644 index 000000000..889c8a91b --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app131/HelloController.java @@ -0,0 +1,99 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app131; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; + +import org.springframework.http.HttpStatus; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.ResponseStatus; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + * + * @param the type parameter + */ +@RestController +class HelloController { + + + /** + * Create organization. + * + * @param organization the organization + */ + @Operation(summary = "Create the organization", description = "Create the organization") + @ApiResponses( + value = { + @ApiResponse( + responseCode = "204", + description = "The organization was created successfully"), + @ApiResponse( + responseCode = "400", + description = "Invalid argument", + content = + @Content( + mediaType = "application/json", + schema = @Schema(implementation = RestControllerError.class))), + @ApiResponse( + responseCode = "409", + description = "An organization with the specified ID already exists", + content = + @Content( + mediaType = "application/json", + schema = @Schema(implementation = RestControllerError.class))), + @ApiResponse( + responseCode = "500", + description = + "An error has occurred and the request could not be processed at this time", + content = + @Content( + mediaType = "application/json", + schema = @Schema(implementation = RestControllerError.class))) + }) + @RequestMapping( + value = "/organizations", + method = RequestMethod.POST, + produces = "application/json") + @ResponseStatus(HttpStatus.NO_CONTENT) + public void createOrganization( + @Parameter(name = "organization", required = true) + @RequestBody + Organization organization) { + + + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app131/Organization.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app131/Organization.java new file mode 100644 index 000000000..711d470d8 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app131/Organization.java @@ -0,0 +1,104 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app131; + + +import java.util.UUID; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import io.swagger.v3.oas.annotations.media.Schema; + +/** + * The type Organization. + */ +@Schema(description = + "This is the description being overwritten") +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ "id", "name" }) +class Organization { + + /** + * The Id. + */ + @Schema( + description = + "The Universally Unique Identifier (UUID) uniquely identifying the organization", + required = true) + @JsonProperty(required = true) + private UUID id; + + /** + * The Name. + */ + @Schema(description = "The name of the organization", required = true) + @JsonProperty(required = true) + private String name; + + /** + * Instantiates a new Organization. + */ + public Organization() { + } + + /** + * Gets id. + * + * @return the id + */ + public UUID getId() { + return id; + } + + /** + * Sets id. + * + * @param id the id + */ + public void setId(UUID id) { + this.id = id; + } + + /** + * Gets name. + * + * @return the name + */ + public String getName() { + return name; + } + + /** + * Sets name. + * + * @param name the name + */ + public void setName(String name) { + this.name = name; + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app131/RestControllerError.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app131/RestControllerError.java new file mode 100644 index 000000000..ba37d7029 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app131/RestControllerError.java @@ -0,0 +1,48 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app131; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The type Rest controller error. + */ +class RestControllerError { + + /** + * The Id. + */ + @JsonProperty + private String id; + + /** + * The Message. + */ + @JsonProperty + private String message; + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app131/SpringDocApp131Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app131/SpringDocApp131Test.java new file mode 100644 index 000000000..91fbad6fe --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app131/SpringDocApp131Test.java @@ -0,0 +1,44 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app131; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + + +/** + * Tests Spring meta-annotations as method parameters + */ +class SpringDocApp131Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app132/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app132/HelloController.java new file mode 100644 index 000000000..534f34cc3 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app132/HelloController.java @@ -0,0 +1,99 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app132; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; + +import org.springframework.http.HttpStatus; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.ResponseStatus; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + * + * @param the type parameter + */ +@RestController +class HelloController { + + + /** + * Create organization. + * + * @param organization the organization + */ + @Operation(summary = "Create the organization", description = "Create the organization") + @ApiResponses( + value = { + @ApiResponse( + responseCode = "204", + description = "The organization was created successfully"), + @ApiResponse( + responseCode = "400", + description = "Invalid argument", + content = + @Content( + mediaType = "application/json", + schema = @Schema(implementation = RestControllerError.class))), + @ApiResponse( + responseCode = "409", + description = "An organization with the specified ID already exists", + content = + @Content( + mediaType = "application/json", + schema = @Schema(implementation = RestControllerError.class))), + @ApiResponse( + responseCode = "500", + description = + "An error has occurred and the request could not be processed at this time", + content = + @Content( + mediaType = "application/json", + schema = @Schema(implementation = RestControllerError.class))) + }) + @RequestMapping( + value = "/organizations", + method = RequestMethod.POST, + produces = "application/json") + @ResponseStatus(HttpStatus.NO_CONTENT) + public void createOrganization( + @Parameter(name = "organization", description = "i want to override the description of this object", required = true) + @RequestBody + Organization organization) { + + + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app132/Organization.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app132/Organization.java new file mode 100644 index 000000000..99d40d7a9 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app132/Organization.java @@ -0,0 +1,104 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app132; + + +import java.util.UUID; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import io.swagger.v3.oas.annotations.media.Schema; + +/** + * The type Organization. + */ +@Schema(description = + "This is the description being overwritten") +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ "id", "name" }) +class Organization { + + /** + * The Id. + */ + @Schema( + description = + "The Universally Unique Identifier (UUID) uniquely identifying the organization", + required = true) + @JsonProperty(required = true) + private UUID id; + + /** + * The Name. + */ + @Schema(description = "The name of the organization", required = true) + @JsonProperty(required = true) + private String name; + + /** + * Instantiates a new Organization. + */ + public Organization() { + } + + /** + * Gets id. + * + * @return the id + */ + public UUID getId() { + return id; + } + + /** + * Sets id. + * + * @param id the id + */ + public void setId(UUID id) { + this.id = id; + } + + /** + * Gets name. + * + * @return the name + */ + public String getName() { + return name; + } + + /** + * Sets name. + * + * @param name the name + */ + public void setName(String name) { + this.name = name; + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app132/RestControllerError.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app132/RestControllerError.java new file mode 100644 index 000000000..d688524e2 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app132/RestControllerError.java @@ -0,0 +1,48 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app132; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The type Rest controller error. + */ +class RestControllerError { + + /** + * The Id. + */ + @JsonProperty + private String id; + + /** + * The Message. + */ + @JsonProperty + private String message; + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app132/SpringDocApp132Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app132/SpringDocApp132Test.java new file mode 100644 index 000000000..53f278f4f --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app132/SpringDocApp132Test.java @@ -0,0 +1,44 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app132; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + + +/** + * Tests Spring meta-annotations as method parameters + */ +class SpringDocApp132Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app133/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app133/HelloController.java new file mode 100644 index 000000000..58a735433 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app133/HelloController.java @@ -0,0 +1,83 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app133; + +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.media.Schema; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestHeader; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * Gets message from header 1. + * + * @param header the header + * @return the message from header 1 + */ + @GetMapping(path = "/test1", headers = { "myHeader" }) + public String getMessageFromHeader1( + @Parameter(name = "myHeader", description = "A header", schema = @Schema(allowableValues = { "foo", "bar" })) + @RequestHeader("myHeader") String header + ) { + return "bar " + header; + } + + /** + * Gets message from header 2. + * + * @param header the header + * @return the message from header 2 + */ + @GetMapping("/test2") + public String getMessageFromHeader2( + @Parameter(name = "myHeader", description = "A header", schema = @Schema(type = "integer")) + @RequestHeader("myHeader") Integer header + ) { + return "bar " + header; + } + + /** + * Gets message from header 3. + * + * @param header the header + * @return the message from header 3 + */ + @GetMapping(path = "/test3", headers = { "myHeader" }) + public String getMessageFromHeader3( + @Parameter(name = "myHeader", description = "A header", schema = @Schema(type = "integer")) + @RequestHeader("myHeader") Integer header + ) { + return "bar " + header; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app133/SpringDocApp133Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app133/SpringDocApp133Test.java new file mode 100644 index 000000000..f7734a8b8 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app133/SpringDocApp133Test.java @@ -0,0 +1,44 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app133; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + + +/** + * Tests Spring meta-annotations as method parameters + */ +class SpringDocApp133Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app134/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app134/HelloController.java new file mode 100644 index 000000000..fc365013c --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app134/HelloController.java @@ -0,0 +1,228 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app134; + +import java.util.Collections; +import java.util.List; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.media.ArraySchema; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.tags.Tag; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.http.HttpStatus; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.ResponseStatus; +import org.springframework.web.bind.annotation.RestController; + + +/** + * The type Hello controller. + */ +@SpringBootApplication +@RestController +@Tag(name = "The sample resource") +class HelloController { + + // ----------------------------------------------------------------------------------------------------------------- + + /** + * The constant VERSION_1. + */ + public static final String VERSION_1 = "application/vnd.samples.v1+json"; + + /** + * The constant VERSION_2. + */ + public static final String VERSION_2 = "application/vnd.samples.v2+json"; + + /** + * The constant HEADER_1. + */ + public static final String HEADER_1 = "X-API-VERSION=1"; + + /** + * The constant HEADER_2. + */ + public static final String HEADER_2 = "Accept-version=v2"; + + /** + * Gets sample v 1. + * + * @param id the id + * @return the sample v 1 + */ + @GetMapping(value = "/{id}", produces = VERSION_1, headers = HEADER_1) + @ResponseStatus(HttpStatus.OK) + @Operation(operationId = "getSampleV1", deprecated = true, description = "Get the sample by its id." + ) + @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = SampleV1.class))) + public SampleV1 getSampleV1(@Parameter(description = "The sample's id", required = true) + @PathVariable final String id) { + return new SampleV1(id); + } + + /** + * Gets sample v 2. + * + * @param id the id + * @return the sample v 2 + */ + @GetMapping(value = "/{id}", produces = VERSION_2, headers = { HEADER_2, HEADER_1 }) + @ResponseStatus(HttpStatus.OK) + @Operation(operationId = "getSampleV2", description = "Get the sample by its id. This represents V2.") + @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = SampleV1.class))) + public SampleV2 getSampleV2(@Parameter(description = "The sample's id", required = true) + @PathVariable final Long id) { + return new SampleV2(id); + } + + /** + * Search samples list. + * + * @param searchRequest the search request + * @return the list + */ + @PostMapping(path = "/search", consumes = VERSION_2, produces = VERSION_2) + @Operation(description = "Searches for sample objects using the given search request.") + @ApiResponse(responseCode = "200", + content = @Content(array = @ArraySchema(schema = @Schema(implementation = SampleV2.class)))) + public List searchSamples(@RequestBody final SampleSearchRequest searchRequest) { + return Collections.singletonList(new SampleV2(searchRequest.getId())); + } + + + /** + * The type Sample v 1. + */ + private class SampleV1 { + + /** + * The Id. + */ + private String id; + + /** + * Instantiates a new Sample v 1. + * + * @param id the id + */ + public SampleV1(String id) { + this.id = id; + } + + /** + * Gets id. + * + * @return the id + */ + public String getId() { + return id; + } + + /** + * Sets id. + * + * @param id the id + */ + public void setId(String id) { + this.id = id; + } + } + + /** + * The type Sample v 2. + */ + private class SampleV2 { + /** + * The Id. + */ + private long id; + + /** + * Instantiates a new Sample v 2. + * + * @param id the id + */ + public SampleV2(long id) { + this.id = id; + } + + /** + * Gets id. + * + * @return the id + */ + public long getId() { + return id; + } + + /** + * Sets id. + * + * @param id the id + */ + public void setId(long id) { + this.id = id; + } + } + + /** + * The type Sample search request. + */ + private class SampleSearchRequest { + /** + * The Id. + */ + private final long id; + + /** + * Instantiates a new Sample search request. + * + * @param id the id + */ + public SampleSearchRequest(long id) { + this.id = id; + } + + /** + * Gets id. + * + * @return the id + */ + public long getId() { + return id; + } + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app134/OpenApiConfig.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app134/OpenApiConfig.java new file mode 100644 index 000000000..36368c352 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app134/OpenApiConfig.java @@ -0,0 +1,99 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app134; + +import org.springdoc.core.models.GroupedOpenApi; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +/** + * The type Open api config. + */ +@Configuration +class OpenApiConfig { + + /** + * Group v 1 open api grouped open api. + * + * @return the grouped open api + */ + @Bean + public GroupedOpenApi groupV1OpenApi() { + return GroupedOpenApi.builder() + .group("v1-group").producesToMatch(HelloController.VERSION_1) + .build(); + } + + /** + * Group v 2 open api grouped open api. + * + * @return the grouped open api + */ + @Bean + public GroupedOpenApi groupV2OpenApi() { + return GroupedOpenApi.builder() + .group("v2-group").producesToMatch(HelloController.VERSION_2) + .build(); + } + + /** + * Group v 3 open api grouped open api. + * + * @return the grouped open api + */ + @Bean + public GroupedOpenApi groupV3OpenApi() { + return GroupedOpenApi.builder() + .group("v2-consumes-group").consumesToMatch(HelloController.VERSION_2) + .build(); + } + + /** + * Group v 4 open api grouped open api. + * + * @return the grouped open api + */ + @Bean + public GroupedOpenApi groupV4OpenApi() { + return GroupedOpenApi.builder() + .group("v1-headers-group").headersToMatch(HelloController.HEADER_1) + .build(); + } + + /** + * Group v 5 open api grouped open api. + * + * @return the grouped open api + */ + @Bean + public GroupedOpenApi groupV5OpenApi() { + return GroupedOpenApi.builder() + .group("v1-v2-headers-group").headersToMatch(HelloController.HEADER_1, HelloController.HEADER_2) + .build(); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app134/SpringDocApp134Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app134/SpringDocApp134Test.java new file mode 100644 index 000000000..45a01232f --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app134/SpringDocApp134Test.java @@ -0,0 +1,116 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app134; + +import org.junit.jupiter.api.Test; +import org.springdoc.core.utils.Constants; +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +import static org.hamcrest.Matchers.is; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + + +/** + * Tests Spring meta-annotations as method parameters + */ +class SpringDocApp134Test extends AbstractSpringDocTest { + + /** + * Test app. + * + * @throws Exception the exception + */ + @Test + protected void testApp() throws Exception { + mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL + "/v1-group")) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.openapi", is("3.0.1"))) + .andExpect(content().json(getContent("results/3.0.1/app134-1.json"), true)); + } + + /** + * Test app 2. + * + * @throws Exception the exception + */ + @Test + void testApp2() throws Exception { + mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL + "/v2-group")) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.openapi", is("3.0.1"))) + .andExpect(content().json(getContent("results/3.0.1/app134-2.json"), true)); + } + + /** + * Test app 3. + * + * @throws Exception the exception + */ + @Test + void testApp3() throws Exception { + mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL + "/v1-headers-group")) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.openapi", is("3.0.1"))) + .andExpect(content().json(getContent("results/3.0.1/app134-3.json"), true)); + } + + /** + * Test app 4. + * + * @throws Exception the exception + */ + @Test + void testApp4() throws Exception { + mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL + "/v1-v2-headers-group")) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.openapi", is("3.0.1"))) + .andExpect(content().json(getContent("results/3.0.1/app134-4.json"), true)); + } + + /** + * Test app 5. + * + * @throws Exception the exception + */ + @Test + void testApp5() throws Exception { + mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL + "/v2-consumes-group")) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.openapi", is("3.0.1"))) + .andExpect(content().json(getContent("results/3.0.1/app134-5.json"), true)); + } + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app135/Book.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app135/Book.java new file mode 100644 index 000000000..c85b5f537 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app135/Book.java @@ -0,0 +1,115 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app135; + +/** + * The type Book. + */ +class Book { + + /** + * The Id. + */ + private String id; + + /** + * The Title. + */ + private String title; + + /** + * The Author. + */ + private String author; + + /** + * Instantiates a new Book. + * + * @param id the id + * @param title the title + * @param author the author + */ + public Book(String id, String title, String author) { + this.id = id; + this.title = title; + this.author = author; + } + + /** + * Gets id. + * + * @return the id + */ + public String getId() { + return id; + } + + /** + * Sets id. + * + * @param id the id + */ + public void setId(String id) { + this.id = id; + } + + /** + * Gets title. + * + * @return the title + */ + public String getTitle() { + return title; + } + + /** + * Sets title. + * + * @param title the title + */ + public void setTitle(String title) { + this.title = title; + } + + /** + * Gets author. + * + * @return the author + */ + public String getAuthor() { + return author; + } + + /** + * Sets author. + * + * @param author the author + */ + public void setAuthor(String author) { + this.author = author; + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app135/BookRepository.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app135/BookRepository.java new file mode 100644 index 000000000..bbb48969d --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app135/BookRepository.java @@ -0,0 +1,60 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app135; + +import java.util.Arrays; +import java.util.List; + +import org.springframework.stereotype.Component; + +/** + * The type Book repository. + */ +@Component +class BookRepository { + + /** + * Find by author list. + * + * @param author the author + * @return the list + */ + List findByAuthor(String author) { + Book[] books = { new Book("1", "title1", "author1") }; + return Arrays.asList(books); + } + + /** + * Find all list. + * + * @return the list + */ + List findAll() { + Book[] books = { new Book("2", "title2", "author2") }; + return Arrays.asList(books); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app135/BookRouter.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app135/BookRouter.java new file mode 100644 index 000000000..7b368cb3c --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app135/BookRouter.java @@ -0,0 +1,140 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app135; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.enums.ParameterIn; +import org.springdoc.core.annotations.RouterOperation; +import org.springdoc.core.annotations.RouterOperations; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.http.MediaType; +import org.springframework.web.servlet.function.RequestPredicates; +import org.springframework.web.servlet.function.RouterFunction; +import org.springframework.web.servlet.function.RouterFunctions; +import org.springframework.web.servlet.function.ServerResponse; + +import static org.springframework.web.servlet.function.RouterFunctions.nest; +import static org.springframework.web.servlet.function.RouterFunctions.route; +import static org.springframework.web.servlet.function.ServerResponse.ok; + +/** + * The type Book router. + */ +@Configuration +class BookRouter { + + /** + * Routes router function. + * + * @param br the br + * @return the router function + */ + @Bean + @RouterOperations({ + @RouterOperation(path = "/greeter/greeter2/books", produces = { MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE }, beanClass = BookRepository.class, beanMethod = "findAll"), + @RouterOperation(path = "/greeter/greeter2/books", produces = { MediaType.TEXT_PLAIN_VALUE, MediaType.APPLICATION_XML_VALUE }, beanClass = BookRepository.class, beanMethod = "findAll"), + @RouterOperation(path = "/greeter/greeter2/books/{author}", beanClass = BookRepository.class, beanMethod = "findByAuthor", + operation = @Operation(operationId = "findByAuthor" + , parameters = { @Parameter(in = ParameterIn.PATH, name = "author") })) }) + RouterFunction routes(BookRepository br) { + return + RouterFunctions.nest(RequestPredicates.path("/greeter").and(RequestPredicates.path("/greeter2")), + RouterFunctions.route(RequestPredicates.GET("/books").and(RequestPredicates.accept(MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML)), req -> ok().body(br.findAll())) + .and(route(RequestPredicates.GET("/books").and(RequestPredicates.accept(MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN)), req -> ok().body(br.findAll()))) + .andRoute(RequestPredicates.GET("/books/{author}"), req -> ok().body(br.findByAuthor(req.pathVariable("author"))))); + } + + /** + * Routes 1 router function. + * + * @param br the br + * @return the router function + */ + @Bean + @RouterOperations({ + @RouterOperation(path = "/books", produces = { MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE }, beanClass = BookRepository.class, beanMethod = "findAll"), + @RouterOperation(path = "/books/{author}", beanClass = BookRepository.class, beanMethod = "findByAuthor", + operation = @Operation(operationId = "findByAuthor" + , parameters = { @Parameter(in = ParameterIn.PATH, name = "author") })) }) + RouterFunction routes1(BookRepository br) { + return + RouterFunctions.nest(RequestPredicates.accept(MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML), + RouterFunctions.route(RequestPredicates.GET("/books"), req -> ServerResponse.ok().body(br.findAll())) + .andRoute(RequestPredicates.GET("/books/{author}"), req -> ServerResponse.ok().body(br.findByAuthor(req.pathVariable("author"))))); + } + + /** + * Routes 3 router function. + * + * @param br the br + * @return the router function + */ + @Bean + @RouterOperations({ + @RouterOperation(path = "/greeter/books", produces = { MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE }, beanClass = BookRepository.class, beanMethod = "findAll"), + @RouterOperation(path = "/greeter/books", produces = { MediaType.TEXT_PLAIN_VALUE, MediaType.APPLICATION_XML_VALUE }, beanClass = BookRepository.class, beanMethod = "findAll"), + @RouterOperation(path = "/greeter/books/{author}", beanClass = BookRepository.class, beanMethod = "findByAuthor", + operation = @Operation(operationId = "findByAuthor" + , parameters = { @Parameter(in = ParameterIn.PATH, name = "author") })), + @RouterOperation(path = "/greeter2/books", produces = { MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE }, beanClass = BookRepository.class, beanMethod = "findAll"), + @RouterOperation(path = "/greeter2/books", produces = { MediaType.TEXT_PLAIN_VALUE, MediaType.APPLICATION_XML_VALUE }, beanClass = BookRepository.class, beanMethod = "findAll"), + @RouterOperation(path = "/greeter2/books/{author}", beanClass = BookRepository.class, beanMethod = "findByAuthor", + operation = @Operation(operationId = "findByAuthor" + , parameters = { @Parameter(in = ParameterIn.PATH, name = "author") })) }) + RouterFunction routes3(BookRepository br) { + return + nest(RequestPredicates.path("/greeter").or(RequestPredicates.path("/greeter2")), + route(RequestPredicates.GET("/books").and(RequestPredicates.accept(MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML)), req -> ok().body(br.findAll())) + .and(route(RequestPredicates.GET("/books").and(RequestPredicates.accept(MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN)), req -> ok().body(br.findAll()))) + .andRoute(RequestPredicates.GET("/books/{author}"), req -> ok().body(br.findByAuthor(req.pathVariable("author"))))); + } + + /** + * Routes 4 router function. + * + * @param br the br + * @return the router function + */ + @Bean + @RouterOperations({ + @RouterOperation(path = "/test/greeter/greeter2/books", produces = { MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE }, beanClass = BookRepository.class, beanMethod = "findAll"), + @RouterOperation(path = "/test/greeter/greeter2/books", produces = { MediaType.TEXT_PLAIN_VALUE, MediaType.APPLICATION_XML_VALUE }, beanClass = BookRepository.class, beanMethod = "findAll"), + @RouterOperation(path = "/test/greeter/greeter2/books/{author}", beanClass = BookRepository.class, beanMethod = "findByAuthor", + operation = @Operation(operationId = "findByAuthor" + , parameters = { @Parameter(in = ParameterIn.PATH, name = "author") })) }) + RouterFunction routes4(BookRepository br) { + return + nest(RequestPredicates.path("/test"), + nest(RequestPredicates.path("/greeter").and(RequestPredicates.path("/greeter2")), + route(RequestPredicates.GET("/books").and(RequestPredicates.accept(MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML)), req -> ok().body(br.findAll())) + .and(route(RequestPredicates.GET("/books").and(RequestPredicates.accept(MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN)), req -> ok().body(br.findAll()))) + .andRoute(RequestPredicates.GET("/books/{author}"), req -> ok().body(br.findByAuthor(req.pathVariable("author")))))); + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app135/SpringDocApp135Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app135/SpringDocApp135Test.java new file mode 100644 index 000000000..f8a6bfa83 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app135/SpringDocApp135Test.java @@ -0,0 +1,44 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app135; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + + +/** + * Tests Spring meta-annotations as method parameters + */ +class SpringDocApp135Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app137/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app137/HelloController.java new file mode 100644 index 000000000..f3d9f38eb --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app137/HelloController.java @@ -0,0 +1,49 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app137; + +import io.swagger.v3.oas.annotations.security.SecurityRequirement; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +@SecurityRequirement(name = "security_auth") +class HelloController { + + /** + * Test. + * + * @param hello the hello + */ + @GetMapping("/test") + public void test(String hello) { + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app137/OpenApiConfig.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app137/OpenApiConfig.java new file mode 100644 index 000000000..f90dffeff --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app137/OpenApiConfig.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.app137; + +import io.swagger.v3.oas.annotations.OpenAPIDefinition; +import io.swagger.v3.oas.annotations.enums.SecuritySchemeType; +import io.swagger.v3.oas.annotations.info.Info; +import io.swagger.v3.oas.annotations.security.OAuthFlow; +import io.swagger.v3.oas.annotations.security.OAuthFlows; +import io.swagger.v3.oas.annotations.security.SecurityScheme; +import io.swagger.v3.oas.annotations.servers.Server; + +/** + * The type Open api config. + */ +@OpenAPIDefinition(servers = @Server(url = "${test.server}", description = "${test.desc}"), info = @Info(title = "My App", + description = "Some long and useful description", version = "v1")) +@SecurityScheme(name = "security_auth", type = SecuritySchemeType.OAUTH2, + flows = @OAuthFlows(authorizationCode = @OAuthFlow( + authorizationUrl = "http://authorization.url" + , tokenUrl = "http://token.url", scopes = {}))) +class OpenApiConfig {} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app137/SpringDocApp137Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app137/SpringDocApp137Test.java new file mode 100644 index 000000000..362368f00 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app137/SpringDocApp137Test.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.app137; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.test.context.TestPropertySource; + + +/** + * Tests Spring meta-annotations as method parameters + */ +@TestPropertySource(properties = { "test.server=http://test.toto.com", "test.desc=toto desc" }) +class SpringDocApp137Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app138/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app138/HelloController.java new file mode 100644 index 000000000..90bf11f4f --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app138/HelloController.java @@ -0,0 +1,55 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app138; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * Test a. + * + * @param hello the hello + */ + @GetMapping("/testA") + public void testA(String hello) { + } + + /** + * Test b. + * + * @param hello the hello + */ + @GetMapping("/testB") + public void testB(String hello) { + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app138/SpringDocApp138Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app138/SpringDocApp138Test.java new file mode 100644 index 000000000..c3363de18 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app138/SpringDocApp138Test.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.app138; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.test.context.TestPropertySource; + + +/** + * Tests Spring meta-annotations as method parameters + */ +@TestPropertySource(properties = "springdoc.writer-with-order-by-keys=true") +class SpringDocApp138Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app139/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app139/HelloController.java new file mode 100644 index 000000000..68aa09885 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app139/HelloController.java @@ -0,0 +1,62 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app139; + +import org.springframework.http.MediaType; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * Echo 1 string. + * + * @param text the text + * @return the string + */ + @GetMapping(produces = MediaType.TEXT_PLAIN_VALUE, path = "/test1") + public String echo1(@RequestParam(name = "${test.name}", defaultValue = "${test.default-value}") String text) { + return text; + } + + /** + * Echo 2 string. + * + * @param text the text + * @return the string + */ + @GetMapping(produces = MediaType.TEXT_PLAIN_VALUE, path = "/test2") + public String echo2(@RequestParam(value = "${test.value}", defaultValue = "${test.default-value}") String text) { + return text; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app139/SpringDocApp139Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app139/SpringDocApp139Test.java new file mode 100644 index 000000000..d3f2b1173 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app139/SpringDocApp139Test.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.app139; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.test.context.TestPropertySource; + + +/** + * Tests Spring meta-annotations as method parameters + */ +@TestPropertySource(properties = { "test.name=text", "test.value=text", "test.default-value=default-text" }) +class SpringDocApp139Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app14/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app14/HelloController.java new file mode 100644 index 000000000..489d31c1f --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app14/HelloController.java @@ -0,0 +1,61 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app14; + +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; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * Persons. + * + * @param name the name + */ + @GetMapping("/persons") + public void persons(@Valid @NotBlank String name) { + + } + + /** + * Demo 2 http entity. + * + * @return the http entity + */ + @GetMapping("/test") + public HttpEntity demo2() { + return null; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app14/SpringDocApp14Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app14/SpringDocApp14Test.java new file mode 100644 index 000000000..60f25e133 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app14/SpringDocApp14Test.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app14; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 14 test. + */ +class SpringDocApp14Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app140/HelloApplication.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app140/HelloApplication.java new file mode 100644 index 000000000..95d57eae5 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app140/HelloApplication.java @@ -0,0 +1,314 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app140; + +import java.io.IOException; +import java.net.URI; +import java.util.HashSet; +import java.util.Set; +import java.util.concurrent.atomic.AtomicLong; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.enums.ParameterIn; +import jakarta.servlet.FilterChain; +import jakarta.servlet.GenericFilter; +import jakarta.servlet.ServletException; +import jakarta.servlet.ServletRequest; +import jakarta.servlet.ServletResponse; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.stereotype.Component; +import org.springframework.stereotype.Service; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.servlet.function.HandlerFunction; +import org.springframework.web.servlet.function.RouterFunction; +import org.springframework.web.servlet.function.ServerRequest; +import org.springframework.web.servlet.function.ServerResponse; + +import static org.springdoc.core.fn.builders.operation.Builder.operationBuilder; +import static org.springdoc.core.utils.Constants.OPERATION_ATTRIBUTE; +import static org.springframework.web.servlet.function.RouterFunctions.route; +import static org.springframework.web.servlet.function.ServerResponse.ok; + +/** + * The type Hello application. + */ +@Configuration +class HelloApplication { + + /** + * Filter server response. + * + * @param serverRequest the server request + * @param handlerFunction the handler function + * @return the server response + * @throws Exception the exception + */ + private static ServerResponse filter(ServerRequest serverRequest, HandlerFunction handlerFunction) throws Exception { + return handlerFunction.handle(serverRequest); + } + + /** + * Routes router function. + * + * @param ph the ph + * @return the router function + */ + @Bean + RouterFunction routes(PersonHandler ph) { + String root = ""; + return route() + .GET(root + "/people", ph::handleGetAllPeople) + .withAttribute(OPERATION_ATTRIBUTE, operationBuilder().beanClass(PersonService.class).beanMethod("all")) + .GET(root + "/people/{id}", ph::handleGetPersonById) + .withAttribute(OPERATION_ATTRIBUTE, operationBuilder().beanClass(PersonService.class).beanMethod("byId")) + .POST(root + "/people", ph::handlePostPerson) + .withAttribute(OPERATION_ATTRIBUTE, operationBuilder().beanClass(PersonService.class).beanMethod("save")) + .filter(HelloApplication::filter) + .build(); + } +} + +/** + * The type Simple filter. + */ +@Component +class SimpleFilter extends GenericFilter { + + /** + * Do filter. + * + * @param req the req + * @param res the res + * @param filterChain the filter chain + * @throws IOException the io exception + * @throws ServletException the servlet exception + */ + @Override + public void doFilter(ServletRequest req, ServletResponse res, + FilterChain filterChain) throws IOException, ServletException { + filterChain.doFilter(req, res); + } +} + +/** + * The type Person handler. + */ +@Component +class PersonHandler { + + /** + * The Person service. + */ + private final PersonService personService; + + /** + * Instantiates a new Person handler. + * + * @param personService the person service + */ + PersonHandler(PersonService personService) { + this.personService = personService; + } + + /** + * Handle get all people server response. + * + * @param serverRequest the server request + * @return the server response + */ + ServerResponse handleGetAllPeople(ServerRequest serverRequest) { + return ok().body(personService.all()); + } + + /** + * Handle post person server response. + * + * @param r the r + * @return the server response + * @throws ServletException the servlet exception + * @throws IOException the io exception + */ + ServerResponse handlePostPerson(ServerRequest r) throws ServletException, IOException { + Person result = personService.save(new Person(null, r.body(Person.class).getName())); + URI uri = URI.create("/people/" + result.getId()); + return ServerResponse.created(uri).body(result); + } + + /** + * Handle get person by id server response. + * + * @param r the r + * @return the server response + */ + ServerResponse handleGetPersonById(ServerRequest r) { + return ok().body(personService.byId(Long.parseLong(r.pathVariable("id")))); + } +} + +/** + * The type Greetings rest controller. + */ +@RestController +class GreetingsRestController { + + /** + * Greet string. + * + * @param name the name + * @return the string + */ + @GetMapping("/greet/{name}") + String greet(@PathVariable String name) { + return "hello " + name + "!"; + } +} + +/** + * The type Person service. + */ +@Service +class PersonService { + + /** + * The Counter. + */ + private final AtomicLong counter = new AtomicLong(); + + /** + * The People. + */ + private final Set people = Stream.of( + new Person(counter.incrementAndGet(), "Jane"), + new Person(counter.incrementAndGet(), "Josh"), + new Person(counter.incrementAndGet(), "Gordon")) + .collect(Collectors.toCollection(HashSet::new)); + + + /** + * Save person. + * + * @param p the p + * @return the person + */ + Person save(Person p) { + Person person = new Person(counter.incrementAndGet(), p.getName()); + this.people.add(person); + return person; + } + + /** + * All set. + * + * @return the set + */ + Set all() { + return this.people; + } + + /** + * By id person. + * + * @param id the id + * @return the person + */ + Person byId(@Parameter(in = ParameterIn.PATH) Long id) { + return this.people.stream() + .filter(p -> p.getId().equals(id)) + .findFirst() + .orElseThrow(() -> new IllegalArgumentException("no " + Person.class.getName() + " with that ID found!")); + } + +} + +/** + * The type Person. + */ +class Person { + + /** + * The Id. + */ + private Long id; + + /** + * The Name. + */ + private String name; + + /** + * Instantiates a new Person. + * + * @param id the id + * @param name the name + */ + public Person(Long id, String name) { + this.id = id; + this.name = name; + } + + /** + * Gets id. + * + * @return the id + */ + public Long getId() { + return id; + } + + /** + * Sets id. + * + * @param id the id + */ + public void setId(Long id) { + this.id = id; + } + + /** + * Gets name. + * + * @return the name + */ + public String getName() { + return name; + } + + /** + * Sets name. + * + * @param name the name + */ + public void setName(String name) { + this.name = name; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app140/SpringDocApp140Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app140/SpringDocApp140Test.java new file mode 100644 index 000000000..8d69d9202 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app140/SpringDocApp140Test.java @@ -0,0 +1,44 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app140; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + + +/** + * The type Spring doc app 140 test. + */ +class SpringDocApp140Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app141/Book.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app141/Book.java new file mode 100644 index 000000000..b62163cad --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app141/Book.java @@ -0,0 +1,115 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app141; + +/** + * The type Book. + */ +class Book { + + /** + * The Id. + */ + private String id; + + /** + * The Title. + */ + private String title; + + /** + * The Author. + */ + private String author; + + /** + * Instantiates a new Book. + * + * @param id the id + * @param title the title + * @param author the author + */ + public Book(String id, String title, String author) { + this.id = id; + this.title = title; + this.author = author; + } + + /** + * Gets id. + * + * @return the id + */ + public String getId() { + return id; + } + + /** + * Sets id. + * + * @param id the id + */ + public void setId(String id) { + this.id = id; + } + + /** + * Gets title. + * + * @return the title + */ + public String getTitle() { + return title; + } + + /** + * Sets title. + * + * @param title the title + */ + public void setTitle(String title) { + this.title = title; + } + + /** + * Gets author. + * + * @return the author + */ + public String getAuthor() { + return author; + } + + /** + * Sets author. + * + * @param author the author + */ + public void setAuthor(String author) { + this.author = author; + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app141/BookRepository.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app141/BookRepository.java new file mode 100644 index 000000000..12d55beb4 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app141/BookRepository.java @@ -0,0 +1,60 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app141; + +import java.util.Arrays; +import java.util.List; + +import org.springframework.stereotype.Component; + +/** + * The type Book repository. + */ +@Component +class BookRepository { + + /** + * Find by author list. + * + * @param author the author + * @return the list + */ + List findByAuthor(String author) { + Book[] books = { new Book("1", "title1", "author1") }; + return Arrays.asList(books); + } + + /** + * Find all list. + * + * @return the list + */ + List findAll() { + Book[] books = { new Book("2", "title2", "author2") }; + return Arrays.asList(books); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app141/BookRouter.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app141/BookRouter.java new file mode 100644 index 000000000..bed051c1b --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app141/BookRouter.java @@ -0,0 +1,135 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app141; + +import io.swagger.v3.oas.annotations.enums.ParameterIn; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.http.MediaType; +import org.springframework.web.servlet.function.RouterFunction; + +import static org.springdoc.core.fn.builders.operation.Builder.operationBuilder; +import static org.springdoc.core.fn.builders.parameter.Builder.parameterBuilder; +import static org.springdoc.core.utils.Constants.OPERATION_ATTRIBUTE; +import static org.springframework.web.servlet.function.RequestPredicates.GET; +import static org.springframework.web.servlet.function.RequestPredicates.accept; +import static org.springframework.web.servlet.function.RequestPredicates.path; +import static org.springframework.web.servlet.function.RouterFunctions.nest; +import static org.springframework.web.servlet.function.RouterFunctions.route; +import static org.springframework.web.servlet.function.ServerResponse.ok; + +/** + * The type Book router. + */ +@Configuration +class BookRouter { + + + /** + * Routes router function. + * + * @param br the br + * @return the router function + */ + @Bean + RouterFunction routes(BookRepository br) { + return nest(path("/greeter").and(path("/greeter2")), + route(GET("/books").and(accept(MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML)), req -> ok().body(br.findAll())) + .withAttribute(OPERATION_ATTRIBUTE, operationBuilder().beanClass(BookRepository.class).beanMethod("findAll")) + + .and(route(GET("/books").and(accept(MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN)), req -> ok().body(br.findAll())) + .withAttribute(OPERATION_ATTRIBUTE, operationBuilder().beanClass(BookRepository.class).beanMethod("findAll"))) + + .and(route(GET("/books/{author}"), req -> ok().body(br.findByAuthor(req.pathVariable("author")))) + .withAttribute(OPERATION_ATTRIBUTE, operationBuilder() + .operationId("findByAuthor").parameter(parameterBuilder().name("author").in(ParameterIn.PATH)) + .beanClass(BookRepository.class).beanMethod("findByAuthor"))) + ); + } + + /** + * Routes 1 router function. + * + * @param br the br + * @return the router function + */ + @Bean + RouterFunction routes1(BookRepository br) { + return nest(accept(MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML), + route(GET("/books"), req -> ok().body(br.findAll())) + .withAttribute(OPERATION_ATTRIBUTE, operationBuilder().beanClass(BookRepository.class).beanMethod("findAll")) + + .and(route(GET("/books/{author}"), req -> ok().body(br.findByAuthor(req.pathVariable("author")))) + .withAttribute(OPERATION_ATTRIBUTE, operationBuilder() + .operationId("findByAuthor").parameter(parameterBuilder().name("author").in(ParameterIn.PATH)) + .beanClass(BookRepository.class).beanMethod("findByAuthor")))); + } + + /** + * Routes 3 router function. + * + * @param br the br + * @return the router function + */ + @Bean + RouterFunction routes3(BookRepository br) { + return nest(path("/greeter").or(path("/greeter2")), + route(GET("/books").and(accept(MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML)), req -> ok().body(br.findAll())) + .withAttribute(OPERATION_ATTRIBUTE, operationBuilder().beanClass(BookRepository.class).beanMethod("findAll")) + + + .and(route(GET("/books").and(accept(MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN)), req -> ok().body(br.findAll())) + .withAttribute(OPERATION_ATTRIBUTE, operationBuilder().beanClass(BookRepository.class).beanMethod("findAll"))) + + .and(route(GET("/books/{author}"), req -> ok().body(br.findByAuthor(req.pathVariable("author")))) + .withAttribute(OPERATION_ATTRIBUTE, operationBuilder() + .operationId("findByAuthor").parameter(parameterBuilder().name("author").in(ParameterIn.PATH)) + .beanClass(BookRepository.class).beanMethod("findByAuthor")))); + } + + /** + * Routes 4 router function. + * + * @param br the br + * @return the router function + */ + @Bean + RouterFunction routes4(BookRepository br) { + return nest(path("/test"), nest(path("/greeter").and(path("/greeter2")), + route(GET("/books").and(accept(MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML)), req -> ok().body(br.findAll())) + .withAttribute(OPERATION_ATTRIBUTE, operationBuilder().beanClass(BookRepository.class).beanMethod("findAll")) + + .and(route(GET("/books").and(accept(MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN)), req -> ok().body(br.findAll())) + .withAttribute(OPERATION_ATTRIBUTE, operationBuilder().beanClass(BookRepository.class).beanMethod("findAll"))) + + .and(route(GET("/books/{author}"), req -> ok().body(br.findByAuthor(req.pathVariable("author")))) + .withAttribute(OPERATION_ATTRIBUTE, operationBuilder() + .operationId("findByAuthor").parameter(parameterBuilder().name("author").in(ParameterIn.PATH)) + .beanClass(BookRepository.class).beanMethod("findByAuthor"))))); + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app141/SpringDocApp141Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app141/SpringDocApp141Test.java new file mode 100644 index 000000000..4258ec311 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app141/SpringDocApp141Test.java @@ -0,0 +1,44 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app141; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + + +/** + * Tests Spring meta-annotations as method parameters + */ +class SpringDocApp141Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app142/HelloApplication.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app142/HelloApplication.java new file mode 100644 index 000000000..9f9755355 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app142/HelloApplication.java @@ -0,0 +1,296 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app142; + +import java.io.IOException; +import java.net.URI; +import java.util.HashSet; +import java.util.Set; +import java.util.concurrent.atomic.AtomicLong; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.enums.ParameterIn; +import jakarta.servlet.FilterChain; +import jakarta.servlet.GenericFilter; +import jakarta.servlet.ServletException; +import jakarta.servlet.ServletRequest; +import jakarta.servlet.ServletResponse; +import org.springdoc.webmvc.core.fn.SpringdocRouteBuilder; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.stereotype.Component; +import org.springframework.stereotype.Service; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.servlet.function.RouterFunction; +import org.springframework.web.servlet.function.ServerRequest; +import org.springframework.web.servlet.function.ServerResponse; + +import static org.springframework.web.servlet.function.ServerResponse.ok; + +/** + * The type Hello application. + */ +@Configuration +class HelloApplication { + + + /** + * Routes router function. + * + * @param ph the ph + * @return the router function + */ + @Bean + RouterFunction routes(PersonHandler ph) { + String root = ""; + return SpringdocRouteBuilder.route() + .GET(root + "/people", ph::handleGetAllPeople, ops -> ops.beanClass(PersonService.class).beanMethod("all")) + .GET(root + "/people/{id}", ph::handleGetPersonById, ops -> ops.beanClass(PersonService.class).beanMethod("byId")) + .POST(root + "/people", ph::handlePostPerson, ops -> ops.beanClass(PersonService.class).beanMethod("save")).build(); + } + +} + +/** + * The type Simple filter. + */ +@Component +class SimpleFilter extends GenericFilter { + + /** + * Do filter. + * + * @param req the req + * @param res the res + * @param filterChain the filter chain + * @throws IOException the io exception + * @throws ServletException the servlet exception + */ + @Override + public void doFilter(ServletRequest req, ServletResponse res, + FilterChain filterChain) throws IOException, ServletException { + filterChain.doFilter(req, res); + } +} + +/** + * The type Person handler. + */ +@Component +class PersonHandler { + + /** + * The Person service. + */ + private final PersonService personService; + + /** + * Instantiates a new Person handler. + * + * @param personService the person service + */ + PersonHandler(PersonService personService) { + this.personService = personService; + } + + /** + * Handle get all people server response. + * + * @param serverRequest the server request + * @return the server response + */ + ServerResponse handleGetAllPeople(ServerRequest serverRequest) { + return ok().body(personService.all()); + } + + /** + * Handle post person server response. + * + * @param r the r + * @return the server response + * @throws ServletException the servlet exception + * @throws IOException the io exception + */ + ServerResponse handlePostPerson(ServerRequest r) throws ServletException, IOException { + Person result = personService.save(new Person(null, r.body(Person.class).getName())); + URI uri = URI.create("/people/" + result.getId()); + return ServerResponse.created(uri).body(result); + } + + /** + * Handle get person by id server response. + * + * @param r the r + * @return the server response + */ + ServerResponse handleGetPersonById(ServerRequest r) { + return ok().body(personService.byId(Long.parseLong(r.pathVariable("id")))); + } +} + +/** + * The type Greetings rest controller. + */ +@RestController +class GreetingsRestController { + + /** + * Greet string. + * + * @param name the name + * @return the string + */ + @GetMapping("/greet/{name}") + String greet(@PathVariable String name) { + return "hello " + name + "!"; + } +} + +/** + * The type Person service. + */ +@Service +class PersonService { + + /** + * The Counter. + */ + private final AtomicLong counter = new AtomicLong(); + + /** + * The People. + */ + private final Set people = Stream.of( + new Person(counter.incrementAndGet(), "Jane"), + new Person(counter.incrementAndGet(), "Josh"), + new Person(counter.incrementAndGet(), "Gordon")) + .collect(Collectors.toCollection(HashSet::new)); + + + /** + * Save person. + * + * @param p the p + * @return the person + */ + Person save(Person p) { + Person person = new Person(counter.incrementAndGet(), p.getName()); + this.people.add(person); + return person; + } + + /** + * All set. + * + * @return the set + */ + Set all() { + return this.people; + } + + /** + * By id person. + * + * @param id the id + * @return the person + */ + Person byId(@Parameter(in = ParameterIn.PATH) Long id) { + return this.people.stream() + .filter(p -> p.getId().equals(id)) + .findFirst() + .orElseThrow(() -> new IllegalArgumentException("no " + Person.class.getName() + " with that ID found!")); + } + +} + +/** + * The type Person. + */ +class Person { + + /** + * The Id. + */ + private Long id; + + /** + * The Name. + */ + private String name; + + /** + * Instantiates a new Person. + * + * @param id the id + * @param name the name + */ + public Person(Long id, String name) { + this.id = id; + this.name = name; + } + + /** + * Gets id. + * + * @return the id + */ + public Long getId() { + return id; + } + + /** + * Sets id. + * + * @param id the id + */ + public void setId(Long id) { + this.id = id; + } + + /** + * Gets name. + * + * @return the name + */ + public String getName() { + return name; + } + + /** + * Sets name. + * + * @param name the name + */ + public void setName(String name) { + this.name = name; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app142/SpringDocApp142Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app142/SpringDocApp142Test.java new file mode 100644 index 000000000..3826b1462 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app142/SpringDocApp142Test.java @@ -0,0 +1,44 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app142; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + + +/** + * The type Spring doc app 142 test. + */ +class SpringDocApp142Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app149/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app149/HelloController.java new file mode 100644 index 000000000..b14431f63 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app149/HelloController.java @@ -0,0 +1,91 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app149; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.servlet.ModelAndView; + +/** + * To test the case a user does not use @RestController but puts @Operation on handler methods + * and wants these methods to be exposed. + * + * @author Azige + */ +@Controller +class HelloController { + + /** + * Hello string. + * + * @return the string + */ + @GetMapping("/hello") + @Operation(responses = @ApiResponse( + responseCode = "200", + description = "OK", + content = @Content(schema = @Schema(implementation = HelloMessage.class)) + )) + public String hello() { + return "forward:/message"; + } + + /** + * Message hello message. + * + * @return the hello message + */ + @GetMapping("/message") + @Operation + @ResponseBody + public HelloMessage message() { + return new HelloMessage("Lucky numbers!", 777); + } + + /** + * Hello model and view model and view. + * + * @return the model and view + */ + @GetMapping("/helloModelAndView") + @Operation(responses = @ApiResponse( + responseCode = "200", + description = "OK", + content = @Content(schema = @Schema(implementation = HelloMessage.class)) + )) + public ModelAndView helloModelAndView() { + ModelAndView mav = new ModelAndView(); + mav.setViewName("forward:/message"); + return mav; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app149/HelloMessage.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app149/HelloMessage.java new file mode 100644 index 000000000..4acda09a8 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app149/HelloMessage.java @@ -0,0 +1,53 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app149; + +/** + * The type Hello message. + */ +class HelloMessage { + /** + * The Text. + */ + public String text; + + /** + * The Number. + */ + public int number; + + /** + * Instantiates a new Hello message. + * + * @param text the text + * @param number the number + */ + public HelloMessage(String text, int number) { + this.text = text; + this.number = number; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app149/SpringDocApp149Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app149/SpringDocApp149Test.java new file mode 100644 index 000000000..7a50ca415 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app149/SpringDocApp149Test.java @@ -0,0 +1,45 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app149; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.test.context.TestPropertySource; + +/** + * The type Spring doc app 149 test. + */ +@TestPropertySource(properties = "springdoc.model-and-view-allowed=true") +class SpringDocApp149Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app15/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app15/HelloController.java new file mode 100644 index 000000000..90e01758f --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app15/HelloController.java @@ -0,0 +1,55 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app15; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import org.json.JSONObject; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * Persons json object. + * + * @return the json object + */ + @GetMapping(value = "/persons") + @Operation(description = "${springdoc.operation-descriptions.myOperation}", responses = @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(hidden = true)))) + public JSONObject persons() { + return new JSONObject(); + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app15/SpringDocApp15Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app15/SpringDocApp15Test.java new file mode 100644 index 000000000..25fbf4c03 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app15/SpringDocApp15Test.java @@ -0,0 +1,75 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app15; + +import io.swagger.v3.oas.annotations.OpenAPIDefinition; +import io.swagger.v3.oas.annotations.info.Contact; +import io.swagger.v3.oas.annotations.info.Info; +import io.swagger.v3.oas.annotations.info.License; +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.test.context.TestPropertySource; + +/** + * The type Spring doc app 15 test. + */ +@TestPropertySource(properties = { + "springdoc.operation-descriptions.myOperation=My Desc", + "springdoc.openapidefinition.info.title=My title", + "springdoc.openapidefinition.info.desc=My description", + "springdoc.openapidefinition.info.version=My version", + "springdoc.openapidefinition.info.terms=My terms", + "springdoc.openapidefinition.info.license.name=My license name", + "springdoc.openapidefinition.info.license.url=My license url", + "springdoc.openapidefinition.info.contact.name=My contact name", + "springdoc.openapidefinition.info.contact.email=My contact email", + "springdoc.openapidefinition.info.contact.url=My contact url" +}) +class SpringDocApp15Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + @OpenAPIDefinition(info = @Info( + title = "${springdoc.openapidefinition.info.title}", + description = "${springdoc.openapidefinition.info.desc}", + version = "${springdoc.openapidefinition.info.version}", + termsOfService = "${springdoc.openapidefinition.info.terms}", + license = @License( + name = "${springdoc.openapidefinition.info.license.name}", + url = "${springdoc.openapidefinition.info.license.url}" + ), + contact = @Contact( + name = "${springdoc.openapidefinition.info.contact.name}", + email = "${springdoc.openapidefinition.info.contact.email}", + url = "${springdoc.openapidefinition.info.contact.url}" + ) + )) + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app150/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app150/HelloController.java new file mode 100644 index 000000000..e468b3c8f --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app150/HelloController.java @@ -0,0 +1,99 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app150; + +import java.time.LocalDate; +import java.util.List; + +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; + +import org.springframework.format.annotation.DateTimeFormat; +import org.springframework.http.HttpStatus; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.ResponseStatus; +import org.springframework.web.bind.annotation.RestController; + +import static org.springframework.format.annotation.DateTimeFormat.ISO.DATE; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * Test. + * + * @param toto the toto + */ + @GetMapping("/test/") + @ApiResponse(responseCode = "204", description = "No content") + @ResponseStatus(value = HttpStatus.NO_CONTENT) + public void test(@RequestParam(defaultValue = "1") Integer toto) { + + } + + /** + * Test 1. + * + * @param toto the toto + */ + @GetMapping("/test1") + @ApiResponse(responseCode = "204", description = "No content") + @ResponseStatus(value = HttpStatus.NO_CONTENT) + public void test1(@RequestParam @Parameter(schema = @Schema(defaultValue = "false", type = "boolean")) boolean toto) { + + } + + /** + * Test 3. + * + * @param toto the toto + */ + @GetMapping("/test3") + @ApiResponse(responseCode = "204", description = "No content") + @ResponseStatus(value = HttpStatus.NO_CONTENT) + public void test3(@RequestParam(defaultValue = "users,123") List toto) { + + } + + /** + * Test 4. + * + * @param localDate the local date + */ + @GetMapping("/test4") + @ApiResponse(responseCode = "204", description = "No content") + @ResponseStatus(value = HttpStatus.NO_CONTENT) + public void test4(@DateTimeFormat(iso = DATE) @RequestParam(defaultValue = "2021-03-08") LocalDate localDate) { + + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app150/SpringDocApp150Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app150/SpringDocApp150Test.java new file mode 100644 index 000000000..47afbcaf0 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app150/SpringDocApp150Test.java @@ -0,0 +1,45 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app150; + + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * Tests Spring meta-annotations as method parameters + */ +class SpringDocApp150Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app151/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app151/HelloController.java new file mode 100644 index 000000000..f0a38d220 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app151/HelloController.java @@ -0,0 +1,53 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app151; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +@RequestMapping("/test") +class HelloController { + + /** + * Test int. + * + * @return the int + */ + @GetMapping("") + /** + * A test endpoint mounted under `/test` + * @return 0 + */ + public int test() { + return 0; + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app151/SpringDocApp151Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app151/SpringDocApp151Test.java new file mode 100644 index 000000000..f4ea0be20 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app151/SpringDocApp151Test.java @@ -0,0 +1,45 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app151; + + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * Tests Spring meta-annotations as method parameters + */ +class SpringDocApp151Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app152/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app152/HelloController.java new file mode 100644 index 000000000..1c83adb6b --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app152/HelloController.java @@ -0,0 +1,72 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app152; + +import org.springframework.context.annotation.Configuration; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.servlet.config.annotation.PathMatchConfigurer; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; +import org.springframework.web.util.pattern.PathPatternParser; + +/** + * The type Hello controller. + */ +@RestController +@RequestMapping("/api") +class HelloController { + + /** + * Hello world string. + * + * @return the string + */ + @GetMapping + public String helloWorld() { + return "ok"; + } + + /** + * The type Web config. + */ + @Configuration + class WebConfig implements WebMvcConfigurer { + + /** + * Configure path match. + * + * @param configurer the configurer + */ + @Override + public void configurePathMatch(PathMatchConfigurer configurer) { + configurer.setPatternParser(new PathPatternParser()); + } + + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app152/SpringDocApp152Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app152/SpringDocApp152Test.java new file mode 100644 index 000000000..8dbd6a524 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app152/SpringDocApp152Test.java @@ -0,0 +1,45 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app152; + + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * Tests Spring meta-annotations as method parameters + */ +class SpringDocApp152Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app153/OrderState.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app153/OrderState.java new file mode 100644 index 000000000..a4034d84a --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app153/OrderState.java @@ -0,0 +1,68 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app153; + +import io.swagger.v3.oas.annotations.media.Schema; + + +/** + * The enum Order state. + */ +@Schema(type = "string", allowableValues = { "finished", "new" }) +public enum OrderState { + /** + *Finished order state. + */ + FINISHED("finished"), + /** + *New order state. + */ + NEW("new"); + + /** + * The Value. + */ + private final String value; + + /** + * Instantiates a new Order state. + * + * @param value the value + */ + OrderState(String value) { + this.value = value; + } + + /** + * Gets value. + * + * @return the value + */ + public String getValue() { + return value; + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app153/OrderStateMapper.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app153/OrderStateMapper.java new file mode 100644 index 000000000..c1e26d8a3 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app153/OrderStateMapper.java @@ -0,0 +1,53 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app153; + +import java.beans.PropertyEditorSupport; +import java.util.Arrays; + +import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException; + +/** + * The type Order state mapper. + */ +class OrderStateMapper extends PropertyEditorSupport { + + /** + * Sets as text. + * + * @param text the text + */ + @Override + public void setAsText(String text) { + setValue( + Arrays.stream(OrderState.class.getEnumConstants()) + .filter(e -> e.getValue().equals(text)) + .findFirst() + .orElseThrow(() -> new MethodArgumentTypeMismatchException( + text, OrderState.class, "orderState", null, null))); + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app153/SpringDocApp153Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app153/SpringDocApp153Test.java new file mode 100644 index 000000000..6c0c71983 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app153/SpringDocApp153Test.java @@ -0,0 +1,45 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app153; + + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * Tests Spring meta-annotations as method parameters + */ +class SpringDocApp153Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app153/TestController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app153/TestController.java new file mode 100644 index 000000000..742239b89 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app153/TestController.java @@ -0,0 +1,62 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app153; + +import org.springframework.web.bind.WebDataBinder; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.InitBinder; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Test controller. + */ +@RestController +class TestController { + + /** + * Init binder. + * + * @param dataBinder the data binder + */ + @InitBinder + public void initBinder(WebDataBinder dataBinder) { + dataBinder.registerCustomEditor(OrderState.class, new OrderStateMapper()); + } + + /** + * Method object. + * + * @param orderState the order state + * @return the object + */ + @GetMapping(value = { "/orders" }) + public Object method( + @RequestParam(value = "state", defaultValue = "finished") OrderState orderState) { + return null; + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app154/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app154/HelloController.java new file mode 100644 index 000000000..f9ac10cfc --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app154/HelloController.java @@ -0,0 +1,97 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app154; + +import java.time.Instant; + +import org.springdoc.core.annotations.ParameterObject; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + + /** + * Hello string. + * + * @return the string + */ + @GetMapping(path = "/") + public String hello() { + return "Hello world at " + Instant.now().toString(); + } + + /** + * Create. + * + * @param id the id + * @param o the o + */ + @PostMapping(value = "/persons") + public void create(@ParameterObject Long id, @RequestBody Object o) { + + } + + /** + * Createone. + * + * @param id the id + * @param o the o + */ + @PostMapping(value = "/personsone") + public void createone(Long id, @RequestBody Object o) { + + } + + /** + * Createtwo. + * + * @param id the id + */ + @PostMapping(value = "/createtwo") + public void createtwo(int id) { + + } + + /** + * Createthree. + * + * @param id the id + */ + @PostMapping(value = "/createthree") + public void createthree(Integer id) { + + } + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app154/OpenApiConfiguration.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app154/OpenApiConfiguration.java new file mode 100644 index 000000000..0c4ff3658 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app154/OpenApiConfiguration.java @@ -0,0 +1,56 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app154; + +import io.swagger.v3.oas.annotations.OpenAPIDefinition; +import io.swagger.v3.oas.annotations.enums.SecuritySchemeType; +import io.swagger.v3.oas.annotations.info.Info; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.security.SecurityScheme; +import io.swagger.v3.oas.annotations.security.SecuritySchemes; + +/** + * The type Open api configuration. + */ +@OpenAPIDefinition(info = @Info(title = "toto", version = "1.0"), + security = { @SecurityRequirement(name = "basicAuth"), @SecurityRequirement(name = "bearerToken") } +) +@SecuritySchemes({ + @SecurityScheme( + name = "basicAuth", + type = SecuritySchemeType.HTTP, + scheme = "basic" + ), + @SecurityScheme( + name = "bearerToken", + type = SecuritySchemeType.HTTP, + scheme = "bearer", + bearerFormat = "JWT" + ) +}) +class OpenApiConfiguration { +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app154/SpringDocApp154Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app154/SpringDocApp154Test.java new file mode 100644 index 000000000..089299b23 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app154/SpringDocApp154Test.java @@ -0,0 +1,45 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app154; + + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * Tests Spring meta-annotations as method parameters + */ +class SpringDocApp154Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app155/AbstractIntParameterObject.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app155/AbstractIntParameterObject.java new file mode 100644 index 000000000..76bc5207c --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app155/AbstractIntParameterObject.java @@ -0,0 +1,81 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app155; + +/** + * The type Abstract int parameter object. + * + * @param the type parameter + */ +class AbstractIntParameterObject { + + /** + * The Primitive base field. + */ + int primitiveBaseField; + + /** + * The Generic field. + */ + T genericField; + + /** + * Gets primitive base field. + * + * @return the primitive base field + */ + public int getPrimitiveBaseField() { + return primitiveBaseField; + } + + /** + * Sets primitive base field. + * + * @param primitiveBaseField the primitive base field + */ + public void setPrimitiveBaseField(int primitiveBaseField) { + this.primitiveBaseField = primitiveBaseField; + } + + /** + * Gets generic field. + * + * @return the generic field + */ + public T getGenericField() { + return genericField; + } + + /** + * Sets generic field. + * + * @param genericField the generic field + */ + public void setGenericField(T genericField) { + this.genericField = genericField; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app155/AbstractParameterObject.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app155/AbstractParameterObject.java new file mode 100644 index 000000000..37e7e27da --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app155/AbstractParameterObject.java @@ -0,0 +1,85 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app155; + +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.media.Schema; + +/** + * The type Abstract parameter object. + * + * @param the type parameter + */ +class AbstractParameterObject> { + + /** + * The Primitive base field. + */ + int primitiveBaseField; + + /** + * The Generic field. + */ + @Parameter(schema = @Schema(type = "string", allowableValues = { "ONE", "TWO" })) + T genericField; + + /** + * Gets primitive base field. + * + * @return the primitive base field + */ + public int getPrimitiveBaseField() { + return primitiveBaseField; + } + + /** + * Sets primitive base field. + * + * @param primitiveBaseField the primitive base field + */ + public void setPrimitiveBaseField(int primitiveBaseField) { + this.primitiveBaseField = primitiveBaseField; + } + + /** + * Gets generic field. + * + * @return the generic field + */ + public T getGenericField() { + return genericField; + } + + /** + * Sets generic field. + * + * @param genericField the generic field + */ + public void setGenericField(T genericField) { + this.genericField = genericField; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app155/ConcreteEnum.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app155/ConcreteEnum.java new file mode 100644 index 000000000..97cfc60e9 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app155/ConcreteEnum.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app155; + + +/** + * The enum Concrete enum. + */ +enum ConcreteEnum { + /** + *One concrete enum. + */ + ONE, + /** + *Two concrete enum. + */ + TWO + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app155/ConcreteIntParameterObject.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app155/ConcreteIntParameterObject.java new file mode 100644 index 000000000..57a0822b4 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app155/ConcreteIntParameterObject.java @@ -0,0 +1,56 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app155; + +/** + * The type Concrete int parameter object. + */ +class ConcreteIntParameterObject extends AbstractIntParameterObject { + + /** + * The Primitive concrete field. + */ + int primitiveConcreteField; + + /** + * Gets primitive concrete field. + * + * @return the primitive concrete field + */ + public int getPrimitiveConcreteField() { + return primitiveConcreteField; + } + + /** + * Sets primitive concrete field. + * + * @param primitiveConcreteField the primitive concrete field + */ + public void setPrimitiveConcreteField(int primitiveConcreteField) { + this.primitiveConcreteField = primitiveConcreteField; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app155/ConcreteParameterObject.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app155/ConcreteParameterObject.java new file mode 100644 index 000000000..11f5a59c4 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app155/ConcreteParameterObject.java @@ -0,0 +1,56 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app155; + +/** + * The type Concrete parameter object. + */ +class ConcreteParameterObject extends AbstractParameterObject { + + /** + * The Primitive concrete field. + */ + int primitiveConcreteField; + + /** + * Gets primitive concrete field. + * + * @return the primitive concrete field + */ + public int getPrimitiveConcreteField() { + return primitiveConcreteField; + } + + /** + * Sets primitive concrete field. + * + * @param primitiveConcreteField the primitive concrete field + */ + public void setPrimitiveConcreteField(int primitiveConcreteField) { + this.primitiveConcreteField = primitiveConcreteField; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app155/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app155/HelloController.java new file mode 100644 index 000000000..7c6431c60 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app155/HelloController.java @@ -0,0 +1,66 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app155; + +import org.springdoc.core.annotations.ParameterObject; + +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * Say hello response entity. + * + * @param test the test + * @return the response entity + */ + @GetMapping("/test1") + public ResponseEntity sayHello(@ParameterObject final ConcreteParameterObject test) { + System.out.println("Field B = " + test); + return new ResponseEntity("{\"Say\": \"Hello\"}", HttpStatus.OK); + } + + /** + * Say hello response entity. + * + * @param test the test + * @return the response entity + */ + @GetMapping("/test2") + public ResponseEntity sayHello(@ParameterObject final ConcreteIntParameterObject test) { + System.out.println("Field B = " + test); + return new ResponseEntity("{\"Say\": \"Hello\"}", HttpStatus.OK); + } + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app155/SpringDocApp155Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app155/SpringDocApp155Test.java new file mode 100644 index 000000000..bf3487dfd --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app155/SpringDocApp155Test.java @@ -0,0 +1,45 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app155; + + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * Tests Spring meta-annotations as method parameters + */ +class SpringDocApp155Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app156/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app156/HelloController.java new file mode 100644 index 000000000..a2daa3652 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app156/HelloController.java @@ -0,0 +1,80 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app156; + +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.media.ArraySchema; +import io.swagger.v3.oas.annotations.media.Schema; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +import static io.swagger.v3.oas.annotations.enums.ParameterIn.QUERY; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + /** + * Hello string. + * + * @param user the user + * @return the string + */ + @GetMapping("/hello") + @Parameter(name = "someEnums", in = QUERY, description = "SomeEum decs", + array = @ArraySchema(schema = @Schema(implementation = SomeEnum.class))) + @Parameter(name = "textSet", in = QUERY, description = "First decs", + array = @ArraySchema(schema = @Schema(implementation = String.class))) + @Parameter(name = "someText", in = QUERY, description = "Second decs", + schema = @Schema(type = "string")) + public String hello(@Parameter(hidden = true) User user) { + String forReturn = "Hello "; + StringBuilder stringBuilder = new StringBuilder(forReturn); + + if (user.getSomeEnums() != null) { + for (SomeEnum some : user.getSomeEnums()) { + stringBuilder.append(some); + stringBuilder.append(" "); + } + } + + if (user.getSomeText() != null) { + for (String text : user.getTextSet()) { + stringBuilder.append(text); + stringBuilder.append(" "); + } + } + + if (user.getSomeText() != null) { + stringBuilder.append(user.getSomeText()); + } + + return stringBuilder.toString(); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app156/SomeEnum.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app156/SomeEnum.java new file mode 100644 index 000000000..7737cbe33 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app156/SomeEnum.java @@ -0,0 +1,41 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app156; + +/** + * The enum Some enum. + */ +public enum SomeEnum { + /** + *First some enum. + */ + FIRST, + /** + *Second some enum. + */ + SECOND +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app156/SpringDocApp156Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app156/SpringDocApp156Test.java new file mode 100644 index 000000000..7052cea34 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app156/SpringDocApp156Test.java @@ -0,0 +1,45 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app156; + + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * Tests Spring meta-annotations as method parameters + */ +class SpringDocApp156Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app156/User.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app156/User.java new file mode 100644 index 000000000..5e1fd9837 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app156/User.java @@ -0,0 +1,103 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app156; + +import java.util.Set; + +/** + * The type User. + */ +class User { + /** + * The Some text. + */ + private String someText; + + /** + * The Text set. + */ + private Set textSet; + + /** + * The Some enums. + */ + private Set someEnums; + + /** + * Gets some text. + * + * @return the some text + */ + public String getSomeText() { + return someText; + } + + /** + * Sets some text. + * + * @param someText the some text + */ + public void setSomeText(String someText) { + this.someText = someText; + } + + /** + * Gets text set. + * + * @return the text set + */ + public Set getTextSet() { + return textSet; + } + + /** + * Sets text set. + * + * @param textSet the text set + */ + public void setTextSet(Set textSet) { + this.textSet = textSet; + } + + /** + * Gets some enums. + * + * @return the some enums + */ + public Set getSomeEnums() { + return someEnums; + } + + /** + * Sets some enums. + * + * @param someEnums the some enums + */ + public void setSomeEnums(Set someEnums) { + this.someEnums = someEnums; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app157/Bar.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app157/Bar.java new file mode 100644 index 000000000..95afc897e --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app157/Bar.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.app157; + +/** + * A class without a String in it + */ +class Bar { + /** + * The Child. + */ + private Object child; + + /** + * Gets child. + * + * @return the child + */ + public Object getChild() { + return this.child; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app157/Foo.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app157/Foo.java new file mode 100644 index 000000000..ad636dba6 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app157/Foo.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.app157; + +/** + * A class with a String in it + */ +class Foo { + /** + * The Child. + */ + private String child; + + /** + * Gets child. + * + * @return the child + */ + public String getChild() { + return this.child; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app157/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app157/HelloController.java new file mode 100644 index 000000000..411392f28 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app157/HelloController.java @@ -0,0 +1,61 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app157; + +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * Put Foo and Bar in the schema's components, make sure there is an ignored wrapper + * ({@code ResponseEntity}). + */ +@RestController +class HelloController { + + /** + * Gets foo. + * + * @return the foo + */ + @GetMapping("/foo") + public ResponseEntity getFoo() { + return new ResponseEntity(HttpStatus.OK); + } + + /** + * Gets bar. + * + * @return the bar + */ + @GetMapping("/bar") + public ResponseEntity getBar() { + return new ResponseEntity(HttpStatus.OK); + } + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app157/SpringDocApp157Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app157/SpringDocApp157Test.java new file mode 100644 index 000000000..9aa716151 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app157/SpringDocApp157Test.java @@ -0,0 +1,91 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app157; + +import java.util.ArrayList; + +import io.swagger.v3.core.converter.ModelConverters; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Test; +import org.springdoc.core.utils.Constants; +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +import static org.hamcrest.Matchers.hasProperty; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.not; +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; + +/** + * This test is to make sure that a new model converter can access the parent of a type, even if + * the type is enclosed in an ignored wrapper. We test this by setting up a model converter which + * adds "stringy" to the "required" property of a schema's parent, when the sub schema is a String. + */ +class SpringDocApp157Test extends AbstractSpringDocTest { + + /** + * The Converters. + */ + private final ModelConverters converters = ModelConverters.getInstance(); + + @Autowired + private StringyConverter stringyConverter; + + /** + * Unregister converter. + */ + @AfterEach + public void unregisterConverter() { + converters.removeConverter(stringyConverter); + } + + /** + * Test app. + * + * @throws Exception the exception + */ + @Test + protected void testApp() throws Exception { + mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL)) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.openapi", is("3.0.1"))) + .andExpect(jsonPath("$.components.schemas.Foo.required", is(new ArrayList() {{ + add("stringy"); + }}))) + .andExpect(jsonPath("$.components.schemas.Bar", not(hasProperty("required")))); + } + + /** + * The type Spring boot app. + */ + @SpringBootApplication + static class SpringBootApp {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app157/StringyConverter.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app157/StringyConverter.java new file mode 100644 index 000000000..ac74ead63 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app157/StringyConverter.java @@ -0,0 +1,64 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app157; + +import java.util.Iterator; + +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.oas.models.media.Schema; +import org.springdoc.core.providers.ObjectMapperProvider; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + + +@Component +class StringyConverter implements ModelConverter { + + @Autowired + ObjectMapperProvider objectMapperProvider; + + public StringyConverter(ObjectMapperProvider objectMapperProvider) { + this.objectMapperProvider = objectMapperProvider; + } + + + @Override + public Schema resolve(AnnotatedType type, ModelConverterContext context, + Iterator chain) { + + JavaType javaType = objectMapperProvider.jsonMapper().constructType(type.getType()); + + if (javaType.getRawClass().equals(String.class)) { + type.getParent().addRequiredItem("stringy"); + } + return chain.next().resolve(type, context, chain); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app158/CommonFooErrorHandler.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app158/CommonFooErrorHandler.java new file mode 100644 index 000000000..83e286b46 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app158/CommonFooErrorHandler.java @@ -0,0 +1,49 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app158; + +import org.springframework.http.HttpStatus; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.ResponseStatus; + +/** + * The type Common foo error handler. + */ +class CommonFooErrorHandler { + + /** + * On exception error dto. + * + * @param e the e + * @return the error dto + */ + @ExceptionHandler + @ResponseStatus(HttpStatus.CONFLICT) + public ErrorDTO onException(Exception e) { + return new ErrorDTO("Something wrong has happened"); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app158/ErrorDTO.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app158/ErrorDTO.java new file mode 100644 index 000000000..5b9b24be9 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app158/ErrorDTO.java @@ -0,0 +1,70 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app158; + +/** + * The type Error dto. + */ +class ErrorDTO { + /** + * The Message. + */ + private String message; + + /** + * Instantiates a new Error dto. + */ + public ErrorDTO() { + } + + /** + * Instantiates a new Error dto. + * + * @param message the message + */ + public ErrorDTO(String message) { + this.message = message; + } + + /** + * Gets message. + * + * @return the message + */ + public String getMessage() { + return message; + } + + /** + * Sets message. + * + * @param message the message + */ + public void setMessage(String message) { + this.message = message; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app158/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app158/HelloController.java new file mode 100644 index 000000000..1fe6051dd --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app158/HelloController.java @@ -0,0 +1,54 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app158; + +import io.swagger.v3.oas.annotations.OpenAPIDefinition; +import io.swagger.v3.oas.annotations.info.Info; +import io.swagger.v3.oas.annotations.tags.Tag; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +@RequestMapping("/api") +@OpenAPIDefinition(info = @Info(title = "API Examples", version = "1.0"), tags = @Tag(name = "Operations")) +class HelloController { + + /** + * Hello simple dto. + * + * @return the simple dto + */ + @GetMapping("/foo") + public SimpleDTO hello() { + return new SimpleDTO("foo"); + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app158/SimpleDTO.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app158/SimpleDTO.java new file mode 100644 index 000000000..5180b27a1 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app158/SimpleDTO.java @@ -0,0 +1,72 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app158; + +/** + * The type Simple dto. + */ +class SimpleDTO { + + /** + * The Payload. + */ + private String payload; + + /** + * Instantiates a new Simple dto. + */ + public SimpleDTO() { + } + + /** + * Instantiates a new Simple dto. + * + * @param payload the payload + */ + public SimpleDTO(String payload) { + this.payload = payload; + } + + /** + * Gets payload. + * + * @return the payload + */ + public String getPayload() { + return payload; + } + + /** + * Sets payload. + * + * @param payload the payload + */ + public void setPayload(String payload) { + this.payload = payload; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app158/SpecificFooErrorHandler.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app158/SpecificFooErrorHandler.java new file mode 100644 index 000000000..5ed6c035f --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app158/SpecificFooErrorHandler.java @@ -0,0 +1,36 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app158; + +import org.springframework.web.bind.annotation.ControllerAdvice; + +/** + * The type Specific foo error handler. + */ +@ControllerAdvice(assignableTypes = HelloController.class) +class SpecificFooErrorHandler extends CommonFooErrorHandler { +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app158/SpringDocApp158Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app158/SpringDocApp158Test.java new file mode 100644 index 000000000..26a839caf --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app158/SpringDocApp158Test.java @@ -0,0 +1,44 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app158; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 158 test. + */ +class SpringDocApp158Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app159/CustomException.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app159/CustomException.java new file mode 100644 index 000000000..12398844a --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app159/CustomException.java @@ -0,0 +1,41 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app159; + +/** + * The type Custom exception. + */ +class CustomException extends RuntimeException { + /** + * Instantiates a new Custom exception. + * + * @param message the message + */ + public CustomException(String message) { + super(message); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app159/FooBean.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app159/FooBean.java new file mode 100644 index 000000000..51d744f05 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app159/FooBean.java @@ -0,0 +1,93 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app159; + +import com.fasterxml.jackson.annotation.JsonView; + +/** + * The type Foo bean. + */ +class FooBean { + /** + * The Message. + */ + @JsonView(Views.View2.class) + private String message; + + /** + * The Code. + */ + @JsonView(Views.View1.class) + private int code; + + /** + * Instantiates a new Foo bean. + * + * @param message the message + * @param code the code + */ + public FooBean(String message, int code) { + this.message = message; + this.code = code; + } + + /** + * Gets message. + * + * @return the message + */ + public String getMessage() { + return message; + } + + /** + * Sets message. + * + * @param message the message + */ + public void setMessage(String message) { + this.message = message; + } + + /** + * Gets code. + * + * @return the code + */ + public int getCode() { + return code; + } + + /** + * Sets code. + * + * @param code the code + */ + public void setCode(int code) { + this.code = code; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app159/FooErrorHandler.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app159/FooErrorHandler.java new file mode 100644 index 000000000..a7460696f --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app159/FooErrorHandler.java @@ -0,0 +1,68 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app159; + +import com.fasterxml.jackson.annotation.JsonView; + +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.ControllerAdvice; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.ResponseStatus; + +/** + * The type Foo error handler. + */ +@ControllerAdvice(assignableTypes = HelloController.class) +class FooErrorHandler { + + /** + * Store assignment publishing error response entity. + * + * @param e the e + * @return the response entity + */ + @ExceptionHandler + @ResponseStatus(value = HttpStatus.INTERNAL_SERVER_ERROR) + @JsonView(Views.View1.class) + public ResponseEntity storeAssignmentPublishingError(Exception e) { + return new ResponseEntity<>(new FooBean("INTERNAL_SERVER_ERROR", 500), HttpStatus.INTERNAL_SERVER_ERROR); + } + + /** + * Store assignment publishing error response entity. + * + * @param e the e + * @return the response entity + */ + @ExceptionHandler + @ResponseStatus(value = HttpStatus.BAD_REQUEST) + @JsonView(Views.View2.class) + public ResponseEntity storeAssignmentPublishingError(CustomException e) { + return new ResponseEntity<>(new FooBean("BAD Request", 400), HttpStatus.BAD_REQUEST); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app159/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app159/HelloController.java new file mode 100644 index 000000000..a4845e0be --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app159/HelloController.java @@ -0,0 +1,57 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app159; + +import io.swagger.v3.oas.annotations.OpenAPIDefinition; +import io.swagger.v3.oas.annotations.info.Info; +import io.swagger.v3.oas.annotations.tags.Tag; + +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +@RequestMapping("/api") +@OpenAPIDefinition(info = @Info(title = "API Examples", version = "1.0"), tags = @Tag(name = "Operations")) +class HelloController { + + /** + * Create string. + * + * @param foo the foo + * @return the string + */ + @PostMapping("/foo") + public String create(@RequestBody String foo) { + return "foo"; + } +} + diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app159/SpringDocApp159Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app159/SpringDocApp159Test.java new file mode 100644 index 000000000..ce831d4f5 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app159/SpringDocApp159Test.java @@ -0,0 +1,44 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app159; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 159 test. + */ +class SpringDocApp159Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app159/Views.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app159/Views.java new file mode 100644 index 000000000..758d652a1 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app159/Views.java @@ -0,0 +1,44 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app159; + +/** + * The type Views. + */ +class Views { + /** + * The type View 1. + */ + public static class View1 { + } + + /** + * The type View 2. + */ + public static class View2 extends View1 { + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app16/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app16/HelloController.java new file mode 100644 index 000000000..e717e6bf9 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app16/HelloController.java @@ -0,0 +1,48 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app16; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * Persons string. + * + * @return the string + */ + @GetMapping("/persons") + public String persons() { + return "OK"; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app16/SpringDocApp16Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app16/SpringDocApp16Test.java new file mode 100644 index 000000000..557a3ff56 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app16/SpringDocApp16Test.java @@ -0,0 +1,61 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app16; + +import org.junit.jupiter.api.Test; +import org.springdoc.core.utils.Constants; +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.SpringBootConfiguration; +import org.springframework.test.context.TestPropertySource; + +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + +/** + * The type Spring doc app 16 test. + */ +@TestPropertySource(properties = "springdoc.api-docs.enabled=false") +class SpringDocApp16Test extends AbstractSpringDocTest { + + /** + * Test app. + * + * @throws Exception the exception + */ + @Test + protected void testApp() throws Exception { + mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL)) + .andExpect(status().isNotFound()); + } + + /** + * The type Spring doc test app. + */ + @SpringBootConfiguration + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app160/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app160/HelloController.java new file mode 100644 index 000000000..5a62e821e --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app160/HelloController.java @@ -0,0 +1,111 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app160; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.v3.oas.annotations.media.Schema; +import org.springdoc.core.models.GroupedOpenApi; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.PropertySource; +import org.springframework.context.support.ResourceBundleMessageSource; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * Do something interesting error response. + * + * @return the error response + */ + @PostMapping("test") + public ErrorResponse doSomethingInteresting() { + return null; + } + + /** + * Bundle api grouped open api. + * + * @return the grouped open api + */ + @Bean + public GroupedOpenApi bundleApi() { + return GroupedOpenApi.builder() + .group("test") + .pathsToMatch("/**") + .build(); + } + + /** + * Translator resource bundle message source. + * + * @return the resource bundle message source + */ + @Bean + public ResourceBundleMessageSource translator() { + ResourceBundleMessageSource source = new ResourceBundleMessageSource(); + source.setBasenames("swagger-message-160"); + source.setUseCodeAsDefaultMessage(true); + source.setDefaultEncoding("utf-8"); + return source; + } + + /** + * The type Swagger message. + */ + @PropertySource("classpath:swagger-message-160.properties") + @Configuration + class SwaggerMessage {} + + /** + * The type Error response. + */ + @Schema(description = "${ErrorResponse}") + class ErrorResponse { + + /** + * The Error code. + */ + @Schema(description = "${ErrorCode}", required = true) + @JsonProperty + private Integer errorCode; + + /** + * The Error message. + */ + @Schema(description = "${ErrorMessage}") + @JsonProperty + private String errorMessage; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app160/SpringDocApp160Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app160/SpringDocApp160Test.java new file mode 100644 index 000000000..047f9948a --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app160/SpringDocApp160Test.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.app160; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.test.context.TestPropertySource; + +/** + * The type Spring doc app 160 test. + */ +@TestPropertySource(properties = "springdoc.api-docs.resolve-schema-properties=true") +class SpringDocApp160Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app161/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app161/HelloController.java new file mode 100644 index 000000000..6f71e0ce2 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app161/HelloController.java @@ -0,0 +1,86 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app161; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; + +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + + /** + * Add response entity. + * + * @param content the content + * @return the response entity + * @throws Exception the exception + */ + @Operation(summary = "add") + @PostMapping(value = "/add", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.MULTIPART_FORM_DATA_VALUE) + public ResponseEntity add(@Parameter(description = "content") @RequestPart(value = "content") String content) throws Exception { + return null; + } + + + /** + * Add 2 response entity. + * + * @param content the content + * @param type the type + * @return the response entity + */ + @Operation(summary = "add2") + @PostMapping(value = "/add2", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.MULTIPART_FORM_DATA_VALUE) + public ResponseEntity add2( + @Parameter(description = "content") @RequestPart(value = "content") String content, + @RequestPart(value = "type") String type + ) { + return null; + } + + /** + * Test. + * + * @param strValue the str value + * @param intValue the int value + */ + @PostMapping(produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.MULTIPART_FORM_DATA_VALUE) + @Operation(summary = "test") + public void test(@RequestPart("strValue") String strValue, + @RequestPart("intValue") Integer intValue) { + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app161/SpringDocApp161Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app161/SpringDocApp161Test.java new file mode 100644 index 000000000..79db3addb --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app161/SpringDocApp161Test.java @@ -0,0 +1,44 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app161; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 161 test. + */ +class SpringDocApp161Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app162/SpringDocApp162Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app162/SpringDocApp162Test.java new file mode 100644 index 000000000..6b0548936 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app162/SpringDocApp162Test.java @@ -0,0 +1,64 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app162; + +import io.swagger.v3.oas.models.OpenAPI; +import io.swagger.v3.oas.models.info.Info; +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; +import org.springframework.test.context.TestPropertySource; + +/** + * The type Spring doc app 162 test. + */ +@TestPropertySource(properties = "springdoc.override-with-generic-response=true") +class SpringDocApp162Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp { + /** + * Custom open api open api. + * + * @return the open api + */ + @Bean + public OpenAPI customOpenAPI() { + return new OpenAPI() + .info(new Info() + .title("SpringShop API") + .version("v1") + .description("The description of the api")); + } + + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app162/exception/NoResultException.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app162/exception/NoResultException.java new file mode 100644 index 000000000..00c94c4d5 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app162/exception/NoResultException.java @@ -0,0 +1,30 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app162.exception; + +public class NoResultException extends RuntimeException { +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app162/exception/NonUniqueResultException.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app162/exception/NonUniqueResultException.java new file mode 100644 index 000000000..1a24d02a5 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app162/exception/NonUniqueResultException.java @@ -0,0 +1,33 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app162.exception; + +/** + * Multiple results found instead of a unique result. + */ +public class NonUniqueResultException extends RuntimeException { +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app162/rest/JavadocOnlyRestController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app162/rest/JavadocOnlyRestController.java new file mode 100644 index 000000000..5994516f5 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app162/rest/JavadocOnlyRestController.java @@ -0,0 +1,116 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app162.rest; + +import java.util.List; + +import test.org.springdoc.api.v30.app162.exception.NoResultException; +import test.org.springdoc.api.v30.app162.exception.NonUniqueResultException; +import test.org.springdoc.api.v30.app162.rest.dto.JavadocOnlyRestDto; + +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseStatus; +import org.springframework.web.bind.annotation.RestController; + +/** + * This is the {@code JavadocOnlyRestController} class javadoc. + */ +@RestController +@RequestMapping("/javadoc-only") +class JavadocOnlyRestController { + /** + * This is the create method's javadoc. + * The method's signature: {@code #create(JavadocOnlyRestDto)} + * + * @param input the {@code @param input} javadoc for the {@code #create(JavadocOnlyRestDto)} method + * @return the {@code @return} javadoc for the {@code #create(JavadocOnlyRestDto)} method + */ + @PostMapping(consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) + @ResponseStatus(HttpStatus.CREATED) + public ResponseEntity create(@RequestBody JavadocOnlyRestDto input) { + return new ResponseEntity<>(HttpStatus.CREATED); + } + + /** + * This is the update method's javadoc. + * The method's signature: {@code #update(String, JavadocOnlyRestDto)} + * + * @param guid the {@code @param input} javadoc for the {@code #update(String, JavadocOnlyRestDto)} method + * @return the {@code @return} javadoc for the {@code #update(String, JavadocOnlyRestDto)} method + */ + @PutMapping(path = "{guid}", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) + @ResponseStatus(HttpStatus.OK) + public ResponseEntity update(@PathVariable String guid, @RequestBody JavadocOnlyRestDto input) throws NoResultException { + return new ResponseEntity<>(HttpStatus.CREATED); + } + + /** + * This is the list method's javadoc. + * The method's signature: {@code #list()} + * + * @return the {@code @return} javadoc for the {@code #list()} method + */ + @GetMapping(produces = MediaType.APPLICATION_JSON_VALUE) + public ResponseEntity> list() { + return new ResponseEntity<>(HttpStatus.OK); + } + + /** + * This is the find method's javadoc. + * The method's signature: {@code #find(String)} + * + * @param guid the {@code @param guid} javadoc for the {@code #find(String)} method + * @return the {@code @return} javadoc for the {@code #find(String)} method + * @throws NoResultException the {@code @throws NoResultException} javadoc for the {@code #find(String)} method + */ + @GetMapping(path = "{guid}", produces = MediaType.APPLICATION_JSON_VALUE) + public ResponseEntity find(@PathVariable String guid) throws NoResultException { + return new ResponseEntity<>(HttpStatus.OK); + } + + /** + * This is the findStartsBy method's javadoc. + * The method's signature: {@code #findStartsBy(String)} + * + * @param prefix the {@code @param prefix} javadoc for the {@code #findStartsBy(String)} method + * @return the {@code @return} javadoc for the {@code #findStartsBy(String)} method + * @throws NoResultException the {@code @throws NoResultException} javadoc for the {@code #findStartsBy(String)} method + * @throws NonUniqueResultException the {@code @throws NonUniqueResultException} javadoc for the {@code #findStartsBy(String)} method + */ + @GetMapping(path = "startsBy/{prefix}", produces = MediaType.APPLICATION_JSON_VALUE) + public ResponseEntity findStartsBy(@PathVariable String prefix) throws NoResultException, NonUniqueResultException { + return new ResponseEntity<>(HttpStatus.OK); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app162/rest/dto/JavadocOnlyRestDto.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app162/rest/dto/JavadocOnlyRestDto.java new file mode 100644 index 000000000..c972ca1f5 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app162/rest/dto/JavadocOnlyRestDto.java @@ -0,0 +1,85 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app162.rest.dto; + +/** + * This is the {@code JavadocOnlyRestDto} class javadoc. + */ +public class JavadocOnlyRestDto { + /** + * This is the private {@code #guid} field's javadoc. + */ + private String guid; + + /** + * This is the private {@code #inner} field's javadoc. + * + * This javadoc description is ignored by the REST documentation: + * the {@code $ref} can't have a description as any sibling elements of a $ref are ignored. + */ + private JavadocOnlyStaticInnerRestDto inner; + + public JavadocOnlyRestDto() { + } + + public String getGuid() { + return guid; + } + + public void setGuid(String guid) { + this.guid = guid; + } + + public JavadocOnlyStaticInnerRestDto getInner() { + return inner; + } + + public void setInner(JavadocOnlyStaticInnerRestDto inner) { + this.inner = inner; + } + + /** + * This is the {@code JavadocOnlyStaticInnerRestDto} class javadoc. + */ + public static class JavadocOnlyStaticInnerRestDto { + /** + * This is the private {@code #content} field's javadoc. + */ + private String content; + + public JavadocOnlyStaticInnerRestDto() { + } + + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app162/rest/util/RestExceptionHandler.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app162/rest/util/RestExceptionHandler.java new file mode 100644 index 000000000..bf46ebfe7 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app162/rest/util/RestExceptionHandler.java @@ -0,0 +1,71 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app162.rest.util; + +import test.org.springdoc.api.v30.app162.exception.NoResultException; +import test.org.springdoc.api.v30.app162.exception.NonUniqueResultException; + +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.ResponseStatus; +import org.springframework.web.bind.annotation.RestControllerAdvice; + +/** + * REST exception handlers. + * + * This javadoc description is ignored by the REST documentation. + */ +@RestControllerAdvice +class RestExceptionHandler { + /** + * REST exception handler for {@code NoResultException}. + * + * This javadoc description is ignored by the REST documentation. + * + * @return the {@code return} javadoc for the {@code #handleNotFoundException(NoResultException)} method + */ + @ExceptionHandler(NoResultException.class) + @ResponseStatus(code = HttpStatus.NOT_FOUND) + public ResponseEntity handleNotFoundException(NoResultException exception) { + return new ResponseEntity<>("No result for the arguments.", HttpStatus.NOT_FOUND); + } + + /** + * REST exception handler for {@code NonUniqueResultException}. + * + * This javadoc description is ignored by the REST documentation. + * + * @return the {@code return} javadoc for the {@code #handleNonUniqueResultException(NonUniqueResultException)} method + */ + @ExceptionHandler(NonUniqueResultException.class) + @ResponseStatus(code = HttpStatus.BAD_REQUEST) + public ResponseEntity handleNonUniqueResultException(NonUniqueResultException exception) { + return new ResponseEntity<>("No unique result found for the arguments.", HttpStatus.BAD_REQUEST); + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app163/SpringDocApp163Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app163/SpringDocApp163Test.java new file mode 100644 index 000000000..b2017462d --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app163/SpringDocApp163Test.java @@ -0,0 +1,64 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app163; + +import io.swagger.v3.oas.models.OpenAPI; +import io.swagger.v3.oas.models.info.Info; +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; +import org.springframework.test.context.TestPropertySource; + +/** + * The type Spring doc app 163 test. + */ +@TestPropertySource(properties = "springdoc.override-with-generic-response=true") +class SpringDocApp163Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp { + /** + * Custom open api open api. + * + * @return the open api + */ + @Bean + public OpenAPI customOpenAPI() { + return new OpenAPI() + .info(new Info() + .title("SpringShop API") + .version("v1") + .description("The description of the api")); + } + + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app163/exception/NoResultException.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app163/exception/NoResultException.java new file mode 100644 index 000000000..7e7236dc7 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app163/exception/NoResultException.java @@ -0,0 +1,30 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app163.exception; + +public class NoResultException extends RuntimeException { +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app163/exception/NonUniqueResultException.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app163/exception/NonUniqueResultException.java new file mode 100644 index 000000000..a9c5521ab --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app163/exception/NonUniqueResultException.java @@ -0,0 +1,33 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app163.exception; + +/** + * Multiple results found instead of a unique result. + */ +public class NonUniqueResultException extends RuntimeException { +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app163/rest/AnnotationOverrideForJavadocRestController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app163/rest/AnnotationOverrideForJavadocRestController.java new file mode 100644 index 000000000..e84986430 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app163/rest/AnnotationOverrideForJavadocRestController.java @@ -0,0 +1,131 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app163.rest; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.tags.Tag; +import test.org.springdoc.api.v30.app163.exception.NoResultException; +import test.org.springdoc.api.v30.app163.exception.NonUniqueResultException; +import test.org.springdoc.api.v30.app163.rest.dto.AnnotationOverrideForJavadocRestDto; + +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseStatus; +import org.springframework.web.bind.annotation.RestController; + +/** + * This is the {@code AnnotationOverrideForJavadocRestController} class javadoc. + */ +@Tag( + name = "annotation-override", + description = "Description for the tag." +) +@RestController +@RequestMapping("/annotation-override") +class AnnotationOverrideForJavadocRestController { + /** + * This is the update method's javadoc. + * The method's signature: {@code #update(String, AnnotationOverrideForJavadocRestDto)} + * + * @param guid the {@code @param input} javadoc for the {@code #update(String, AnnotationOverrideForJavadocRestDto)} method + * @return the {@code @return} javadoc for the {@code #update(String, AnnotationOverrideForJavadocRestDto)} method + */ + @Operation( + summary = "Summary for #update(String, AnnotationOverrideForJavadocRestDto)" + ) + @PutMapping(path = "{guid}", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) + @ResponseStatus(HttpStatus.OK) + public ResponseEntity update(@PathVariable String guid, @RequestBody AnnotationOverrideForJavadocRestDto input) throws NoResultException { + return new ResponseEntity<>(HttpStatus.CREATED); + } + + /** + * This is the create method's javadoc. + * The method's signature: {@code #create(AnnotationOverrideForJavadocRestDto)} + * + * @param input the {@code @param input} javadoc for the {@code #create(AnnotationOverrideForJavadocRestDto)} method + * @return the {@code @return} javadoc for the {@code #create(AnnotationOverrideForJavadocRestDto)} method + */ + @Operation( + summary = "Summary for #create(AnnotationOverrideForJavadocRestDto)", + description = "Description for #create(AnnotationOverrideForJavadocRestDto)", + requestBody = @io.swagger.v3.oas.annotations.parameters.RequestBody( + description = "Request body for #create(AnnotationOverrideForJavadocRestDto)" + ), + responses = { + @ApiResponse( + description = "API Response 201 for #create(AnnotationOverrideForJavadocRestDto)" + ) + } + ) + @PostMapping(consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) + @ResponseStatus(HttpStatus.CREATED) + public ResponseEntity create(@RequestBody AnnotationOverrideForJavadocRestDto input) { + return new ResponseEntity<>(HttpStatus.CREATED); + } + + /** + * This is the findStartsBy method's javadoc. + * The method's signature: {@code #findStartsBy(String)} + * + * @param prefix the {@code @param prefix} javadoc for the {@code #findStartsBy(String)} method + * @return the {@code @return} javadoc for the {@code #findStartsBy(String)} method + * @throws NoResultException the {@code @throws NoResultException} javadoc for the {@code #findStartsBy(String)} method + * @throws NonUniqueResultException the {@code @throws NonUniqueResultException} javadoc for the {@code #findStartsBy(String)} method + */ + @Operation( + parameters = { + @Parameter( + name = "prefix", + description = "Parameter prefix" + ) + }, + responses = { + @ApiResponse( + responseCode = "200", + description = "API Response 200 for #findStartsBy(prefix)" + ), + @ApiResponse( + responseCode = "400", + description = "API Response 400 for #findStartsBy(prefix)" + ) + } + ) + @GetMapping(path = "startsBy/{prefix}", produces = MediaType.APPLICATION_JSON_VALUE) + public ResponseEntity findStartsBy(@PathVariable String prefix) throws NoResultException, NonUniqueResultException { + return new ResponseEntity<>(HttpStatus.OK); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app163/rest/dto/AnnotationOverrideForJavadocRestDto.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app163/rest/dto/AnnotationOverrideForJavadocRestDto.java new file mode 100644 index 000000000..13ca7ae39 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app163/rest/dto/AnnotationOverrideForJavadocRestDto.java @@ -0,0 +1,86 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app163.rest.dto; + +import io.swagger.v3.oas.annotations.media.Schema; + +/** + * This is the {@code AnnotationOverrideForJavadocRestDto} class javadoc. + */ +@Schema( + title = "annotation-override-dto", + description = "Description for the tag." +) +public class AnnotationOverrideForJavadocRestDto { + /** + * This is the private {@code #guid} field's javadoc. + */ + @Schema(description = "Description for the #guid field") + private String guid; + + /** + * This is the private {@code #inner} field's javadoc. + *

+ * This javadoc description is ignored by the REST documentation: + * the {@code $ref} can't have a description as any sibling elements of a $ref are ignored. + */ + private AnnotationOverrideForJavadocStaticInnerRestDto inner; + + public String getGuid() { + return guid; + } + + public void setGuid(String guid) { + this.guid = guid; + } + + public AnnotationOverrideForJavadocStaticInnerRestDto getInner() { + return inner; + } + + public void setInner(AnnotationOverrideForJavadocStaticInnerRestDto inner) { + this.inner = inner; + } + + /** + * This is the {@code AnnotationOverrideForJavadocStaticInnerRestDto} class javadoc. + */ + public static class AnnotationOverrideForJavadocStaticInnerRestDto { + /** + * This is the private {@code #content} field's javadoc. + */ + private String content; + + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app163/rest/dto/AnnotationOverrideForJavadocRestDto2.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app163/rest/dto/AnnotationOverrideForJavadocRestDto2.java new file mode 100644 index 000000000..886d36aa5 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app163/rest/dto/AnnotationOverrideForJavadocRestDto2.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.app163.rest.dto; + +/** + * This is the {@code AnnotationOverrideForJavadocRestDto2} class javadoc. + */ +class AnnotationOverrideForJavadocRestDto2 { + /** + * This is the private {@code #guid3} field's javadoc. + */ + private String guid3; + + public String getGuid3() { + return guid3; + } + + public void setGuid3(String guid3) { + this.guid3 = guid3; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app163/rest/dto/AnnotationOverrideForJavadocRestDto3.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app163/rest/dto/AnnotationOverrideForJavadocRestDto3.java new file mode 100644 index 000000000..ff558a2e1 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app163/rest/dto/AnnotationOverrideForJavadocRestDto3.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.app163.rest.dto; + +/** + * This is the {@code AnnotationOverrideForJavadocRestDto3} class javadoc. + */ +class AnnotationOverrideForJavadocRestDto3 { + /** + * This is the private {@code #guid4} field's javadoc. + */ + private String guid4; + + public String getGuid4() { + return guid4; + } + + public void setGuid4(String guid4) { + this.guid4 = guid4; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app163/rest/util/RestExceptionHandler.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app163/rest/util/RestExceptionHandler.java new file mode 100644 index 000000000..b17fef094 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app163/rest/util/RestExceptionHandler.java @@ -0,0 +1,71 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app163.rest.util; + +import test.org.springdoc.api.v30.app163.exception.NoResultException; +import test.org.springdoc.api.v30.app163.exception.NonUniqueResultException; + +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.ResponseStatus; +import org.springframework.web.bind.annotation.RestControllerAdvice; + +/** + * REST exception handlers. + * + * This javadoc description is ignored by the REST documentation. + */ +@RestControllerAdvice +class RestExceptionHandler { + /** + * REST exception handler for {@code NoResultException}. + * + * This javadoc description is ignored by the REST documentation. + * + * @return the {@code return} javadoc for the {@code #handleNotFoundException(NoResultException)} method + */ + @ExceptionHandler(NoResultException.class) + @ResponseStatus(code = HttpStatus.NOT_FOUND) + public ResponseEntity handleNotFoundException(NoResultException exception) { + return new ResponseEntity<>("No result for the arguments.", HttpStatus.NOT_FOUND); + } + + /** + * REST exception handler for {@code NonUniqueResultException}. + * + * This javadoc description is ignored by the REST documentation. + * + * @return the {@code return} javadoc for the {@code #handleNonUniqueResultException(NonUniqueResultException)} method + */ + @ExceptionHandler(NonUniqueResultException.class) + @ResponseStatus(code = HttpStatus.BAD_REQUEST) + public ResponseEntity handleNonUniqueResultException(NonUniqueResultException exception) { + return new ResponseEntity<>("No unique result found for the arguments.", HttpStatus.BAD_REQUEST); + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app164/SpringDocApp164Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app164/SpringDocApp164Test.java new file mode 100644 index 000000000..dc9f9122e --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app164/SpringDocApp164Test.java @@ -0,0 +1,62 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app164; + +import io.swagger.v3.oas.models.OpenAPI; +import io.swagger.v3.oas.models.info.Info; +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; + +/** + * The type Spring doc app 164 test. + */ +class SpringDocApp164Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp { + /** + * Custom open api open api. + * + * @return the open api + */ + @Bean + public OpenAPI customOpenAPI() { + return new OpenAPI() + .info(new Info() + .title("SpringShop API") + .version("v1") + .description("The description of the api")); + } + + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app164/SpringDocJavadocProviderTest.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app164/SpringDocJavadocProviderTest.java new file mode 100644 index 000000000..316d07972 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app164/SpringDocJavadocProviderTest.java @@ -0,0 +1,87 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app164; + +import java.util.stream.Stream; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; +import org.springdoc.core.providers.JavadocProvider; +import org.springdoc.core.providers.SpringDocJavadocProvider; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.params.provider.Arguments.arguments; + +class SpringDocJavadocProviderTest { + private JavadocProvider javadocProvider; + + static Stream getFirstSentence() { + return Stream.of( + arguments(null, null), + arguments("", ""), + arguments("A b c. D e f", "A b c."), + arguments("A b c", "A b c"), + arguments("A b c

D e f", "A b c"), + arguments("A b c. D

e f", "A b c"), + arguments("A b c

D. e f", "A b c"), + arguments("

A b c

D e f", "A b c"), + arguments("

A b c. D

e f", "A b c"), + arguments("A b c.d e f", "A b c.d e f") + ); + } + + /** + * Edge cases not handled by the implementation. + */ + static Stream getFirstSentenceNotHandled() { + return Stream.of( + arguments("

A b c

d e f

", "A b c") + ); + } + + @BeforeEach + public void setup() { + javadocProvider = new SpringDocJavadocProvider(); + } + + @ParameterizedTest + @MethodSource + public void getFirstSentence(String javadoc, String expectedFirstSentence) { + assertThat(javadocProvider.getFirstSentence(javadoc)) + .isEqualTo(expectedFirstSentence); + } + + @ParameterizedTest + @MethodSource + public void getFirstSentenceNotHandled(String javadoc, String correctFirstSentence) { + assertThat(javadocProvider.getFirstSentence(javadoc)) + .isNotEqualTo(correctFirstSentence); + } + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app164/exception/NoResultException.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app164/exception/NoResultException.java new file mode 100644 index 000000000..cf9169219 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app164/exception/NoResultException.java @@ -0,0 +1,30 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app164.exception; + +public class NoResultException extends RuntimeException { +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app164/exception/NonUniqueResultException.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app164/exception/NonUniqueResultException.java new file mode 100644 index 000000000..b5ab92305 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app164/exception/NonUniqueResultException.java @@ -0,0 +1,33 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app164.exception; + +/** + * Multiple results found instead of a unique result. + */ +public class NonUniqueResultException extends RuntimeException { +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app164/rest/NoGenericOverrideRestController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app164/rest/NoGenericOverrideRestController.java new file mode 100644 index 000000000..61aae0169 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app164/rest/NoGenericOverrideRestController.java @@ -0,0 +1,75 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app164.rest; + +import test.org.springdoc.api.v30.app164.exception.NoResultException; +import test.org.springdoc.api.v30.app164.exception.NonUniqueResultException; + +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseStatus; +import org.springframework.web.bind.annotation.RestController; + +/** + * This is the {@code JavadocOnlyRestController} class javadoc. + */ +@RestController +@RequestMapping("/no-generic-override") +class NoGenericOverrideRestController { + /** + * This is the create method's javadoc. + * The method's signature: {@code #create(JavadocOnlyRestDto)} + * + * @param input the {@code @param input} javadoc for the {@code #create(JavadocOnlyRestDto)} method + * @return the {@code @return} javadoc for the {@code #create(JavadocOnlyRestDto)} method + */ + @PostMapping(consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) + @ResponseStatus(HttpStatus.CREATED) + public ResponseEntity create(@RequestBody String input) { + return new ResponseEntity<>(HttpStatus.CREATED); + } + + /** + * This is the findStartsBy method's javadoc. + * The method's signature: {@code #findStartsBy(String)} + * + * @param prefix the {@code @param prefix} javadoc for the {@code #findStartsBy(String)} method + * @return the {@code @return} javadoc for the {@code #findStartsBy(String)} method + * @throws NoResultException the {@code @throws NoResultException} javadoc for the {@code #findStartsBy(String)} method + * @throws NonUniqueResultException the {@code @throws NonUniqueResultException} javadoc for the {@code #findStartsBy(String)} method + */ + @GetMapping(path = "startsBy/{prefix}", produces = MediaType.APPLICATION_JSON_VALUE) + public ResponseEntity findStartsBy(@PathVariable String prefix) throws NoResultException, NonUniqueResultException { + return new ResponseEntity<>(HttpStatus.OK); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app164/rest/util/RestExceptionHandler.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app164/rest/util/RestExceptionHandler.java new file mode 100644 index 000000000..0d53703df --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app164/rest/util/RestExceptionHandler.java @@ -0,0 +1,71 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app164.rest.util; + +import test.org.springdoc.api.v30.app164.exception.NoResultException; +import test.org.springdoc.api.v30.app164.exception.NonUniqueResultException; + +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.ResponseStatus; +import org.springframework.web.bind.annotation.RestControllerAdvice; + +/** + * REST exception handlers. + * + * This javadoc description is ignored by the REST documentation. + */ +@RestControllerAdvice +class RestExceptionHandler { + /** + * REST exception handler for {@code NoResultException}. + * + * This javadoc description is ignored by the REST documentation. + * + * @return the {@code return} javadoc for the {@code #handleNotFoundException(NoResultException)} method + */ + @ExceptionHandler(NoResultException.class) + @ResponseStatus(code = HttpStatus.NOT_FOUND) + public ResponseEntity handleNotFoundException(NoResultException exception) { + return new ResponseEntity<>("No result for the arguments.", HttpStatus.NOT_FOUND); + } + + /** + * REST exception handler for {@code NonUniqueResultException}. + * + * This javadoc description is ignored by the REST documentation. + * + * @return the {@code return} javadoc for the {@code #handleNonUniqueResultException(NonUniqueResultException)} method + */ + @ExceptionHandler(NonUniqueResultException.class) + @ResponseStatus(code = HttpStatus.BAD_REQUEST) + public ResponseEntity handleNonUniqueResultException(NonUniqueResultException exception) { + return new ResponseEntity<>("No unique result found for the arguments.", HttpStatus.BAD_REQUEST); + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app166/ConcreteSubclassFromGeneric.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app166/ConcreteSubclassFromGeneric.java new file mode 100644 index 000000000..98ac4ad72 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app166/ConcreteSubclassFromGeneric.java @@ -0,0 +1,39 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app166; + +class ConcreteSubclassFromGeneric extends SimpleGeneric { + + /** + * Return the top name + */ + private String topName; + + public String getTopName() { + return topName; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app166/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app166/HelloController.java new file mode 100644 index 000000000..837ce9ce2 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app166/HelloController.java @@ -0,0 +1,53 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app166; + + +import org.springdoc.core.annotations.ParameterObject; + +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +class HelloController { + @GetMapping("/nested") + public ResponseEntity nested(@ParameterObject final SimpleOuterClass filter) { + return new ResponseEntity<>("{\"Say\": \"Hello\"}", HttpStatus.OK); + } + + @GetMapping("/nestedTypeErasureGeneric") + public ResponseEntity nestedTypeErasureGeneric(@ParameterObject final SimpleGeneric filter) { + return new ResponseEntity<>("{\"Say\": \"Hello\"}", HttpStatus.OK); + } + + @GetMapping("/nestedReifiableGeneric") + public ResponseEntity nestedReifiableGeneric(@ParameterObject final ConcreteSubclassFromGeneric filter) { + return new ResponseEntity<>("{\"Say\": \"Hello\"}", HttpStatus.OK); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app166/MyData.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app166/MyData.java new file mode 100644 index 000000000..9479fabec --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app166/MyData.java @@ -0,0 +1,48 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app166; + +class MyData { + + /** + * Returns the first name + */ + private String firstName; + + /** + * Returns the max number + */ + private Integer maxNumber; + + public Integer getMaxNumber() { + return maxNumber; + } + + public String getFirstName() { + return firstName; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app166/SimpleGeneric.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app166/SimpleGeneric.java new file mode 100644 index 000000000..7fe3657f8 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app166/SimpleGeneric.java @@ -0,0 +1,48 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app166; + +class SimpleGeneric { + + /** + * Returns name + */ + private String name; + + /** + * Returns the generic child + */ + private T child; + + public T getChild() { + return child; + } + + public String getName() { + return name; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app166/SimpleInnerClass.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app166/SimpleInnerClass.java new file mode 100644 index 000000000..bb4674085 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app166/SimpleInnerClass.java @@ -0,0 +1,57 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app166; + +class SimpleInnerClass { + + /** + * Returns the inner inner class + */ + private SimpleInnerInnerClass innerInnerClass; + + /** + * Returns the boolean name + */ + private Boolean name; + + /** + * Returns the max number + */ + private Integer maxNumber; + + public Integer getMaxNumber() { + return maxNumber; + } + + public Boolean getName() { + return name; + } + + public SimpleInnerInnerClass getInnerInnerClass() { + return innerInnerClass; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app166/SimpleInnerInnerClass.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app166/SimpleInnerInnerClass.java new file mode 100644 index 000000000..9f9d922a6 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app166/SimpleInnerInnerClass.java @@ -0,0 +1,47 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app166; + +class SimpleInnerInnerClass { + /** + * Returns the name of the inner inner class + */ + Boolean name; + + /** + * Returns the maxNumber of the inner inner class + */ + private Integer maxNumber; + + public Integer getMaxNumber() { + return maxNumber; + } + + public Boolean getName() { + return name; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app166/SimpleOuterClass.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app166/SimpleOuterClass.java new file mode 100644 index 000000000..cbe7fa343 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app166/SimpleOuterClass.java @@ -0,0 +1,48 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app166; + +class SimpleOuterClass { + + /** + * Returns the name of the outer class + */ + private String name; + + /** + * Returns the inner class + */ + private SimpleInnerClass innerClass; + + public String getName() { + return name; + } + + public SimpleInnerClass getInnerClass() { + return innerClass; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app166/SpringDocApp166Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app166/SpringDocApp166Test.java new file mode 100644 index 000000000..90bf83540 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app166/SpringDocApp166Test.java @@ -0,0 +1,44 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app166; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 165 test. + */ +class SpringDocApp166Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp { + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app167/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app167/HelloController.java new file mode 100644 index 000000000..d913705b5 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app167/HelloController.java @@ -0,0 +1,42 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app167; + +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController("/api") +class HelloController { + + @RequestMapping("/process") + public void process() { + + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app167/SpringDocApp167Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app167/SpringDocApp167Test.java new file mode 100644 index 000000000..b99885767 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app167/SpringDocApp167Test.java @@ -0,0 +1,44 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app167; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 167 test. + */ +class SpringDocApp167Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp { + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app168/DescriptionFieldInRequestBodyIsNullController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app168/DescriptionFieldInRequestBodyIsNullController.java new file mode 100644 index 000000000..60d917abb --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app168/DescriptionFieldInRequestBodyIsNullController.java @@ -0,0 +1,53 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app168; + +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; + +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * If the RequestBody description field is null, get the description from the javadoc. + */ +@RestController +@RequestMapping("description-in-requestbody-is-null") +class DescriptionFieldInRequestBodyIsNullController { + + /** + * Person person. + * + * @param person the person + */ + @PostMapping + public void person( + @io.swagger.v3.oas.annotations.parameters.RequestBody(content = @Content(schema = @Schema(implementation = Person.class))) @RequestBody Person person) { + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app168/Person.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app168/Person.java new file mode 100644 index 000000000..7369d2897 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app168/Person.java @@ -0,0 +1,55 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app168; + +/** + * The type Person. + */ +class Person { + /** + * The Id. + */ + private long id; + + /** + * Gets id. + * + * @return the id + */ + public long getId() { + return id; + } + + /** + * Sets id. + * + * @param id the id + */ + public void setId(long id) { + this.id = id; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app168/SpringDocApp168Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app168/SpringDocApp168Test.java new file mode 100644 index 000000000..bd7ccd819 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app168/SpringDocApp168Test.java @@ -0,0 +1,44 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app168; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 168 test. + */ +class SpringDocApp168Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp { + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app169/RecordController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app169/RecordController.java new file mode 100644 index 000000000..e4c9fd29a --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app169/RecordController.java @@ -0,0 +1,42 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app169; + +import org.springdoc.core.annotations.ParameterObject; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequestMapping("record") +class RecordController { + @GetMapping + public SimpleOuterClass index(@ParameterObject SimpleOuterClass filter) { + return null; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app169/SimpleInnerClass.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app169/SimpleInnerClass.java new file mode 100644 index 000000000..8fc3f0217 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app169/SimpleInnerClass.java @@ -0,0 +1,36 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app169; + +/** + * simple inner class + * + * @param name the boolean name + * @param maxNumber the max number + */ +public record SimpleInnerClass(Boolean name, Integer maxNumber) { +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app169/SimpleOuterClass.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app169/SimpleOuterClass.java new file mode 100644 index 000000000..f1364bf77 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app169/SimpleOuterClass.java @@ -0,0 +1,36 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app169; + +/** + * simple outer class + * + * @param name the name of the outer class + * @param simpleInnerClass the inner class + */ +public record SimpleOuterClass(String name, SimpleInnerClass simpleInnerClass) { +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app169/SpringDocApp169Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app169/SpringDocApp169Test.java new file mode 100644 index 000000000..c80a28009 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app169/SpringDocApp169Test.java @@ -0,0 +1,44 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app169; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 169 test. + */ +class SpringDocApp169Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp { + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app17/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app17/HelloController.java new file mode 100644 index 000000000..471be5f5a --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app17/HelloController.java @@ -0,0 +1,52 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app17; + +import jakarta.validation.Valid; +import jakarta.validation.constraints.Size; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * Persons. + * + * @param name the name + */ + @GetMapping(value = "/persons") + public void persons(@Valid @RequestParam @Size(min = 4, max = 6) String name) { + + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app17/SpringDocApp17Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app17/SpringDocApp17Test.java new file mode 100644 index 000000000..7bff2dd29 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app17/SpringDocApp17Test.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app17; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 17 test. + */ +class SpringDocApp17Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app170/Animal.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app170/Animal.java new file mode 100644 index 000000000..b94bf7500 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app170/Animal.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app170; + + +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import io.swagger.v3.oas.annotations.media.Schema; + +/** + * Interface of the Animal. + */ +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.WRAPPER_OBJECT) +@JsonSubTypes({ + @JsonSubTypes.Type(value = Dog.class, name = "dog"), + @JsonSubTypes.Type(value = Cat.class, name = "cat"), +}) +@Schema(description = "Represents an Animal class.") +public interface Animal {} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app170/BasicController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app170/BasicController.java new file mode 100644 index 000000000..260faed8c --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app170/BasicController.java @@ -0,0 +1,45 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app170; + +import io.swagger.v3.oas.annotations.Operation; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequestMapping(path = "/") +class BasicController { + + @GetMapping("/test1") + @Operation(summary = "get1", description = "Provides an animal.") + public Animal get1() { + + return new Dog("Foo", 12); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app170/Cat.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app170/Cat.java new file mode 100644 index 000000000..4a116dab6 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app170/Cat.java @@ -0,0 +1,48 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app170; + + +import io.swagger.v3.oas.annotations.media.Schema; + +@Schema +class Cat implements Animal { + + private Integer speed; + + public Cat(Integer speed) { + this.speed = speed; + } + + public Integer getSpeed() { + return speed; + } + + public void setSpeed(Integer speed) { + this.speed = speed; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app170/Dog.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app170/Dog.java new file mode 100644 index 000000000..892480ceb --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app170/Dog.java @@ -0,0 +1,59 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app170; + + +import io.swagger.v3.oas.annotations.media.Schema; + +@Schema(description = "Represents a Dog class.") +class Dog implements Animal { + + private String name; + + private Integer age; + + public Dog(String name, Integer age) { + this.name = name; + this.age = age; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Integer getAge() { + return age; + } + + public void setAge(Integer age) { + this.age = age; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app170/SpringDocApp170Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app170/SpringDocApp170Test.java new file mode 100644 index 000000000..17faafdc3 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app170/SpringDocApp170Test.java @@ -0,0 +1,45 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app170; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 193 test. + */ +class SpringDocApp170Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp { + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app171/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app171/HelloController.java new file mode 100644 index 000000000..5eeef9437 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app171/HelloController.java @@ -0,0 +1,48 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app171; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * PersonProjection interface. + * + * @return the PersonProjection + */ + @GetMapping(value = "/persons") + public PersonProjection persons() { + return new PersonDTO(); + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app171/PersonDTO.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app171/PersonDTO.java new file mode 100644 index 000000000..8ebe74abf --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app171/PersonDTO.java @@ -0,0 +1,81 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app171; + +/** + * Simulate a dynamically generated class that implements the PersonProjection interface. + */ +class PersonDTO implements PersonProjection { + private String email; + + private String firstName; + + private String lastName; + + /** + * Instantiates a new Person dto. + */ + public PersonDTO() { + } + + /** + * Instantiates a new Person dto. + * + * @param email the email + * @param firstName the first name + * @param lastName the last name + */ + public PersonDTO(final String email, final String firstName, final String lastName) { + this.email = email; + this.firstName = firstName; + this.lastName = lastName; + } + + public String getEmail() { + return email; + } + + public void setEmail(final String email) { + this.email = email; + } + + public String getFirstName() { + return firstName; + } + + public void setFirstName(final String firstName) { + this.firstName = firstName; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(final String lastName) { + this.lastName = lastName; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app171/PersonProjection.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app171/PersonProjection.java new file mode 100644 index 000000000..ea663dbe5 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app171/PersonProjection.java @@ -0,0 +1,50 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app171; + +/** + * The type PersonProjection dto interface. + */ +public interface PersonProjection { + /** + * The Email. + * + */ + String getEmail(); + + /** + * The First name. + * + */ + String getFirstName(); + + /** + * The Last name. + * + */ + String getLastName(); +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app171/SpringDocApp171Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app171/SpringDocApp171Test.java new file mode 100644 index 000000000..691922268 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app171/SpringDocApp171Test.java @@ -0,0 +1,45 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app171; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 193 test. + */ +class SpringDocApp171Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp { + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app172/JavadocPropertyCustomizerTest.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app172/JavadocPropertyCustomizerTest.java new file mode 100644 index 000000000..03dbafc78 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app172/JavadocPropertyCustomizerTest.java @@ -0,0 +1,144 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app172; + +import java.beans.IntrospectionException; +import java.beans.Introspector; +import java.beans.PropertyDescriptor; +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.io.PrintWriter; +import java.lang.reflect.Field; +import java.net.URL; +import java.net.URLClassLoader; +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +import javax.tools.JavaCompiler; +import javax.tools.ToolProvider; + +import io.swagger.v3.oas.models.media.ObjectSchema; +import io.swagger.v3.oas.models.media.Schema; +import io.swagger.v3.oas.models.media.StringSchema; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.condition.EnabledForJreRange; +import org.junit.jupiter.api.condition.JRE; +import org.junit.jupiter.api.io.TempDir; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import org.springdoc.core.customizers.JavadocPropertyCustomizer; +import org.springdoc.core.providers.JavadocProvider; +import org.springdoc.core.providers.ObjectMapperProvider; +import org.springdoc.core.providers.SpringDocJavadocProvider; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +/** + * Tests for {@link JavadocPropertyCustomizer}. + */ +class JavadocPropertyCustomizerTest { + @TempDir + private File tempDir; + + private JavadocProvider javadocProvider; + + @Mock + private ObjectMapperProvider objectMapperProvider; + + private JavadocPropertyCustomizer javadocPropertyCustomizer; + + @BeforeEach + void setup() { + MockitoAnnotations.openMocks(this); + this.javadocProvider = new SpringDocJavadocProvider(); + this.javadocPropertyCustomizer = new JavadocPropertyCustomizer(javadocProvider, objectMapperProvider); + } + + + /** + * Tests for {@link JavadocPropertyCustomizer#setJavadocDescription(Class, List, List, Schema)}. + */ + @Nested + class setJavadocDescription { + @Test + @EnabledForJreRange(min = JRE.JAVA_17) + void ifRecordObjectShouldGetField() throws IOException, ClassNotFoundException, IntrospectionException { + File recordObject = new File(tempDir, "RecordObject.java"); + try (PrintWriter writer = new PrintWriter(new FileWriter(recordObject))) { + writer.println("/**"); + writer.println(" * Record Object"); + writer.println(" *"); + writer.println(" * @param id the id"); + writer.println(" * @param name the name"); + writer.println(" */"); + writer.println("public record RecordObject(String id, String name){"); + writer.println("}"); + } + File recordObjectJavadocJson = new File(tempDir, "RecordObject__Javadoc.json"); + try (PrintWriter writer = new PrintWriter(new FileWriter(recordObjectJavadocJson))) { + writer.print("{"); + writer.print("\"doc\":\"Record Object\\n\\n @param id the id\\n @param name the name\","); + writer.print("\"fields\":[],"); + writer.print("\"methods\":[],"); + writer.print("\"constructors\":[]"); + writer.println("}"); + } + + String[] args = { + recordObject.getAbsolutePath() + }; + JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); + int r = compiler.run(null, null, null, args); + if (r != 0) { + throw new IllegalStateException("Compilation failed"); + } + URL[] urls = { tempDir.toURI().toURL() }; + ClassLoader loader = URLClassLoader.newInstance(urls); + + Class cls = loader.loadClass("RecordObject"); + + List fields = Arrays.asList(cls.getFields()); + + Schema existingSchema = new ObjectSchema().name("RecordObject") + .addProperty("id", new StringSchema().name("id")) + .addProperty("name", new StringSchema().name("name")); + + List propertyDescriptors = Arrays.asList(Introspector.getBeanInfo(cls).getPropertyDescriptors()); + javadocPropertyCustomizer.setJavadocDescription(cls, fields, propertyDescriptors, existingSchema,false); + + assertEquals("Record Object", existingSchema.getDescription()); + Map properties = existingSchema.getProperties(); + assertEquals(2, properties.size()); + assertEquals("the id", properties.get("id").getDescription()); + assertEquals("the name", properties.get("name").getDescription()); + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app173/Example.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app173/Example.java new file mode 100644 index 000000000..46d6b944c --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app173/Example.java @@ -0,0 +1,47 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app173; + +import io.swagger.v3.oas.annotations.media.Schema; + +/** + * The Example object + */ +@Schema +class Example { + + private String name; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app173/ExampleController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app173/ExampleController.java new file mode 100644 index 000000000..b6950a013 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app173/ExampleController.java @@ -0,0 +1,65 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app173; + +import java.util.UUID; + +import io.swagger.v3.oas.annotations.Operation; + +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.PatchMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RestController; + +import static org.springframework.http.HttpStatus.OK; + +/** + * The Example Controller + */ +@RestController +class ExampleController { + + @PostMapping("/example") + @Operation(summary = "insert example", description = "Allows to insert an example") + public ResponseEntity postExample(@io.swagger.v3.oas.annotations.parameters.RequestBody(description = "${example.description}") @RequestBody Example example) { + return new ResponseEntity<>(UUID.randomUUID(), OK); + } + + @PutMapping("/example") + @Operation(summary = "update example", description = "Allows to update an example") + public ResponseEntity putExample(@io.swagger.v3.oas.annotations.parameters.RequestBody(description = "${example2.description:Default description for example}") @RequestBody Example example) { + return new ResponseEntity<>(UUID.randomUUID(), OK); + } + + @PatchMapping("/example") + @Operation(summary = "patch example", description = "Allows to patch an example") + public ResponseEntity patchExample(@io.swagger.v3.oas.annotations.parameters.RequestBody(description = "Description without the use of variables") @RequestBody Example example) { + return new ResponseEntity<>(UUID.randomUUID(), OK); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app173/SpringDocApp173Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app173/SpringDocApp173Test.java new file mode 100644 index 000000000..4fa2ec170 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app173/SpringDocApp173Test.java @@ -0,0 +1,47 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app173; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.test.context.TestPropertySource; + +/** + * The type Spring doc app 173 test. + */ +@TestPropertySource(properties = "example.description=The example object") +class SpringDocApp173Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp { + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app174/ExampleController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app174/ExampleController.java new file mode 100644 index 000000000..f437ca0d0 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app174/ExampleController.java @@ -0,0 +1,50 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app174; + +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The Example Controller + */ +@RestController +class ExampleController { + + @PostMapping + public Test post(){ + return null; + } + +} + + + + + + + diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app174/Question.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app174/Question.java new file mode 100644 index 000000000..3b63c1ea8 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app174/Question.java @@ -0,0 +1,68 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app174; + +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; + +/** + * The type Question. + * + * @author bnasslahsen base class for all questions in test with polymorphism + */ +@JsonTypeInfo( + use = JsonTypeInfo.Id.NAME, + property = "type") +@JsonSubTypes({ + @JsonSubTypes.Type(value = TestQuestion.class, name = "test"), + @JsonSubTypes.Type(value = TextQuestion.class, name = "text") +}) +public abstract class Question { + private final String question; + private final String type; + + public Question(String question, String type) { + this.question = question; + this.type = type; + } + + public String getQuestion() { + return question; + } + + public String getType() { + return type; + } + + @Override + public String toString() { + return "Question{" + + "question='" + question + '\'' + + ", type='" + type + '\'' + + '}'; + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app174/SpringDocApp174Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app174/SpringDocApp174Test.java new file mode 100644 index 000000000..84246cce2 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app174/SpringDocApp174Test.java @@ -0,0 +1,45 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app174; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 174 test. + */ +class SpringDocApp174Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp { + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app174/Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app174/Test.java new file mode 100644 index 000000000..85cda2fd0 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app174/Test.java @@ -0,0 +1,70 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app174; + +import java.io.Serializable; +import java.util.List; + +/** + * The type Test. + * + * @author bnasslahsen + */ + +class Test implements Serializable { + + private static final long serialVersionUID = 1L; // Recommended for Serializable classes + + private List questions; + + // No-argument constructor + public Test() { + } + + // Constructor with arguments + public Test(List questions) { + this.questions = questions; + } + + // Getter method for 'questions' + public List getQuestions() { + return questions; + } + + // Setter method for 'questions' + public void setQuestions(List questions) { + this.questions = questions; + } + + // Optionally, you can override toString, hashCode, equals, etc. + @Override + public String toString() { + return "Test{" + + "questions=" + questions + + '}'; + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app174/TestQuestion.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app174/TestQuestion.java new file mode 100644 index 000000000..21073cc9c --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app174/TestQuestion.java @@ -0,0 +1,68 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app174; + +import java.util.List; + +/** + * The type Test question. + * + * @author bnasslahsen test question + */ +class TestQuestion extends Question { + /** + * list of variants + */ + private final List variants; + /** + * correct answer + */ + private final int answer; + + public TestQuestion(String question, String type, List variants, int answer) { + super(question, type); + this.variants = variants; + this.answer = answer; + } + + public List getVariants() { + return variants; + } + + public int getAnswer() { + return answer; + } + + @Override + public String toString() { + return "TestQuestion{" + + "question='" + getQuestion() + '\'' + + ", variants=" + variants + + ", answer=" + answer + + '}'; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app174/TextQuestion.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app174/TextQuestion.java new file mode 100644 index 000000000..2a537732b --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app174/TextQuestion.java @@ -0,0 +1,54 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app174; + +/** + * The type Text question. + * + * @author bnasslahsen + */ +class TextQuestion extends Question { + private final String answer; + + public TextQuestion(String question, String type, String answer) { + super(question, type); + this.answer = answer; + } + + public String getAnswer() { + return answer; + } + + @Override + public String toString() { + return "TextQuestion{" + + "question='" + getQuestion() + '\'' + + ", type='" + getType() + '\'' + + ", answer='" + answer + '\'' + + '}'; + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app18/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app18/HelloController.java new file mode 100644 index 000000000..8a567878e --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app18/HelloController.java @@ -0,0 +1,111 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app18; + +import io.swagger.v3.oas.annotations.Parameter; +import jakarta.validation.constraints.NegativeOrZero; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotEmpty; +import jakarta.validation.constraints.PositiveOrZero; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * Persons string. + * + * @param name the name + * @return the string + */ + @GetMapping(value = "/persons") + public String persons(@NotBlank String name) { + return "OK"; + } + + /** + * Persons 2 string. + * + * @param name the name + * @return the string + */ + @GetMapping(value = "/persons2") + public String persons2(@NotBlank @Parameter(description = "persons name") String name) { + return "OK"; + } + + /** + * Persons 3 string. + * + * @param name the name + * @return the string + */ + @GetMapping(value = "/persons3") + public String persons3(@NotBlank @Parameter(description = "persons name") @RequestParam String name) { + return "OK"; + } + + /** + * Persons 4 string. + * + * @param age the age + * @return the string + */ + @GetMapping(value = "/persons4") + public String persons4(@PositiveOrZero int age) { + return "OK"; + } + + /** + * Persons 5 string. + * + * @param age the age + * @return the string + */ + @GetMapping(value = "/persons5") + public String persons5(@NegativeOrZero int age) { + return "OK"; + } + + /** + * Persons 6 string. + * + * @param name the name + * @return the string + */ + @GetMapping(value = "/persons6") + public String persons6(@NotEmpty @Parameter(description = "persons name") String name) { + return "OK"; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app18/SpringDocApp18Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app18/SpringDocApp18Test.java new file mode 100644 index 000000000..0a78466d8 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app18/SpringDocApp18Test.java @@ -0,0 +1,45 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app18; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.test.context.TestPropertySource; + +/** + * The type Spring doc app 18 test. + */ +@TestPropertySource(properties = "springdoc.pre-loading-enabled=true") +class SpringDocApp18Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app19/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app19/HelloController.java new file mode 100644 index 000000000..9c934de7a --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app19/HelloController.java @@ -0,0 +1,77 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app19; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.parameters.RequestBody; +import jakarta.validation.constraints.NotBlank; + +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * Persons string. + * + * @param name the name + * @return the string + */ + @PostMapping(value = "/persons") + public String persons(@RequestBody(description = "requestBody description as parameter") String name) { + return "OK"; + } + + /** + * Persons 2 string. + * + * @param name the name + * @return the string + */ + @RequestBody(description = "requestBody description outside") + @PostMapping(value = "/persons2") + public String persons2(String name) { + return "OK"; + } + + /** + * Persons 3 string. + * + * @param name the name + * @return the string + */ + @Operation(requestBody = @RequestBody(description = "requestBody inside operation annotation")) + @PostMapping(value = "/persons3") + public String persons3(@NotBlank String name) { + return "OK"; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app19/SpringDocApp19Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app19/SpringDocApp19Test.java new file mode 100644 index 000000000..575afa798 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app19/SpringDocApp19Test.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app19; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 19 test. + */ +class SpringDocApp19Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app2/SpringDocApp2Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app2/SpringDocApp2Test.java new file mode 100644 index 000000000..b890eb8b4 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app2/SpringDocApp2Test.java @@ -0,0 +1,65 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app2; + +import io.swagger.v3.oas.models.Components; +import io.swagger.v3.oas.models.OpenAPI; +import io.swagger.v3.oas.models.info.Info; +import io.swagger.v3.oas.models.info.License; +import io.swagger.v3.oas.models.security.SecurityScheme; +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; + +/** + * The type Spring doc app 2 test. + */ +class SpringDocApp2Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp { + /** + * Custom open api open api. + * + * @return the open api + */ + @Bean + public OpenAPI customOpenAPI() { + return new OpenAPI() + .components(new Components().addSecuritySchemes("basicScheme", + new SecurityScheme().type(SecurityScheme.Type.HTTP).scheme("basic"))) + .info(new Info().title("Petstore API").version("v0").description( + "This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.") + .termsOfService("http://swagger.io/terms/") + .license(new License().name("Apache 2.0").url("http://springdoc.org"))); + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app2/api/ApiUtil.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app2/api/ApiUtil.java new file mode 100644 index 000000000..aae08d565 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app2/api/ApiUtil.java @@ -0,0 +1,69 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app2.api; + +import java.io.IOException; + +import jakarta.servlet.http.HttpServletResponse; + +import org.springframework.http.HttpStatus; +import org.springframework.web.context.request.NativeWebRequest; +import org.springframework.web.server.ResponseStatusException; + +/** + * The type Api util. + */ +class ApiUtil { + + /** + * Sets example response. + * + * @param req the req + * @param contentType the content type + * @param example the example + */ + public static void setExampleResponse(NativeWebRequest req, String contentType, String example) { + try { + req.getNativeResponse(HttpServletResponse.class).addHeader("Content-Type", contentType); + req.getNativeResponse(HttpServletResponse.class).getOutputStream().print(example); + } + catch (IOException e) { + throw new RuntimeException(e); + } + } + + /** + * Check api key. + * + * @param req the req + */ + public static void checkApiKey(NativeWebRequest req) { + if (!"1".equals(System.getenv("DISABLE_API_KEY")) && !"special-key".equals(req.getHeader("api_key"))) { + throw new ResponseStatusException(HttpStatus.UNAUTHORIZED, "Missing API key!"); + } + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app2/api/ExceptionTranslator.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app2/api/ExceptionTranslator.java new file mode 100644 index 000000000..a79041463 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app2/api/ExceptionTranslator.java @@ -0,0 +1,74 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app2.api; + +import java.util.Map; + +import jakarta.validation.ConstraintViolationException; + +import org.springframework.boot.web.error.ErrorAttributeOptions; +import org.springframework.boot.web.servlet.error.ErrorAttributes; +import org.springframework.http.HttpStatus; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.ResponseStatus; +import org.springframework.web.bind.annotation.RestControllerAdvice; +import org.springframework.web.context.request.RequestAttributes; +import org.springframework.web.context.request.WebRequest; + +/** + * The type Exception translator. + */ +@RestControllerAdvice +class ExceptionTranslator { + + /** + * The Error attributes. + */ + private final ErrorAttributes errorAttributes; + + /** + * Instantiates a new Exception translator. + * + * @param errorAttributes the error attributes + */ + public ExceptionTranslator(ErrorAttributes errorAttributes) { + this.errorAttributes = errorAttributes; + } + + /** + * Process constraint violation exception map. + * + * @param request the request + * @return the map + */ + @ExceptionHandler(ConstraintViolationException.class) + @ResponseStatus(HttpStatus.BAD_REQUEST) + public Map processConstraintViolationException(WebRequest request) { + request.setAttribute("jakarta.servlet.error.status_code", HttpStatus.BAD_REQUEST.value(), RequestAttributes.SCOPE_REQUEST); + return errorAttributes.getErrorAttributes(request, ErrorAttributeOptions.defaults()); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app2/api/HomeController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app2/api/HomeController.java new file mode 100644 index 000000000..6bc9fc4fe --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app2/api/HomeController.java @@ -0,0 +1,58 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app2.api; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.GetMapping; + +import static org.springdoc.core.utils.Constants.SWAGGER_UI_PATH; +import static org.springframework.util.AntPathMatcher.DEFAULT_PATH_SEPARATOR; +import static org.springframework.web.servlet.view.UrlBasedViewResolver.REDIRECT_URL_PREFIX; + +/** + * Home redirection to swagger api documentation + */ +@Controller +class HomeController { + + /** + * The Swagger ui path. + */ + @Value(SWAGGER_UI_PATH) + private String swaggerUiPath; + + /** + * Index string. + * + * @return the string + */ + @GetMapping(DEFAULT_PATH_SEPARATOR) + public String index() { + return REDIRECT_URL_PREFIX + swaggerUiPath; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app2/api/PetApi.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app2/api/PetApi.java new file mode 100644 index 000000000..47142103d --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app2/api/PetApi.java @@ -0,0 +1,229 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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. + * * * * * + * * * * + * * * + * * + * + */ + +/** + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (3.0.0). + * https://openapi-generator.tech + * Do not edit the class manually. + */ +package test.org.springdoc.api.v30.app2.api; + +import java.util.List; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.enums.SecuritySchemeType; +import io.swagger.v3.oas.annotations.media.ArraySchema; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; +import io.swagger.v3.oas.annotations.security.OAuthFlow; +import io.swagger.v3.oas.annotations.security.OAuthFlows; +import io.swagger.v3.oas.annotations.security.OAuthScope; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.security.SecurityScheme; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.validation.Valid; +import jakarta.validation.constraints.NotNull; +import test.org.springdoc.api.v30.app2.model.ModelApiResponse; +import test.org.springdoc.api.v30.app2.model.Pet; + +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestHeader; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.multipart.MultipartFile; + +/** + * The interface Pet api. + */ +@SecurityScheme(name = "petstore_auth", type = SecuritySchemeType.OAUTH2, flows = @OAuthFlows(implicit = @OAuthFlow(authorizationUrl = "http://petstore.swagger.io/oauth/dialog", scopes = { + @OAuthScope(name = "write:pets", description = "modify pets in your account"), + @OAuthScope(name = "read:pets", description = "read your pets") }))) +@Tag(name = "pet", description = "the pet API") +@ResponseBody +public interface PetApi { + + /** + * Gets delegate. + * + * @return the delegate + */ + default PetApiDelegate getDelegate() { + return new PetApiDelegate() { + }; + } + + /** + * Add pet. + * + * @param pet the pet + */ + @Operation(summary = "Add a new pet to the store", description = "", security = { + @SecurityRequirement(name = "petstore_auth", scopes = { "write:pets", "read:pets" }) }, tags = { "pet" }) + @ApiResponses(value = { @ApiResponse(responseCode = "405", description = "Invalid input") }) + @PostMapping(value = "/pet", consumes = { "application/json", "application/xml" }) + default void addPet( + @io.swagger.v3.oas.annotations.parameters.RequestBody(description = "Pet object that needs to be added to the store", required = true) @Valid @RequestBody Pet pet) { + // return getDelegate().addPet(pet); + } + + /** + * Delete pet response entity. + * + * @param petId the pet id + * @param apiKey the api key + * @return the response entity + */ + @Operation(summary = "Deletes a pet", description = "", security = { + @SecurityRequirement(name = "petstore_auth", scopes = { "write:pets", "read:pets" }) }, tags = { "pet" }) + @ApiResponses(value = { @ApiResponse(responseCode = "400", description = "Invalid ID supplied"), + @ApiResponse(responseCode = "404", description = "Pet not found") }) + @DeleteMapping(value = "/pet/{petId}") + default ResponseEntity deletePet( + @Parameter(description = "Pet id to delete", required = true) @PathVariable("petId") Long petId, + @Parameter(description = "") @RequestHeader(value = "api_key", required = false) String apiKey) { + return getDelegate().deletePet(petId, apiKey); + } + + /** + * Find pets by status response entity. + * + * @param status the status + * @return the response entity + */ + @Operation(summary = "Finds Pets by status", description = "Multiple status values can be provided with comma separated strings", security = { + @SecurityRequirement(name = "petstore_auth", scopes = { "write:pets", "read:pets" }) }, tags = { "pet" }) + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(array = @ArraySchema(schema = @Schema(implementation = Pet.class)))), + @ApiResponse(responseCode = "400", description = "Invalid status value") }) + @GetMapping(value = "/pet/findByStatus", produces = { "application/xml", "application/json" }) + default ResponseEntity> findPetsByStatus( + @NotNull @Parameter(description = "Status values that need to be considered for filter", required = true) @Valid @RequestParam(value = "status", required = true) List status) { + return getDelegate().findPetsByStatus(status); + } + + /** + * Find pets by tags response entity. + * + * @param tags the tags + * @return the response entity + */ + @Operation(summary = "Finds Pets by tags", description = "Muliple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.", security = { + @SecurityRequirement(name = "petstore_auth", scopes = { "write:pets", "read:pets" }) }, tags = { "pet" }) + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(array = @ArraySchema(schema = @Schema(implementation = Pet.class)))), + @ApiResponse(responseCode = "400", description = "Invalid tag value") }) + @GetMapping(value = "/pet/findByTags", produces = { "application/xml", "application/json" }) + default ResponseEntity> findPetsByTags( + @NotNull @Parameter(description = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) List tags) { + return getDelegate().findPetsByTags(tags); + } + + /** + * Gets pet by id. + * + * @param petId the pet id + * @return the pet by id + */ + @Operation(summary = "Find pet by ID", description = "Returns a single pet", security = { + @SecurityRequirement(name = "api_key") }, tags = { "pet" }) + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(schema = @Schema(implementation = Pet.class))), + @ApiResponse(responseCode = "400", description = "Invalid ID supplied"), + @ApiResponse(responseCode = "404", description = "Pet not found") }) + @GetMapping(value = "/pet/{petId}", produces = { "application/xml", "application/json" }) + default ResponseEntity getPetById( + @Parameter(description = "ID of pet to return", required = true) @PathVariable("petId") Long petId) { + return getDelegate().getPetById(petId); + } + + /** + * Update pet response entity. + * + * @param pet the pet + * @return the response entity + */ + @Operation(summary = "Update an existing pet", description = "", security = { + @SecurityRequirement(name = "petstore_auth", scopes = { "write:pets", "read:pets" }) }, tags = { "pet" }) + @ApiResponses(value = { @ApiResponse(responseCode = "400", description = "Invalid ID supplied"), + @ApiResponse(responseCode = "404", description = "Pet not found"), + @ApiResponse(responseCode = "405", description = "Validation exception") }) + @PutMapping(value = "/pet", consumes = { "application/json", "application/xml" }) + default ResponseEntity updatePet( + @io.swagger.v3.oas.annotations.parameters.RequestBody(description = "Pet object that needs to be added to the store", required = true) @Valid @RequestBody Pet pet) { + return getDelegate().updatePet(pet); + } + + /** + * Update pet with form response entity. + * + * @param petId the pet id + * @param name the name + * @param status the status + * @return the response entity + */ + @Operation(summary = "Updates a pet in the store with form data", description = "", security = { + @SecurityRequirement(name = "petstore_auth", scopes = { "write:pets", "read:pets" }) }, tags = { "pet" }) + @ApiResponses(value = { @ApiResponse(responseCode = "405", description = "Invalid input") }) + @PostMapping(value = "/pet/{petId}", consumes = { "application/x-www-form-urlencoded" }) + default ResponseEntity updatePetWithForm( + @Parameter(description = "ID of pet that needs to be updated", required = true) @PathVariable("petId") Long petId, + @Parameter(description = "Updated name of the pet") @RequestParam(value = "name", required = false) String name, + @Parameter(description = "Updated status of the pet") @RequestParam(value = "status", required = false) String status) { + return getDelegate().updatePetWithForm(petId, name, status); + } + + /** + * Upload file response entity. + * + * @param petId the pet id + * @param additionalMetadata the additional metadata + * @param file the file + * @return the response entity + */ + @Operation(summary = "uploads an image", description = "", security = { + @SecurityRequirement(name = "petstore_auth", scopes = { "write:pets", "read:pets" }) }, tags = { "pet" }) + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(schema = @Schema(implementation = ModelApiResponse.class))) }) + @PostMapping(value = "/pet/{petId}/uploadImage", produces = { "application/json" }, consumes = { + "multipart/form-data" }) + default ResponseEntity uploadFile( + @Parameter(description = "ID of pet to update", required = true) @PathVariable("petId") Long petId, + @Parameter(description = "Additional data to pass to server") @RequestParam(value = "additionalMetadata", required = false) String additionalMetadata, + @Parameter(description = "file detail") @Valid @RequestPart("file") MultipartFile file) { + return getDelegate().uploadFile(petId, additionalMetadata, file); + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app2/api/PetApiController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app2/api/PetApiController.java new file mode 100644 index 000000000..224b691f2 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app2/api/PetApiController.java @@ -0,0 +1,68 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app2.api; + +import java.util.Optional; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; + +/** + * The type Pet api controller. + */ +@jakarta.annotation.Generated(value = "org.springdoc.demo.app2.codegen.languages.SpringCodegen", date = "2019-07-11T00:09:29.839+02:00[Europe/Paris]") + +@Controller +@RequestMapping("${openapi.openAPIPetstore.base-path:/}") +class PetApiController implements PetApi { + + /** + * The Delegate. + */ + private final PetApiDelegate delegate; + + /** + * Instantiates a new Pet api controller. + * + * @param delegate the delegate + */ + public PetApiController(@org.springframework.beans.factory.annotation.Autowired(required = false) PetApiDelegate delegate) { + this.delegate = Optional.ofNullable(delegate).orElse(new PetApiDelegate() { + }); + } + + /** + * Gets delegate. + * + * @return the delegate + */ + @Override + public PetApiDelegate getDelegate() { + return delegate; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app2/api/PetApiDelegate.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app2/api/PetApiDelegate.java new file mode 100644 index 000000000..9cd0e4201 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app2/api/PetApiDelegate.java @@ -0,0 +1,192 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app2.api; + +import java.util.List; +import java.util.Optional; + +import jakarta.validation.Valid; +import test.org.springdoc.api.v30.app2.model.ModelApiResponse; +import test.org.springdoc.api.v30.app2.model.Pet; + +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.web.context.request.NativeWebRequest; +import org.springframework.web.multipart.MultipartFile; + +/** + * A delegate to be called by the {@link PetApiController}}. + * Implement this interface with a {@link org.springframework.stereotype.Service} annotated class. + */ +@jakarta.annotation.Generated(value = "org.springdoc.demo.app2.codegen.languages.SpringCodegen", date = "2019-07-11T00:09:29.839+02:00[Europe/Paris]") + +public interface PetApiDelegate { + + /** + * Gets request. + * + * @return the request + */ + default Optional getRequest() { + return Optional.empty(); + } + + /** + * Add pet. + * + * @param pet the pet + * @see PetApi#addPet PetApi#addPet + */ + default void addPet(Pet pet) { + + } + + /** + * Delete pet response entity. + * + * @param petId the pet id + * @param apiKey the api key + * @return the response entity + * @see PetApi#deletePet PetApi#deletePet + */ + default ResponseEntity deletePet(Long petId, + String apiKey) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * Find pets by status response entity. + * + * @param status the status + * @return the response entity + * @see PetApi#findPetsByStatus PetApi#findPetsByStatus + */ + default ResponseEntity> findPetsByStatus(List status) { + extract(); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * Extract. + */ + default void extract() { + getRequest().ifPresent(request -> { + for (MediaType mediaType : MediaType.parseMediaTypes(request.getHeader("Accept"))) { + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + ApiUtil.setExampleResponse(request, "application/json", "{ \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\"}"); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/xml"))) { + ApiUtil.setExampleResponse(request, "application/xml", " 123456789 doggie aeiou aeiou"); + break; + } + } + }); + } + + /** + * Find pets by tags response entity. + * + * @param tags the tags + * @return the response entity + * @see PetApi#findPetsByTags PetApi#findPetsByTags + */ + default ResponseEntity> findPetsByTags(List tags) { + extract(); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * Gets pet by id. + * + * @param petId the pet id + * @return the pet by id + * @see PetApi#getPetById PetApi#getPetById + */ + default ResponseEntity getPetById(Long petId) { + extract(); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * Update pet response entity. + * + * @param pet the pet + * @return the response entity + * @see PetApi#updatePet PetApi#updatePet + */ + default ResponseEntity updatePet(Pet pet) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * Update pet with form response entity. + * + * @param petId the pet id + * @param name the name + * @param status the status + * @return the response entity + * @see PetApi#updatePetWithForm PetApi#updatePetWithForm + */ + default ResponseEntity updatePetWithForm(Long petId, + String name, + String status) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * Upload file response entity. + * + * @param petId the pet id + * @param additionalMetadata the additional metadata + * @param file the file + * @return the response entity + * @see PetApi#uploadFile PetApi#uploadFile + */ + default ResponseEntity uploadFile(Long petId, + String additionalMetadata, + @Valid MultipartFile file) { + getRequest().ifPresent(request -> { + for (MediaType mediaType : MediaType.parseMediaTypes(request.getHeader("Accept"))) { + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + ApiUtil.setExampleResponse(request, "application/json", "{ \"code\" : 0, \"type\" : \"type\", \"message\" : \"message\"}"); + break; + } + } + }); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app2/api/PetApiDelegateImpl.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app2/api/PetApiDelegateImpl.java new file mode 100644 index 000000000..e2771a869 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app2/api/PetApiDelegateImpl.java @@ -0,0 +1,38 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app2.api; + +import org.springframework.stereotype.Service; + +/** + * The type Pet api delegate. + */ +@Service +class PetApiDelegateImpl implements PetApiDelegate { + + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app2/api/StoreApi.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app2/api/StoreApi.java new file mode 100644 index 000000000..0f92f20d1 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app2/api/StoreApi.java @@ -0,0 +1,143 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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. + * * * * * + * * * * + * * * + * * + * + */ + +/** + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (3.0.0). + * https://openapi-generator.tech + * Do not edit the class manually. + */ +package test.org.springdoc.api.v30.app2.api; + +import java.util.Map; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.media.ArraySchema; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.validation.Valid; +import jakarta.validation.constraints.Max; +import jakarta.validation.constraints.Min; +import test.org.springdoc.api.v30.app2.model.Order; + +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.ResponseBody; + +/** + * The interface Store api. + */ +@jakarta.annotation.Generated(value = "org.springdoc.demo.app2.codegen.languages.SpringCodegen", date = "2019-07-11T00:09:29.839+02:00[Europe/Paris]") + +@Tag(name = "store", description = "the store API") +public interface StoreApi { + + /** + * Gets delegate. + * + * @return the delegate + */ + default StoreApiDelegate getDelegate() { + return new StoreApiDelegate() { + }; + } + + /** + * Delete order response entity. + * + * @param orderId the order id + * @return the response entity + */ + @Operation(summary = "Delete purchase order by ID", tags = { "store" }) + @ApiResponses(value = { @ApiResponse(responseCode = "400", description = "Invalid ID supplied"), + @ApiResponse(responseCode = "404", description = "Order not found") }) + @DeleteMapping(value = "/store/order/{orderId}") + @ResponseBody + default ResponseEntity deleteOrder( + @Parameter(description = "ID of the order that needs to be deleted", required = true) @PathVariable("orderId") String orderId) { + return getDelegate().deleteOrder(orderId); + } + + /** + * Gets inventory. + * + * @return the inventory + */ + @Operation(summary = "Returns pet inventories by status", description = "Returns a map of status codes to quantities", security = { + @SecurityRequirement(name = "api_key") }, tags = { "store" }) + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(array = @ArraySchema(schema = @Schema(implementation = Map.class)))) }) + @GetMapping(value = "/store/inventory", produces = { "application/json" }) + @ResponseBody + default ResponseEntity> getInventory() { + return getDelegate().getInventory(); + } + + /** + * Gets order by id. + * + * @param orderId the order id + * @return the order by id + */ + @Operation(summary = "Find purchase order by ID", tags = { "store" }) + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(schema = @Schema(implementation = Order.class))), + @ApiResponse(responseCode = "400", description = "Invalid ID supplied"), + @ApiResponse(responseCode = "404", description = "Order not found") }) + @GetMapping(value = "/store/order/{orderId}", produces = { "application/xml", "application/json" }) + @ResponseBody + default ResponseEntity getOrderById( + @Min(1L) @Max(5L) @Parameter(description = "ID of pet that needs to be fetched", required = true) @PathVariable("orderId") Long orderId) { + return getDelegate().getOrderById(orderId); + } + + /** + * Place order response entity. + * + * @param order the order + * @return the response entity + */ + @Operation(summary = "Place an order for a pet", tags = { "store" }) + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(schema = @Schema(implementation = Order.class))), + @ApiResponse(responseCode = "400", description = "Invalid Order") }) + @PostMapping(value = "/store/order", produces = { "application/xml", "application/json" }, consumes = { + "application/json" }) + @ResponseBody + default ResponseEntity placeOrder( + @Parameter(description = "order placed for purchasing the pet", required = true) @Valid @RequestBody Order order) { + return getDelegate().placeOrder(order); + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app2/api/StoreApiController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app2/api/StoreApiController.java new file mode 100644 index 000000000..5f0204831 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app2/api/StoreApiController.java @@ -0,0 +1,68 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app2.api; + +import java.util.Optional; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; + +/** + * The type Store api controller. + */ +@jakarta.annotation.Generated(value = "org.springdoc.demo.app2.codegen.languages.SpringCodegen", date = "2019-07-11T00:09:29.839+02:00[Europe/Paris]") + +@Controller +@RequestMapping("${openapi.openAPIPetstore.base-path:/}") +class StoreApiController implements StoreApi { + + /** + * The Delegate. + */ + private final StoreApiDelegate delegate; + + /** + * Instantiates a new Store api controller. + * + * @param delegate the delegate + */ + public StoreApiController(@org.springframework.beans.factory.annotation.Autowired(required = false) StoreApiDelegate delegate) { + this.delegate = Optional.ofNullable(delegate).orElse(new StoreApiDelegate() { + }); + } + + /** + * Gets delegate. + * + * @return the delegate + */ + @Override + public StoreApiDelegate getDelegate() { + return delegate; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app2/api/StoreApiDelegate.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app2/api/StoreApiDelegate.java new file mode 100644 index 000000000..59cafb2b2 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app2/api/StoreApiDelegate.java @@ -0,0 +1,123 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app2.api; + +import java.util.Map; +import java.util.Optional; + +import test.org.springdoc.api.v30.app2.model.Order; + +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.web.context.request.NativeWebRequest; + +/** + * A delegate to be called by the {@link StoreApiController}}. + * Implement this interface with a {@link org.springframework.stereotype.Service} annotated class. + */ +@jakarta.annotation.Generated(value = "org.springdoc.demo.app2.codegen.languages.SpringCodegen", date = "2019-07-11T00:09:29.839+02:00[Europe/Paris]") + +public interface StoreApiDelegate { + + /** + * Gets request. + * + * @return the request + */ + default Optional getRequest() { + return Optional.empty(); + } + + /** + * Delete order response entity. + * + * @param orderId the order id + * @return the response entity + * @see StoreApi#deleteOrder StoreApi#deleteOrder + */ + default ResponseEntity deleteOrder(String orderId) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * Gets inventory. + * + * @return the inventory + * @see StoreApi#getInventory StoreApi#getInventory + */ + default ResponseEntity> getInventory() { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * Gets order by id. + * + * @param orderId the order id + * @return the order by id + * @see StoreApi#getOrderById StoreApi#getOrderById + */ + default ResponseEntity getOrderById(Long orderId) { + extract(); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * Extract. + */ + default void extract() { + getRequest().ifPresent(request -> { + for (MediaType mediaType : MediaType.parseMediaTypes(request.getHeader("Accept"))) { + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + ApiUtil.setExampleResponse(request, "application/json", "{ \"petId\" : 6, \"quantity\" : 1, \"id\" : 0, \"shipDate\" : \"2000-01-23T04:56:07.000+00:00\", \"complete\" : false, \"status\" : \"placed\"}"); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/xml"))) { + ApiUtil.setExampleResponse(request, "application/xml", " 123456789 123456789 123 2000-01-23T04:56:07.000Z aeiou true"); + break; + } + } + }); + } + + /** + * Place order response entity. + * + * @param order the order + * @return the response entity + * @see StoreApi#placeOrder StoreApi#placeOrder + */ + default ResponseEntity placeOrder(Order order) { + extract(); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app2/api/StoreApiDelegateImpl.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app2/api/StoreApiDelegateImpl.java new file mode 100644 index 000000000..d7bc3e5c0 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app2/api/StoreApiDelegateImpl.java @@ -0,0 +1,38 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app2.api; + +import org.springframework.stereotype.Service; + +/** + * The type Store api delegate. + */ +@Service +class StoreApiDelegateImpl implements StoreApiDelegate { + + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app2/api/UserApi.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app2/api/UserApi.java new file mode 100644 index 000000000..d69daa354 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app2/api/UserApi.java @@ -0,0 +1,197 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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. + * * * * * + * * * * + * * * + * * + * + */ + +/** + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (3.0.0). + * https://openapi-generator.tech + * Do not edit the class manually. + */ +package test.org.springdoc.api.v30.app2.api; + +import java.util.List; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.validation.Valid; +import jakarta.validation.constraints.NotNull; +import test.org.springdoc.api.v30.app2.model.User; + +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestParam; + +/** + * The interface User api. + */ +@jakarta.annotation.Generated(value = "org.springdoc.demo.app2.codegen.languages.SpringCodegen", date = "2019-07-11T00:09:29.839+02:00[Europe/Paris]") + +@Tag(name = "user", description = "the user API") +public interface UserApi { + + /** + * Gets delegate. + * + * @return the delegate + */ + default UserApiDelegate getDelegate() { + return new UserApiDelegate() { + }; + } + + /** + * Create user response entity. + * + * @param user the user + * @return the response entity + */ + @Operation(summary = "Create user", tags = { "user" }) + @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "successful operation") }) + @PostMapping(value = "/user", consumes = { "application/json" }) + default ResponseEntity createUser( + @io.swagger.v3.oas.annotations.parameters.RequestBody(description = "Created user object", required = true) @Valid @RequestBody User user) { + return getDelegate().createUser(user); + } + + /** + * Create users with array input response entity. + * + * @param user the user + * @return the response entity + */ + @Operation(summary = "Creates list of users with given input array", tags = { "user" }) + @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "successful operation") }) + + @PostMapping(value = "/user/createWithArray", consumes = { "application/json" }) + default ResponseEntity createUsersWithArrayInput( + @io.swagger.v3.oas.annotations.parameters.RequestBody(description = "List of user object", required = true) @Valid @RequestBody List user) { + return getDelegate().createUsersWithArrayInput(user); + } + + /** + * Create users with list input response entity. + * + * @param user the user + * @return the response entity + */ + @Operation(summary = "Creates list of users with given input array", tags = { "user" }) + @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "successful operation") }) + @PostMapping(value = "/user/createWithList", consumes = { "application/json" }) + default ResponseEntity createUsersWithListInput( + @io.swagger.v3.oas.annotations.parameters.RequestBody(description = "List of user object", required = true) @Valid @RequestBody List user) { + return getDelegate().createUsersWithListInput(user); + } + + /** + * Delete user response entity. + * + * @param username the username + * @return the response entity + */ + @Operation(summary = "Creates list of users with given input array", tags = { "user" }) + @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "successful operation") }) + + @DeleteMapping(value = "/user/{username}") + default ResponseEntity deleteUser( + @io.swagger.v3.oas.annotations.parameters.RequestBody(description = "The name that needs to be deleted", required = true) @PathVariable("username") String username) { + return getDelegate().deleteUser(username); + } + + /** + * Gets user by name. + * + * @param username the username + * @return the user by name + */ + @Operation(summary = "Get user by user name", tags = { "user" }) + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(schema = @Schema(implementation = User.class))), + @ApiResponse(responseCode = "400", description = "Invalid username supplied"), + @ApiResponse(responseCode = "404", description = "User not found") }) + + @GetMapping(value = "/user/{username}", produces = { "application/xml", "application/json" }) + default ResponseEntity getUserByName( + @Parameter(description = "The name that needs to be fetched. Use user1 for testing.", required = true) @PathVariable("username") String username) { + return getDelegate().getUserByName(username); + } + + /** + * Login user response entity. + * + * @param username the username + * @param password the password + * @return the response entity + */ + @Operation(summary = "Logs user into the system", tags = { "user" }) + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(schema = @Schema(implementation = String.class))), + @ApiResponse(responseCode = "400", description = "Invalid username/password supplied") }) + @GetMapping(value = "/user/login", produces = { "application/xml", "application/json" }) + default ResponseEntity loginUser( + @NotNull @Parameter(description = "The user name for login", required = true) @Valid @RequestParam(value = "username", required = true) String username, + @NotNull @Parameter(description = "The password for login in clear text", required = true) @Valid @RequestParam(value = "password", required = true) String password) { + return getDelegate().loginUser(username, password); + } + + /** + * Logout user response entity. + * + * @return the response entity + */ + @Operation(summary = "Logs out current logged in user session", tags = { "user" }) + @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "successful operation") }) + @GetMapping(value = "/user/logout") + default ResponseEntity logoutUser() { + return getDelegate().logoutUser(); + } + + /** + * Update user response entity. + * + * @param username the username + * @param user the user + * @return the response entity + */ + @Operation(summary = "Updated user", tags = { "user" }) + @ApiResponses(value = { @ApiResponse(responseCode = "400", description = "Invalid user supplied"), + @ApiResponse(responseCode = "404", description = "User not found") }) + @PutMapping(value = "/user/{username}", consumes = { "application/json" }) + default ResponseEntity updateUser( + @Parameter(description = "name that need to be deleted", required = true) @PathVariable("username") String username, + @io.swagger.v3.oas.annotations.parameters.RequestBody(description = "Updated user object", required = true) @Valid @RequestBody User user) { + return getDelegate().updateUser(username, user); + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app2/api/UserApiController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app2/api/UserApiController.java new file mode 100644 index 000000000..1bf19064b --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app2/api/UserApiController.java @@ -0,0 +1,70 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app2.api; + +import java.util.Optional; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; + +/** + * The type User api controller. + */ +@jakarta.annotation.Generated(value = "org.springdoc.demo.app2.codegen.languages.SpringCodegen", date = "2019-07-11T00:09:29.839+02:00[Europe/Paris]") + +@Controller +@ResponseBody +@RequestMapping("${openapi.openAPIPetstore.base-path:/}") +class UserApiController implements UserApi { + + /** + * The Delegate. + */ + private final UserApiDelegate delegate; + + /** + * Instantiates a new User api controller. + * + * @param delegate the delegate + */ + public UserApiController(@org.springframework.beans.factory.annotation.Autowired(required = false) UserApiDelegate delegate) { + this.delegate = Optional.ofNullable(delegate).orElse(new UserApiDelegate() { + }); + } + + /** + * Gets delegate. + * + * @return the delegate + */ + @Override + public UserApiDelegate getDelegate() { + return delegate; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app2/api/UserApiDelegate.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app2/api/UserApiDelegate.java new file mode 100644 index 000000000..00a3666c8 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app2/api/UserApiDelegate.java @@ -0,0 +1,167 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app2.api; + +import java.util.List; +import java.util.Optional; + +import test.org.springdoc.api.v30.app2.model.User; + +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.web.context.request.NativeWebRequest; + +/** + * A delegate to be called by the {@link UserApiController}}. + * Implement this interface with a {@link org.springframework.stereotype.Service} annotated class. + */ +@jakarta.annotation.Generated(value = "org.springdoc.demo.app2.codegen.languages.SpringCodegen", date = "2019-07-11T00:09:29.839+02:00[Europe/Paris]") + +public interface UserApiDelegate { + + /** + * Gets request. + * + * @return the request + */ + default Optional getRequest() { + return Optional.empty(); + } + + /** + * Create user response entity. + * + * @param user the user + * @return the response entity + * @see UserApi#createUser UserApi#createUser + */ + default ResponseEntity createUser(User user) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * Create users with array input response entity. + * + * @param user the user + * @return the response entity + * @see UserApi#createUsersWithArrayInput UserApi#createUsersWithArrayInput + */ + default ResponseEntity createUsersWithArrayInput(List user) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * Create users with list input response entity. + * + * @param user the user + * @return the response entity + * @see UserApi#createUsersWithListInput UserApi#createUsersWithListInput + */ + default ResponseEntity createUsersWithListInput(List user) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * Delete user response entity. + * + * @param username the username + * @return the response entity + * @see UserApi#deleteUser UserApi#deleteUser + */ + default ResponseEntity deleteUser(String username) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * Gets user by name. + * + * @param username the username + * @return the user by name + * @see UserApi#getUserByName UserApi#getUserByName + */ + default ResponseEntity getUserByName(String username) { + getRequest().ifPresent(request -> { + for (MediaType mediaType : MediaType.parseMediaTypes(request.getHeader("Accept"))) { + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + ApiUtil.setExampleResponse(request, "application/json", "{ \"firstName\" : \"firstName\", \"lastName\" : \"lastName\", \"password\" : \"password\", \"userStatus\" : 6, \"phone\" : \"phone\", \"id\" : 0, \"email\" : \"email\", \"username\" : \"username\"}"); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/xml"))) { + ApiUtil.setExampleResponse(request, "application/xml", " 123456789 aeiou aeiou aeiou aeiou aeiou aeiou 123"); + break; + } + } + }); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * Login user response entity. + * + * @param username the username + * @param password the password + * @return the response entity + * @see UserApi#loginUser UserApi#loginUser + */ + default ResponseEntity loginUser(String username, + String password) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * Logout user response entity. + * + * @return the response entity + * @see UserApi#logoutUser UserApi#logoutUser + */ + default ResponseEntity logoutUser() { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * Update user response entity. + * + * @param username the username + * @param user the user + * @return the response entity + * @see UserApi#updateUser UserApi#updateUser + */ + default ResponseEntity updateUser(String username, + User user) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app2/api/UserApiDelegateImpl.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app2/api/UserApiDelegateImpl.java new file mode 100644 index 000000000..0362cb087 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app2/api/UserApiDelegateImpl.java @@ -0,0 +1,38 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app2.api; + +import org.springframework.stereotype.Service; + +/** + * The type User api delegate. + */ +@Service +class UserApiDelegateImpl implements UserApiDelegate { + + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app2/model/Category.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app2/model/Category.java new file mode 100644 index 000000000..25acbb51a --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app2/model/Category.java @@ -0,0 +1,134 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app2.model; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The type Category. + */ +class Category { + + /** + * The Id. + */ + private Long id = null; + + /** + * The Name. + */ + private String name = null; + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + * @param o the o + * @return the string + */ + private static String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Get id + * + * @return id id + */ + @JsonProperty("id") + public Long getId() { + return id; + } + + /** + * Sets id. + * + * @param id the id + */ + public void setId(Long id) { + this.id = id; + } + + /** + * Id category. + * + * @param id the id + * @return the category + */ + public Category id(Long id) { + this.id = id; + return this; + } + + /** + * Get name + * + * @return name name + */ + @JsonProperty("name") + public String getName() { + return name; + } + + /** + * Sets name. + * + * @param name the name + */ + public void setName(String name) { + this.name = name; + } + + /** + * Name category. + * + * @param name the name + * @return the category + */ + public Category name(String name) { + this.name = name; + return this; + } + + /** + * To string string. + * + * @return the string + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Category {\n"); + + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append("}"); + return sb.toString(); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app2/model/ModelApiResponse.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app2/model/ModelApiResponse.java new file mode 100644 index 000000000..f9dd5efeb --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app2/model/ModelApiResponse.java @@ -0,0 +1,170 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app2.model; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The type Model api response. + */ +public class ModelApiResponse { + + /** + * The Code. + */ + private Integer code = null; + + /** + * The Type. + */ + private String type = null; + + /** + * The Message. + */ + private String message = null; + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + * @param o the o + * @return the string + */ + private static String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Get code + * + * @return code code + */ + @JsonProperty("code") + public Integer getCode() { + return code; + } + + /** + * Sets code. + * + * @param code the code + */ + public void setCode(Integer code) { + this.code = code; + } + + /** + * Code model api response. + * + * @param code the code + * @return the model api response + */ + public ModelApiResponse code(Integer code) { + this.code = code; + return this; + } + + /** + * Get type + * + * @return type type + */ + @JsonProperty("type") + public String getType() { + return type; + } + + /** + * Sets type. + * + * @param type the type + */ + public void setType(String type) { + this.type = type; + } + + /** + * Type model api response. + * + * @param type the type + * @return the model api response + */ + public ModelApiResponse type(String type) { + this.type = type; + return this; + } + + /** + * Get message + * + * @return message message + */ + @JsonProperty("message") + public String getMessage() { + return message; + } + + /** + * Sets message. + * + * @param message the message + */ + public void setMessage(String message) { + this.message = message; + } + + /** + * Message model api response. + * + * @param message the message + * @return the model api response + */ + public ModelApiResponse message(String message) { + this.message = message; + return this; + } + + /** + * To string string. + * + * @return the string + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ModelApiResponse {\n"); + + sb.append(" code: ").append(toIndentedString(code)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" message: ").append(toIndentedString(message)).append("\n"); + sb.append("}"); + return sb.toString(); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app2/model/Order.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app2/model/Order.java new file mode 100644 index 000000000..8ca543cae --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app2/model/Order.java @@ -0,0 +1,360 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app2.model; + +import java.util.Date; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.v3.oas.annotations.media.Schema; + +/** + * The type Order. + */ +public class Order { + + /** + * The Id. + */ + @Schema(description = "") + private Long id = null; + + /** + * The Pet id. + */ + @Schema(description = "") + private Long petId = null; + + /** + * The Quantity. + */ + @Schema(description = "") + private Integer quantity = null; + + /** + * The Ship date. + */ + @Schema(description = "") + private Date shipDate = null; + + /** + * Order Status + */ + private StatusEnum status = null; + + /** + * The Complete. + */ + @Schema(description = "") + private Boolean complete = false; + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + * @param o the o + * @return the string + */ + private static String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Get id + * + * @return id id + */ + @JsonProperty("id") + public Long getId() { + return id; + } + + /** + * Sets id. + * + * @param id the id + */ + public void setId(Long id) { + this.id = id; + } + + /** + * Id order. + * + * @param id the id + * @return the order + */ + public Order id(Long id) { + this.id = id; + return this; + } + + /** + * Get petId + * + * @return petId pet id + */ + @JsonProperty("petId") + public Long getPetId() { + return petId; + } + + /** + * Sets pet id. + * + * @param petId the pet id + */ + public void setPetId(Long petId) { + this.petId = petId; + } + + /** + * Pet id order. + * + * @param petId the pet id + * @return the order + */ + public Order petId(Long petId) { + this.petId = petId; + return this; + } + + /** + * Get quantity + * + * @return quantity quantity + */ + @JsonProperty("quantity") + public Integer getQuantity() { + return quantity; + } + + /** + * Sets quantity. + * + * @param quantity the quantity + */ + public void setQuantity(Integer quantity) { + this.quantity = quantity; + } + + /** + * Quantity order. + * + * @param quantity the quantity + * @return the order + */ + public Order quantity(Integer quantity) { + this.quantity = quantity; + return this; + } + + /** + * Get shipDate + * + * @return shipDate ship date + */ + @JsonProperty("shipDate") + public Date getShipDate() { + return shipDate; + } + + /** + * Sets ship date. + * + * @param shipDate the ship date + */ + public void setShipDate(Date shipDate) { + this.shipDate = shipDate; + } + + /** + * Ship date order. + * + * @param shipDate the ship date + * @return the order + */ + public Order shipDate(Date shipDate) { + this.shipDate = shipDate; + return this; + } + + /** + * Order Status + * + * @return status status + */ + @JsonProperty("status") + public String getStatus() { + if (status == null) { + return null; + } + return status.getValue(); + } + + /** + * Sets status. + * + * @param status the status + */ + public void setStatus(StatusEnum status) { + this.status = status; + } + + /** + * Status order. + * + * @param status the status + * @return the order + */ + public Order status(StatusEnum status) { + this.status = status; + return this; + } + + /** + * Get complete + * + * @return complete boolean + */ + @JsonProperty("complete") + public Boolean isisComplete() { + return complete; + } + + /** + * Sets complete. + * + * @param complete the complete + */ + public void setComplete(Boolean complete) { + this.complete = complete; + } + + /** + * Complete order. + * + * @param complete the complete + * @return the order + */ + public Order complete(Boolean complete) { + this.complete = complete; + return this; + } + + + /** + * To string string. + * + * @return the string + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Order {\n"); + + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" petId: ").append(toIndentedString(petId)).append("\n"); + sb.append(" quantity: ").append(toIndentedString(quantity)).append("\n"); + sb.append(" shipDate: ").append(toIndentedString(shipDate)).append("\n"); + sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append(" complete: ").append(toIndentedString(complete)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * The enum Status enum. + */ + public enum StatusEnum { + /** + *Placed status enum. + */ + PLACED("placed"), + /** + *Approved status enum. + */ + APPROVED("approved"), + /** + *Delivered status enum. + */ + DELIVERED("delivered"); + + /** + * The Value. + */ + private String value; + + /** + * Instantiates a new Status enum. + * + * @param value the value + */ + StatusEnum(String value) { + this.value = value; + } + + /** + * From value status enum. + * + * @param text the text + * @return the status enum + */ + @JsonCreator + public static StatusEnum fromValue(String text) { + for (StatusEnum b : StatusEnum.values()) { + if (String.valueOf(b.value).equals(text)) { + return b; + } + } + return null; + } + + /** + * Gets value. + * + * @return the value + */ + @JsonValue + public String getValue() { + return value; + } + + /** + * To string string. + * + * @return the string + */ + @Override + public String toString() { + return String.valueOf(value); + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app2/model/Pet.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app2/model/Pet.java new file mode 100644 index 000000000..57064373d --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app2/model/Pet.java @@ -0,0 +1,392 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app2.model; + +import java.util.ArrayList; +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotNull; + +/** + * The type Pet. + */ +public class Pet { + + /** + * The Id. + */ + @Schema(description = "") + private Long id = null; + + /** + * The Category. + */ + @Schema(description = "") + private Category category = null; + + /** + * The Name. + */ + @Schema(example = "doggie", required = true, description = "") + private String name = null; + + /** + * The Photo urls. + */ + @Schema(required = true, description = "") + private List photoUrls = new ArrayList(); + + /** + * The Tags. + */ + @Schema(description = "") + private List tags = null; + + /** + * The Status. + */ + @Schema(description = "pet status in the store") + /** + * pet status in the store + **/ + private StatusEnum status = null; + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + * @param o the o + * @return the string + */ + private static String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Get id + * + * @return id id + */ + @JsonProperty("id") + public Long getId() { + return id; + } + + /** + * Sets id. + * + * @param id the id + */ + public void setId(Long id) { + this.id = id; + } + + /** + * Id pet. + * + * @param id the id + * @return the pet + */ + public Pet id(Long id) { + this.id = id; + return this; + } + + /** + * Get category + * + * @return category category + */ + @JsonProperty("category") + public Category getCategory() { + return category; + } + + /** + * Sets category. + * + * @param category the category + */ + public void setCategory(Category category) { + this.category = category; + } + + /** + * Category pet. + * + * @param category the category + * @return the pet + */ + public Pet category(Category category) { + this.category = category; + return this; + } + + /** + * Get name + * + * @return name name + */ + @JsonProperty("name") + @NotNull + public String getName() { + return name; + } + + /** + * Sets name. + * + * @param name the name + */ + public void setName(String name) { + this.name = name; + } + + /** + * Name pet. + * + * @param name the name + * @return the pet + */ + public Pet name(String name) { + this.name = name; + return this; + } + + /** + * Get photoUrls + * + * @return photoUrls photo urls + */ + @JsonProperty("photoUrls") + @NotNull + public List getPhotoUrls() { + return photoUrls; + } + + /** + * Sets photo urls. + * + * @param photoUrls the photo urls + */ + public void setPhotoUrls(List photoUrls) { + this.photoUrls = photoUrls; + } + + /** + * Photo urls pet. + * + * @param photoUrls the photo urls + * @return the pet + */ + public Pet photoUrls(List photoUrls) { + this.photoUrls = photoUrls; + return this; + } + + /** + * Add photo urls item pet. + * + * @param photoUrlsItem the photo urls item + * @return the pet + */ + public Pet addPhotoUrlsItem(String photoUrlsItem) { + this.photoUrls.add(photoUrlsItem); + return this; + } + + /** + * Get tags + * + * @return tags tags + */ + @JsonProperty("tags") + public List getTags() { + return tags; + } + + /** + * Sets tags. + * + * @param tags the tags + */ + public void setTags(List tags) { + this.tags = tags; + } + + /** + * Tags pet. + * + * @param tags the tags + * @return the pet + */ + public Pet tags(List tags) { + this.tags = tags; + return this; + } + + /** + * Add tags item pet. + * + * @param tagsItem the tags item + * @return the pet + */ + public Pet addTagsItem(Tag tagsItem) { + if (this.tags == null) { + this.tags = new ArrayList<>(); + } + this.tags.add(tagsItem); + return this; + } + + /** + * pet status in the store + * + * @return status status + */ + @JsonProperty("status") + public StatusEnum getStatus() { + if (status == null) { + return null; + } + return status; + } + + /** + * Sets status. + * + * @param status the status + */ + public void setStatus(StatusEnum status) { + this.status = status; + } + + /** + * Status pet. + * + * @param status the status + * @return the pet + */ + public Pet status(StatusEnum status) { + this.status = status; + return this; + } + + /** + * To string string. + * + * @return the string + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Pet {\n"); + + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" category: ").append(toIndentedString(category)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" photoUrls: ").append(toIndentedString(photoUrls)).append("\n"); + sb.append(" tags: ").append(toIndentedString(tags)).append("\n"); + sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * The enum Status enum. + */ + public enum StatusEnum { + /** + *Available status enum. + */ + AVAILABLE("available"), + /** + *Pending status enum. + */ + PENDING("pending"), + /** + *Sold status enum. + */ + SOLD("sold"); + + /** + * The Value. + */ + private String value; + + /** + * Instantiates a new Status enum. + * + * @param value the value + */ + StatusEnum(String value) { + this.value = value; + } + + /** + * From value status enum. + * + * @param text the text + * @return the status enum + */ + @JsonCreator + public static StatusEnum fromValue(String text) { + for (StatusEnum b : StatusEnum.values()) { + if (String.valueOf(b.value).equals(text)) { + return b; + } + } + return null; + } + + /** + * Gets value. + * + * @return the value + */ + @JsonValue + public String getValue() { + return value; + } + + /** + * To string string. + * + * @return the string + */ + @Override + public String toString() { + return String.valueOf(value); + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app2/model/Tag.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app2/model/Tag.java new file mode 100644 index 000000000..c2f1a11a1 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app2/model/Tag.java @@ -0,0 +1,137 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app2.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.v3.oas.annotations.media.Schema; + +/** + * The type Tag. + */ +class Tag { + + /** + * The Id. + */ + @Schema(description = "") + private Long id = null; + + /** + * The Name. + */ + @Schema(description = "") + private String name = null; + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + * @param o the o + * @return the string + */ + private static String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Get id + * + * @return id id + */ + @JsonProperty("id") + public Long getId() { + return id; + } + + /** + * Sets id. + * + * @param id the id + */ + public void setId(Long id) { + this.id = id; + } + + /** + * Id tag. + * + * @param id the id + * @return the tag + */ + public Tag id(Long id) { + this.id = id; + return this; + } + + /** + * Get name + * + * @return name name + */ + @JsonProperty("name") + public String getName() { + return name; + } + + /** + * Sets name. + * + * @param name the name + */ + public void setName(String name) { + this.name = name; + } + + /** + * Name tag. + * + * @param name the name + * @return the tag + */ + public Tag name(String name) { + this.name = name; + return this; + } + + /** + * To string string. + * + * @return the string + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Tag {\n"); + + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append("}"); + return sb.toString(); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app2/model/User.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app2/model/User.java new file mode 100644 index 000000000..9248a9036 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app2/model/User.java @@ -0,0 +1,358 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app2.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.v3.oas.annotations.media.Schema; + +/** + * The type User. + */ +public class User { + + /** + * The Id. + */ + @Schema(description = "") + private Long id = null; + + /** + * The Username. + */ + @Schema(description = "") + private String username = null; + + /** + * The First name. + */ + @Schema(description = "") + private String firstName = null; + + /** + * The Last name. + */ + @Schema(description = "") + private String lastName = null; + + /** + * The Email. + */ + @Schema(description = "") + private String email = null; + + /** + * The Password. + */ + @Schema(description = "") + private String password = null; + + /** + * The Phone. + */ + @Schema(description = "") + private String phone = null; + + /** + * User Status + */ + private Integer userStatus = null; + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + * @param o the o + * @return the string + */ + private static String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Get id + * + * @return id id + */ + @JsonProperty("id") + public Long getId() { + return id; + } + + /** + * Sets id. + * + * @param id the id + */ + public void setId(Long id) { + this.id = id; + } + + /** + * Id user. + * + * @param id the id + * @return the user + */ + public User id(Long id) { + this.id = id; + return this; + } + + /** + * Get username + * + * @return username username + */ + @JsonProperty("username") + public String getUsername() { + return username; + } + + /** + * Sets username. + * + * @param username the username + */ + public void setUsername(String username) { + this.username = username; + } + + /** + * Username user. + * + * @param username the username + * @return the user + */ + public User username(String username) { + this.username = username; + return this; + } + + /** + * Get firstName + * + * @return firstName first name + */ + @JsonProperty("firstName") + public String getFirstName() { + return firstName; + } + + /** + * Sets first name. + * + * @param firstName the first name + */ + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + /** + * First name user. + * + * @param firstName the first name + * @return the user + */ + public User firstName(String firstName) { + this.firstName = firstName; + return this; + } + + /** + * Get lastName + * + * @return lastName last name + */ + @JsonProperty("lastName") + public String getLastName() { + return lastName; + } + + /** + * Sets last name. + * + * @param lastName the last name + */ + public void setLastName(String lastName) { + this.lastName = lastName; + } + + /** + * Last name user. + * + * @param lastName the last name + * @return the user + */ + public User lastName(String lastName) { + this.lastName = lastName; + return this; + } + + /** + * Get email + * + * @return email email + */ + @JsonProperty("email") + public String getEmail() { + return email; + } + + /** + * Sets email. + * + * @param email the email + */ + public void setEmail(String email) { + this.email = email; + } + + /** + * Email user. + * + * @param email the email + * @return the user + */ + public User email(String email) { + this.email = email; + return this; + } + + /** + * Get password + * + * @return password password + */ + @JsonProperty("password") + public String getPassword() { + return password; + } + + /** + * Sets password. + * + * @param password the password + */ + public void setPassword(String password) { + this.password = password; + } + + /** + * Password user. + * + * @param password the password + * @return the user + */ + public User password(String password) { + this.password = password; + return this; + } + + /** + * Get phone + * + * @return phone phone + */ + @JsonProperty("phone") + public String getPhone() { + return phone; + } + + /** + * Sets phone. + * + * @param phone the phone + */ + public void setPhone(String phone) { + this.phone = phone; + } + + /** + * Phone user. + * + * @param phone the phone + * @return the user + */ + public User phone(String phone) { + this.phone = phone; + return this; + } + + /** + * User Status + * + * @return userStatus user status + */ + @JsonProperty("userStatus") + public Integer getUserStatus() { + return userStatus; + } + + /** + * Sets user status. + * + * @param userStatus the user status + */ + public void setUserStatus(Integer userStatus) { + this.userStatus = userStatus; + } + + /** + * User status user. + * + * @param userStatus the user status + * @return the user + */ + public User userStatus(Integer userStatus) { + this.userStatus = userStatus; + return this; + } + + /** + * To string string. + * + * @return the string + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class User {\n"); + + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" username: ").append(toIndentedString(username)).append("\n"); + sb.append(" firstName: ").append(toIndentedString(firstName)).append("\n"); + sb.append(" lastName: ").append(toIndentedString(lastName)).append("\n"); + sb.append(" email: ").append(toIndentedString(email)).append("\n"); + sb.append(" password: ").append(toIndentedString(password)).append("\n"); + sb.append(" phone: ").append(toIndentedString(phone)).append("\n"); + sb.append(" userStatus: ").append(toIndentedString(userStatus)).append("\n"); + sb.append("}"); + return sb.toString(); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app20/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app20/HelloController.java new file mode 100644 index 000000000..3e899721e --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app20/HelloController.java @@ -0,0 +1,53 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app20; + +import io.swagger.v3.oas.annotations.Hidden; +import jakarta.validation.Valid; +import jakarta.validation.constraints.NotBlank; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * Persons. + * + * @param name the name + */ + @GetMapping(value = "/persons") + @Hidden + public void persons(@Valid @NotBlank String name) { + + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app20/SpringDocApp20Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app20/SpringDocApp20Test.java new file mode 100644 index 000000000..1d4fecbcd --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app20/SpringDocApp20Test.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app20; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 20 test. + */ +class SpringDocApp20Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app21/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app21/HelloController.java new file mode 100644 index 000000000..7a6e67727 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app21/HelloController.java @@ -0,0 +1,64 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app21; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.enums.SecuritySchemeType; +import io.swagger.v3.oas.annotations.security.OAuthFlow; +import io.swagger.v3.oas.annotations.security.OAuthFlows; +import io.swagger.v3.oas.annotations.security.OAuthScope; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.security.SecurityScheme; +import jakarta.validation.Valid; +import jakarta.validation.constraints.NotBlank; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +@SecurityScheme(name = "personstore_auth", type = SecuritySchemeType.OAUTH2, flows = @OAuthFlows(implicit = @OAuthFlow(authorizationUrl = "${springdoc.oAuthFlow.authorizationUrl}", scopes = { + @OAuthScope(name = "write:persons", description = "modify persons in your account"), + @OAuthScope(name = "read:persons", description = "read your persons") }))) +class HelloController { + + /** + * Persons. + * + * @param name the name + */ + @Operation(summary = "Add a new person to the store", description = "", security = { + @SecurityRequirement(name = "personstore_auth", scopes = { "write:persons", "read:persons" }) }, tags = { + "person" }) + @GetMapping(value = "/persons") + public void persons(@Valid @NotBlank String name) { + + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app21/SpringDocApp21Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app21/SpringDocApp21Test.java new file mode 100644 index 000000000..17cd76363 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app21/SpringDocApp21Test.java @@ -0,0 +1,45 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app21; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.test.context.TestPropertySource; + +/** + * The type Spring doc app 21 test. + */ +@TestPropertySource(properties = "springdoc.oAuthFlow.authorizationUrl=http://personstore.swagger.io/oauth/dialog") +class SpringDocApp21Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app22/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app22/HelloController.java new file mode 100644 index 000000000..8098c0d31 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app22/HelloController.java @@ -0,0 +1,52 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app22; + +import java.util.List; + +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + + /** + * Do get response entity. + * + * @return the response entity + */ + @GetMapping(value = "/persons") + public ResponseEntity>> doGet() { + return null; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app22/PersonDTO.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app22/PersonDTO.java new file mode 100644 index 000000000..4045bacc0 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app22/PersonDTO.java @@ -0,0 +1,120 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app22; + +/** + * The type Person dto. + */ +class PersonDTO { + /** + * The Email. + */ + private String email; + + /** + * The First name. + */ + private String firstName; + + /** + * The Last name. + */ + private String lastName; + + /** + * Instantiates a new Person dto. + */ + public PersonDTO() { + } + + /** + * Instantiates a new Person dto. + * + * @param email the email + * @param firstName the first name + * @param lastName the last name + */ + public PersonDTO(final String email, final String firstName, final String lastName) { + this.email = email; + this.firstName = firstName; + this.lastName = lastName; + } + + /** + * Gets email. + * + * @return the email + */ + public String getEmail() { + return email; + } + + /** + * Sets email. + * + * @param email the email + */ + public void setEmail(final String email) { + this.email = email; + } + + /** + * Gets first name. + * + * @return the first name + */ + public String getFirstName() { + return firstName; + } + + /** + * Sets first name. + * + * @param firstName the first name + */ + public void setFirstName(final String firstName) { + this.firstName = firstName; + } + + /** + * Gets last name. + * + * @return the last name + */ + public String getLastName() { + return lastName; + } + + /** + * Sets last name. + * + * @param lastName the last name + */ + public void setLastName(final String lastName) { + this.lastName = lastName; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app22/SpringDocApp22Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app22/SpringDocApp22Test.java new file mode 100644 index 000000000..b041e7144 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app22/SpringDocApp22Test.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app22; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 22 test. + */ +class SpringDocApp22Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app23/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app23/HelloController.java new file mode 100644 index 000000000..7da8708d2 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app23/HelloController.java @@ -0,0 +1,59 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app23; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.enums.SecuritySchemeIn; +import io.swagger.v3.oas.annotations.enums.SecuritySchemeType; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.security.SecurityScheme; +import jakarta.validation.Valid; +import jakarta.validation.constraints.NotBlank; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +@SecurityScheme(type = SecuritySchemeType.APIKEY, in = SecuritySchemeIn.HEADER, name = "Authorization", paramName = "JWT", description = "A core-auth Bearer token") +class HelloController { + + /** + * Persons. + * + * @param name the name + */ + @Operation(summary = "Add a new person to the store", description = "", security = { + @SecurityRequirement(name = "Authorization") }) + @GetMapping(value = "/persons") + public void persons(@Valid @NotBlank String name) { + + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app23/SpringDocApp23Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app23/SpringDocApp23Test.java new file mode 100644 index 000000000..5bce0629d --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app23/SpringDocApp23Test.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app23; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 23 test. + */ +class SpringDocApp23Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app24/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app24/HelloController.java new file mode 100644 index 000000000..bc254a5fc --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app24/HelloController.java @@ -0,0 +1,59 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app24; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.enums.SecuritySchemeIn; +import io.swagger.v3.oas.annotations.enums.SecuritySchemeType; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.security.SecurityScheme; +import jakarta.validation.Valid; +import jakarta.validation.constraints.NotBlank; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +@SecurityScheme(type = SecuritySchemeType.APIKEY, in = SecuritySchemeIn.HEADER, name = "Authorization", description = "A core-auth Bearer token") +class HelloController { + + /** + * Persons. + * + * @param name the name + */ + @Operation(summary = "Add a new person to the store", description = "", security = { + @SecurityRequirement(name = "Authorization") }) + @GetMapping(value = "/persons") + public void persons(@Valid @NotBlank String name) { + + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app24/SpringDocApp24Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app24/SpringDocApp24Test.java new file mode 100644 index 000000000..d4051f6be --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app24/SpringDocApp24Test.java @@ -0,0 +1,37 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app24; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +/** + * The type Spring doc app 24 test. + */ +class SpringDocApp24Test extends AbstractSpringDocTest { + + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app24/SpringDocTestApp.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app24/SpringDocTestApp.java new file mode 100644 index 000000000..2b94d5432 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app24/SpringDocTestApp.java @@ -0,0 +1,77 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app24; + +import io.swagger.v3.oas.models.Components; +import io.swagger.v3.oas.models.OpenAPI; +import io.swagger.v3.oas.models.headers.Header; +import io.swagger.v3.oas.models.info.Info; +import io.swagger.v3.oas.models.info.License; +import io.swagger.v3.oas.models.media.StringSchema; +import io.swagger.v3.oas.models.parameters.Parameter; +import io.swagger.v3.oas.models.security.SecurityScheme; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; + +/** + * The type Spring doc test app. + */ +@SpringBootApplication +class SpringDocTestApp { + + /** + * The entry point of application. + * + * @param args the input arguments + */ + public static void main(String[] args) { + SpringApplication.run(SpringDocTestApp.class, args); + } + + /** + * Custom open api open api. + * + * @return the open api + */ + @Bean + public OpenAPI customOpenAPI() { + return new OpenAPI() + .components(new Components() + .addSecuritySchemes("basicScheme", + new SecurityScheme().type(SecurityScheme.Type.HTTP).scheme("basic")) + .addParameters("myHeader1", + new Parameter().in("header").schema(new StringSchema()).name("myHeader1")) + .addHeaders("myHeader2", + new Header().description("myHeader2 header").schema(new StringSchema()))) + .info(new Info().title("Petstore API").version("v0").description( + "This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.") + .termsOfService("http://swagger.io/terms/") + .license(new License().name("Apache 2.0").url("http://springdoc.org"))); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app25/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app25/HelloController.java new file mode 100644 index 000000000..f2999f6e3 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app25/HelloController.java @@ -0,0 +1,109 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app25; + +import java.time.Instant; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.enums.ParameterIn; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; + +import org.springframework.http.HttpStatus; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.ResponseStatus; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * Check. + */ + @GetMapping(value = "/check") + @ResponseStatus(HttpStatus.OK) + void check() { + } + + /** + * List. + * + * @param trackerId the tracker id + * @param startDate the start date + * @param endDate the end date + */ + @GetMapping(value = "/list/{trackerId}") + void list( + + @Parameter(name = "trackerId", in = ParameterIn.PATH, required = true, schema = @Schema(type = "string", example = "the-tracker-id")) @PathVariable String trackerId, + @Parameter(name = "start", in = ParameterIn.QUERY, required = false, schema = @Schema(type = "string", format = "date-time", required = false, example = "1970-01-01T00:00:00.000Z")) @RequestParam(value = "start", required = false) Instant startDate, + @Parameter(name = "end", in = ParameterIn.QUERY, required = false, schema = @Schema(type = "string", format = "date-time", required = false, example = "1970-01-01T00:10:00.000Z")) @RequestParam(value = "end", required = false) Instant endDate) { + } + + /** + * Secondlist. + * + * @param trackerId the tracker id + * @param startDate the start date + * @param endDate the end date + */ + @GetMapping(value = "/secondlist/{trackerId}") + void secondlist( + @Parameter(name = "trackerId", in = ParameterIn.PATH, required = true, schema = @Schema(type = "string", example = "the-tracker-id")) @PathVariable String trackerId, + @Parameter(name = "start", in = ParameterIn.QUERY, required = false, schema = @Schema(type = "string", format = "date-time", required = false, example = "1970-01-01T00:00:00.000Z")) @RequestParam(value = "start", required = false) Instant startDate, + @Parameter(name = "end", in = ParameterIn.QUERY, required = false, schema = @Schema(type = "string", format = "date-time", required = false, example = "1970-01-01T00:10:00.000Z")) @RequestParam(value = "end", required = false) Instant endDate) { + + } + + /** + * Third list. + * + * @param trackerId the tracker id + * @param start the start + * @param end the end + * @param limit the limit + */ + @Operation(description = "Get last data from a tracker", parameters = { + @Parameter(name = "trackerId", in = ParameterIn.PATH, required = true, schema = @Schema(type = "string", example = "the-tracker-id")), + @Parameter(name = "start", in = ParameterIn.QUERY, required = false, schema = @Schema(type = "string", format = "date-time", required = false, example = "1970-01-01T00:00:00.000Z")), + @Parameter(name = "end", in = ParameterIn.QUERY, required = false, schema = @Schema(type = "string", format = "date-time", required = false, example = "1970-01-01T00:10:00.000Z")), + @Parameter(name = "limit", in = ParameterIn.QUERY, required = false, schema = @Schema(type = "number", required = false, example = "10")) }, responses = { + @ApiResponse(responseCode = "200") }) + + @GetMapping(value = "/values/{trackerId}/data") + void thirdList(@PathVariable String trackerId, @RequestParam(value = "start", required = false) Instant start, + @RequestParam(value = "end", required = false) Instant end, + @RequestParam(value = "limit", required = false) Integer limit) { + + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app25/SpringDocApp25Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app25/SpringDocApp25Test.java new file mode 100644 index 000000000..acfba1b74 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app25/SpringDocApp25Test.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app25; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 25 test. + */ +class SpringDocApp25Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app26/Bar.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app26/Bar.java new file mode 100644 index 000000000..05348a36b --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app26/Bar.java @@ -0,0 +1,56 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app26; + +/** + * The type Bar. + */ +class Bar { + /** + * The Bar. + */ + private String bar; + + /** + * Gets bar. + * + * @return the bar + */ + public String getBar() { + return bar; + } + + /** + * Sets bar. + * + * @param bar the bar + */ + public void setBar(String bar) { + this.bar = bar; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app26/Foo.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app26/Foo.java new file mode 100644 index 000000000..6422501c6 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app26/Foo.java @@ -0,0 +1,57 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app26; + +/** + * The type Foo. + */ +class Foo { + + /** + * The Foo. + */ + private String foo; + + /** + * Gets foo. + * + * @return the foo + */ + public String getFoo() { + return foo; + } + + /** + * Sets foo. + * + * @param foo the foo + */ + public void setFoo(String foo) { + this.foo = foo; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app26/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app26/HelloController.java new file mode 100644 index 000000000..b3fa71199 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app26/HelloController.java @@ -0,0 +1,49 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app26; + +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * Persons my model. + * + * @param myModel the my model + * @return the my model + */ + @PostMapping(value = "/persons") + public MyModel persons(MyModel myModel) { + return new MyModel(); + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app26/MyModel.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app26/MyModel.java new file mode 100644 index 000000000..0bb4e9424 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app26/MyModel.java @@ -0,0 +1,59 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app26; + +import io.swagger.v3.oas.annotations.media.Schema; + +/** + * The type My model. + */ +class MyModel { + + /** + * The Thing. + */ + @Schema(description = "Hello", type = "object", oneOf = { Foo.class, Bar.class }) + private Object thing; + + /** + * Gets thing. + * + * @return the thing + */ + public Object getThing() { + return thing; + } + + /** + * Sets thing. + * + * @param thing the thing + */ + public void setThing(Object thing) { + this.thing = thing; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app26/SpringDocApp26Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app26/SpringDocApp26Test.java new file mode 100644 index 000000000..676e1211d --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app26/SpringDocApp26Test.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app26; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 26 test. + */ +class SpringDocApp26Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app27/Advice.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app27/Advice.java new file mode 100644 index 000000000..d5800a0c5 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app27/Advice.java @@ -0,0 +1,82 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app27; + +import io.swagger.v3.oas.annotations.Hidden; + +import org.springframework.http.HttpStatus; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.ResponseStatus; +import org.springframework.web.bind.annotation.RestControllerAdvice; +import org.springframework.web.context.request.WebRequest; + +/** + * The type Advice. + */ +@RestControllerAdvice +class Advice { + + /** + * Handle exception foo. + * + * @param ex the ex + * @param request the request + * @return the foo + */ + @ExceptionHandler(Exception.class) + @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR) + public Foo handleException(Exception ex, WebRequest request) { + return new Foo(); + } + + /** + * Handle my exception bar. + * + * @param ex the ex + * @param request the request + * @return the bar + */ + @ExceptionHandler(MyException.class) + @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR) + public Bar handleMyException(MyException ex, WebRequest request) { + return new Bar(); + } + + /** + * Handle my exception 2 bar. + * + * @param ex the ex + * @param request the request + * @return the bar + */ + @Hidden + @ExceptionHandler(Throwable.class) + @ResponseStatus(HttpStatus.NOT_FOUND) + public Bar handleMyException2(MyException ex, WebRequest request) { + return new Bar(); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app27/Bar.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app27/Bar.java new file mode 100644 index 000000000..232eb2b14 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app27/Bar.java @@ -0,0 +1,37 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app27; + +/** + * The type Bar. + */ +class Bar { + /** + * The Bar. + */ + public String bar = "bar"; +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app27/Foo.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app27/Foo.java new file mode 100644 index 000000000..14d650eb7 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app27/Foo.java @@ -0,0 +1,37 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app27; + +/** + * The type Foo. + */ +class Foo { + /** + * The Foo. + */ + public String foo = "foo"; +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app27/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app27/HelloController.java new file mode 100644 index 000000000..1fd75f436 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app27/HelloController.java @@ -0,0 +1,65 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app27; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * The Flag. + */ + private boolean flag = false; + + /** + * Index string. + * + * @return the string + */ + @RequestMapping("/") + public String index() { + return ""; + } + + /** + * Test string. + * + * @return the string + */ + @GetMapping("/test") + public String test() { + flag = !flag; + throw flag ? new MyException() : new RuntimeException(); + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app27/MyException.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app27/MyException.java new file mode 100644 index 000000000..1a7451889 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app27/MyException.java @@ -0,0 +1,39 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app27; + +/** + * The type My exception. + */ +class MyException extends RuntimeException { + + /** + * The constant serialVersionUID. + */ + private static final long serialVersionUID = 1L; + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app27/SpringDocApp27Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app27/SpringDocApp27Test.java new file mode 100644 index 000000000..7131c9db4 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app27/SpringDocApp27Test.java @@ -0,0 +1,63 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app27; + +import org.junit.jupiter.api.Test; +import org.springdoc.core.utils.Constants; +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +import static org.hamcrest.Matchers.containsInAnyOrder; +import static org.hamcrest.Matchers.is; +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; + +/** + * The type Spring doc app 27 test. + */ +class SpringDocApp27Test extends AbstractSpringDocTest { + + /** + * Test app. + * + * @throws Exception the exception + */ + @Test + protected void testApp() throws Exception { + mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL)).andExpect(status().isOk()) + .andExpect(jsonPath("$.openapi", is("3.0.1"))).andExpect(jsonPath("$.paths./test.get.responses.500.content.['*/*'].schema.oneOf").isArray()).andExpect(jsonPath("$.paths./test.get.responses.500.content.['*/*'].schema.oneOf[*].$ref", containsInAnyOrder("#/components/schemas/Bar", + "#/components/schemas/Foo"))); + } + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app28/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app28/HelloController.java new file mode 100644 index 000000000..59b4a0d93 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app28/HelloController.java @@ -0,0 +1,52 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app28; + +import org.springframework.http.MediaType; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.multipart.MultipartFile; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * Upload 2 string. + * + * @param one the one + * @param two the two + * @return the string + */ + @PostMapping(value = "/upload2", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) + public String upload2(@RequestPart("one") MultipartFile one, @RequestPart("two") MultipartFile two) { + return "Ok"; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app28/SpringDocApp28Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app28/SpringDocApp28Test.java new file mode 100644 index 000000000..eda40b964 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app28/SpringDocApp28Test.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app28; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 28 test. + */ +class SpringDocApp28Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app29/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app29/HelloController.java new file mode 100644 index 000000000..9d0e6dd28 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app29/HelloController.java @@ -0,0 +1,62 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app29; + +import java.util.List; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.media.ArraySchema; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.parameters.RequestBody; +import io.swagger.v3.oas.annotations.responses.ApiResponse; + +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * Post entity list. + * + * @param postEntity the post entity + * @return the list + */ + @PostMapping(value = "/post-entity") + @Operation(description = "Post entity", + requestBody = @RequestBody(content = @Content(mediaType = "application/json", schema = @Schema(implementation = TrackerData.class))), + responses = + { @ApiResponse(responseCode = "200", content = @Content(mediaType = "application/json", array = @ArraySchema(schema = @Schema(implementation = TrackerData.class)))) }) + List postEntity(@RequestBody TrackerData postEntity) { + return null; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app29/SpringDocApp29Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app29/SpringDocApp29Test.java new file mode 100644 index 000000000..24f07d2d2 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app29/SpringDocApp29Test.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app29; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 29 test. + */ +class SpringDocApp29Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app29/TrackerData.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app29/TrackerData.java new file mode 100644 index 000000000..d05f6c62b --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app29/TrackerData.java @@ -0,0 +1,61 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app29; + +import java.time.Instant; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.v3.oas.annotations.media.Schema; + +/** + * The type Tracker data. + */ +@Schema(name = "TrackerData") +class TrackerData { + + /** + * The Tracker id. + */ + @Schema(name = "trackerId", type = "string", required = true, example = "the-tracker-id") + @JsonProperty("trackerId") + String trackerId; + + /** + * The Timestamp. + */ + @Schema(name = "timestamp", type = "string", format = "date-time", required = true, example = "2018-01-01T00:00:00Z") + @JsonProperty("timestamp") + Instant timestamp; + + /** + * The Value. + */ + @Schema(name = "value", type = "number", format = "double", description = "The data value", required = true, example = "19.0") + @JsonProperty("value") + Double value; + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app3/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app3/HelloController.java new file mode 100644 index 000000000..436d62124 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app3/HelloController.java @@ -0,0 +1,52 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app3; + +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * Echo playing card. + * + * @param card the card baby + * @param toto the toto baby + * @return the playing card baby + */ + @PostMapping + public PersonDTO echo(@RequestBody PlayingCard card, @RequestParam String toto) { + return null; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app3/PersonDTO.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app3/PersonDTO.java new file mode 100644 index 000000000..8b930f831 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app3/PersonDTO.java @@ -0,0 +1,121 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app3; + +/** + * The type Person dto. + */ +class PersonDTO { + + /** + * The email + */ + private String email; + + /** + * The firstName + */ + private String firstName; + + /** + * The lastName + */ + private String lastName; + + /** + * Instantiates a new Person dto. + */ + public PersonDTO() { + } + + /** + * Instantiates a new Person dto. + * + * @param email the email + * @param firstName the first name + * @param lastName the last name + */ + public PersonDTO(final String email, final String firstName, final String lastName) { + this.email = email; + this.firstName = firstName; + this.lastName = lastName; + } + + /** + * Gets email. + * + * @return the email + */ + public String getEmail() { + return email; + } + + /** + * Sets email. + * + * @param email the email + */ + public void setEmail(final String email) { + this.email = email; + } + + /** + * Gets first name. + * + * @return the first name + */ + public String getFirstName() { + return firstName; + } + + /** + * Sets first name. + * + * @param firstName the first name + */ + public void setFirstName(final String firstName) { + this.firstName = firstName; + } + + /** + * Gets last name. + * + * @return the last name + */ + public String getLastName() { + return lastName; + } + + /** + * Sets last name. + * + * @param lastName the last name + */ + public void setLastName(final String lastName) { + this.lastName = lastName; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app3/PlayingCard.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app3/PlayingCard.java new file mode 100644 index 000000000..6575be910 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app3/PlayingCard.java @@ -0,0 +1,151 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app3; + +import java.util.Date; + +import com.fasterxml.jackson.annotation.JsonValue; + +/** + * The type Playing card. + */ +class PlayingCard { + /** + * The Suit. + */ + private Suit suit; + + /** + * The Value. + */ + private Integer value; + + /** + * The Toto. + */ + private Date toto; + + /** + * Gets toto. + * + * @return the toto + */ + public Date getToto() { + return toto; + } + + /** + * Sets toto. + * + * @param toto the toto + */ + public void setToto(Date toto) { + this.toto = toto; + } + + /** + * Gets suit. + * + * @return the suit + */ + public Suit getSuit() { + return suit; + } + + /** + * Sets suit. + * + * @param suit the suit + */ + public void setSuit(Suit suit) { + this.suit = suit; + } + + /** + * Gets value. + * + * @return the value + */ + public Integer getValue() { + return value; + } + + /** + * Sets value. + * + * @param value the value + */ + public void setValue(Integer value) { + this.value = value; + } + + /** + * The enum Suit. + */ + public enum Suit { + /** + *Hearts suit. + */ + HEARTS("Hearts"), + /** + *Diamonds suit. + */ + DIAMONDS("Diamonds"), + /** + *Clubs suit. + */ + CLUBS("Clubs"), + /** + *Spades suit. + */ + SPADES("Spades"); + + /** + * The Json value. + */ + private final String jsonValue; + + /** + * Instantiates a new Suit. + * + * @param jsonValue the json value + */ + Suit(String jsonValue) { + this.jsonValue = jsonValue; + } + + /** + * Gets json value. + * + * @return the json value + */ + @JsonValue + public String getJsonValue() { + return jsonValue; + } + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app3/SpringDocApp3Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app3/SpringDocApp3Test.java new file mode 100644 index 000000000..293b12b37 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app3/SpringDocApp3Test.java @@ -0,0 +1,42 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app3; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 3 test. + */ +class SpringDocApp3Test extends AbstractSpringDocTest { + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app30/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app30/HelloController.java new file mode 100644 index 000000000..bd35f10a7 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app30/HelloController.java @@ -0,0 +1,51 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app30; + +import org.springframework.http.MediaType; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * Echo string. + * + * @param text the text + * @return the string + */ + @GetMapping(produces = MediaType.TEXT_PLAIN_VALUE, path = "/test") + public String echo(@RequestParam(name = "text", defaultValue = "Hello, World!") String text) { + return text; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app30/SpringDocApp30Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app30/SpringDocApp30Test.java new file mode 100644 index 000000000..3968b0316 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app30/SpringDocApp30Test.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app30; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 30 test. + */ +class SpringDocApp30Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app31/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app31/HelloController.java new file mode 100644 index 000000000..2e8d6b126 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app31/HelloController.java @@ -0,0 +1,99 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app31; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.callbacks.Callback; +import io.swagger.v3.oas.annotations.enums.ParameterIn; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; + +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestHeader; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * Subscribe subscription response. + * + * @param token the token + * @param url the url + * @return the subscription response + */ + @PostMapping("/test") + @Callback(callbackUrlExpression = "http://$request.query.url", name = "subscription", operation = { + @Operation(method = "post", description = "payload data will be sent", parameters = { + @Parameter(in = ParameterIn.PATH, name = "subscriptionId", required = true, schema = @Schema(type = "string", format = "uuid", description = "the generated UUID", accessMode = Schema.AccessMode.READ_ONLY)) }, responses = { + @ApiResponse(responseCode = "200", description = "Return this code if the callback was received and processed successfully"), + @ApiResponse(responseCode = "205", description = "Return this code to unsubscribe from future data updates"), + @ApiResponse(responseCode = "default", description = "All other response codes will disable this callback subscription") }) }) + @Operation(description = "subscribes a client to updates relevant to the requestor's account, as " + + "identified by the input token. The supplied url will be used as the delivery address for response payloads") + public SubscriptionResponse subscribe(@Schema(required = true, description = "the authentication token " + + "provided after initially authenticating to the application") @RequestHeader("x-auth-token") String token, + @Schema(required = true, description = "the URL to call with response " + + "data") @RequestParam("url") String url) { + return null; + } + + /** + * The type Subscription response. + */ + static class SubscriptionResponse { + /** + * The Subscription uuid. + */ + private String subscriptionUuid; + + /** + * Gets subscription uuid. + * + * @return the subscription uuid + */ + public String getSubscriptionUuid() { + return subscriptionUuid; + } + + /** + * Sets subscription uuid. + * + * @param subscriptionUuid the subscription uuid + */ + public void setSubscriptionUuid(String subscriptionUuid) { + this.subscriptionUuid = subscriptionUuid; + } + + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app31/SpringDocApp31Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app31/SpringDocApp31Test.java new file mode 100644 index 000000000..0364650ca --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app31/SpringDocApp31Test.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app31; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 31 test. + */ +class SpringDocApp31Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app32/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app32/HelloController.java new file mode 100644 index 000000000..201f11499 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app32/HelloController.java @@ -0,0 +1,75 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app32; + +import io.swagger.v3.oas.annotations.parameters.RequestBody; + +import org.springframework.http.HttpStatus; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.ResponseStatus; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * Filter post string. + * + * @param filter the filter + * @return the string + */ + @RequestMapping(value = "/filter", method = RequestMethod.POST) + @ResponseStatus(value = HttpStatus.OK) + public String filterPost(@RequestBody final MyTestDto filter) { + return "OK"; + } + + /** + * The type My test dto. + */ + class MyTestDto { + /** + * The Object 1. + */ + public String object1; + + /** + * The Object 2. + */ + public String object2; + + /** + * The Object 3. + */ + public String object3; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app32/SpringDocApp32Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app32/SpringDocApp32Test.java new file mode 100644 index 000000000..f845e714b --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app32/SpringDocApp32Test.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app32; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 32 test. + */ +class SpringDocApp32Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app33/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app33/HelloController.java new file mode 100644 index 000000000..1a060e058 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app33/HelloController.java @@ -0,0 +1,56 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app33; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.responses.ApiResponse; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + * + * @param the type parameter + */ +@RestController +class HelloController { + + /** + * Index t. + * + * @param numTel the num tel + * @param adresse the adresse + * @return the t + */ + @GetMapping(value = "/hello/{numTelco}") + @Operation(summary = "GET Persons", responses = @ApiResponse(responseCode = "418")) + public T index(@PathVariable("numTelco") String numTel, String adresse) { + return null; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app33/SpringDocApp33Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app33/SpringDocApp33Test.java new file mode 100644 index 000000000..fb5c63a63 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app33/SpringDocApp33Test.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app33; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 33 test. + */ +class SpringDocApp33Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app34/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app34/HelloController.java new file mode 100644 index 000000000..24483ad61 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app34/HelloController.java @@ -0,0 +1,56 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app34; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.responses.ApiResponse; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + * + * @param the type parameter + */ +@RestController +class HelloController { + + /** + * Index t. + * + * @param numTel the num tel + * @param adresse the adresse + * @return the t + */ + @GetMapping(value = "/hello/{numTelco}") + @Operation(summary = "GET Persons", responses = @ApiResponse(responseCode = "418")) + public T index(@PathVariable("numTelco") String numTel, String adresse) { + return null; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app34/MyExceptionHandler.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app34/MyExceptionHandler.java new file mode 100644 index 000000000..757eab474 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app34/MyExceptionHandler.java @@ -0,0 +1,66 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app34; + +import io.swagger.v3.oas.annotations.Hidden; + +import org.springframework.http.HttpStatus; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.ResponseStatus; +import org.springframework.web.bind.annotation.RestControllerAdvice; +import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler; + +/** + * The type My exception handler. + */ +@RestControllerAdvice +@Hidden +class MyExceptionHandler extends ResponseEntityExceptionHandler { + /** + * Bad object. + * + * @param e the e + * @return the object + */ + @ExceptionHandler(IllegalArgumentException.class) + @ResponseStatus(HttpStatus.BAD_REQUEST) + public Object bad(IllegalArgumentException e) { + return null; + } + + /** + * Gateway object. + * + * @param e the e + * @return the object + */ + @ExceptionHandler(RuntimeException.class) + @ResponseStatus(HttpStatus.BAD_GATEWAY) + public Object gateway(RuntimeException e) { + return null; + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app34/SpringDocApp34Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app34/SpringDocApp34Test.java new file mode 100644 index 000000000..b25bed593 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app34/SpringDocApp34Test.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app34; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 34 test. + */ +class SpringDocApp34Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app35/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app35/HelloController.java new file mode 100644 index 000000000..8023984ad --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app35/HelloController.java @@ -0,0 +1,73 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app35; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; + +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; + +/** + * The type Hello controller. + */ +@Controller +@RequestMapping("/api/v1/poc/") +class HelloController { + + /** + * Testme response entity. + * + * @return the response entity + */ + @Operation(summary = "Get thing", responses = { + @ApiResponse(description = "Successful Operation", responseCode = "200", content = @Content(mediaType = "application/json", schema = @Schema(implementation = String.class))), + @ApiResponse(responseCode = "404", description = "Not found", content = @Content), + @ApiResponse(responseCode = "401", description = "Authentication Failure", content = @Content(schema = @Schema(hidden = true))) }) + @RequestMapping(path = "/testme", method = RequestMethod.GET) + ResponseEntity testme() { + return ResponseEntity.ok("Hello"); + } + + /** + * Test response entity. + * + * @return the response entity + */ + @Operation(summary = "Get thing", responses = { + @ApiResponse(description = "Successful Operation", responseCode = "200", content = @Content(mediaType = "application/json", schema = @Schema(implementation = String.class))), + @ApiResponse(responseCode = "404", description = "Not found", content = @Content(schema = @Schema(hidden = true))), + @ApiResponse(responseCode = "401", description = "Authentication Failure", content = @Content(schema = @Schema(hidden = true))) }) + @RequestMapping(path = "/test", method = RequestMethod.GET) + ResponseEntity test() { + return ResponseEntity.ok("Hello"); + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app35/SpringDocApp35Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app35/SpringDocApp35Test.java new file mode 100644 index 000000000..102d0c163 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app35/SpringDocApp35Test.java @@ -0,0 +1,49 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app35; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +import static org.springdoc.core.utils.SpringDocUtils.getConfig; + +/** + * The type Spring doc app 35 test. + */ +class SpringDocApp35Test extends AbstractSpringDocTest { + + static { + getConfig().addRestControllers(HelloController.class); + } + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app37/Bar.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app37/Bar.java new file mode 100644 index 000000000..54516162e --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app37/Bar.java @@ -0,0 +1,37 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app37; + +/** + * The type Bar. + */ +class Bar { + /** + * The Bar. + */ + public String bar = "bar"; +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app37/Car.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app37/Car.java new file mode 100644 index 000000000..d557c4abb --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app37/Car.java @@ -0,0 +1,38 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app37; + +/** + * The type Car. + */ +class Car { + /** + * The Car. + */ + public String car = "car"; + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app37/Foo.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app37/Foo.java new file mode 100644 index 000000000..90f94ebd6 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app37/Foo.java @@ -0,0 +1,37 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app37; + +/** + * The type Foo. + */ +class Foo { + /** + * The Foo. + */ + public String foo = "foo"; +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app37/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app37/HelloController.java new file mode 100644 index 000000000..5126211ad --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app37/HelloController.java @@ -0,0 +1,99 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app37; + +import io.swagger.v3.oas.annotations.parameters.RequestBody; +import jakarta.validation.Valid; + +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController("/api") +class HelloController { + + /** + * Process foo. + * + * @param a the a + * @return the foo + */ + @PostMapping(path = "/bar/baz", consumes = "application/x.a+json", produces = MediaType.TEXT_PLAIN_VALUE) + public Foo process(@RequestBody Foo a) { + return a; + } + + /** + * Process bar. + * + * @param b the b + * @return the bar + */ + @PostMapping(path = "/bar/baz", consumes = "application/x.b+json", produces = MediaType.TEXT_PLAIN_VALUE) + public Bar process(@RequestBody Bar b) { + return b; + } + + /** + * Process car. + * + * @param c the c + * @return the car + */ + @PostMapping(path = "/bar/baz", consumes = "application/x.c+json", produces = MediaType.APPLICATION_JSON_VALUE) + public Car process(@RequestBody Car c) { + return c; + } + + + /** + * Pets post response entity. + * + * @param pet the pet + * @return the response entity + */ + @PostMapping(value = "/pets1", consumes = "text/plain") + public ResponseEntity petsPost1(@Valid @RequestBody String pet) { + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); + } + + /** + * Pets post response entity. + * + * @param pet the pet + * @return the response entity + */ + @PostMapping(value = "/pets2", consumes = "application/json") + public ResponseEntity petsPost2(@Valid @RequestBody Pet pet) { + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app37/Pet.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app37/Pet.java new file mode 100644 index 000000000..4ebad7d77 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app37/Pet.java @@ -0,0 +1,38 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app37; + +/** + * The type Pet. + */ +class Pet { + /** + * The Pet. + */ + public String pet = "pet"; + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app37/SpringDocApp37Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app37/SpringDocApp37Test.java new file mode 100644 index 000000000..1019d24f1 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app37/SpringDocApp37Test.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app37; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 37 test. + */ +class SpringDocApp37Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app38/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app38/HelloController.java new file mode 100644 index 000000000..1a20a7ff5 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app38/HelloController.java @@ -0,0 +1,51 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app38; + +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController("/api") +class HelloController { + + /** + * Gets model resource. + * + * @return the model resource + */ + @RequestMapping(value = "/npe_error", method = RequestMethod.GET) + public ResponseEntity getModelResource() { + return new ResponseEntity<>(new byte[0], HttpStatus.OK); + } + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app38/SpringDocApp38Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app38/SpringDocApp38Test.java new file mode 100644 index 000000000..26e02e666 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app38/SpringDocApp38Test.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app38; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 38 test. + */ +class SpringDocApp38Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app39/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app39/HelloController.java new file mode 100644 index 000000000..0f6e2b8b4 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app39/HelloController.java @@ -0,0 +1,64 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app39; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.parameters.RequestBody; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * Search employee. + * + * @param test the test + */ + @Operation(summary = "test Request") + @RequestBody(description = "test value", required = true, content = @Content(schema = @Schema(implementation = String.class))) + @PostMapping("/test") + public void searchEmployee(String test) { + } + + /** + * Hello string. + * + * @return the string + */ + @GetMapping("/hello") + public String hello() { + return "hello"; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app39/SpringDocApp39Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app39/SpringDocApp39Test.java new file mode 100644 index 000000000..c1fc8b815 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app39/SpringDocApp39Test.java @@ -0,0 +1,37 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app39; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +/** + * The type Spring doc app 39 test. + */ +class SpringDocApp39Test extends AbstractSpringDocTest { + + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app39/SpringDocTestApp.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app39/SpringDocTestApp.java new file mode 100644 index 000000000..8af3b7043 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app39/SpringDocTestApp.java @@ -0,0 +1,76 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app39; + +import io.swagger.v3.oas.models.Components; +import io.swagger.v3.oas.models.OpenAPI; +import io.swagger.v3.oas.models.media.StringSchema; +import io.swagger.v3.oas.models.parameters.HeaderParameter; +import org.springdoc.core.customizers.OpenApiCustomizer; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; + +/** + * The type Spring doc test app. + */ +@SpringBootApplication +class SpringDocTestApp { + + /** + * The entry point of application. + * + * @param args the input arguments + */ + public static void main(String[] args) { + SpringApplication.run(SpringDocTestApp.class, args); + } + + /** + * Custom open api open api. + * + * @return the open api + */ + @Bean + public OpenAPI customOpenAPI() { + StringSchema schema = new StringSchema(); + return new OpenAPI() + .components(new Components().addParameters("myGlobalHeader", new HeaderParameter().required(true).name("My-Global-Header").description("My Global Header").schema(schema))); + } + + /** + * Customer global header open api customiser open api customiser. + * + * @return the open api customiser + */ + @Bean + public OpenApiCustomizer customerGlobalHeaderOpenApiCustomizer() { + return openApi -> openApi.getPaths().values().stream().flatMap(pathItem -> pathItem.readOperations().stream()) + .forEach(operation -> operation.addParametersItem(new HeaderParameter().$ref("#/components/parameters/myGlobalHeader"))); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app4/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app4/HelloController.java new file mode 100644 index 000000000..46c19fdd2 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app4/HelloController.java @@ -0,0 +1,50 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app4; + +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * List tracker data. + * + * @param toto the toto + * @return the tracker data + */ + @PostMapping(value = "/values/data") + TrackerData list(TrackerData toto) { + return toto; + + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app4/SpringDocApp4Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app4/SpringDocApp4Test.java new file mode 100644 index 000000000..f81ae0c11 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app4/SpringDocApp4Test.java @@ -0,0 +1,55 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app4; + +import io.swagger.v3.core.jackson.TypeNameResolver; +import org.junit.jupiter.api.AfterAll; +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.test.context.TestPropertySource; + +/** + * The type Spring doc app 4 test. + */ +@TestPropertySource(properties = "springdoc.use-fqn=true") +class SpringDocApp4Test extends AbstractSpringDocTest { + + /** + * Restore. + */ + @AfterAll + static void restore() { + TypeNameResolver.std.setUseFqn(false); + } + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app4/TrackerData.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app4/TrackerData.java new file mode 100644 index 000000000..cfa99ec6c --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app4/TrackerData.java @@ -0,0 +1,60 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app4; + +import java.time.Instant; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.v3.oas.annotations.media.Schema; + +/** + * The type Tracker data. + */ +class TrackerData { + + /** + * The Tracker id. + */ + @Schema(name = "trackerId", type = "string", required = true, example = "the-tracker-id") + @JsonProperty("trackerId") + String trackerId; + + /** + * The Timestamp. + */ + @Schema(name = "timestamp", type = "string", format = "date-time", required = true, example = "2018-01-01T00:00:00Z") + @JsonProperty("timestamp") + Instant timestamp; + + /** + * The Value. + */ + @Schema(name = "value", type = "number", format = "double", description = "The data value", required = true, example = "19.0") + @JsonProperty("value") + Double value; + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app40/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app40/HelloController.java new file mode 100644 index 000000000..e8ef58a7d --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app40/HelloController.java @@ -0,0 +1,50 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app40; + +import com.fasterxml.jackson.databind.node.ObjectNode; + +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController("/api") +class HelloController { + + /** + * Gets start form properties. + * + * @return the start form properties + */ + @RequestMapping(value = "/iae_error", method = RequestMethod.GET) + public ObjectNode getStartFormProperties() { + return null; + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app40/SpringDocApp40Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app40/SpringDocApp40Test.java new file mode 100644 index 000000000..5a0c6b75d --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app40/SpringDocApp40Test.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app40; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 40 test. + */ +class SpringDocApp40Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app41/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app41/HelloController.java new file mode 100644 index 000000000..e85122053 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app41/HelloController.java @@ -0,0 +1,68 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app41; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; +import jakarta.validation.Valid; +import jakarta.validation.constraints.NotNull; + +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController("/api") +class HelloController { + + /** + * Gets file. + * + * @param path the path + * @return the file + */ + @Operation(description = "Download file") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "File resource", content = @Content(schema = @Schema(implementation = java.io.File.class))), + @ApiResponse(responseCode = "400", description = "Wrong request", content = @Content(schema = @Schema(implementation = Error.class))), + @ApiResponse(responseCode = "500", description = "Unexpected error", content = @Content(schema = @Schema(implementation = Error.class))) }) + @GetMapping(value = "/file", produces = MediaType.APPLICATION_JSON_VALUE) + public ResponseEntity getFile( + @NotNull @Parameter(description = "File path", required = true) @Valid @RequestParam(value = "path") String path) { + return ResponseEntity.status(HttpStatus.NOT_IMPLEMENTED).build(); + } + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app41/SpringDocApp411Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app41/SpringDocApp411Test.java new file mode 100644 index 000000000..c4c34d1cb --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app41/SpringDocApp411Test.java @@ -0,0 +1,78 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app41; + +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; + +import org.junit.jupiter.api.Test; +import org.springdoc.core.utils.Constants; +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +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; + +/** + * The type Spring doc app 411 test. + */ +class SpringDocApp411Test extends AbstractSpringDocTest { + + /** + * Test app. + * + * @throws Exception the exception + */ + @Test + protected void testApp() throws Exception { + String className = getClass().getSimpleName(); + String testNumber = className.replaceAll("[^0-9]", ""); + MvcResult mockMvcResult = mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL)).andExpect(status().isOk()) + .andExpect(jsonPath("$.openapi", is("3.0.1"))).andReturn(); + // Test result consistency + mockMvcResult = mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL)).andExpect(status().isOk()) + .andExpect(jsonPath("$.openapi", is("3.0.1"))).andReturn(); + String result = mockMvcResult.getResponse().getContentAsString(); + Path path = Paths.get(getClass().getClassLoader().getResource("results/3.0.1/app41.json").toURI()); + byte[] fileBytes = Files.readAllBytes(path); + String expected = new String(fileBytes); + assertEquals(expected, result, false); + } + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app41/SpringDocApp41Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app41/SpringDocApp41Test.java new file mode 100644 index 000000000..258a6c9d6 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app41/SpringDocApp41Test.java @@ -0,0 +1,80 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app41; + +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; + +import org.junit.jupiter.api.Test; +import org.springdoc.core.utils.Constants; +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +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; + +/** + * The type Spring doc app 41 test. + */ +@TestPropertySource(properties = "springdoc.cache.disabled=true") +class SpringDocApp41Test extends AbstractSpringDocTest { + + /** + * Test app. + * + * @throws Exception the exception + */ + @Test + protected void testApp() throws Exception { + String className = getClass().getSimpleName(); + String testNumber = className.replaceAll("[^0-9]", ""); + MvcResult mockMvcResult = mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL)).andExpect(status().isOk()) + .andExpect(jsonPath("$.openapi", is("3.0.1"))).andReturn(); + // Test result consistency + mockMvcResult = mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL)).andExpect(status().isOk()) + .andExpect(jsonPath("$.openapi", is("3.0.1"))).andReturn(); + String result = mockMvcResult.getResponse().getContentAsString(); + Path path = Paths.get(getClass().getClassLoader().getResource("results/3.0.1/app" + testNumber + ".json").toURI()); + byte[] fileBytes = Files.readAllBytes(path); + String expected = new String(fileBytes); + assertEquals(expected, result, false); + } + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app42/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app42/HelloController.java new file mode 100644 index 000000000..59ee9c8f2 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app42/HelloController.java @@ -0,0 +1,50 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app42; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RestController; + + +/** + * The type Hello controller. + */ +@RestController("/api") +class HelloController { + + /** + * Tweets. + * + * @param id the id + */ + @GetMapping(value = "/tweets/{id}") + public void tweets(@PathVariable TweetId id) { + + } + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app42/SpringDocApp42Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app42/SpringDocApp42Test.java new file mode 100644 index 000000000..64f06b051 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app42/SpringDocApp42Test.java @@ -0,0 +1,58 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app42; + +import io.swagger.v3.oas.models.Components; +import io.swagger.v3.oas.models.OpenAPI; +import io.swagger.v3.oas.models.media.StringSchema; +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; + +/** + * The type Spring doc app 42 test. + */ +class SpringDocApp42Test extends AbstractSpringDocTest { + + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp { + /** + * Custom open api open api. + * + * @return the open api + */ + @Bean + public OpenAPI customOpenAPI() { + return new OpenAPI().components(new Components().addSchemas("TweetId", new StringSchema())); + } + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app42/TweetId.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app42/TweetId.java new file mode 100644 index 000000000..ded1a4b3d --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app42/TweetId.java @@ -0,0 +1,55 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app42; + +/** + * The type Tweet id. + */ +class TweetId { + /** + * The Value. + */ + private final String value; + + /** + * Instantiates a new Tweet id. + * + * @param value the value + */ + public TweetId(String value) { + this.value = value; + } + + /** + * Gets value. + * + * @return the value + */ + public String getValue() { + return value; + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app43/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app43/HelloController.java new file mode 100644 index 000000000..5717612e9 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app43/HelloController.java @@ -0,0 +1,54 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app43; + +import java.util.List; + +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.multipart.MultipartFile; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * Upload documents response entity. + * + * @param multipartFiles the multipart files + * @return the response entity + */ + @PostMapping(path = "/documents", consumes = "multipart/form-data") + public ResponseEntity uploadDocuments(@RequestPart("doc") List multipartFiles) { + return null; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app43/SpringDocApp43Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app43/SpringDocApp43Test.java new file mode 100644 index 000000000..67e8ff37f --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app43/SpringDocApp43Test.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app43; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 43 test. + */ +class SpringDocApp43Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app44/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app44/HelloController.java new file mode 100644 index 000000000..8758ad533 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app44/HelloController.java @@ -0,0 +1,234 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app44; + +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; + +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController("/api") +class HelloController { + + /** + * Hello response entity. + * + * @param request the request + * @return the response entity + */ + @PostMapping(value = "/helloworld", produces = "application/json", consumes = "application/vnd.v1+json") + @ApiResponses({ + @ApiResponse(responseCode = "200", description = "Successful operation", content = @Content(schema = @Schema(implementation = HelloDTO1.class))), + @ApiResponse(responseCode = "400", description = "Bad name", content = @Content(schema = @Schema(implementation = ErrorDTO.class))) }) + public ResponseEntity hello(@RequestBody RequestV1 request) { + final String name = request.getNameV1(); + if ("error".equalsIgnoreCase(name)) { + return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ErrorDTO("invalid name: " + name)); + } + return ResponseEntity.ok(new HelloDTO1("Greetings from Spring Boot v1! " + name)); + } + + /** + * Hello response entity. + * + * @param request the request + * @return the response entity + */ + @PostMapping(value = "/helloworld", produces = "application/json", consumes = "application/vnd.v2+json") + @ApiResponses({ + @ApiResponse(responseCode = "200", description = "Successful operation", content = @Content(schema = @Schema(implementation = HelloDTO2.class))), + @ApiResponse(responseCode = "400", description = "Bad name", content = @Content(schema = @Schema(implementation = ErrorDTO.class))) }) + public ResponseEntity hello(@RequestBody RequestV2 request) { + final String name = request.getNameV2(); + if ("error".equalsIgnoreCase(name)) { + return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ErrorDTO("invalid name: " + name)); + } + return ResponseEntity.ok(new HelloDTO2("Greetings from Spring Boot v2! " + name)); + } + + /** + * The type Request v 1. + */ + static class RequestV1 { + /** + * The Name v 1. + */ + private String nameV1; + + /** + * Instantiates a new Request v 1. + */ + public RequestV1() { + } + + /** + * Gets name v 1. + * + * @return the name v 1 + */ + public String getNameV1() { + return nameV1; + } + + /** + * Sets name v 1. + * + * @param nameV1 the name v 1 + */ + public void setNameV1(String nameV1) { + this.nameV1 = nameV1; + } + } + + /** + * The type Request v 2. + */ + static class RequestV2 { + /** + * The Name v 2. + */ + private String nameV2; + + /** + * Instantiates a new Request v 2. + */ + public RequestV2() { + } + + /** + * Gets name v 2. + * + * @return the name v 2 + */ + public String getNameV2() { + return nameV2; + } + + /** + * Sets name v 2. + * + * @param nameV2 the name v 2 + */ + public void setNameV2(String nameV2) { + this.nameV2 = nameV2; + } + } + + /** + * The type Hello dto 1. + */ + class HelloDTO1 { + /** + * The Message. + */ + private String message; + + /** + * Instantiates a new Hello dto 1. + * + * @param message the message + */ + public HelloDTO1(String message) { + this.message = message; + } + + /** + * Gets message. + * + * @return the message + */ + public String getMessage() { + return message; + } + } + + /** + * The type Hello dto 2. + */ + class HelloDTO2 { + /** + * The Message. + */ + private String message; + + /** + * Instantiates a new Hello dto 2. + * + * @param message the message + */ + public HelloDTO2(String message) { + this.message = message; + } + + /** + * Gets message. + * + * @return the message + */ + public String getMessage() { + return message; + } + } + + /** + * The type Error dto. + */ + class ErrorDTO { + /** + * The Error message. + */ + private String errorMessage; + + /** + * Instantiates a new Error dto. + * + * @param errorMessage the error message + */ + public ErrorDTO(String errorMessage) { + this.errorMessage = errorMessage; + } + + /** + * Gets error message. + * + * @return the error message + */ + public String getErrorMessage() { + return errorMessage; + } + } + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app44/SpringDocApp44Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app44/SpringDocApp44Test.java new file mode 100644 index 000000000..c2c9c52a5 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app44/SpringDocApp44Test.java @@ -0,0 +1,68 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app44; + +import org.junit.jupiter.api.Test; +import org.springdoc.core.utils.Constants; +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +import static org.hamcrest.Matchers.containsInAnyOrder; +import static org.hamcrest.Matchers.is; +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; + +/** + * The type Spring doc app 44 test. + */ +class SpringDocApp44Test extends AbstractSpringDocTest { + + /** + * Test app. + * + * @throws Exception the exception + */ + @Test + protected void testApp() throws Exception { + mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL)).andExpect(status().isOk()) + .andExpect(jsonPath("$.openapi", is("3.0.1"))).andExpect(jsonPath("$.paths./helloworld.post.responses.200.content.['application/json'].schema.oneOf").isArray()).andExpect(jsonPath("$.paths./helloworld.post.responses.200.content.['application/json'].schema.oneOf[*].$ref", containsInAnyOrder("#/components/schemas/HelloDTO2", + "#/components/schemas/HelloDTO1"))) + .andExpect(jsonPath("$.paths./helloworld.post.requestBody.content.['application/vnd.v1+json'].schema.$ref", is("#/components/schemas/RequestV1"))) + .andExpect(jsonPath("$.paths./helloworld.post.requestBody.content.['application/vnd.v2+json'].schema.$ref", is("#/components/schemas/RequestV2"))) + .andExpect(jsonPath("$.paths./helloworld.post.responses.400.content.['application/json'].schema.$ref", is("#/components/schemas/ErrorDTO"))); + + } + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app45/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app45/HelloController.java new file mode 100644 index 000000000..01f3f23a5 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app45/HelloController.java @@ -0,0 +1,84 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app45; + +import java.util.Collections; +import java.util.List; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.media.ArraySchema; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.tags.Tag; + +import org.springframework.http.MediaType; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + + +/** + * The type Hello controller. + */ +@Tag(name = "People", description = "Use this resource to serve all requests and initiate all operations related to people") +@RestController +@RequestMapping(value = "/v1/people") +class HelloController { + + + /** + * List list. + * + * @return the list + */ + @Operation(description = "List all persons") + @SecurityRequirement(name = "bearer") + @ApiResponse(responseCode = "200", description = "", content = @Content(array = @ArraySchema(schema = @Schema(implementation = PersonDTO.class)))) + @GetMapping(path = "/list", consumes = MediaType.ALL_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) + public List list() { + PersonDTO person = new PersonDTO(); + person.setFirstName("Nass"); + return Collections.singletonList(person); + } + + /** + * List two list. + * + * @return the list + */ + @Operation(description = "List all persons") + @ApiResponse(responseCode = "200", description = "", content = @Content(array = @ArraySchema(schema = @Schema(implementation = PersonDTO.class)))) + @GetMapping(path = "/listTwo", consumes = MediaType.ALL_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) + public List listTwo() { + PersonDTO person = new PersonDTO(); + person.setFirstName("Nass"); + return Collections.singletonList(person); + } + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app45/HelloController2.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app45/HelloController2.java new file mode 100644 index 000000000..4d9ec2913 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app45/HelloController2.java @@ -0,0 +1,84 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app45; + +import java.util.Collections; +import java.util.List; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.media.ArraySchema; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.tags.Tag; + +import org.springframework.http.MediaType; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + + +/** + * The type Hello controller 2. + */ +@Tag(name = "People", description = "Use this resource to serve all requests and initiate all operations related to people") +@SecurityRequirement(name = "bearer") +@RestController +@RequestMapping(value = "/v1/people2") +class HelloController2 { + + + /** + * List list. + * + * @return the list + */ + @Operation(description = "List all persons") + @ApiResponse(responseCode = "200", description = "", content = @Content(array = @ArraySchema(schema = @Schema(implementation = PersonDTO.class)))) + @GetMapping(path = "/list", consumes = MediaType.ALL_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) + public List list() { + PersonDTO person = new PersonDTO(); + person.setFirstName("Nass"); + return Collections.singletonList(person); + } + + /** + * List two list. + * + * @return the list + */ + @Operation(description = "List all persons") + @ApiResponse(responseCode = "200", description = "", content = @Content(array = @ArraySchema(schema = @Schema(implementation = PersonDTO.class)))) + @GetMapping(path = "/listTwo", consumes = MediaType.ALL_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) + public List listTwo() { + PersonDTO person = new PersonDTO(); + person.setFirstName("Nass"); + return Collections.singletonList(person); + } + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app45/OpenApiConfig.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app45/OpenApiConfig.java new file mode 100644 index 000000000..b1d5d3752 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app45/OpenApiConfig.java @@ -0,0 +1,41 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app45; + +import io.swagger.v3.oas.annotations.OpenAPIDefinition; +import io.swagger.v3.oas.annotations.enums.SecuritySchemeType; +import io.swagger.v3.oas.annotations.info.Info; +import io.swagger.v3.oas.annotations.info.License; +import io.swagger.v3.oas.annotations.security.SecurityScheme; + +/** + * The type Open api config. + */ +@OpenAPIDefinition(info = @Info(title = "My App", description = "Some long and useful description", version = "v1", license = @License(name = "Apache 2.0", url = "https://www.apache.org/licenses/LICENSE-2.0"))) +@SecurityScheme(name = "bearer", type = SecuritySchemeType.HTTP, scheme = "bearer", bearerFormat = "JWT") +class OpenApiConfig { +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app45/PersonDTO.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app45/PersonDTO.java new file mode 100644 index 000000000..3600f7d80 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app45/PersonDTO.java @@ -0,0 +1,120 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app45; + +/** + * The type Person dto. + */ +class PersonDTO { + /** + * The Email. + */ + private String email; + + /** + * The First name. + */ + private String firstName; + + /** + * The Last name. + */ + private String lastName; + + /** + * Instantiates a new Person dto. + */ + public PersonDTO() { + } + + /** + * Instantiates a new Person dto. + * + * @param email the email + * @param firstName the first name + * @param lastName the last name + */ + public PersonDTO(final String email, final String firstName, final String lastName) { + this.email = email; + this.firstName = firstName; + this.lastName = lastName; + } + + /** + * Gets email. + * + * @return the email + */ + public String getEmail() { + return email; + } + + /** + * Sets email. + * + * @param email the email + */ + public void setEmail(final String email) { + this.email = email; + } + + /** + * Gets first name. + * + * @return the first name + */ + public String getFirstName() { + return firstName; + } + + /** + * Sets first name. + * + * @param firstName the first name + */ + public void setFirstName(final String firstName) { + this.firstName = firstName; + } + + /** + * Gets last name. + * + * @return the last name + */ + public String getLastName() { + return lastName; + } + + /** + * Sets last name. + * + * @param lastName the last name + */ + public void setLastName(final String lastName) { + this.lastName = lastName; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app45/SpringDocApp45Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app45/SpringDocApp45Test.java new file mode 100644 index 000000000..8f605d577 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app45/SpringDocApp45Test.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app45; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 45 test. + */ +class SpringDocApp45Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app46/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app46/HelloController.java new file mode 100644 index 000000000..d67822c5a --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app46/HelloController.java @@ -0,0 +1,61 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app46; + +import io.swagger.v3.oas.annotations.ExternalDocumentation; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.enums.ParameterIn; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * Persons string. + * + * @param subscriptionId the subscription id + * @return the string + */ + @GetMapping("/persons/{subscriptionId}") + @Operation(operationId = "operationId", summary = "Operation Summary", description = "Operation Description", tags = { + "Example Tag" }, externalDocs = @ExternalDocumentation(description = "External documentation description", url = "http://url.com"), parameters = { + @Parameter(in = ParameterIn.PATH, name = "subscriptionId", required = true, description = "parameter description", allowEmptyValue = true, allowReserved = true, schema = @Schema(type = "string", format = "uuid", description = "the generated UUID", accessMode = Schema.AccessMode.READ_ONLY)) }, responses = { + @ApiResponse(responseCode = "200", description = "voila!", content = @Content(mediaType = "application/json", schema = @Schema(implementation = String.class))) }) + public String persons(String subscriptionId) { + return "OK"; + } + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app46/SpringDocApp46Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app46/SpringDocApp46Test.java new file mode 100644 index 000000000..1fc002c08 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app46/SpringDocApp46Test.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app46; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 46 test. + */ +class SpringDocApp46Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app47/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app47/HelloController.java new file mode 100644 index 000000000..db5b688ae --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app47/HelloController.java @@ -0,0 +1,55 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app47; + +import java.util.Locale; + +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.media.Schema; + +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + /** + * Gets documents with locale. + * + * @param locale the locale + * @return the documents with locale + */ + @GetMapping(path = "/documents/{locale}") + public ResponseEntity getDocumentsWithLocale( + @Parameter(schema = @Schema(type = "string")) @PathVariable("locale") Locale locale) { + return null; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app47/SpringDocApp47Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app47/SpringDocApp47Test.java new file mode 100644 index 000000000..c571f0437 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app47/SpringDocApp47Test.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app47; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 47 test. + */ +class SpringDocApp47Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app48/AbstractHelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app48/AbstractHelloController.java new file mode 100644 index 000000000..79bbe1aa6 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app48/AbstractHelloController.java @@ -0,0 +1,58 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app48; + +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; + +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; + +/** + * The type Abstract hello controller. + */ +@ApiResponse(responseCode = "410") +@ApiResponses({ + @ApiResponse(responseCode = "411") +}) +class AbstractHelloController { + + /** + * Gets documents. + * + * @return the documents + */ + @GetMapping(path = "/documents/{locale}") + @ApiResponse(responseCode = "412") + @ApiResponses({ + @ApiResponse(responseCode = "413") + }) + public ResponseEntity getDocuments() { + return null; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app48/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app48/HelloController.java new file mode 100644 index 000000000..2d8d1d394 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app48/HelloController.java @@ -0,0 +1,61 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app48; + +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; + +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController + +@ApiResponse(responseCode = "400") +@ApiResponses({ + @ApiResponse(responseCode = "401") +}) +class HelloController extends AbstractHelloController { + + /** + * Gets documents. + * + * @return the documents + */ + @Override + @GetMapping(path = "/documents/{locale}") + @ApiResponse(responseCode = "402") + @ApiResponses({ + @ApiResponse(responseCode = "403") + }) + public ResponseEntity getDocuments() { + return null; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app48/SpringDocApp48Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app48/SpringDocApp48Test.java new file mode 100644 index 000000000..f173d2df1 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app48/SpringDocApp48Test.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app48; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 48 test. + */ +class SpringDocApp48Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app49/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app49/HelloController.java new file mode 100644 index 000000000..99c2959af --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app49/HelloController.java @@ -0,0 +1,57 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app49; + +import java.util.List; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; + +import org.springframework.http.MediaType; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * List list. + * + * @return the list + */ + @Operation(description = "Obtain the list of services available in the system") + @ApiResponses({ @ApiResponse(responseCode = "401", ref = "Unauthorized") }) + @GetMapping(value = "/hello", produces = MediaType.APPLICATION_JSON_VALUE) + List list() { + return null; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app49/SpringDocApp49Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app49/SpringDocApp49Test.java new file mode 100644 index 000000000..4047cc135 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app49/SpringDocApp49Test.java @@ -0,0 +1,37 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app49; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +/** + * The type Spring doc app 49 test. + */ +class SpringDocApp49Test extends AbstractSpringDocTest { + + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app49/SpringDocTestApp.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app49/SpringDocTestApp.java new file mode 100644 index 000000000..711f49f78 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app49/SpringDocTestApp.java @@ -0,0 +1,70 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app49; + +import io.swagger.v3.oas.models.Components; +import io.swagger.v3.oas.models.OpenAPI; +import io.swagger.v3.oas.models.media.Content; +import io.swagger.v3.oas.models.media.StringSchema; +import io.swagger.v3.oas.models.responses.ApiResponse; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; +import org.springframework.http.MediaType; + +/** + * The type Spring doc test app. + */ +@SpringBootApplication +class SpringDocTestApp { + + /** + * The entry point of application. + * + * @param args the input arguments + */ + public static void main(String[] args) { + SpringApplication.run(SpringDocTestApp.class, args); + } + + /** + * Define open api open api. + * + * @return the open api + */ + @Bean + public OpenAPI defineOpenApi() { + OpenAPI api = new OpenAPI(); + api.components(new Components().addResponses("Unauthorized", + new ApiResponse().description("Unauthorized") + .content(new Content().addMediaType(MediaType.APPLICATION_JSON_VALUE, + new io.swagger.v3.oas.models.media.MediaType().schema(new StringSchema()))))); + return api; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app5/CustomOpenAPIConfig.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app5/CustomOpenAPIConfig.java new file mode 100644 index 000000000..18c2c5c8a --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app5/CustomOpenAPIConfig.java @@ -0,0 +1,51 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app5; + +import io.swagger.v3.oas.models.Components; +import io.swagger.v3.oas.models.OpenAPI; +import io.swagger.v3.oas.models.info.Info; +import io.swagger.v3.oas.models.tags.Tag; + +import org.springframework.context.annotation.Bean; + +/** + * The type Custom open api config. + */ +public class CustomOpenAPIConfig { + /** + * Custom open api open api. + * + * @return the open api + */ + @Bean + public OpenAPI customOpenAPI() { + return new OpenAPI() + .components(new Components()) + .info(new Info().title("Custom API").version("100")).addTagsItem(new Tag().name("mytag")); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app5/sample/OpenAPIResourceBeanConfigurationComponentsSecuritySchemesTest.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app5/sample/OpenAPIResourceBeanConfigurationComponentsSecuritySchemesTest.java new file mode 100644 index 000000000..8e3124f43 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app5/sample/OpenAPIResourceBeanConfigurationComponentsSecuritySchemesTest.java @@ -0,0 +1,174 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app5.sample; + +import java.util.ArrayList; + +import io.swagger.v3.oas.models.Components; +import io.swagger.v3.oas.models.OpenAPI; +import io.swagger.v3.oas.models.security.OAuthFlow; +import io.swagger.v3.oas.models.security.OAuthFlows; +import io.swagger.v3.oas.models.security.Scopes; +import io.swagger.v3.oas.models.security.SecurityRequirement; +import io.swagger.v3.oas.models.security.SecurityScheme; +import org.junit.jupiter.api.Test; +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.test.context.TestConfiguration; +import org.springframework.context.annotation.Bean; +import org.springframework.test.context.TestPropertySource; + +import static org.hamcrest.Matchers.is; +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; + +/** + * The type Open api resource bean configuration components security schemes test. + */ +@TestPropertySource(properties = "springdoc.api-docs.path=/api-docs") +class OpenAPIResourceBeanConfigurationComponentsSecuritySchemesTest extends AbstractSpringDocTest { + + /** + * Given: Bean configuration with security scheme http basic (shouldDefineComponentsSecuritySchemesForHttpBasic) + * When: Get api-docs + * Then: Return security definitions http basic + * @throws Exception the exception + */ + @Test + protected void testApp() throws Exception { + mockMvc + .perform(get("/api-docs")) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.security[0].basicScheme", is(new ArrayList()))) + .andExpect(jsonPath("$.components.securitySchemes.basicScheme.type", is("http"))) + .andExpect(jsonPath("$.components.securitySchemes.basicScheme.scheme", is("basic"))) + ; + } + + /** + * Given: Bean configuration with security scheme API key + * When: Get api-docs + * Then: Return security definitions with API key + * @throws Exception the exception + */ + @Test + void shouldDefineComponentsSecuritySchemesForApiKey() throws Exception { + mockMvc + .perform(get("/api-docs")) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.security[1].apiKeyScheme", is(new ArrayList()))) + .andExpect(jsonPath("$.components.securitySchemes.apiKeyScheme.type", is("apiKey"))) + .andExpect(jsonPath("$.components.securitySchemes.apiKeyScheme.in", is("header"))) + ; + } + + /** + * Given: Bean configuration with security scheme OAuth2 + * When: Get api-docs + * Then: Return security definitions with OAuth + * @throws Exception the exception + */ + @Test + void shouldDefineComponentsSecuritySchemesForOAuth2() throws Exception { + mockMvc + .perform(get("/api-docs")) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.security[2].oAuthScheme", is(new ArrayList()))) + .andExpect(jsonPath("$.components.securitySchemes.oAuthScheme.type", is("oauth2"))) + .andExpect(jsonPath("$.components.securitySchemes.oAuthScheme.description", is("This API uses OAuth 2 with the implicit grant flow. [More info](https://api.example.com/docs/auth)"))) + .andExpect(jsonPath("$.components.securitySchemes.oAuthScheme.flows.implicit.authorizationUrl", is("https://api.example.com/oauth2/authorize"))) + .andExpect(jsonPath("$.components.securitySchemes.oAuthScheme.flows.implicit.scopes.read_pets", is("read your pets"))) + .andExpect(jsonPath("$.components.securitySchemes.oAuthScheme.flows.implicit.scopes.write_pets", is("modify pets in your account"))) + ; + } + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} + + /** + * The type Config. + */ + @TestConfiguration + static class Config { + + /** + * Open api open api. + * + * @return the open api + */ + @Bean + public OpenAPI openApi() { + return new OpenAPI() + .components(new Components() + + //HTTP Basic, see: https://swagger.io/docs/specification/authentication/basic-authentication/ + .addSecuritySchemes("basicScheme", new SecurityScheme() + .type(SecurityScheme.Type.HTTP) + .scheme("basic") + ) + + //API Key, see: https://swagger.io/docs/specification/authentication/api-keys/ + .addSecuritySchemes("apiKeyScheme", new SecurityScheme() + .type(SecurityScheme.Type.APIKEY) + .in(SecurityScheme.In.HEADER) + .name("X-API-KEY") + ) + + //OAuth 2.0, see: https://swagger.io/docs/specification/authentication/oauth2/ + .addSecuritySchemes("oAuthScheme", new SecurityScheme() + .type(SecurityScheme.Type.OAUTH2) + .description("This API uses OAuth 2 with the implicit grant flow. [More info](https://api.example.com/docs/auth)") + .flows(new OAuthFlows() + .implicit(new OAuthFlow() + .authorizationUrl("https://api.example.com/oauth2/authorize") + .scopes(new Scopes() + .addString("read_pets", "read your pets") + .addString("write_pets", "modify pets in your account") + ) + ) + ) + ) + ) + .addSecurityItem(new SecurityRequirement() + .addList("basicScheme") + ) + .addSecurityItem(new SecurityRequirement() + .addList("apiKeyScheme") + ) + .addSecurityItem(new SecurityRequirement() + .addList("oAuthScheme") + ) + ; + } + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app5/sample/OpenApiResourceCustomConfigurationTest.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app5/sample/OpenApiResourceCustomConfigurationTest.java new file mode 100644 index 000000000..3763326b9 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app5/sample/OpenApiResourceCustomConfigurationTest.java @@ -0,0 +1,73 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app5.sample; + +import org.junit.jupiter.api.Test; +import test.org.springdoc.api.v30.AbstractSpringDocTest; +import test.org.springdoc.api.v30.app5.CustomOpenAPIConfig; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Import; +import org.springframework.test.context.TestPropertySource; + +import static org.hamcrest.Matchers.is; +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; + +/** + * The type Open api resource custom configuration test. + */ +@Import(CustomOpenAPIConfig.class) +@TestPropertySource(properties = "springdoc.api-docs.path=/api-docs") +class OpenApiResourceCustomConfigurationTest extends AbstractSpringDocTest { + + /** + * givenNoConfiguration_whenGetApiJson_returnsDefaultEmptyDocs - should return + * {"openapi":"3.0.1","info":{"title":"Custom API","version":"100"},"paths":{},"components":{}} + * @throws Exception the exception + */ + @Test + protected void testApp() throws Exception { + mockMvc + .perform(get("/api-docs")) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.openapi", is("3.0.1"))) + .andExpect(jsonPath("$.info.title", is("Custom API"))) + .andExpect(jsonPath("$.info.version", is("100"))) + .andExpect(jsonPath("$.paths").isEmpty()) + .andExpect(jsonPath("$.components").isEmpty()) + .andExpect(jsonPath("$.tags").isNotEmpty()) + .andExpect(jsonPath("$.tags[0].name", is("mytag"))); + } + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app5/sample/OpenApiResourceNoConfigurationTest.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app5/sample/OpenApiResourceNoConfigurationTest.java new file mode 100644 index 000000000..1b42a913d --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app5/sample/OpenApiResourceNoConfigurationTest.java @@ -0,0 +1,68 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app5.sample; + +import org.junit.jupiter.api.Test; +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.test.context.TestPropertySource; + +import static org.hamcrest.Matchers.is; +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; + +/** + * The type Open api resource no configuration test. + */ +@TestPropertySource(properties = "springdoc.api-docs.path=/api-docs") +class OpenApiResourceNoConfigurationTest extends AbstractSpringDocTest { + + /** + * givenNoConfiguration_whenGetApiJson_returnsDefaultEmptyDocs - should return + * {"openapi":"3.0.1","info":{"title":"OpenAPI definition","version":"v0"},"paths":{},"components":{}} + * @throws Exception the exception + */ + @Test + protected void testApp() throws Exception { + mockMvc + .perform(get("/api-docs")) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.openapi", is("3.0.1"))) + .andExpect(jsonPath("$.info.title", is("OpenAPI definition"))) + .andExpect(jsonPath("$.info.version", is("v0"))) + .andExpect(jsonPath("$.paths").isEmpty()) + .andExpect(jsonPath("$.components").isEmpty()); + } + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app50/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app50/HelloController.java new file mode 100644 index 000000000..65a7bfa90 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app50/HelloController.java @@ -0,0 +1,56 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app50; + +import java.util.List; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.responses.ApiResponse; + +import org.springframework.http.MediaType; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * List list. + * + * @return the list + */ + @Operation(description = "Some operation", responses = { @ApiResponse(responseCode = "401") }) + //@ApiResponse(responseCode = "401", content = @Content()) + @GetMapping(value = "/hello", produces = MediaType.APPLICATION_JSON_VALUE) + List list() { + return null; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app50/SpringDocApp50Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app50/SpringDocApp50Test.java new file mode 100644 index 000000000..935a662b6 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app50/SpringDocApp50Test.java @@ -0,0 +1,37 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app50; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +/** + * The type Spring doc app 50 test. + */ +class SpringDocApp50Test extends AbstractSpringDocTest { + + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app50/SpringDocTestApp.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app50/SpringDocTestApp.java new file mode 100644 index 000000000..5c0e07b52 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app50/SpringDocTestApp.java @@ -0,0 +1,70 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app50; + +import io.swagger.v3.oas.models.Components; +import io.swagger.v3.oas.models.OpenAPI; +import io.swagger.v3.oas.models.media.Content; +import io.swagger.v3.oas.models.media.StringSchema; +import io.swagger.v3.oas.models.responses.ApiResponse; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; +import org.springframework.http.MediaType; + +/** + * The type Spring doc test app. + */ +@SpringBootApplication +class SpringDocTestApp { + + /** + * The entry point of application. + * + * @param args the input arguments + */ + public static void main(String[] args) { + SpringApplication.run(SpringDocTestApp.class, args); + } + + /** + * Define open api open api. + * + * @return the open api + */ + @Bean + public OpenAPI defineOpenApi() { + OpenAPI api = new OpenAPI(); + api.components(new Components().addResponses("Unauthorized", + new ApiResponse().description("Unauthorized") + .content(new Content().addMediaType(MediaType.APPLICATION_JSON_VALUE, + new io.swagger.v3.oas.models.media.MediaType().schema(new StringSchema()))))); + return api; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app51/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app51/HelloController.java new file mode 100644 index 000000000..c290c3f2d --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app51/HelloController.java @@ -0,0 +1,115 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app51; + +import java.util.HashMap; +import java.util.Map; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.enums.ParameterIn; +import io.swagger.v3.oas.annotations.media.Schema; + +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * Test 1 string. + * + * @return the string + */ + @Operation(parameters = { + @Parameter(in = ParameterIn.HEADER, name = "test_header", required = true, schema = @Schema(type = "string", example = "rherherherherh")) }) + @GetMapping("/test1") + public String test1() { + return "test"; + } + + /** + * Test 2 string. + * + * @param param1 the param 1 + * @return the string + */ + @Operation(parameters = { + @Parameter(in = ParameterIn.HEADER, name = "test_header", required = true, schema = @Schema(type = "string", example = "rherherherherh")) }) + @GetMapping("/test2") + public String test2(@RequestParam(name = "param1") String param1) { + return "test"; + } + + /** + * Test 3 string. + * + * @param param1 the param 1 + * @return the string + */ + @Operation(parameters = { + @Parameter(in = ParameterIn.HEADER, name = "test_header", required = true, schema = @Schema(type = "string", example = "rherherherherh")), + @Parameter(description = "desc1", in = ParameterIn.QUERY, name = "param1", required = true, schema = @Schema(type = "string", example = "something")) }) + @GetMapping("/test3") + public String test3( + @RequestParam(name = "param1") @Parameter(description = "desc2", in = ParameterIn.QUERY) String param1) { + return "test"; + } + + /** + * Get string. + * + * @param path the path + * @param params the params + * @return the string + */ + @GetMapping("/test/{path}") + public String get( + @PathVariable String path, + @RequestParam(required = false) Map params) { + return null; + } + + /** + * Hello response entity. + * + * @param map the map + * @return the response entity + */ + @PostMapping + public ResponseEntity> hello(@RequestBody HashMap map) { + return ResponseEntity.ok(map); + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app51/SpringDocApp51Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app51/SpringDocApp51Test.java new file mode 100644 index 000000000..9ca3c390b --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app51/SpringDocApp51Test.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app51; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 51 test. + */ +class SpringDocApp51Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app52/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app52/HelloController.java new file mode 100644 index 000000000..26c219e90 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app52/HelloController.java @@ -0,0 +1,104 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app52; + +import java.util.List; + +import org.springframework.http.MediaType; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.multipart.MultipartFile; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * Create test 1 string. + * + * @param username the username + * @param test the test + * @param imageFile the image file + * @return the string + */ + @PostMapping(value = "/test1/{username}", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) + public String createTest1(@PathVariable String username, @RequestPart("test") MyTestDto test, + @RequestPart("image") MultipartFile imageFile) { + return null; + } + + /** + * Create test 2 string. + * + * @param username the username + * @param imageFile the image file + * @param test the test + * @return the string + */ + @PostMapping(value = "/test2/{username}", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) + public String createTest2(@PathVariable String username, @RequestPart("image") MultipartFile imageFile, + @RequestPart("test") MyTestDto test) { + return null; + } + + /** + * Create test 3 string. + * + * @param test the test + * @param multipartFiles the multipart files + * @return the string + */ + @PostMapping(value = "/test3", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) + public String createTest3(@RequestPart("test") MyTestDto test, + @RequestPart("doc") List multipartFiles) { + return null; + } + + /** + * The type My test dto. + */ + class MyTestDto { + /** + * The Object 1. + */ + public String object1; + + /** + * The Object 2. + */ + public String object2; + + /** + * The Object 3. + */ + public String object3; + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app52/SpringDocApp52Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app52/SpringDocApp52Test.java new file mode 100644 index 000000000..aef9dfa1d --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app52/SpringDocApp52Test.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app52; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 52 test. + */ +class SpringDocApp52Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app53/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app53/HelloController.java new file mode 100644 index 000000000..8b8d694a8 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app53/HelloController.java @@ -0,0 +1,155 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app53; + + +import java.util.List; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.responses.ApiResponse; + +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.ResponseStatus; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * List with no api response list. + * + * @return the list + */ + @Operation(description = "Some operation") + @GetMapping(value = "/hello1", produces = MediaType.APPLICATION_JSON_VALUE) + List listWithNoApiResponse() { + return null; + } + + /** + * List with empty api response list. + * + * @return the list + */ + @Operation(description = "Some operation") + @ApiResponse + @GetMapping(value = "/hello2", produces = MediaType.APPLICATION_JSON_VALUE) + List listWithEmptyApiResponse() { + return null; + } + + /** + * List with explicit response status list. + * + * @return the list + */ + @Operation(description = "Some operation") + @GetMapping(value = "/hello3", produces = MediaType.APPLICATION_JSON_VALUE) + @ResponseStatus(HttpStatus.NO_CONTENT) + List listWithExplicitResponseStatus() { + return null; + } + + /** + * Gets dto with explicit response status. + * + * @return the dto with explicit response status + */ + @Operation(description = "Some operation") + @GetMapping(value = "/hello4", produces = MediaType.APPLICATION_JSON_VALUE) + @ResponseStatus(HttpStatus.NO_CONTENT) + HelloDTO1 getDTOWithExplicitResponseStatus() { + return null; + } + + /** + * List with default response status list. + * + * @return the list + */ + @Operation(description = "Some operation") + @GetMapping(value = "/hello5", produces = MediaType.APPLICATION_JSON_VALUE) + List listWithDefaultResponseStatus() { + return null; + } + + /** + * Gets dto with default response status. + * + * @return the dto with default response status + */ + @Operation(description = "Some operation") + @GetMapping(value = "/hello6", produces = MediaType.APPLICATION_JSON_VALUE) + HelloDTO1 getDTOWithDefaultResponseStatus() { + return null; + } + + /** + * Gets nested dto with default response status. + * + * @return the nested dto with default response status + */ + @Operation(description = "Some operation") + @GetMapping(value = "/hello7", produces = MediaType.APPLICATION_JSON_VALUE) + ResponseEntity getNestedDTOWithDefaultResponseStatus() { + return null; + } + + /** + * The type Hello dto 1. + */ + static class HelloDTO1 { + /** + * The Message. + */ + private String message; + + /** + * Instantiates a new Hello dto 1. + * + * @param message the message + */ + public HelloDTO1(String message) { + this.message = message; + } + + /** + * Gets message. + * + * @return the message + */ + public String getMessage() { + return message; + } + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app53/HelloControllerWithGlobalApiResponse.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app53/HelloControllerWithGlobalApiResponse.java new file mode 100644 index 000000000..8999fbd28 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app53/HelloControllerWithGlobalApiResponse.java @@ -0,0 +1,72 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app53; + +import java.util.List; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.responses.ApiResponse; + +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseStatus; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller with global api response. + */ +@RestController +@RequestMapping(path = "/global") +class HelloControllerWithGlobalApiResponse { + + /** + * List with no api response list. + * + * @return the list + */ + @Operation(description = "Some operation", responses = { + @ApiResponse(responseCode = "204", description = "Explicit description for this response") }) + @ResponseStatus(HttpStatus.NO_CONTENT) + @GetMapping(value = "/hello1", produces = MediaType.APPLICATION_JSON_VALUE) + List listWithNoApiResponse() { + return null; + } + + /** + * List with default response status list. + * + * @return the list + */ + @Operation(description = "Some operation") + @ApiResponse(responseCode = "200", description = "Explicit description for this response") + @GetMapping(value = "/hello2", produces = MediaType.APPLICATION_JSON_VALUE) + List listWithDefaultResponseStatus() { + return null; + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app53/SpringDocApp53Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app53/SpringDocApp53Test.java new file mode 100644 index 000000000..952e2319a --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app53/SpringDocApp53Test.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app53; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 53 test. + */ +class SpringDocApp53Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app54/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app54/HelloController.java new file mode 100644 index 000000000..17e4e4390 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app54/HelloController.java @@ -0,0 +1,84 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app54; + +import com.fasterxml.jackson.annotation.JsonView; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.parameters.RequestBody; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; + +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * Gets meal party. + * + * @param mealPartyId the meal party id + * @return the meal party + */ + @GetMapping(value = "/parties/{id}") + @JsonView(Views.Public.class) + @Operation(summary = "Gets meal party details [Meal party admin restricted]") + @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "Successfully retrieved the meal party") }) + public MealParty getMealParty(@PathVariable("id") long mealPartyId) { + return null; + } + + /** + * Save meal party response entity. + * + * @param p the p + * @return the response entity + */ + @JsonView(Views.MealPartyAdmin.class) + @PostMapping(value = "/parties") + public ResponseEntity saveMealParty(@JsonView(Views.Public.class) @RequestBody MealParty p) { + return null; + } + + /** + * Save meal new party response entity. + * + * @param p the p + * @return the response entity + */ + @JsonView(Views.MealPartyAdmin.class) + @PostMapping(value = "/new-parties") + public ResponseEntity saveMealNewParty(@JsonView(Views.Public.class) @org.springframework.web.bind.annotation.RequestBody MealParty p) { + return null; + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app54/MealParty.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app54/MealParty.java new file mode 100644 index 000000000..ac1291fc7 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app54/MealParty.java @@ -0,0 +1,49 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app54; + +import java.util.ArrayList; +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonView; + +/** + * The type Meal party. + */ +class MealParty { + /** + * The Name. + */ + @JsonView(Views.Public.class) + private String name; + + /** + * The Members. + */ + @JsonView(Views.MealPartyAdmin.class) + private List members = new ArrayList<>(); +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app54/SpringDocApp54Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app54/SpringDocApp54Test.java new file mode 100644 index 000000000..07632de24 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app54/SpringDocApp54Test.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app54; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 54 test. + */ +class SpringDocApp54Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app54/Views.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app54/Views.java new file mode 100644 index 000000000..a48628620 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app54/Views.java @@ -0,0 +1,44 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app54; + +/** + * The interface Views. + */ +public interface Views { + /** + * The interface Public. + */ + public interface Public { + } + + /** + * The interface Meal party admin. + */ + public interface MealPartyAdmin extends Public { + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app55/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app55/HelloController.java new file mode 100644 index 000000000..f35b32f8b --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app55/HelloController.java @@ -0,0 +1,60 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app55; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; +import io.swagger.v3.oas.annotations.tags.Tag; + +import org.springframework.http.HttpStatus; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.ResponseStatus; + +/** + * The type Hello controller. + */ +@Controller +@Tag(name = "health") +class HelloController { + + /** + * Ping endpoint used for health checks. + * @return the boolean + */ + @RequestMapping(value = "/ping", method = RequestMethod.GET) + @Operation(summary = "Simple health check") + @ApiResponses({ @ApiResponse(responseCode = "200", description = "OK") }) + @ResponseBody + @ResponseStatus(HttpStatus.OK) + public Boolean ping() { + return true; + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app55/SpringDocApp55Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app55/SpringDocApp55Test.java new file mode 100644 index 000000000..9f5d45444 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app55/SpringDocApp55Test.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app55; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 55 test. + */ +class SpringDocApp55Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app56/GlobalExceptionHandler.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app56/GlobalExceptionHandler.java new file mode 100644 index 000000000..f1ba375c9 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app56/GlobalExceptionHandler.java @@ -0,0 +1,90 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app56; + +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; + +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.ResponseStatus; +import org.springframework.web.bind.annotation.RestControllerAdvice; + +/** + * The type Global exception handler. + */ +@RestControllerAdvice +class GlobalExceptionHandler { + /** + * Handle unhandled error error dto. + * + * @return the error dto + */ + @ExceptionHandler(Exception.class) + @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR) + @ApiResponse( + responseCode = "500", + description = "Internal server error", + content = @Content( + mediaType = MediaType.APPLICATION_JSON_VALUE, + schema = @Schema(implementation = ErrorDTO.class) + ) + ) + ErrorDTO handleUnhandledError() { + return new ErrorDTO("internal error: "); + } + + /** + * The type Error dto. + */ + class ErrorDTO { + /** + * The Error message. + */ + private String errorMessage; + + /** + * Instantiates a new Error dto. + * + * @param errorMessage the error message + */ + ErrorDTO(String errorMessage) { + this.errorMessage = errorMessage; + } + + /** + * Gets error message. + * + * @return the error message + */ + public String getErrorMessage() { + return errorMessage; + } + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app56/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app56/HelloController.java new file mode 100644 index 000000000..0e4464166 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app56/HelloController.java @@ -0,0 +1,48 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app56; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * Persons string. + * + * @return the string + */ + @GetMapping("/persons") + public String persons() { + return "OK"; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app56/SpringDocApp56Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app56/SpringDocApp56Test.java new file mode 100644 index 000000000..9dcbcd8f3 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app56/SpringDocApp56Test.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app56; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 56 test. + */ +class SpringDocApp56Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app57/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app57/HelloController.java new file mode 100644 index 000000000..d7ead7493 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app57/HelloController.java @@ -0,0 +1,53 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app57; + +import io.swagger.v3.oas.annotations.Parameter; + +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * Gets text. + * + * @param name the name + * @return the text + */ + @GetMapping("/{name:.+}") + public ResponseEntity getText(@Parameter(description = "desc", required = true) @PathVariable String name) { + return null; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app57/SpringDocApp57Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app57/SpringDocApp57Test.java new file mode 100644 index 000000000..3511822c8 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app57/SpringDocApp57Test.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app57; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 57 test. + */ +class SpringDocApp57Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app58/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app58/HelloController.java new file mode 100644 index 000000000..cf782375f --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app58/HelloController.java @@ -0,0 +1,183 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app58; + +import com.fasterxml.jackson.databind.JsonNode; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * Example object. + * + * @param json the json + * @return the object + */ + @PostMapping("/examplePost") + @Operation(summary = "schema example") + public Object example(@Parameter(schema = @Schema(hidden = true)) JsonNode json) { + return null; + } + + /** + * Test. + * + * @param json the json + */ + @GetMapping("/example") + public void test(@Parameter(schema = @Schema(hidden = true)) JsonNode json) { + } + + /** + * Foobar. + * + * @param bar the bar + */ + @GetMapping(value = "/foo") + public void foobar(@Parameter(description = "User", name = "user", + schema = @Schema(implementation = PersonDTO.class)) @RequestParam("bar") String bar) { + + } + + /** + * Foobar 1. + * + * @param bar the bar + */ + @GetMapping(value = "/foo1") + public void foobar1(@Parameter(description = "User", name = "user", + content = @Content(mediaType = "application/json", + schema = @Schema(implementation = PersonDTO.class))) @RequestParam("bar") String bar) { + + } + + /** + * The type Person dto. + */ + class PersonDTO { + /** + * The Email. + */ + private String email; + + /** + * The First name. + */ + private String firstName; + + /** + * The Last name. + */ + private String lastName; + + /** + * Instantiates a new Person dto. + */ + public PersonDTO() { + } + + /** + * Instantiates a new Person dto. + * + * @param email the email + * @param firstName the first name + * @param lastName the last name + */ + public PersonDTO(final String email, final String firstName, final String lastName) { + this.email = email; + this.firstName = firstName; + this.lastName = lastName; + } + + /** + * Gets email. + * + * @return the email + */ + public String getEmail() { + return email; + } + + /** + * Sets email. + * + * @param email the email + */ + public void setEmail(final String email) { + this.email = email; + } + + /** + * Gets first name. + * + * @return the first name + */ + public String getFirstName() { + return firstName; + } + + /** + * Sets first name. + * + * @param firstName the first name + */ + public void setFirstName(final String firstName) { + this.firstName = firstName; + } + + /** + * Gets last name. + * + * @return the last name + */ + public String getLastName() { + return lastName; + } + + /** + * Sets last name. + * + * @param lastName the last name + */ + public void setLastName(final String lastName) { + this.lastName = lastName; + } + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app58/SpringDocApp58Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app58/SpringDocApp58Test.java new file mode 100644 index 000000000..4f05365a9 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app58/SpringDocApp58Test.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app58; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 58 test. + */ +class SpringDocApp58Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app59/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app59/HelloController.java new file mode 100644 index 000000000..9cec571c8 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app59/HelloController.java @@ -0,0 +1,44 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app59; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + /** + * Test. + */ + @Deprecated + @GetMapping("/example") + public void test() { + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app59/SpringDocApp59Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app59/SpringDocApp59Test.java new file mode 100644 index 000000000..429381cb8 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app59/SpringDocApp59Test.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app59; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 59 test. + */ +class SpringDocApp59Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app6/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app6/HelloController.java new file mode 100644 index 000000000..e5c7af757 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app6/HelloController.java @@ -0,0 +1,61 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app6; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.ExampleObject; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; + +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * Say hello response entity. + * + * @return the response entity + */ + @Operation(summary = "Get Something by key", responses = { + @ApiResponse(description = "Successful Operation", responseCode = "200", content = @Content(mediaType = "application/json", schema = @Schema(oneOf = { + String.class, Integer.class }), examples = { + @ExampleObject(name = "The String example", value = "urgheiurgheirghieurg"), + @ExampleObject(name = "The Integer example", value = "311414") })), + @ApiResponse(responseCode = "404", description = "Thing not found"), + @ApiResponse(responseCode = "401", description = "Authentication Failure") }) + @GetMapping(value = "/hello") + ResponseEntity sayHello() { + return null; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app6/SpringDocApp6Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app6/SpringDocApp6Test.java new file mode 100644 index 000000000..01cb8c177 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app6/SpringDocApp6Test.java @@ -0,0 +1,44 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app6; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 6 test. + */ +class SpringDocApp6Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app60/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app60/HelloController.java new file mode 100644 index 000000000..2540f06c5 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app60/HelloController.java @@ -0,0 +1,76 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app60; + +import java.util.List; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Parameters; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * List 1 list. + * + * @param page the page + * @param size the size + * @return the list + */ + @GetMapping("/hello1") + @Operation(summary = "summary1") + @Parameters({ + @Parameter(name = "page", description = "The page"), + @Parameter(name = "size", description = "The size") + }) + public List list1(String page, String size) { + return null; + } + + /** + * List 2 list. + * + * @param page the page + * @param size the size + * @param sort the sort + * @return the list + */ + @GetMapping("/hello2") + @Operation(summary = "summary2") + @QuerySort + @QueryPaging + public List list2(String page, String size, String sort) { + return null; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app60/QueryPaging.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app60/QueryPaging.java new file mode 100644 index 000000000..6a161b7fa --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app60/QueryPaging.java @@ -0,0 +1,47 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app60; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Parameters; + +/** + * The interface Query paging. + */ +@Retention(RetentionPolicy.RUNTIME) +@Target({ ElementType.METHOD }) +@Parameters({ + @Parameter(name = "page", description = "desc page from Annotated interface"), + @Parameter(name = "size", description = "desc page from Annotated interface") +}) +public @interface QueryPaging { +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app60/QuerySort.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app60/QuerySort.java new file mode 100644 index 000000000..4d8739dee --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app60/QuerySort.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app60; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import io.swagger.v3.oas.annotations.Parameter; + +/** + * The interface Query sort. + */ +@Retention(RetentionPolicy.RUNTIME) +@Target({ ElementType.METHOD }) +@Parameter(name = "sort", description = "desc sort from Annotated interface") +public @interface QuerySort { +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app60/SpringDocApp60Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app60/SpringDocApp60Test.java new file mode 100644 index 000000000..45d3b2fbf --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app60/SpringDocApp60Test.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app60; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 60 test. + */ +class SpringDocApp60Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app61/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app61/HelloController.java new file mode 100644 index 000000000..040410960 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app61/HelloController.java @@ -0,0 +1,66 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app61; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.enums.ParameterIn; +import io.swagger.v3.oas.annotations.media.ArraySchema; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + + /** + * Persons string. + * + * @param name the name + * @param phone the phone + * @param createdFrom the created from + * @param createdRange the created range + * @return the string + */ + @Operation(description = "List", parameters = { + @Parameter(description = "Name", name = "name", in = ParameterIn.QUERY), + @Parameter(description = "Phone", name = "phone", in = ParameterIn.QUERY), + @Parameter(description = "createdFrom", name = "createdFrom", in = ParameterIn.QUERY, content = @Content(array = @ArraySchema(schema = @Schema(type = "string")))), + @Parameter(description = "createdRange", name = "createdRange", in = ParameterIn.QUERY, array = @ArraySchema(schema = @Schema(type = "string", format = "date"), minItems = 2, maxItems = 2)) + }) + @GetMapping(value = "/persons-with-user") + public String persons(String name, String phone, String createdFrom, String createdRange) { + return "OK"; + } + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app61/SpringDocApp61Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app61/SpringDocApp61Test.java new file mode 100644 index 000000000..c0632a6a1 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app61/SpringDocApp61Test.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app61; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 61 test. + */ +class SpringDocApp61Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app62/BaseController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app62/BaseController.java new file mode 100644 index 000000000..672120f2e --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app62/BaseController.java @@ -0,0 +1,62 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app62; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import org.springframework.core.annotation.AliasFor; +import org.springframework.http.MediaType; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The interface Base controller. + */ +@Target({ ElementType.METHOD, ElementType.TYPE }) +@Retention(RetentionPolicy.RUNTIME) +@RestController +@RequestMapping +public @interface BaseController { + /** + * Value string [ ]. + * + * @return the string [ ] + */ + @AliasFor(annotation = RequestMapping.class) + String[] value() default {}; + + /** + * Produces string [ ]. + * + * @return the string [ ] + */ + @AliasFor(annotation = RequestMapping.class) + String[] produces() default { MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE }; +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app62/SpringDocApp62Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app62/SpringDocApp62Test.java new file mode 100644 index 000000000..c2c58df37 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app62/SpringDocApp62Test.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app62; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 62 test. + */ +class SpringDocApp62Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app62/TestController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app62/TestController.java new file mode 100644 index 000000000..11e4e920f --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app62/TestController.java @@ -0,0 +1,54 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app62; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; + +import org.springframework.web.bind.annotation.RequestHeader; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; + +/** + * The type Test controller. + */ +@BaseController +@Tag(name = "Test Controller") +class TestController { + + /** + * Test string. + * + * @param accept the accept + * @return the string + */ + @RequestMapping(value = "/test", method = RequestMethod.GET) + @Operation(summary = "This is the test endpoint") + public String test(@RequestHeader("Accept") String accept) { + return "This is a test"; + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app63/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app63/HelloController.java new file mode 100644 index 000000000..168c96215 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app63/HelloController.java @@ -0,0 +1,58 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app63; + +import java.util.Locale; + +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; +import jakarta.servlet.http.HttpSession; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * Test. + * + * @param header the header + * @param request the request + * @param response the response + * @param locale the locale + * @param hello the hello + */ + @GetMapping("/test") + public void test(HttpSession header, HttpServletRequest request, HttpServletResponse response, Locale locale, + String hello) { + } + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app63/SpringDocApp63Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app63/SpringDocApp63Test.java new file mode 100644 index 000000000..6c5ef5552 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app63/SpringDocApp63Test.java @@ -0,0 +1,48 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app63; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.test.context.TestPropertySource; + + +/** + * The type Spring doc app 63 test. + */ +@TestPropertySource(properties = { + "springdoc.packagesToScan=hell,hello1, hello.me", + "springdoc.packagesToExclude=test.org.springdoc.api.app63.65" }) +class SpringDocApp63Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app64/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app64/HelloController.java new file mode 100644 index 000000000..b3bd2447e --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app64/HelloController.java @@ -0,0 +1,61 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app64; + +import io.swagger.v3.oas.annotations.Operation; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * Test 1. + * + * @param hello the hello + */ + @GetMapping("/v1/test") + public void test1(String hello) { + } + + /** + * Test 2 string. + * + * @param from the from + * @return the string + */ + @GetMapping(value = "/api/balance/abcd") + @Operation(summary = "This is the test endpoint") + public String test2(String from) { + return "This is a fake test"; + } + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app64/SpringDocApp64Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app64/SpringDocApp64Test.java new file mode 100644 index 000000000..a867eddb8 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app64/SpringDocApp64Test.java @@ -0,0 +1,45 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app64; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.test.context.TestPropertySource; + +/** + * The type Spring doc app 64 test. + */ +@TestPropertySource(properties = "springdoc.paths-to-match=/v1, /api/**") +class SpringDocApp64Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app65/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app65/HelloController.java new file mode 100644 index 000000000..e8402c1a7 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app65/HelloController.java @@ -0,0 +1,55 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app65; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; + +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@Tag(name = "Health", description = "Health check / ping API") +@RestController +class HelloController { + + /** + * Ping response entity. + * + * @return the response entity + */ + @Operation(summary = "Check server status", description = "Check server status, will return 200 with simple string if alive. Do nothing else.") + @GetMapping(value = { "/ping", "/health", "/" }, produces = MediaType.TEXT_PLAIN_VALUE) + public ResponseEntity ping() { + return ResponseEntity.ok("Healthy"); + } + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app65/SpringDocApp65Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app65/SpringDocApp65Test.java new file mode 100644 index 000000000..9af63f98b --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app65/SpringDocApp65Test.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app65; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 65 test. + */ +class SpringDocApp65Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app66/DefaultHealthCheckApi.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app66/DefaultHealthCheckApi.java new file mode 100644 index 000000000..42c3ee8d0 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app66/DefaultHealthCheckApi.java @@ -0,0 +1,57 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app66; + +import java.time.LocalDate; + +import io.swagger.v3.oas.annotations.Hidden; + +import org.springframework.format.annotation.DateTimeFormat; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RestController; + + +/** + * The type Default health check api. + */ +@RestController +@Hidden +class DefaultHealthCheckApi { + + /** + * Test date echo string. + * + * @param date the date + * @return the string + */ + @GetMapping("/test/date/echo/{date}") + public String testDateEcho(@DateTimeFormat(pattern = "yyyyMMdd") @PathVariable LocalDate date) { + return date.toString(); + } + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app66/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app66/HelloController.java new file mode 100644 index 000000000..85104d338 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app66/HelloController.java @@ -0,0 +1,56 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app66; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; + +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@Tag(name = "Health", description = "Health check / ping API") +@RestController +class HelloController { + + /** + * Ping response entity. + * + * @param possiblyInjectedByAspect the possibly injected by aspect + * @return the response entity + */ + @Operation(summary = "Check server status", description = "Check server status, will return 200 with simple string if alive. Do nothing else.") + @GetMapping(value = { "/ping", "/health", "/" }, produces = MediaType.TEXT_PLAIN_VALUE) + public ResponseEntity ping(UndocumentedClass possiblyInjectedByAspect) { + return ResponseEntity.ok("Healthy"); + } + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app66/SpringDocApp66Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app66/SpringDocApp66Test.java new file mode 100644 index 000000000..1ff1c5b44 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app66/SpringDocApp66Test.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app66; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 66 test. + */ +class SpringDocApp66Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app66/UndocumentedClass.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app66/UndocumentedClass.java new file mode 100644 index 000000000..949bfc690 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app66/UndocumentedClass.java @@ -0,0 +1,37 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app66; + +import io.swagger.v3.oas.annotations.Hidden; + +/** + * The type Undocumented class. + */ +@Hidden +class UndocumentedClass { + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app67/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app67/HelloController.java new file mode 100644 index 000000000..e0715d068 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app67/HelloController.java @@ -0,0 +1,141 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app67; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Parameters; +import io.swagger.v3.oas.annotations.enums.ParameterIn; +import io.swagger.v3.oas.annotations.media.Schema; + +import org.springframework.http.MediaType; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +@RequestMapping(path = "/demo", + produces = MediaType.TEXT_PLAIN_VALUE) +class HelloController { + + /** + * Operation 1 string. + * + * @return the string + */ + @GetMapping("operation1") + @Operation(summary = "Operation 1 (expected result - no parameters)") + public String operation1() { + return "operation1"; + } + + /** + * Operation 2 string. + * + * @return the string + */ + @GetMapping("operation2") + @Operation(summary = "Operation 2 (expected result - 3 parameters)", parameters = { + @Parameter(name = "pageNumber", description = "page number", + in = ParameterIn.QUERY, schema = @Schema(type = "integer")), + @Parameter(name = "pageSize", description = "page size", + in = ParameterIn.QUERY, schema = @Schema(type = "integer")), + @Parameter(name = "sort", description = "sort specification", + in = ParameterIn.QUERY, schema = @Schema(type = "string")) + }) + public String operation2() { + return "operation2"; + } + + /** + * Operation 3 string. + * + * @return the string + */ + @GetMapping("operation3") + @Operation(summary = "Operation 3 (expected result - 3 parameters)") + @Parameters({ + @Parameter(name = "pageNumber", description = "page number", + in = ParameterIn.QUERY, schema = @Schema(type = "integer")), + @Parameter(name = "pageSize", description = "page size", + in = ParameterIn.QUERY, schema = @Schema(type = "integer")), + @Parameter(name = "sort", description = "sort specification", + in = ParameterIn.QUERY, schema = @Schema(type = "string")) + }) + public String operation3() { + return "operation3"; + } + + /** + * Operation 4 string. + * + * @return the string + */ + @GetMapping("operation4") + @Operation(summary = "Operation 4 (expected result - 3 parameters)") + @QueryPaging + @QuerySort + public String operation4() { + return "operation4"; + } + + /** + * The interface Query paging. + */ + @Retention(RetentionPolicy.RUNTIME) + @Target({ ElementType.METHOD }) + @Parameters({ + @Parameter(name = "pageNumber", description = "page number", + in = ParameterIn.QUERY, schema = @Schema(type = "integer")), + @Parameter(name = "pageSize", description = "page size", + in = ParameterIn.QUERY, schema = @Schema(type = "integer")) + }) + public @interface QueryPaging { + + } + + /** + * The interface Query sort. + */ + @Retention(RetentionPolicy.RUNTIME) + @Target({ ElementType.METHOD }) + @Parameters({ + @Parameter(name = "sort", description = "sort specification", + in = ParameterIn.QUERY, schema = @Schema(type = "string")) + }) + public @interface QuerySort { + + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app67/SpringDocApp67Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app67/SpringDocApp67Test.java new file mode 100644 index 000000000..dca46fd91 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app67/SpringDocApp67Test.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app67; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 67 test. + */ +class SpringDocApp67Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app69/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app69/HelloController.java new file mode 100644 index 000000000..a4890693d --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app69/HelloController.java @@ -0,0 +1,53 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app69; + +import java.util.concurrent.Callable; + +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * Gets tasks. + * + * @param str the str + * @return the tasks + */ + @RequestMapping(value = "/tasks", method = RequestMethod.GET) + private Callable> getTasks(String str) { + return null; + } + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app69/PersonDTO.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app69/PersonDTO.java new file mode 100644 index 000000000..017406145 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app69/PersonDTO.java @@ -0,0 +1,120 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app69; + +/** + * The type Person dto. + */ +class PersonDTO { + /** + * The Email. + */ + private String email; + + /** + * The First name. + */ + private String firstName; + + /** + * The Last name. + */ + private String lastName; + + /** + * Instantiates a new Person dto. + */ + public PersonDTO() { + } + + /** + * Instantiates a new Person dto. + * + * @param email the email + * @param firstName the first name + * @param lastName the last name + */ + public PersonDTO(final String email, final String firstName, final String lastName) { + this.email = email; + this.firstName = firstName; + this.lastName = lastName; + } + + /** + * Gets email. + * + * @return the email + */ + public String getEmail() { + return email; + } + + /** + * Sets email. + * + * @param email the email + */ + public void setEmail(final String email) { + this.email = email; + } + + /** + * Gets first name. + * + * @return the first name + */ + public String getFirstName() { + return firstName; + } + + /** + * Sets first name. + * + * @param firstName the first name + */ + public void setFirstName(final String firstName) { + this.firstName = firstName; + } + + /** + * Gets last name. + * + * @return the last name + */ + public String getLastName() { + return lastName; + } + + /** + * Sets last name. + * + * @param lastName the last name + */ + public void setLastName(final String lastName) { + this.lastName = lastName; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app69/SpringDocApp69Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app69/SpringDocApp69Test.java new file mode 100644 index 000000000..7700a90a4 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app69/SpringDocApp69Test.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app69; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 69 test. + */ +class SpringDocApp69Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app7/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app7/HelloController.java new file mode 100644 index 000000000..30975a6f4 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app7/HelloController.java @@ -0,0 +1,53 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app7; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.parameters.RequestBody; + +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * Search employee. + * + * @param test the test + */ + @Operation(summary = "test Request") + @RequestBody(description = "test value", required = true, content = @Content(schema = @Schema(implementation = String.class))) + @PostMapping("/test") + public void searchEmployee(String test) { + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app7/SpringDocApp7Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app7/SpringDocApp7Test.java new file mode 100644 index 000000000..4cbd4373b --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app7/SpringDocApp7Test.java @@ -0,0 +1,44 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app7; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 7 test. + */ +class SpringDocApp7Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app70/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app70/HelloController.java new file mode 100644 index 000000000..91559c0e5 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app70/HelloController.java @@ -0,0 +1,57 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app70; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import test.org.springdoc.api.v30.app70.customizer.CustomizedOperation; +import test.org.springdoc.api.v30.app70.customizer.CustomizedParameter; +import test.org.springdoc.api.v30.app70.model.ApiType; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * Test api type. + * + * @param test the test + * @return the api type + */ + @CustomizedOperation + @Operation(description = "Some operation") + @GetMapping("/example/{test}") + public ApiType test(@PathVariable @CustomizedParameter @Parameter(description = "Parameter description") String test) { + return new ApiType(); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app70/SpringDocApp70Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app70/SpringDocApp70Test.java new file mode 100644 index 000000000..29de676fe --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app70/SpringDocApp70Test.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app70; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 70 test. + */ +class SpringDocApp70Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app70/customizer/CustomizedOperation.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app70/customizer/CustomizedOperation.java new file mode 100644 index 000000000..43d2df3d2 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app70/customizer/CustomizedOperation.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app70.customizer; + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + +/** + * The interface Customized operation. + */ +@Retention(RetentionPolicy.RUNTIME) +public @interface CustomizedOperation { + /** + * Addition string. + * + * @return the string + */ + String addition() default "customized operation!"; +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app70/customizer/CustomizedParameter.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app70/customizer/CustomizedParameter.java new file mode 100644 index 000000000..bcbb8590d --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app70/customizer/CustomizedParameter.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app70.customizer; + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + +/** + * The interface Customized parameter. + */ +@Retention(RetentionPolicy.RUNTIME) +public @interface CustomizedParameter { + /** + * Addition string. + * + * @return the string + */ + String addition() default "customized parameter!"; +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app70/customizer/CustomizedProperty.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app70/customizer/CustomizedProperty.java new file mode 100644 index 000000000..6722f8387 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app70/customizer/CustomizedProperty.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app70.customizer; + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + +/** + * The interface Customized property. + */ +@Retention(RetentionPolicy.RUNTIME) +public @interface CustomizedProperty { + /** + * Addition string. + * + * @return the string + */ + String addition() default "customized property!"; +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app70/customizer/OperationCustomizer.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app70/customizer/OperationCustomizer.java new file mode 100644 index 000000000..46aba35a4 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app70/customizer/OperationCustomizer.java @@ -0,0 +1,54 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app70.customizer; + +import io.swagger.v3.oas.models.Operation; + +import org.springframework.stereotype.Component; +import org.springframework.web.method.HandlerMethod; + +/** + * The type Operation customizer. + */ +@Component +class OperationCustomizer implements org.springdoc.core.customizers.OperationCustomizer { + /** + * Customize operation. + * + * @param operation the operation + * @param handlerMethod the handler method + * @return the operation + */ + @Override + public Operation customize(Operation operation, HandlerMethod handlerMethod) { + CustomizedOperation annotation = handlerMethod.getMethodAnnotation(CustomizedOperation.class); + if (annotation != null) { + operation.description(operation.getDescription() + ", " + annotation.addition()); + } + return operation; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app70/customizer/ParameterCustomizer.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app70/customizer/ParameterCustomizer.java new file mode 100644 index 000000000..b0c8e99f7 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app70/customizer/ParameterCustomizer.java @@ -0,0 +1,54 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app70.customizer; + +import io.swagger.v3.oas.models.parameters.Parameter; + +import org.springframework.core.MethodParameter; +import org.springframework.stereotype.Component; + +/** + * The type Parameter customizer. + */ +@Component +class ParameterCustomizer implements org.springdoc.core.customizers.ParameterCustomizer { + /** + * Customize parameter. + * + * @param parameterModel the parameter model + * @param methodParameter the method parameter + * @return the parameter + */ + @Override + public Parameter customize(Parameter parameterModel, MethodParameter methodParameter) { + CustomizedParameter annotation = methodParameter.getParameterAnnotation(CustomizedParameter.class); + if (annotation != null) { + parameterModel.description(parameterModel.getDescription() + ", " + annotation.addition()); + } + return parameterModel; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app70/customizer/PropertyCustomizer.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app70/customizer/PropertyCustomizer.java new file mode 100644 index 000000000..a09a3292e --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app70/customizer/PropertyCustomizer.java @@ -0,0 +1,78 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app70.customizer; + +import java.lang.annotation.Annotation; +import java.time.Duration; +import java.util.Collections; +import java.util.Optional; +import java.util.stream.Stream; + +import com.fasterxml.jackson.databind.JavaType; +import io.swagger.v3.core.converter.AnnotatedType; +import io.swagger.v3.oas.models.media.Schema; +import io.swagger.v3.oas.models.media.StringSchema; +import org.springdoc.core.providers.ObjectMapperProvider; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +/** + * The type Property customizer. + */ +@Component +class PropertyCustomizer implements org.springdoc.core.customizers.PropertyCustomizer { + + @Autowired + ObjectMapperProvider objectMapperProvider; + + /** + * Customize schema. + * + * @param property the property + * @param type the type + * @return the schema + */ + @Override + public Schema customize(Schema property, AnnotatedType type) { + Annotation[] ctxAnnotations = type.getCtxAnnotations(); + if (ctxAnnotations == null) { + return property; + } + + Optional propertyAnnotation = Stream.of(ctxAnnotations) + .filter(CustomizedProperty.class::isInstance) + .findFirst() + .map(CustomizedProperty.class::cast); + + JavaType javaType = objectMapperProvider.jsonMapper().constructType(type.getType()); + if (javaType.getRawClass().equals(Duration.class)) { + property = new StringSchema().format("duration").properties(Collections.emptyMap()); + } + return property; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app70/model/ApiType.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app70/model/ApiType.java new file mode 100644 index 000000000..5a6f86a9e --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app70/model/ApiType.java @@ -0,0 +1,47 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app70.model; + +import java.time.Duration; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.v3.oas.annotations.media.Schema; +import test.org.springdoc.api.v30.app70.customizer.CustomizedProperty; + +/** + * The type Api type. + */ +public class ApiType { + /** + * The Some property. + */ + @CustomizedProperty + @Schema(description = "Test description") + @JsonProperty("someProperty") + private Duration someProperty; + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app71/Dog.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app71/Dog.java new file mode 100644 index 000000000..e7a5e9b24 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app71/Dog.java @@ -0,0 +1,50 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app71; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.v3.oas.annotations.media.Schema; + + +/** + * The type Dog. + */ +@Schema(name = "Dog") +class Dog { + + /** + * The Display name. + */ + @JsonProperty("display_name") + @Schema( + name = "display_name", + description = "A name given to the Dog", + example = "Fido" + ) + String displayName; + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app71/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app71/HelloController.java new file mode 100644 index 000000000..03c21171b --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app71/HelloController.java @@ -0,0 +1,49 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app71; + +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * Persons string. + * + * @param dog the dog + * @return the string + */ + @PostMapping("/persons") + public String persons(Dog dog) { + return null; + } + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app71/SpringDocApp71Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app71/SpringDocApp71Test.java new file mode 100644 index 000000000..9e35bf5e2 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app71/SpringDocApp71Test.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app71; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 71 test. + */ +class SpringDocApp71Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app72/BlockingAutoConfigurationTest.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app72/BlockingAutoConfigurationTest.java new file mode 100644 index 000000000..e1c284b74 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app72/BlockingAutoConfigurationTest.java @@ -0,0 +1,130 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app72; + +import org.junit.jupiter.api.Test; +import org.springdoc.core.models.GroupedOpenApi; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.test.context.FilteredClassLoader; +import org.springframework.boot.test.context.runner.ApplicationContextRunner; +import org.springframework.boot.test.context.runner.WebApplicationContextRunner; +import org.springframework.context.annotation.Bean; + +import static org.assertj.core.api.Assertions.assertThat; + +/** + * The type Blocking auto configuration test. + */ +class BlockingAutoConfigurationTest { + + /** + * The Context runner. + */ + private final WebApplicationContextRunner contextRunner = new WebApplicationContextRunner() + .withUserConfiguration(TestApp.class); + + + /** + * Configurations not loaded when application is not web. + */ + @Test + void configurations_not_loaded_when_application_is_not_web() { + new ApplicationContextRunner() + .withUserConfiguration(TestApp.class) + .run(context -> assertThat(context) + .hasNotFailed() + .doesNotHaveBean("openApiResource") + .doesNotHaveBean("actuatorProvider") + .doesNotHaveBean("multipleOpenApiResource") + ); + } + + /** + * Actuator configuration not loaded when not enabled explicitly. + */ + @Test + void actuator_configuration_not_loaded_when_not_enabled_explicitly() { + contextRunner + .run(context -> assertThat(context) + .hasNotFailed() + .hasBean("openApiResource") + .doesNotHaveBean("actuatorPprrovider") + .hasBean("multipleOpenApiResource") + ); + } + + /** + * Configurations not loaded when disabled. + */ + @Test + void configurations_not_loaded_when_disabled() { + contextRunner + .withPropertyValues("springdoc.api-docs.enabled=false") + .run(context -> assertThat(context) + .hasNotFailed() + .doesNotHaveBean("openApiResource") + .doesNotHaveBean("actuatorProvider") + .doesNotHaveBean("multipleOpenApiResource") + ); + } + + /** + * Configurations not loaded when mvc is not on class path. + */ + @Test + void configurations_not_loaded_when_mvc_is_not_on_class_path() { + contextRunner + .withClassLoader(new FilteredClassLoader("org.springframework.web.context.support.GenericWebApplicationContext")) + .run(context -> assertThat(context) + .hasNotFailed() + .doesNotHaveBean("openApiResource") + .doesNotHaveBean("actuatorProvider") + .doesNotHaveBean("multipleOpenApiResource") + ); + + } + + /** + * The type Test app. + */ + @SpringBootApplication + static class TestApp { + /** + * Test grouped open api grouped open api. + * + * @return the grouped open api + */ + @Bean + GroupedOpenApi testGroupedOpenApi() { + return GroupedOpenApi.builder() + .group("test-group") + .packagesToScan("org.test") + .build(); + } + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app72/CacheAutoConfigurationTest1.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app72/CacheAutoConfigurationTest1.java new file mode 100644 index 000000000..d7aca3501 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app72/CacheAutoConfigurationTest1.java @@ -0,0 +1,114 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app72; + +import org.junit.jupiter.api.Test; + +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.boot.test.context.runner.WebApplicationContextRunner; + +import static org.assertj.core.api.Assertions.assertThat; + +/** + * The type Cache auto configuration test 1. + */ +class CacheAutoConfigurationTest1 { + + /** + * The Context runner. + */ + private final WebApplicationContextRunner contextRunner = new WebApplicationContextRunner() + .withUserConfiguration(TestApp.class); + + /** + * Cache configuration loaded when not disabled explicitly. + */ + @Test + void cache_configuration_loaded_when_not_disabled_explicitly() { + contextRunner + .run(context -> assertThat(context) + .hasNotFailed() + .hasBean("openApiResource") + .doesNotHaveBean("springdocBeanFactoryPostProcessor") + .doesNotHaveBean("multipleOpenApiResource") + ); + } + + /** + * Cache configuration loaded when disabled explicitly. + */ + @Test + void cache_configuration_loaded_when_disabled_explicitly() { + contextRunner + .withPropertyValues("springdoc.cache.disabled=false") + .run(context -> assertThat(context) + .hasNotFailed() + .hasBean("openApiResource") + .doesNotHaveBean("springdocBeanFactoryPostProcessor") + .doesNotHaveBean("multipleOpenApiResource") + ); + } + + /** + * Cache configurations successfully disabled. + */ + @Test + void cache_configurations_successfully_disabled() { + contextRunner + .withPropertyValues("springdoc.cache.disabled=true") + .run(context -> assertThat(context) + .hasNotFailed() + .hasBean("openApiResource") + .hasBean("springdocBeanFactoryPostProcessor") + .doesNotHaveBean("multipleOpenApiResource") + ); + } + + /** + * Group configuration loaded. + */ + @Test + void group_configuration_loaded() { + contextRunner + .withPropertyValues("springdoc.group-configs[0].group=stores", "springdoc.group-configs[0].paths-to-match=/store/**") + .run(context -> assertThat(context) + .hasNotFailed() + .hasBean("openApiResource") + .hasBean("multipleOpenApiResource") + .hasBean("springdocBeanFactoryPostProcessor") + ); + } + + + /** + * The type Test app. + */ + @EnableAutoConfiguration + static class TestApp { + + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app72/GroupAutoConfigurationTest.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app72/GroupAutoConfigurationTest.java new file mode 100644 index 000000000..1c4ef5862 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app72/GroupAutoConfigurationTest.java @@ -0,0 +1,81 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app72; + +import org.junit.jupiter.api.Test; +import org.springdoc.core.models.GroupedOpenApi; + +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.boot.test.context.runner.WebApplicationContextRunner; +import org.springframework.context.annotation.Bean; + +import static org.assertj.core.api.Assertions.assertThat; + +/** + * The type Group auto configuration test. + */ +class GroupAutoConfigurationTest { + + /** + * The Context runner. + */ + private final WebApplicationContextRunner contextRunner = new WebApplicationContextRunner() + .withUserConfiguration(TestApp.class); + + /** + * Group configuration loaded. + */ + @Test + void group_configuration_loaded() { + contextRunner + .run(context -> assertThat(context) + .hasNotFailed() + .hasBean("openApiResource") + .hasBean("springdocBeanFactoryPostProcessor") + .hasBean("multipleOpenApiResource") + ); + } + + /** + * The type Test app. + */ + @EnableAutoConfiguration + static class TestApp { + /** + * Test grouped open api grouped open api. + * + * @return the grouped open api + */ + @Bean + GroupedOpenApi testGroupedOpenApi() { + return GroupedOpenApi.builder() + .group("test-group") + .packagesToScan("org.test") + .build(); + } + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app73/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app73/HelloController.java new file mode 100644 index 000000000..a909b0fe3 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app73/HelloController.java @@ -0,0 +1,71 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app73; + +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.enums.ParameterIn; + +import org.springframework.http.HttpStatus; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseStatus; +import org.springframework.web.bind.annotation.RestController; + + +/** + * The type Hello controller. + */ +@RestController +@RequestMapping({ "/{country_code}/persons/", "/persons" }) +class HelloController { + + /** + * Delete. + * + * @param countryCode the country code + * @param id the id + */ + @DeleteMapping("/{id}") + @ResponseStatus(HttpStatus.NO_CONTENT) + public void delete(@Parameter(name = "country_code", in = ParameterIn.QUERY) String countryCode, @PathVariable("id") String id) { + + } + + /** + * Get string. + * + * @param countryCode the country code + * @param id the id + * @return the string + */ + @GetMapping("/{id}") + public String get(@Parameter(name = "country_code", in = ParameterIn.QUERY) String countryCode, @PathVariable("id") String id) { + return null; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app73/SpringDocApp73Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app73/SpringDocApp73Test.java new file mode 100644 index 000000000..1d7d8fc88 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app73/SpringDocApp73Test.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app73; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 73 test. + */ +class SpringDocApp73Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app74/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app74/HelloController.java new file mode 100644 index 000000000..35b32bd1a --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app74/HelloController.java @@ -0,0 +1,62 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app74; + +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.ExampleObject; +import io.swagger.v3.oas.annotations.parameters.RequestBody; + +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RestController; + + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * Post my request body string. + * + * @param myRequestBody the my request body + * @return the string + */ + @PostMapping("/test") + @RequestBody( + content = @Content( + examples = @ExampleObject( + value = "sample" + ) + ) + ) + public String postMyRequestBody( + String myRequestBody) { + return null; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app74/SpringDocApp74Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app74/SpringDocApp74Test.java new file mode 100644 index 000000000..169cbf8cd --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app74/SpringDocApp74Test.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app74; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 74 test. + */ +class SpringDocApp74Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app75/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app75/HelloController.java new file mode 100644 index 000000000..da686a248 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app75/HelloController.java @@ -0,0 +1,127 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app75; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.enums.ParameterIn; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; + +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * Post my request body 1 string. + * + * @return the string + */ + @PostMapping("/test1/{uuid}") + @Operation(summary = "Example api that realize an ECHO operation", + description = "The result of the echo is the input value of the api", + parameters = { @Parameter(in = ParameterIn.PATH, + name = "uuid", + required = true, + description = "Is the identification of the document", + schema = @Schema(type = "string", + example = "uuid")) } + + + ) + @ApiResponses(value = { + @ApiResponse(description = "Successful Operation", + responseCode = "200", + content = @Content(mediaType = "application/json", + schema = @Schema(implementation = PersonDTO.class))), + @ApiResponse(responseCode = "201", + description = "other possible response") + }) + public String postMyRequestBody1() { + return null; + } + + /** + * Post my request body 2 string. + * + * @return the string + */ + @PostMapping("/test2/{uuid}") + @Operation(summary = "Example api that realize an ECHO operation", + description = "The result of the echo is the input value of the api", + responses = { + @ApiResponse(description = "Successful Operation", + responseCode = "200", + content = @Content(mediaType = "application/json", + schema = @Schema(implementation = PersonDTO.class))), + @ApiResponse(responseCode = "201", + description = "other possible response") + }, + parameters = { @Parameter(in = ParameterIn.PATH, + name = "uuid", + required = true, + description = "Is the identification of the document", + schema = @Schema(type = "string", + example = "uuid")) } + + + ) + public String postMyRequestBody2() { + return null; + } + + /** + * Post my request body 3 string. + * + * @return the string + */ + @PostMapping("/test3/{uuid}") + @Operation(summary = "Example api that realize an ECHO operation", + description = "The result of the echo is the input value of the api", + parameters = { @Parameter(in = ParameterIn.PATH, + name = "uuid", + required = true, + description = "Is the identification of the document", + schema = @Schema(type = "string", + example = "uuid")) } + + + ) + @ApiResponse(responseCode = "201", + description = "other possible response") + public String postMyRequestBody3() { + return null; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app75/PersonDTO.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app75/PersonDTO.java new file mode 100644 index 000000000..53feafd13 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app75/PersonDTO.java @@ -0,0 +1,120 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app75; + +/** + * The type Person dto. + */ +class PersonDTO { + /** + * The Email. + */ + private String email; + + /** + * The First name. + */ + private String firstName; + + /** + * The Last name. + */ + private String lastName; + + /** + * Instantiates a new Person dto. + */ + public PersonDTO() { + } + + /** + * Instantiates a new Person dto. + * + * @param email the email + * @param firstName the first name + * @param lastName the last name + */ + public PersonDTO(final String email, final String firstName, final String lastName) { + this.email = email; + this.firstName = firstName; + this.lastName = lastName; + } + + /** + * Gets email. + * + * @return the email + */ + public String getEmail() { + return email; + } + + /** + * Sets email. + * + * @param email the email + */ + public void setEmail(final String email) { + this.email = email; + } + + /** + * Gets first name. + * + * @return the first name + */ + public String getFirstName() { + return firstName; + } + + /** + * Sets first name. + * + * @param firstName the first name + */ + public void setFirstName(final String firstName) { + this.firstName = firstName; + } + + /** + * Gets last name. + * + * @return the last name + */ + public String getLastName() { + return lastName; + } + + /** + * Sets last name. + * + * @param lastName the last name + */ + public void setLastName(final String lastName) { + this.lastName = lastName; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app75/RestResponseEntityExceptionHandler.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app75/RestResponseEntityExceptionHandler.java new file mode 100644 index 000000000..01dfc2d68 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app75/RestResponseEntityExceptionHandler.java @@ -0,0 +1,58 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app75; + +import java.util.List; + +import jakarta.servlet.http.HttpServletRequest; + +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.ControllerAdvice; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.ResponseStatus; +import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler; + +/** + * The type Rest response entity exception handler. + */ +@ControllerAdvice +class RestResponseEntityExceptionHandler + extends ResponseEntityExceptionHandler { + /** + * Bad request response entity. + * + * @param req the req + * @param exception the exception + * @return the response entity + */ + @ResponseStatus(value = HttpStatus.OK) + @ExceptionHandler({ Exception.class }) + public ResponseEntity> badRequest(HttpServletRequest req, Exception exception) { + return null; + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app75/SpringDocApp75Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app75/SpringDocApp75Test.java new file mode 100644 index 000000000..b43ab18c1 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app75/SpringDocApp75Test.java @@ -0,0 +1,44 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app75; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 75 test. + */ +class SpringDocApp75Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp { + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app76/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app76/HelloController.java new file mode 100644 index 000000000..2685c3dcf --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app76/HelloController.java @@ -0,0 +1,65 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app76; + +import io.swagger.v3.oas.annotations.security.SecurityRequirements; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.RestController; + + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * Secured string. + * + * @return the string + */ + @GetMapping("/secure") + @ResponseBody + public String secured() { + return "It works!"; + } + + /** + * Open string. + * + * @return the string + */ + @GetMapping("/open") + @ResponseBody + @SecurityRequirements + public String open() { + return "It works!"; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app76/SpringDocApp76Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app76/SpringDocApp76Test.java new file mode 100644 index 000000000..2e37f74b5 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app76/SpringDocApp76Test.java @@ -0,0 +1,68 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app76; + +import java.util.Arrays; + +import io.swagger.v3.oas.models.Components; +import io.swagger.v3.oas.models.OpenAPI; +import io.swagger.v3.oas.models.security.SecurityRequirement; +import io.swagger.v3.oas.models.security.SecurityScheme; +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; + +/** + * The type Spring doc app 76 test. + */ +class SpringDocApp76Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp { + /** + * Open api open api. + * + * @return the open api + */ + @Bean + public OpenAPI openAPI() { + return new OpenAPI() + .components(new Components().addSecuritySchemes("bearer-jwt", + new SecurityScheme() + .type(SecurityScheme.Type.HTTP) + .scheme("bearer") + .bearerFormat("JWT")) + ) + .addSecurityItem( + new SecurityRequirement().addList("bearer-jwt", Arrays.asList("read", "write"))); + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app77/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app77/HelloController.java new file mode 100644 index 000000000..7a30804b3 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app77/HelloController.java @@ -0,0 +1,71 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app77; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.extensions.Extension; +import io.swagger.v3.oas.annotations.extensions.ExtensionProperty; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import jakarta.validation.Valid; +import org.hibernate.validator.constraints.NotBlank; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * Persons. + * + * @param name the name + */ + @ApiResponse(content = @Content(schema = @Schema(type = "string")), extensions = @Extension(properties = @ExtensionProperty(name = "x-is-file", value = "true"))) + @GetMapping(value = "/persons") + public void persons(@Valid @NotBlank String name) { + + } + + + /** + * Persons 2. + * + * @param name the name + */ + @Operation(responses = @ApiResponse(content = @Content(schema = @Schema(type = "string")), extensions = @Extension(properties = @ExtensionProperty(name = "x-is-file", value = "true")))) + @GetMapping(value = "/persons2") + public void persons2(@Valid @NotBlank String name) { + + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app77/SpringDocApp77Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app77/SpringDocApp77Test.java new file mode 100644 index 000000000..46f805d5b --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app77/SpringDocApp77Test.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app77; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 77 test. + */ +class SpringDocApp77Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app78/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app78/HelloController.java new file mode 100644 index 000000000..001a4367b --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app78/HelloController.java @@ -0,0 +1,65 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app78; + +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.CompletionStage; + +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * Gets person 1. + * + * @param str the str + * @return the person 1 + */ + @RequestMapping(value = "/person1", method = RequestMethod.GET) + private CompletionStage> getPerson1(String str) { + return null; + } + + /** + * Gets person 2. + * + * @param str the str + * @return the person 2 + */ + @RequestMapping(value = "/person2", method = RequestMethod.GET) + private CompletableFuture getPerson2(String str) { + return null; + } + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app78/PersonDTO.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app78/PersonDTO.java new file mode 100644 index 000000000..0ffb34f70 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app78/PersonDTO.java @@ -0,0 +1,120 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app78; + +/** + * The type Person dto. + */ +class PersonDTO { + /** + * The Email. + */ + private String email; + + /** + * The First name. + */ + private String firstName; + + /** + * The Last name. + */ + private String lastName; + + /** + * Instantiates a new Person dto. + */ + public PersonDTO() { + } + + /** + * Instantiates a new Person dto. + * + * @param email the email + * @param firstName the first name + * @param lastName the last name + */ + public PersonDTO(final String email, final String firstName, final String lastName) { + this.email = email; + this.firstName = firstName; + this.lastName = lastName; + } + + /** + * Gets email. + * + * @return the email + */ + public String getEmail() { + return email; + } + + /** + * Sets email. + * + * @param email the email + */ + public void setEmail(final String email) { + this.email = email; + } + + /** + * Gets first name. + * + * @return the first name + */ + public String getFirstName() { + return firstName; + } + + /** + * Sets first name. + * + * @param firstName the first name + */ + public void setFirstName(final String firstName) { + this.firstName = firstName; + } + + /** + * Gets last name. + * + * @return the last name + */ + public String getLastName() { + return lastName; + } + + /** + * Sets last name. + * + * @param lastName the last name + */ + public void setLastName(final String lastName) { + this.lastName = lastName; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app78/SpringDocApp78Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app78/SpringDocApp78Test.java new file mode 100644 index 000000000..f6e6360fd --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app78/SpringDocApp78Test.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app78; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 78 test. + */ +class SpringDocApp78Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app79/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app79/HelloController.java new file mode 100644 index 000000000..297f66ea2 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app79/HelloController.java @@ -0,0 +1,53 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app79; + +import java.util.Optional; + +import org.springframework.http.MediaType; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * Echo string. + * + * @param text the text + * @return the string + */ + @GetMapping(produces = MediaType.TEXT_PLAIN_VALUE, path = "/test") + public String echo(@RequestParam Optional text) { + return text.orElse("not-specified"); + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app79/SpringDocApp79Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app79/SpringDocApp79Test.java new file mode 100644 index 000000000..ece32eeee --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app79/SpringDocApp79Test.java @@ -0,0 +1,44 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app79; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + + +/** + * The type Spring doc app 79 test. + */ +class SpringDocApp79Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app8/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app8/HelloController.java new file mode 100644 index 000000000..72994c474 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app8/HelloController.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.app8; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * Test. + * + * @param hello the hello + */ + @GetMapping("/test") + public void test(String hello) { + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app8/SpringDocApp8Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app8/SpringDocApp8Test.java new file mode 100644 index 000000000..261a1bef3 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app8/SpringDocApp8Test.java @@ -0,0 +1,60 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app8; + +import org.junit.jupiter.api.Test; +import org.springdoc.core.utils.Constants; +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + + +/** + * The type Spring doc app 8 test. + */ +class SpringDocApp8Test extends AbstractSpringDocTest { + + /** + * Test app. + * + * @throws Exception the exception + */ + @Test + protected void testApp() throws Exception { + mockMvc.perform(get("/myapp" + Constants.DEFAULT_API_DOCS_URL).contextPath("/myapp")) + .andExpect(status().isOk()); + } + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app80/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app80/HelloController.java new file mode 100644 index 000000000..4a70e5ecf --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app80/HelloController.java @@ -0,0 +1,81 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app80; + +import java.net.URISyntaxException; + +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +@RequestMapping("/api") +class HelloController { + + + /** + * Testpost 1 response entity. + * + * @param dto the dto + * @return the response entity + * @throws URISyntaxException the uri syntax exception + */ + @RequestMapping(value = "/testpost1", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) + public ResponseEntity testpost1(@RequestBody TestObject dto) throws URISyntaxException { + return ResponseEntity.ok(dto); + } + + /** + * Testpost 2 response entity. + * + * @param dto the dto + * @return the response entity + * @throws URISyntaxException the uri syntax exception + */ + @RequestMapping(value = "/testpost2", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) + public ResponseEntity testpost2(@RequestBody TestObject dto) throws URISyntaxException { + return ResponseEntity.ok(dto); + } + + /** + * Hello response entity. + * + * @return the response entity + * @throws URISyntaxException the uri syntax exception + */ + @RequestMapping(value = "/hello", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) + public ResponseEntity hello() throws URISyntaxException { + return ResponseEntity.ok("Hello World"); + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app80/SpringDocApp80Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app80/SpringDocApp80Test.java new file mode 100644 index 000000000..d696b7f07 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app80/SpringDocApp80Test.java @@ -0,0 +1,45 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app80; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.test.context.ActiveProfiles; + +/** + * The type Spring doc app 80 test. + */ +@ActiveProfiles("80") +class SpringDocApp80Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app80/TestObject.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app80/TestObject.java new file mode 100644 index 000000000..58c957f54 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app80/TestObject.java @@ -0,0 +1,80 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app80; + +import java.time.LocalDateTime; + +/** + * The type Test object. + */ +class TestObject { + /** + * The String value. + */ + public String stringValue; + + /** + * The Local date time. + */ + public LocalDateTime localDateTime; + + /** + * Gets string value. + * + * @return the string value + */ + public String getStringValue() { + return stringValue; + } + + /** + * Sets string value. + * + * @param stringValue the string value + */ + public void setStringValue(String stringValue) { + this.stringValue = stringValue; + } + + /** + * Gets local date time. + * + * @return the local date time + */ + public LocalDateTime getLocalDateTime() { + return localDateTime; + } + + /** + * Sets local date time. + * + * @param localDateTime the local date time + */ + public void setLocalDateTime(LocalDateTime localDateTime) { + this.localDateTime = localDateTime; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app81/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app81/HelloController.java new file mode 100644 index 000000000..add396316 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app81/HelloController.java @@ -0,0 +1,49 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app81; + +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +@RequestMapping("/api") +class HelloController { + + /** + * Test string. + * + * @return the string + */ + @RequestMapping + public String test() { + return "ok"; + } + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app81/SpringDocApp81Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app81/SpringDocApp81Test.java new file mode 100644 index 000000000..6ce67cf8c --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app81/SpringDocApp81Test.java @@ -0,0 +1,84 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app81; + +import org.junit.jupiter.api.Test; +import org.springdoc.core.utils.Constants; +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +import static org.hamcrest.Matchers.containsString; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.startsWith; +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; + +/** + * The type Spring doc app 81 test. + */ +class SpringDocApp81Test extends AbstractSpringDocTest { + + /** + * Test app. + * + * @throws Exception the exception + */ + @Test + protected void testApp() throws Exception { + mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL)).andExpect(status().isOk()) + .andExpect(jsonPath("$.openapi", is("3.0.1"))) + .andExpect(jsonPath("$.paths./api.get.tags[0]", containsString("hello-controller"))) + .andExpect(jsonPath("$.paths./api.get.operationId", startsWith("test"))) + .andExpect(jsonPath("$.paths./api.get.responses.200.content.['*/*'].schema.type", is("string"))) + .andExpect(jsonPath("$.paths./api.post.tags[0]", containsString("hello-controller"))) + .andExpect(jsonPath("$.paths./api.post.operationId", startsWith("test"))) + .andExpect(jsonPath("$.paths./api.post.responses.200.content.['*/*'].schema.type", is("string"))) + .andExpect(jsonPath("$.paths./api.put.tags[0]", containsString("hello-controller"))) + .andExpect(jsonPath("$.paths./api.put.operationId", startsWith("test"))) + .andExpect(jsonPath("$.paths./api.put.responses.200.content.['*/*'].schema.type", is("string"))) + .andExpect(jsonPath("$.paths./api.patch.tags[0]", containsString("hello-controller"))) + .andExpect(jsonPath("$.paths./api.patch.operationId", startsWith("test"))) + .andExpect(jsonPath("$.paths./api.patch.responses.200.content.['*/*'].schema.type", is("string"))) + .andExpect(jsonPath("$.paths./api.delete.tags[0]", containsString("hello-controller"))) + .andExpect(jsonPath("$.paths./api.delete.operationId", startsWith("test"))) + .andExpect(jsonPath("$.paths./api.delete.responses.200.content.['*/*'].schema.type", is("string"))) + .andExpect(jsonPath("$.paths./api.options.tags[0]", containsString("hello-controller"))) + .andExpect(jsonPath("$.paths./api.options.operationId", startsWith("test"))) + .andExpect(jsonPath("$.paths./api.options.responses.200.content.['*/*'].schema.type", is("string"))) + .andExpect(jsonPath("$.paths./api.head.tags[0]", containsString("hello-controller"))) + .andExpect(jsonPath("$.paths./api.head.operationId", startsWith("test"))) + .andExpect(jsonPath("$.paths./api.head.responses.200.content.['*/*'].schema.type", is("string"))); + } + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app82/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app82/HelloController.java new file mode 100644 index 000000000..beed630e7 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app82/HelloController.java @@ -0,0 +1,55 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app82; + +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + + /** + * Put response entity. + * + * @param configuration the configuration + * @param second the second + * @param personDTO the person dto + * @return the response entity + */ + @PutMapping(value = "/test") + public ResponseEntity put( + String configuration, + String second, PersonDTO personDTO) { + return null; + } + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app82/PersonDTO.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app82/PersonDTO.java new file mode 100644 index 000000000..5e4818438 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app82/PersonDTO.java @@ -0,0 +1,120 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app82; + +/** + * The type Person dto. + */ +class PersonDTO { + /** + * The Email. + */ + private String email; + + /** + * The First name. + */ + private String firstName; + + /** + * The Last name. + */ + private String lastName; + + /** + * Instantiates a new Person dto. + */ + public PersonDTO() { + } + + /** + * Instantiates a new Person dto. + * + * @param email the email + * @param firstName the first name + * @param lastName the last name + */ + public PersonDTO(final String email, final String firstName, final String lastName) { + this.email = email; + this.firstName = firstName; + this.lastName = lastName; + } + + /** + * Gets email. + * + * @return the email + */ + public String getEmail() { + return email; + } + + /** + * Sets email. + * + * @param email the email + */ + public void setEmail(final String email) { + this.email = email; + } + + /** + * Gets first name. + * + * @return the first name + */ + public String getFirstName() { + return firstName; + } + + /** + * Sets first name. + * + * @param firstName the first name + */ + public void setFirstName(final String firstName) { + this.firstName = firstName; + } + + /** + * Gets last name. + * + * @return the last name + */ + public String getLastName() { + return lastName; + } + + /** + * Sets last name. + * + * @param lastName the last name + */ + public void setLastName(final String lastName) { + this.lastName = lastName; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app82/SpringDocApp82Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app82/SpringDocApp82Test.java new file mode 100644 index 000000000..9ea40348b --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app82/SpringDocApp82Test.java @@ -0,0 +1,44 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app82; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 82 test. + */ +class SpringDocApp82Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app83/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app83/HelloController.java new file mode 100644 index 000000000..898a92105 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app83/HelloController.java @@ -0,0 +1,68 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app83; + +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.media.Schema; + +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.multipart.MultipartFile; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + + /** + * Put response entity. + * + * @param config the config + * @param configuration the configuration + * @param aFile the a file + * @return the response entity + */ + @RequestMapping(value = "/{config}", + method = RequestMethod.PUT, + consumes = { MediaType.MULTIPART_FORM_DATA_VALUE }, + produces = { MediaType.APPLICATION_JSON_VALUE } + ) + public ResponseEntity put( + @PathVariable("config") final String config, + @Parameter(name = "configuration", schema = @Schema(name = "configuration", type = "string", format = "binary")) @RequestPart(value = "configuration") final PersonDTO configuration, + @RequestPart(value = "file") final MultipartFile aFile) { + return null; + } + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app83/PersonDTO.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app83/PersonDTO.java new file mode 100644 index 000000000..cca50b971 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app83/PersonDTO.java @@ -0,0 +1,120 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app83; + +/** + * The type Person dto. + */ +class PersonDTO { + /** + * The Email. + */ + private String email; + + /** + * The First name. + */ + private String firstName; + + /** + * The Last name. + */ + private String lastName; + + /** + * Instantiates a new Person dto. + */ + public PersonDTO() { + } + + /** + * Instantiates a new Person dto. + * + * @param email the email + * @param firstName the first name + * @param lastName the last name + */ + public PersonDTO(final String email, final String firstName, final String lastName) { + this.email = email; + this.firstName = firstName; + this.lastName = lastName; + } + + /** + * Gets email. + * + * @return the email + */ + public String getEmail() { + return email; + } + + /** + * Sets email. + * + * @param email the email + */ + public void setEmail(final String email) { + this.email = email; + } + + /** + * Gets first name. + * + * @return the first name + */ + public String getFirstName() { + return firstName; + } + + /** + * Sets first name. + * + * @param firstName the first name + */ + public void setFirstName(final String firstName) { + this.firstName = firstName; + } + + /** + * Gets last name. + * + * @return the last name + */ + public String getLastName() { + return lastName; + } + + /** + * Sets last name. + * + * @param lastName the last name + */ + public void setLastName(final String lastName) { + this.lastName = lastName; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app83/SpringDocApp83Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app83/SpringDocApp83Test.java new file mode 100644 index 000000000..07ad1db4d --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app83/SpringDocApp83Test.java @@ -0,0 +1,44 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app83; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 83 test. + */ +class SpringDocApp83Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app84/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app84/HelloController.java new file mode 100644 index 000000000..3f8aaa020 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app84/HelloController.java @@ -0,0 +1,61 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app84; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +@RequestMapping("/api") +class HelloController { + + /** + * Persons string. + * + * @return the string + */ + @GetMapping("/persons") + public String persons() { + return "OK"; + } + + /** + * Persons string. + * + * @param toto the toto + * @return the string + */ + @GetMapping("/persons1") + public String persons(String toto) { + return "OK"; + } + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app84/SpringDocApp84Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app84/SpringDocApp84Test.java new file mode 100644 index 000000000..6b305a50c --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app84/SpringDocApp84Test.java @@ -0,0 +1,44 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app84; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 84 test. + */ +class SpringDocApp84Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app85/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app85/HelloController.java new file mode 100644 index 000000000..c96c2c93a --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app85/HelloController.java @@ -0,0 +1,58 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app85; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; + +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +@RequestMapping("/api") +class HelloController { + + /** + * Testme. + * + * @param id the id + */ + @PostMapping("/test/{id}") + @Operation( + parameters = { + @Parameter(ref = "#/components/parameters/paramA"), + @Parameter(ref = "#/components/parameters/paramB") + } + ) + public void testme(@PathVariable("id") String id) { + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app85/SpringDocApp85Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app85/SpringDocApp85Test.java new file mode 100644 index 000000000..52b9f6d52 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app85/SpringDocApp85Test.java @@ -0,0 +1,44 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app85; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 85 test. + */ +class SpringDocApp85Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app86/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app86/HelloController.java new file mode 100644 index 000000000..ca37fb711 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app86/HelloController.java @@ -0,0 +1,58 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app86; + +import java.util.Locale; + +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; +import jakarta.servlet.http.HttpSession; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * Test. + * + * @param header the header + * @param request the request + * @param response the response + * @param locale the locale + * @param hello the hello + */ + @GetMapping("/test") + public void test(HttpSession header, HttpServletRequest request, HttpServletResponse response, Locale locale, + String hello) { + } + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app86/SpringDocApp86Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app86/SpringDocApp86Test.java new file mode 100644 index 000000000..d42da0ad2 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app86/SpringDocApp86Test.java @@ -0,0 +1,47 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app86; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.test.context.TestPropertySource; + +/** + * The type Spring doc app 86 test. + */ +@TestPropertySource(properties = { + "springdoc.packagesToScan=test.org.springdoc.api.v30.app86", + "springdoc.packagesToExclude=test.org.springdoc.api.v30.app86.test" }) +class SpringDocApp86Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app86/test/HelloController2.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app86/test/HelloController2.java new file mode 100644 index 000000000..887022a44 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app86/test/HelloController2.java @@ -0,0 +1,58 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app86.test; + +import java.util.Locale; + +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; +import jakarta.servlet.http.HttpSession; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller 2. + */ +@RestController +class HelloController2 { + + /** + * Test. + * + * @param header the header + * @param request the request + * @param response the response + * @param locale the locale + * @param hello the hello + */ + @GetMapping("/test2") + public void test(HttpSession header, HttpServletRequest request, HttpServletResponse response, Locale locale, + String hello) { + } + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app87/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app87/HelloController.java new file mode 100644 index 000000000..af460d82d --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app87/HelloController.java @@ -0,0 +1,72 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app87; + +import java.util.UUID; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.parameters.RequestBody; + +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.CookieValue; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RestController; + + +/** + * The type Hello controller. + */ +@RestController("cookie") +class HelloController { + + /** + * Put item response entity. + * + * @param cookie the cookie + * @param itemId the item id + * @param item the item + * @return the response entity + */ + @PutMapping("/{itemId}") + @Operation + public ResponseEntity putItem( + @CookieValue( + name = "cookie" + ) String cookie, + @PathVariable UUID itemId, + @RequestBody Item item + ) { + return ResponseEntity.ok(item); + } + + /** + * The type Item. + */ + public static class Item { + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app87/SpringDocApp87Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app87/SpringDocApp87Test.java new file mode 100644 index 000000000..8a148885c --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app87/SpringDocApp87Test.java @@ -0,0 +1,44 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app87; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 87 test. + */ +class SpringDocApp87Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app88/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app88/HelloController.java new file mode 100644 index 000000000..972684e93 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app88/HelloController.java @@ -0,0 +1,48 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app88; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * Persons string. + * + * @return the string + */ + @GetMapping(value = "/persons") + public String persons() { + return null; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app88/SpringDocApp88Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app88/SpringDocApp88Test.java new file mode 100644 index 000000000..dc5bd3618 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app88/SpringDocApp88Test.java @@ -0,0 +1,45 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app88; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.test.context.TestPropertySource; + +/** + * The type Spring doc app 88 test. + */ +@TestPropertySource(properties = "springdoc.auto-tag-classes=false") +class SpringDocApp88Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app89/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app89/HelloController.java new file mode 100644 index 000000000..6434aa907 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app89/HelloController.java @@ -0,0 +1,54 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app89; + +import io.swagger.v3.oas.annotations.Operation; + +import org.springframework.http.MediaType; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.servlet.ModelAndView; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * Gets address. + * + * @param id the id + * @return the address + */ + @Operation(summary = "Get Status") + @GetMapping(value = "/status/{id}", produces = MediaType.TEXT_HTML_VALUE) + public ModelAndView getAddress(@PathVariable String id) { + return null; + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app89/SpringDocApp89Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app89/SpringDocApp89Test.java new file mode 100644 index 000000000..1ae41bca4 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app89/SpringDocApp89Test.java @@ -0,0 +1,54 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app89; + + +import io.swagger.v3.oas.models.media.ObjectSchema; +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.test.context.TestPropertySource; +import org.springframework.web.servlet.ModelAndView; + +import static org.springdoc.core.utils.SpringDocUtils.getConfig; + +/** + * The type Spring doc app 89 test. + */ +@TestPropertySource(properties = "springdoc.model-and-view-allowed=true") +class SpringDocApp89Test extends AbstractSpringDocTest { + + static { + getConfig().replaceWithSchema(ModelAndView.class, new ObjectSchema()); + } + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app9/MyApi.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app9/MyApi.java new file mode 100644 index 000000000..b0e7ed46e --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app9/MyApi.java @@ -0,0 +1,54 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app9; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.enums.ParameterIn; + +import org.springframework.http.HttpHeaders; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestHeader; +import org.springframework.web.bind.annotation.RequestMapping; + +/** + * The interface My api. + */ +@RequestMapping("/myapi") +public interface MyApi { + + /** + * Get string. + * + * @param language the language + * @return the string + */ + @Operation(description = "Annotations from interfaces test") + @GetMapping + String get( + @Parameter(hidden = true, in = ParameterIn.HEADER, name = HttpHeaders.ACCEPT_LANGUAGE) @RequestHeader(value = HttpHeaders.ACCEPT_LANGUAGE, required = false) String language); +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app9/MyApiController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app9/MyApiController.java new file mode 100644 index 000000000..bc0c835a6 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app9/MyApiController.java @@ -0,0 +1,62 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app9; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type My api controller. + */ +@RestController +class MyApiController implements MyApi { + /** + * Get string. + * + * @param language the language + * @return the string + */ + public String get(String language) { + return language; + } + + + /** + * Gets code. + * + * @param code the code + * @return the code + */ + @Operation(description = "Annotations from class with hidden parameter code") + @GetMapping("/getCode") + public String getCode(@Parameter(hidden = true) String code) { + return code; + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app9/SpringDocApp9Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app9/SpringDocApp9Test.java new file mode 100644 index 000000000..e2268f485 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app9/SpringDocApp9Test.java @@ -0,0 +1,44 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app9; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 9 test. + */ +class SpringDocApp9Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app90/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app90/HelloController.java new file mode 100644 index 000000000..d8a5d7479 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app90/HelloController.java @@ -0,0 +1,81 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app90; + +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.ExampleObject; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.parameters.RequestBody; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; + +import org.springframework.http.MediaType; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * Test 1. + * + * @param hello the hello + */ + @GetMapping("/test") + @ApiResponses(value = { @ApiResponse(description = "successful operation", content = { @Content(examples = @ExampleObject(name = "500", ref = "#/components/examples/http500Example"), mediaType = "application/json", schema = @Schema(implementation = User.class)), @Content(mediaType = "application/xml", schema = @Schema(implementation = User.class)) }) }) + public void test1(String hello) { + } + + /** + * Test 2. + * + * @param hello the hello + */ + @PostMapping("/test2") + @RequestBody( + description = "Details of the Item to be created", + required = true, + content = @Content( + schema = @Schema(implementation = User.class), + mediaType = MediaType.APPLICATION_JSON_VALUE, + examples = { + @ExampleObject( + name = "An example request with the minimum required fields to create.", + value = "min", + summary = "Minimal request"), + @ExampleObject( + name = "An example request with all fields provided with example values.", + value = "full", + summary = "Full request") })) + public void test2(String hello) { + } + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app90/SpringDocApp90Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app90/SpringDocApp90Test.java new file mode 100644 index 000000000..f9cefdf96 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app90/SpringDocApp90Test.java @@ -0,0 +1,37 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app90; + + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +/** + * The type Spring doc app 90 test. + */ +class SpringDocApp90Test extends AbstractSpringDocTest { + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app90/SpringDocTestApp.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app90/SpringDocTestApp.java new file mode 100644 index 000000000..039ab29a7 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app90/SpringDocTestApp.java @@ -0,0 +1,103 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app90; + +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.Reader; +import java.io.UncheckedIOException; +import java.util.AbstractMap; +import java.util.Collection; +import java.util.Map.Entry; + +import io.swagger.v3.oas.models.examples.Example; +import org.springdoc.core.customizers.OpenApiCustomizer; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; +import org.springframework.core.io.Resource; +import org.springframework.util.FileCopyUtils; + +/** + * The type Spring doc test app. + */ +@SpringBootApplication +class SpringDocTestApp { + + /** + * The Http 500 example resource. + */ + @Value("classpath:/500-90.txt") + private Resource http500ExampleResource; + + /** + * As string string. + * + * @param resource the resource + * @return the string + */ + public static String asString(Resource resource) { + try (Reader reader = new InputStreamReader(resource.getInputStream())) { + return FileCopyUtils.copyToString(reader); + } + catch (IOException e) { + throw new UncheckedIOException(e); + } + } + + /** + * Open api customiser open api customiser. + * + * @param examples the examples + * @return the open api customiser + */ + @Bean + public OpenApiCustomizer openApiCustomizer(Collection> examples) { + return openAPI -> { + examples.forEach(example -> { + openAPI.getComponents().addExamples(example.getKey(), example.getValue()); + }); + }; + } + + /** + * Http 500 example entry. + * + * @return the entry + */ + @Bean + public Entry http500Example() { + Example http500Example = new Example(); + Entry entry = new AbstractMap.SimpleEntry("http500Example", http500Example); + http500Example.setSummary("HTTP 500 JSON Body response example"); + http500Example.setDescription( + "An example of HTTP response in case an error occurs on server side. instance attribute reference a traceId to ease server side analysis."); + http500Example.setValue(asString(http500ExampleResource)); + return entry; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app90/User.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app90/User.java new file mode 100644 index 000000000..d378af816 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app90/User.java @@ -0,0 +1,448 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app90; + +import java.util.Objects; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.v3.oas.annotations.media.Schema; + +/** + * User + */ +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen", date = "2019-11-30T09:49:26.034469-01:00[Atlantic/Azores]") + + +class User { + + /** + * The Id. + */ + @JsonProperty("id") + + private Long id; + + + /** + * The Username. + */ + @JsonProperty("username") + + private String username; + + + /** + * The First name. + */ + @JsonProperty("firstName") + + private String firstName; + + + /** + * The Last name. + */ + @JsonProperty("lastName") + + private String lastName; + + + /** + * The Email. + */ + @JsonProperty("email") + + private String email; + + + /** + * The Password. + */ + @JsonProperty("password") + + private String password; + + + /** + * The Phone. + */ + @JsonProperty("phone") + + private String phone; + + + /** + * The User status. + */ + @JsonProperty("userStatus") + + private Integer userStatus; + + + /** + * Id user. + * + * @param id the id + * @return the user + */ + public User id(Long id) { + this.id = id; + return this; + } + + + /** + * Get id + * + * @return id id + */ + @Schema(example = "10", description = "") + + + public Long getId() { + return id; + } + + /** + * Sets id. + * + * @param id the id + */ + public void setId(Long id) { + this.id = id; + } + + + /** + * Username user. + * + * @param username the username + * @return the user + */ + public User username(String username) { + this.username = username; + return this; + } + + + /** + * Get username + * + * @return username username + */ + @Schema(example = "theUser", description = "") + + + public String getUsername() { + return username; + } + + /** + * Sets username. + * + * @param username the username + */ + public void setUsername(String username) { + this.username = username; + } + + + /** + * First name user. + * + * @param firstName the first name + * @return the user + */ + public User firstName(String firstName) { + this.firstName = firstName; + return this; + } + + + /** + * Get firstName + * + * @return firstName first name + */ + @Schema(example = "John", description = "") + + + public String getFirstName() { + return firstName; + } + + /** + * Sets first name. + * + * @param firstName the first name + */ + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + + /** + * Last name user. + * + * @param lastName the last name + * @return the user + */ + public User lastName(String lastName) { + this.lastName = lastName; + return this; + } + + + /** + * Get lastName + * + * @return lastName last name + */ + @Schema(example = "James", description = "") + + + public String getLastName() { + return lastName; + } + + /** + * Sets last name. + * + * @param lastName the last name + */ + public void setLastName(String lastName) { + this.lastName = lastName; + } + + + /** + * Email user. + * + * @param email the email + * @return the user + */ + public User email(String email) { + this.email = email; + return this; + } + + + /** + * Get email + * + * @return email email + */ + @Schema(example = "john@email.com", description = "") + + + public String getEmail() { + return email; + } + + /** + * Sets email. + * + * @param email the email + */ + public void setEmail(String email) { + this.email = email; + } + + + /** + * Password user. + * + * @param password the password + * @return the user + */ + public User password(String password) { + this.password = password; + return this; + } + + + /** + * Get password + * + * @return password password + */ + @Schema(example = "12345", description = "") + + + public String getPassword() { + return password; + } + + /** + * Sets password. + * + * @param password the password + */ + public void setPassword(String password) { + this.password = password; + } + + + /** + * Phone user. + * + * @param phone the phone + * @return the user + */ + public User phone(String phone) { + this.phone = phone; + return this; + } + + + /** + * Get phone + * + * @return phone phone + */ + @Schema(example = "12345", description = "") + + + public String getPhone() { + return phone; + } + + /** + * Sets phone. + * + * @param phone the phone + */ + public void setPhone(String phone) { + this.phone = phone; + } + + + /** + * User status user. + * + * @param userStatus the user status + * @return the user + */ + public User userStatus(Integer userStatus) { + this.userStatus = userStatus; + return this; + } + + + /** + * User Status + * + * @return userStatus user status + */ + @Schema(example = "1", description = "User Status") + + + public Integer getUserStatus() { + return userStatus; + } + + /** + * Sets user status. + * + * @param userStatus the user status + */ + public void setUserStatus(Integer userStatus) { + this.userStatus = userStatus; + } + + + /** + * Equals boolean. + * + * @param o the o + * @return the boolean + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + User user = (User) o; + return Objects.equals(this.id, user.id) && + Objects.equals(this.username, user.username) && + Objects.equals(this.firstName, user.firstName) && + Objects.equals(this.lastName, user.lastName) && + Objects.equals(this.email, user.email) && + Objects.equals(this.password, user.password) && + Objects.equals(this.phone, user.phone) && + Objects.equals(this.userStatus, user.userStatus); + } + + /** + * Hash code int. + * + * @return the int + */ + @Override + public int hashCode() { + return Objects.hash(id, username, firstName, lastName, email, password, phone, userStatus); + } + + /** + * To string string. + * + * @return the string + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class User {\n"); + + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" username: ").append(toIndentedString(username)).append("\n"); + sb.append(" firstName: ").append(toIndentedString(firstName)).append("\n"); + sb.append(" lastName: ").append(toIndentedString(lastName)).append("\n"); + sb.append(" email: ").append(toIndentedString(email)).append("\n"); + sb.append(" password: ").append(toIndentedString(password)).append("\n"); + sb.append(" phone: ").append(toIndentedString(phone)).append("\n"); + sb.append(" userStatus: ").append(toIndentedString(userStatus)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + * @param o the o + * @return the string + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app91/Advice.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app91/Advice.java new file mode 100644 index 000000000..d49dc80b3 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app91/Advice.java @@ -0,0 +1,110 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app91; + +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.ExampleObject; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import jakarta.servlet.http.HttpServletRequest; + +import org.springframework.beans.TypeMismatchException; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.ResponseStatus; +import org.springframework.web.bind.annotation.RestControllerAdvice; + +/** + * The type Advice. + */ +@RestControllerAdvice +class Advice { + + /** + * Bad request response entity. + * + * @param req the req + * @param exception the exception + * @return the response entity + */ + @ExceptionHandler(TypeMismatchException.class) + @ResponseStatus(HttpStatus.BAD_REQUEST) + @ApiResponse( + responseCode = "400", + description = "Bad Request", + content = + @Content( + mediaType = MediaType.APPLICATION_JSON_VALUE, + schema = @Schema(implementation = ApiError.class), + examples = { + @ExampleObject( + name = "Service-400", + summary = "400 from the service directly", + value = + "{\"status\": 400," + + "\"errorCode\": \"ERROR_001\"," + + "\"message\": \"An example message...\"" + + "}") + })) + public ResponseEntity badRequest(HttpServletRequest req, Exception exception) { + ApiError erroObj = new ApiError(400, "A code", "A message"); + return new ResponseEntity<>(erroObj, HttpStatus.BAD_REQUEST); + } + + /** + * Internal server error response entity. + * + * @param req the req + * @param exception the exception + * @return the response entity + */ + @ExceptionHandler(Exception.class) + @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR) + @ApiResponse( + responseCode = "500", + description = "Internal Server Error", + content = + @Content( + mediaType = MediaType.APPLICATION_JSON_VALUE, + schema = @Schema(implementation = ApiError.class), + examples = { + @ExampleObject( + name = "Service-500", + summary = "500 from the service directly", + value = + "{\"status\": 500," + + "\"errorCode\": \"ERROR_002\"," + + "\"message\": \"Another example message...\"" + + "}") + })) + public ResponseEntity internalServerError(HttpServletRequest req, Exception exception) { + ApiError erroObj = new ApiError(500, "A different code", "A different message"); + return new ResponseEntity<>(erroObj, HttpStatus.INTERNAL_SERVER_ERROR); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app91/ApiError.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app91/ApiError.java new file mode 100644 index 000000000..8e02bb9e7 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app91/ApiError.java @@ -0,0 +1,79 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app91; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.v3.oas.annotations.media.Schema; + +/** + * The type Api error. + */ +@Schema( + type = "object", + name = "ApiError", + title = "ApiError", + description = "A consistent response object for sending errors over the wire.") +class ApiError { + + /** + * The Status. + */ + @Schema(name = "status", description = "The Http Status value", type = "int", nullable = true) + @JsonProperty("status") + private int status; + + /** + * The Error code. + */ + @Schema( + name = "errorCode", + description = "An Error Code which can help with identifying issues.", + type = "string", + nullable = true) + @JsonProperty("errorCode") + private String errorCode; + + /** + * The Message. + */ + @Schema(name = "message", description = "The Error Message.", type = "string", nullable = false) + @JsonProperty("message") + private String message; + + /** + * Instantiates a new Api error. + * + * @param status the status + * @param errorCode the error code + * @param message the message + */ + public ApiError(int status, String errorCode, String message) { + this.status = status; + this.errorCode = errorCode; + this.message = message; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app91/Greeting.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app91/Greeting.java new file mode 100644 index 000000000..74de2eb62 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app91/Greeting.java @@ -0,0 +1,63 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app91; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.v3.oas.annotations.media.Schema; + +/** + * The type Greeting. + */ +@Schema( + type = "object", + name = "Greeting", + title = "Greeting", + description = "An object containing a greeting message") +class Greeting { + + + /** + * The Payload. + */ + @Schema( + name = "payload", + description = "The greeting value", + type = "string", + nullable = false, + example = "sdfsdfs") + @JsonProperty("payload") + private String payload; + + /** + * Instantiates a new Greeting. + * + * @param payload the payload + */ + public Greeting(String payload) { + this.payload = payload; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app91/GreetingController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app91/GreetingController.java new file mode 100644 index 000000000..744d4832f --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app91/GreetingController.java @@ -0,0 +1,72 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app91; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.apache.commons.lang3.RandomStringUtils; + +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE; + +/** + * The type Greeting controller. + */ +@RestController +@Tag(name = "Demo", description = "The Demo API") +class GreetingController { + + /** + * Say hello response entity. + * + * @return the response entity + */ + @GetMapping(produces = APPLICATION_JSON_VALUE) + @Operation(summary = "This API will return a random greeting.") + public ResponseEntity sayHello() { + return ResponseEntity.ok(new Greeting(RandomStringUtils.randomAlphanumeric(10))); + } + + /** + * Say hello 2 response entity. + * + * @return the response entity + */ + @GetMapping("/test") + @ApiResponses(value = { @ApiResponse(responseCode = "201", description = "item created"), + @ApiResponse(responseCode = "400", description = "invalid input, object invalid"), + @ApiResponse(responseCode = "409", description = "an existing item already exists") }) + public ResponseEntity sayHello2() { + return ResponseEntity.ok(new Greeting(RandomStringUtils.randomAlphanumeric(10))); + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app91/SpringDocApp91Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app91/SpringDocApp91Test.java new file mode 100644 index 000000000..53292a5a8 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app91/SpringDocApp91Test.java @@ -0,0 +1,47 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app91; + + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.test.context.TestPropertySource; + +/** + * The type Spring doc app 91 test. + */ +@TestPropertySource(properties = "springdoc.override-with-generic-response=false") +class SpringDocApp91Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app92/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app92/HelloController.java new file mode 100644 index 000000000..5f814955a --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app92/HelloController.java @@ -0,0 +1,53 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app92; + +import jakarta.validation.constraints.NotNull; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +@RequestMapping("/test") +class HelloController { + + /** + * Index string. + * + * @param test the test + * @return the string + */ + @GetMapping + String index(@NotNull String test) { + return null; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app92/ParameterCustomizer.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app92/ParameterCustomizer.java new file mode 100644 index 000000000..617c2befd --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app92/ParameterCustomizer.java @@ -0,0 +1,55 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app92; + +import io.swagger.v3.oas.models.parameters.Parameter; +import jakarta.validation.constraints.NotNull; + +import org.springframework.core.MethodParameter; +import org.springframework.stereotype.Component; + +/** + * The type Parameter customizer. + */ +@Component +class ParameterCustomizer implements org.springdoc.core.customizers.ParameterCustomizer { + /** + * Customize parameter. + * + * @param parameterModel the parameter model + * @param methodParameter the method parameter + * @return the parameter + */ + @Override + public Parameter customize(Parameter parameterModel, MethodParameter methodParameter) { + NotNull annotation = methodParameter.getParameterAnnotation(NotNull.class); + if (annotation != null) { + parameterModel.required(false); + } + return parameterModel; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app92/SpringDocApp92Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app92/SpringDocApp92Test.java new file mode 100644 index 000000000..5a8839d36 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app92/SpringDocApp92Test.java @@ -0,0 +1,45 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app92; + + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 92 test. + */ +class SpringDocApp92Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app93/BaseClientModel.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app93/BaseClientModel.java new file mode 100644 index 000000000..bfca1bbc1 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app93/BaseClientModel.java @@ -0,0 +1,40 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app93; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The type Base client model. + */ +public abstract class BaseClientModel { + /** + * The Id. + */ + @JsonProperty("id") + int id; +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app93/BaseController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app93/BaseController.java new file mode 100644 index 000000000..70bf8fc7e --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app93/BaseController.java @@ -0,0 +1,50 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app93; + +import io.swagger.v3.oas.annotations.Operation; + +import org.springframework.web.bind.annotation.GetMapping; + +/** + * The type Base controller. + * + * @param the type parameter + */ +public abstract class BaseController { + /** + * Get t client model. + * + * @param param the param + * @return the t client model + */ + @Operation + @GetMapping + TClientModel get(TClientModel param) { + return null; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app93/SpecificClientModel.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app93/SpecificClientModel.java new file mode 100644 index 000000000..301a05524 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app93/SpecificClientModel.java @@ -0,0 +1,40 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app93; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The type Specific client model. + */ +class SpecificClientModel extends BaseClientModel { + /** + * The Name. + */ + @JsonProperty("name") + String name; +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app93/SpecificController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app93/SpecificController.java new file mode 100644 index 000000000..729eaaddd --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app93/SpecificController.java @@ -0,0 +1,35 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app93; + +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Specific controller. + */ +@RestController +class SpecificController extends BaseController {} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app93/SpringDocApp93Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app93/SpringDocApp93Test.java new file mode 100644 index 000000000..8fae2b218 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app93/SpringDocApp93Test.java @@ -0,0 +1,45 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app93; + + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 93 test. + */ +class SpringDocApp93Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app94/Greeting.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app94/Greeting.java new file mode 100644 index 000000000..3acdad822 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app94/Greeting.java @@ -0,0 +1,63 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app94; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.v3.oas.annotations.media.Schema; + +/** + * The type Greeting. + */ +@Schema( + type = "object", + name = "Greeting", + title = "Greeting", + description = "An object containing a greeting message") +class Greeting { + + + /** + * The Payload. + */ + @Schema( + name = "payload", + description = "The greeting value", + type = "string", + nullable = false, + example = "sdfsdfs") + @JsonProperty("payload") + private String payload; + + /** + * Instantiates a new Greeting. + * + * @param payload the payload + */ + public Greeting(String payload) { + this.payload = payload; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app94/SpringDocApp94Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app94/SpringDocApp94Test.java new file mode 100644 index 000000000..4ce7f653d --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app94/SpringDocApp94Test.java @@ -0,0 +1,186 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app94; + +import java.util.Collections; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.apache.commons.lang3.RandomStringUtils; +import org.springdoc.core.customizers.OpenApiBuilderCustomizer; +import org.springdoc.core.customizers.SpringDocCustomizers; +import org.springdoc.core.properties.SpringDocConfigProperties; +import org.springdoc.core.providers.SpringDocProviders; +import org.springdoc.core.service.AbstractRequestService; +import org.springdoc.core.service.GenericResponseService; +import org.springdoc.core.service.OpenAPIService; +import org.springdoc.core.service.OperationService; +import org.springdoc.webmvc.api.OpenApiWebMvcResource; +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.beans.BeansException; +import org.springframework.beans.factory.ObjectFactory; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.ApplicationContext; +import org.springframework.context.ApplicationContextAware; +import org.springframework.context.annotation.Bean; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.test.context.TestPropertySource; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.servlet.mvc.method.RequestMappingInfo; +import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping; + +import static org.springdoc.core.utils.Constants.DEFAULT_GROUP_NAME; +import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE; + +/** + * The type Spring doc app 94 test. + */ +@TestPropertySource(properties = "springdoc.default-produces-media-type=application/json") +class SpringDocApp94Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp implements ApplicationContextAware { + + /** + * The Application context. + */ + private ApplicationContext applicationContext; + + /** + * Greeting controller greeting controller. + * + * @return the greeting controller + */ + @Bean + public GreetingController greetingController() { + return new GreetingController(); + } + + /** + * Custom open api open api builder customizer. + * + * @return the open api builder customizer + */ + @Bean + public OpenApiBuilderCustomizer customOpenAPI() { + return openApiBuilder -> openApiBuilder.addMappings(Collections.singletonMap("greetingController", new GreetingController())); + } + + /** + * Default test handler mapping request mapping handler mapping. + * + * @param greetingController the greeting controller + * @return the request mapping handler mapping + * @throws NoSuchMethodException the no such method exception + */ + @Bean + public RequestMappingHandlerMapping defaultTestHandlerMapping(GreetingController greetingController) throws NoSuchMethodException { + RequestMappingHandlerMapping result = new RequestMappingHandlerMapping(); + RequestMappingInfo requestMappingInfo = + RequestMappingInfo.paths("/test").methods(RequestMethod.GET).produces(MediaType.APPLICATION_JSON_VALUE).build(); + + result.setApplicationContext(this.applicationContext); + result.registerMapping(requestMappingInfo, "greetingController", GreetingController.class.getDeclaredMethod("sayHello2")); + //result.handlerme + return result; + } + + /** + * Open api resource open api web mvc resource. + * + * @param openAPIBuilderObjectFactory the open api builder object factory + * @param requestBuilder the request builder + * @param responseBuilder the response builder + * @param operationParser the operation parser + * @param springDocConfigProperties the spring doc config properties + * @param springDocProviders the spring doc providers + * @param springDocCustomizers the spring doc customizers + * @return the open api web mvc resource + */ + @Bean(name = "openApiResource") + public OpenApiWebMvcResource openApiResource(ObjectFactory openAPIBuilderObjectFactory, AbstractRequestService requestBuilder, GenericResponseService responseBuilder, + OperationService operationParser, + SpringDocConfigProperties springDocConfigProperties, + SpringDocProviders springDocProviders, SpringDocCustomizers springDocCustomizers) { + return new OpenApiWebMvcResource(DEFAULT_GROUP_NAME, openAPIBuilderObjectFactory, requestBuilder, responseBuilder, operationParser, + springDocConfigProperties, springDocProviders, springDocCustomizers); + } + + /** + * Sets application context. + * + * @param applicationContext the application context + * @throws BeansException the beans exception + */ + @Override + public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { + this.applicationContext = applicationContext; + } + } + + /** + * The type Greeting controller. + */ + @ResponseBody + @Tag(name = "Demo", description = "The Demo API") + public static class GreetingController { + + /** + * Say hello response entity. + * + * @return the response entity + */ + @GetMapping(produces = APPLICATION_JSON_VALUE) + @Operation(summary = "This API will return a random greeting.") + public ResponseEntity sayHello() { + return ResponseEntity.ok(new Greeting(RandomStringUtils.randomAlphanumeric(10))); + } + + /** + * Say hello 2 response entity. + * + * @return the response entity + */ + @GetMapping("/test") + @ApiResponses(value = { @ApiResponse(responseCode = "201", description = "item created"), + @ApiResponse(responseCode = "400", description = "invalid input, object invalid"), + @ApiResponse(responseCode = "409", description = "an existing item already exists") }) + public ResponseEntity sayHello2() { + return ResponseEntity.ok(new Greeting(RandomStringUtils.randomAlphanumeric(10))); + } + + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app95/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app95/HelloController.java new file mode 100644 index 000000000..645a1ded4 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app95/HelloController.java @@ -0,0 +1,55 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app95; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +@RequestMapping("/persons") +class HelloController { + + /** + * Persons. + * + * @param name the name + */ + @GetMapping + @Operation(summary = "${test.app95.operation.persons.summary}", + description = "${test.app95.operation.persons.description}") + public void persons(@Parameter(description = "${test.app95.param.name.description}") String name) { + + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app95/SpringDocApp95Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app95/SpringDocApp95Test.java new file mode 100644 index 000000000..5825c21ae --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app95/SpringDocApp95Test.java @@ -0,0 +1,47 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app95; + + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.test.context.ActiveProfiles; + +/** + * The type Spring doc app 95 test. + */ +@ActiveProfiles("95") +class SpringDocApp95Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app96/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app96/HelloController.java new file mode 100644 index 000000000..5a1e98c5b --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app96/HelloController.java @@ -0,0 +1,76 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app96; + +import jakarta.validation.constraints.Min; +import jakarta.validation.constraints.NotNull; + +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + + /** + * Test 1 string. + * + * @param test the test + * @return the string + */ + @PostMapping("/api1") + String test1(@RequestBody @Min(2) int test) { + return null; + } + + /** + * Test 2 string. + * + * @param test the test + * @return the string + */ + @PostMapping("/api2") + String test2(@RequestBody String test) { + return null; + } + + /** + * Test 3 string. + * + * @param test the test + * @return the string + */ + @PostMapping("/api3") + String test3(@NotNull String test) { + return null; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app96/SpringDocApp96Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app96/SpringDocApp96Test.java new file mode 100644 index 000000000..4047322f7 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app96/SpringDocApp96Test.java @@ -0,0 +1,45 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app96; + + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 96 test. + */ +class SpringDocApp96Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app97/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app97/HelloController.java new file mode 100644 index 000000000..96656d538 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app97/HelloController.java @@ -0,0 +1,69 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app97; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +@RequestMapping("/api") +class HelloController { + + /** + * Header v 1 student v 1. + * + * @return the student v 1 + */ + @GetMapping(value = "/student/header1", headers = "X-API-VERSION=1") + public StudentV1 headerV1() { + return new StudentV1("Bob Charlie"); + } + + /** + * Header v 2 student v 2. + * + * @return the student v 2 + */ + @GetMapping(value = "/student/header2", headers = "X-API-VERSION=2") + public StudentV2 headerV2() { + return new StudentV2("Charlie"); + } + + /** + * Header v 3 student v 3. + * + * @return the student v 3 + */ + @GetMapping(value = "/student/header3", headers = "X-API-VERSION") + public StudentV3 headerV3() { + return new StudentV3("Tom Charlie"); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app97/SpringDocApp97Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app97/SpringDocApp97Test.java new file mode 100644 index 000000000..ef92e1ecd --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app97/SpringDocApp97Test.java @@ -0,0 +1,45 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app97; + + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 97 test. + */ +class SpringDocApp97Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app97/StudentV1.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app97/StudentV1.java new file mode 100644 index 000000000..19df77966 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app97/StudentV1.java @@ -0,0 +1,50 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app97; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The type Student v 1. + */ +class StudentV1 { + + /** + * The Name. + */ + @JsonProperty("name") + private String name; + + /** + * Instantiates a new Student v 1. + * + * @param name the name + */ + public StudentV1(String name) { + this.name = name; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app97/StudentV2.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app97/StudentV2.java new file mode 100644 index 000000000..424465428 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app97/StudentV2.java @@ -0,0 +1,50 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app97; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The type Student v 2. + */ +class StudentV2 { + + /** + * The Name. + */ + @JsonProperty("bb") + private String name; + + /** + * Instantiates a new Student v 2. + * + * @param name the name + */ + public StudentV2(String name) { + this.name = name; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app97/StudentV3.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app97/StudentV3.java new file mode 100644 index 000000000..5ed3c6859 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app97/StudentV3.java @@ -0,0 +1,50 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app97; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The type Student v 3. + */ +class StudentV3 { + + /** + * The Name. + */ + @JsonProperty("name") + private String name; + + /** + * Instantiates a new Student v 3. + * + * @param name the name + */ + public StudentV3(String name) { + this.name = name; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app98/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app98/HelloController.java new file mode 100644 index 000000000..187887983 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app98/HelloController.java @@ -0,0 +1,48 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app98; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * Persons. + * + * @param name the name + */ + @GetMapping("/persons") + public void persons(@IgnoredAnnotationParameter String name) { + + } + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app98/IgnoredAnnotationParameter.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app98/IgnoredAnnotationParameter.java new file mode 100644 index 000000000..43d67d01c --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app98/IgnoredAnnotationParameter.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app98; + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + +/** + * The interface Ignored annotation parameter. + */ +@Retention(RetentionPolicy.RUNTIME) +public @interface IgnoredAnnotationParameter { + /** + * Addition string. + * + * @return the string + */ + String addition() default "customized parameter!"; +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app98/SpringDocApp98Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app98/SpringDocApp98Test.java new file mode 100644 index 000000000..904f44bda --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app98/SpringDocApp98Test.java @@ -0,0 +1,49 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app98; + + +import org.springdoc.core.utils.SpringDocUtils; +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 98 test. + */ +class SpringDocApp98Test extends AbstractSpringDocTest { + + static { + SpringDocUtils.getConfig().addAnnotationsToIgnore(IgnoredAnnotationParameter.class); + } + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app99/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app99/HelloController.java new file mode 100644 index 000000000..1d7974240 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app99/HelloController.java @@ -0,0 +1,54 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app99; + +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +@RequestMapping("/persons") +class HelloController { + + /** + * Persons. + */ + @GetMapping + @ApiResponses({ + @ApiResponse(responseCode = "202", description = "${test.app99.operation.persons.response.202.description}") + }) + public void persons() { + + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app99/SpringDocApp99Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app99/SpringDocApp99Test.java new file mode 100644 index 000000000..09403cf14 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v30/app99/SpringDocApp99Test.java @@ -0,0 +1,47 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app99; + + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.test.context.ActiveProfiles; + +/** + * The type Spring doc app 99 test. + */ +@ActiveProfiles("99") +class SpringDocApp99Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/AbstractSpringDocTest.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/AbstractSpringDocTest.java new file mode 100644 index 000000000..b8893cc2d --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/AbstractSpringDocTest.java @@ -0,0 +1,102 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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; + +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; + +import org.junit.jupiter.api.Test; +import org.springdoc.core.utils.Constants; + +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.web.servlet.MockMvc; +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; + +/** + * The type Abstract spring doc test. + */ +@ActiveProfiles("test") +@SpringBootTest +@AutoConfigureMockMvc +public abstract class AbstractSpringDocTest { + + /** + * The constant className. + */ + public static String className; + + /** + * The Mock mvc. + */ + @Autowired + protected MockMvc mockMvc; + + /** + * Gets content. + * + * @param fileName the file name + * @return the content + * @throws Exception the exception + */ + public static String getContent(String fileName) throws Exception { + try { + Path path = Paths.get(AbstractSpringDocTest.class.getClassLoader().getResource(fileName).toURI()); + byte[] fileBytes = Files.readAllBytes(path); + return new String(fileBytes, StandardCharsets.UTF_8); + } + catch (Exception e) { + throw new RuntimeException("Failed to read file: " + fileName, e); + } + } + + /** + * Test app. + * + * @throws Exception the exception + */ + @Test + protected void testApp() throws Exception { + className = getClass().getSimpleName(); + String testNumber = className.replaceAll("[^0-9]", ""); + MvcResult mockMvcResult = mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL)).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 + ".json"); + assertEquals(expected, result, true); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app1/ApiException.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app1/ApiException.java new file mode 100644 index 000000000..dad236231 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app1/ApiException.java @@ -0,0 +1,56 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app1; + +/** + * The type Api exception. + */ +public final class ApiException extends Exception { + + /** + * The constant serialVersionUID. + */ + private static final long serialVersionUID = 1L; + + /** + * The Code. + */ + @SuppressWarnings("unused") + + private final int code; + + /** + * Instantiates a new Api exception. + * + * @param code the code + * @param msg the msg + */ + public ApiException(int code, String msg) { + super(msg); + this.code = code; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app1/ApiOriginFilter.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app1/ApiOriginFilter.java new file mode 100644 index 000000000..5e90f1014 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app1/ApiOriginFilter.java @@ -0,0 +1,77 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app1; + +import java.io.IOException; + +import jakarta.servlet.FilterChain; +import jakarta.servlet.FilterConfig; +import jakarta.servlet.ServletException; +import jakarta.servlet.ServletRequest; +import jakarta.servlet.ServletResponse; +import jakarta.servlet.http.HttpServletResponse; + +/** + * The type Api origin filter. + */ +class ApiOriginFilter implements jakarta.servlet.Filter { + /** + * Do filter. + * + * @param request the request + * @param response the response + * @param chain the chain + * @throws IOException the io exception + * @throws ServletException the servlet exception + */ + @Override + public void doFilter(ServletRequest request, ServletResponse response, + FilterChain chain) throws IOException, ServletException { + HttpServletResponse res = (HttpServletResponse) response; + res.addHeader("Access-Control-Allow-Origin", "*"); + res.addHeader("Access-Control-Allow-Methods", "GET, POST, DELETE, PUT"); + res.addHeader("Access-Control-Allow-Headers", "Content-Type"); + chain.doFilter(request, response); + } + + /** + * Destroy. + */ + @Override + public void destroy() { + } + + /** + * Init. + * + * @param filterConfig the filter config + * @throws ServletException the servlet exception + */ + @Override + public void init(FilterConfig filterConfig) throws ServletException { + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app1/ApiResponseMessage.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app1/ApiResponseMessage.java new file mode 100644 index 000000000..085d1feab --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app1/ApiResponseMessage.java @@ -0,0 +1,168 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app1; + +import jakarta.xml.bind.annotation.XmlTransient; + +/** + * The type Api response message. + */ +@jakarta.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2019-07-08T09:37:36.546Z[GMT]") +@jakarta.xml.bind.annotation.XmlRootElement +class ApiResponseMessage { + /** + * The constant ERROR. + */ + public static final int ERROR = 1; + + /** + * The constant WARNING. + */ + public static final int WARNING = 2; + + /** + * The constant INFO. + */ + public static final int INFO = 3; + + /** + * The constant OK. + */ + public static final int OK = 4; + + /** + * The constant TOO_BUSY. + */ + public static final int TOO_BUSY = 5; + + /** + * The Code. + */ + int code; + + /** + * The Type. + */ + String type; + + /** + * The Message. + */ + String message; + + /** + * Instantiates a new Api response message. + */ + public ApiResponseMessage() { + } + + /** + * Instantiates a new Api response message. + * + * @param code the code + * @param message the message + */ + public ApiResponseMessage(int code, String message) { + this.code = code; + switch (code) { + case ERROR: + setType("error"); + break; + case WARNING: + setType("warning"); + break; + case INFO: + setType("info"); + break; + case OK: + setType("ok"); + break; + case TOO_BUSY: + setType("too busy"); + break; + default: + setType("unknown"); + break; + } + this.message = message; + } + + /** + * Gets code. + * + * @return the code + */ + @XmlTransient + public int getCode() { + return code; + } + + /** + * Sets code. + * + * @param code the code + */ + public void setCode(int code) { + this.code = code; + } + + /** + * Gets type. + * + * @return the type + */ + public String getType() { + return type; + } + + /** + * Sets type. + * + * @param type the type + */ + public void setType(String type) { + this.type = type; + } + + /** + * Gets message. + * + * @return the message + */ + public String getMessage() { + return message; + } + + /** + * Sets message. + * + * @param message the message + */ + public void setMessage(String message) { + this.message = message; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app1/ErrorMessage.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app1/ErrorMessage.java new file mode 100644 index 000000000..6ca3d831a --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app1/ErrorMessage.java @@ -0,0 +1,91 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app1; + +/** + * The type Error message. + */ +class ErrorMessage { + + /** + * The Id. + */ + private String id; + + /** + * The Message. + */ + private String message; + + /** + * Instantiates a new Error message. + * + * @param id the id + * @param message2 the message 2 + */ + public ErrorMessage(String id, String message2) { + this.id = id; + this.message = message2; + } + + /** + * Gets id. + * + * @return the id + */ + public String getId() { + return id; + } + + /** + * Sets id. + * + * @param id the id + */ + public void setId(String id) { + this.id = id; + } + + /** + * Gets message. + * + * @return the message + */ + public String getMessage() { + return message; + } + + /** + * Sets message. + * + * @param message the message + */ + public void setMessage(String message) { + this.message = message; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app1/ExceptionTranslator.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app1/ExceptionTranslator.java new file mode 100644 index 000000000..dd71a4cfe --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app1/ExceptionTranslator.java @@ -0,0 +1,75 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app1; + +import java.util.UUID; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.ControllerAdvice; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.ResponseStatus; + +/** + * The type Exception translator. + */ +@ControllerAdvice +class ExceptionTranslator { + + /** + * The constant LOGGER. + */ + private static final Logger LOGGER = LoggerFactory.getLogger(ExceptionTranslator.class); + + /** + * Handle run time exception response entity. + * + * @param e the e + * @return the response entity + */ + @ExceptionHandler({ RuntimeException.class }) + @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR) + public ResponseEntity handleRunTimeException(RuntimeException e) { + return error(HttpStatus.INTERNAL_SERVER_ERROR, e); + } + + + /** + * Error response entity. + * + * @param status the status + * @param e the e + * @return the response entity + */ + private ResponseEntity error(HttpStatus status, Exception e) { + LOGGER.error("Exception : ", e); + return ResponseEntity.status(status).body(new ErrorMessage(UUID.randomUUID().toString(), e.getMessage())); + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app1/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app1/HelloController.java new file mode 100644 index 000000000..c28db707c --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app1/HelloController.java @@ -0,0 +1,58 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app1; + + +import io.swagger.v3.oas.annotations.tags.Tag; + +import org.springframework.http.HttpStatus; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.ResponseStatus; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * Index string. + * + * @param numTel the num tel + * @param adresse the adresse + * @return the string + */ + @GetMapping(value = "/hello/{numTelco}") + @ResponseStatus(HttpStatus.I_AM_A_TEAPOT) + @Tag(name = "tea") + public String index(@PathVariable("numTelco") String numTel, String adresse) { + return "Greetings from Spring Boot!"; + } + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app1/HomeController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app1/HomeController.java new file mode 100644 index 000000000..e4d4638cd --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app1/HomeController.java @@ -0,0 +1,58 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app1; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.GetMapping; + +import static org.springdoc.core.utils.Constants.SWAGGER_UI_PATH; +import static org.springframework.util.AntPathMatcher.DEFAULT_PATH_SEPARATOR; +import static org.springframework.web.servlet.view.UrlBasedViewResolver.REDIRECT_URL_PREFIX; + +/** + * Home redirection to swagger api documentation + */ +@Controller +class HomeController { + + /** + * The Swagger ui path. + */ + @Value(SWAGGER_UI_PATH) + private String swaggerUiPath; + + /** + * Index string. + * + * @return the string + */ + @GetMapping(DEFAULT_PATH_SEPARATOR) + public String index() { + return REDIRECT_URL_PREFIX + swaggerUiPath; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app1/InventoryApi.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app1/InventoryApi.java new file mode 100644 index 000000000..1c9d5ed95 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app1/InventoryApi.java @@ -0,0 +1,92 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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. + * * * * * + * * * * + * * * + * * + * + */ + +/** + * NOTE: This class is auto generated by the swagger code generator program (3.0.8). + * https://github.com/swagger-api/swagger-codegen + * Do not edit the class manually. + */ +package test.org.springdoc.api.v31.app1; + +import java.util.List; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.validation.Valid; +import jakarta.validation.constraints.Max; +import jakarta.validation.constraints.Min; + +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestParam; + +/** + * The interface Inventory api. + */ +@jakarta.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2019-07-08T09:37:36.546Z[GMT]") +@Tag(name = "inventory") +public interface InventoryApi { + + /** + * Add inventory response entity. + * + * @param body the body + * @return the response entity + */ + @Operation(description = "adds an inventory item", operationId = "addInventory", summary = "Adds an item to the system", tags = { + "admins", }) + @ApiResponses(value = { @ApiResponse(responseCode = "201", description = "item created"), + @ApiResponse(responseCode = "400", description = "invalid input, object invalid"), + @ApiResponse(responseCode = "409", description = "an existing item already exists") }) + @PostMapping(value = "/inventory", consumes = { "application/json" }) + ResponseEntity addInventory( + @io.swagger.v3.oas.annotations.parameters.RequestBody(description = "Inventory item to do") @Valid @RequestBody InventoryItem body); + + /** + * Search inventory response entity. + * + * @param searchString the search string + * @param skip the skip + * @param limit the limit + * @return the response entity + */ + @Operation(description = "searches inventory", operationId = "searchInventory", summary = "By passing in the appropriate options, you can search for available inventory in the system ", tags = { + "developers", }, parameters = { + @Parameter(description = "pass an optional search string for looking up inventory", name = "searchString") }) + @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "search results matching criteria"), + @ApiResponse(responseCode = "400", description = "bad input parameter") }) + @GetMapping(value = "/inventory", produces = { "application/json" }) + ResponseEntity> searchInventory( + @Valid @RequestParam(value = "searchString", required = false) String searchString, + @Min(0) @Parameter(description = "number of records to skip for pagination") @Valid @RequestParam(value = "skip", required = true) Integer skip, + @Min(0) @Max(50) @Parameter(description = "maximum number of records to return") @Valid @RequestParam(value = "limit", required = true) Integer limit); + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app1/InventoryApiController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app1/InventoryApiController.java new file mode 100644 index 000000000..e7bf184d8 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app1/InventoryApiController.java @@ -0,0 +1,115 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app1; + +import java.util.List; + +import com.fasterxml.jackson.databind.ObjectMapper; +import io.swagger.v3.oas.annotations.Parameter; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.validation.Valid; +import jakarta.validation.constraints.Max; +import jakarta.validation.constraints.Min; + +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Inventory api controller. + */ +@jakarta.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2019-07-08T09:37:36.546Z[GMT]") +@RestController +class InventoryApiController implements InventoryApi { + + + /** + * The Object mapper. + */ + @SuppressWarnings("unused") + private final ObjectMapper objectMapper; + + /** + * The Request. + */ + private final HttpServletRequest request; + + /** + * Instantiates a new Inventory api controller. + * + * @param objectMapper the object mapper + * @param request the request + */ + @org.springframework.beans.factory.annotation.Autowired + public InventoryApiController(ObjectMapper objectMapper, HttpServletRequest request) { + this.objectMapper = objectMapper; + this.request = request; + } + + /** + * Add inventory response entity. + * + * @param body the body + * @return the response entity + */ + public ResponseEntity addInventory( + @io.swagger.v3.oas.annotations.parameters.RequestBody(description = "Inventory item to add") @Valid @RequestBody InventoryItem body) { + @SuppressWarnings("unused") + String accept = request.getHeader("Accept"); + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); + } + + /** + * Search inventory response entity. + * + * @param searchString the search string + * @param skip the skip + * @param limit the limit + * @return the response entity + */ + public ResponseEntity> searchInventory( + @Parameter(description = "pass an optional search string for looking up inventory") @Valid @RequestParam(value = "searchString", required = false) String searchString, + @Min(0) @Parameter(description = "number of records to skip for pagination") @Valid @RequestParam(value = "skip", required = true) Integer skip, + @Min(0) @Max(50) @Parameter(description = "maximum number of records to return") @Valid @RequestParam(value = "limit", required = true) Integer limit) { + @SuppressWarnings("unused") + String accept = request.getHeader("Accept"); + return new ResponseEntity>(HttpStatus.NOT_IMPLEMENTED); + } + + /** + * Gets . + * + * @param language the language + * @return the + */ + public String getme(String language) { + return language; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app1/InventoryItem.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app1/InventoryItem.java new file mode 100644 index 000000000..de0c974c8 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app1/InventoryItem.java @@ -0,0 +1,261 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app1; + +import java.util.Objects; +import java.util.UUID; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.Valid; +import jakarta.validation.constraints.NotNull; + +import org.springframework.validation.annotation.Validated; + +/** + * InventoryItem + */ +@Validated +@jakarta.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2019-07-08T09:37:36.546Z[GMT]") +class InventoryItem { + /** + * The Id. + */ + @JsonProperty("id") + private UUID id = null; + + /** + * The Name. + */ + @JsonProperty("name") + private String name = null; + + /** + * The Release date. + */ + @JsonProperty("releaseDate") + private String releaseDate = null; + + /** + * The Manufacturer. + */ + @JsonProperty("manufacturer") + private Manufacturer manufacturer = null; + + /** + * Id inventory item. + * + * @param id the id + * @return the inventory item + */ + public InventoryItem id(UUID id) { + this.id = id; + return this; + } + + /** + * Get id + * + * @return id id + */ + @Schema(example = "d290f1ee-6c54-4b01-90e6-d701748f0851", required = true) + @NotNull + + @Valid + public UUID getId() { + return id; + } + + /** + * Sets id. + * + * @param id the id + */ + public void setId(UUID id) { + this.id = id; + } + + /** + * Name inventory item. + * + * @param name the name + * @return the inventory item + */ + public InventoryItem name(String name) { + this.name = name; + return this; + } + + /** + * Get name + * + * @return name name + */ + @Schema(example = "Widget Adapter", required = true) + @NotNull + + public String getName() { + return name; + } + + /** + * Sets name. + * + * @param name the name + */ + public void setName(String name) { + this.name = name; + } + + /** + * Release date inventory item. + * + * @param releaseDate the release date + * @return the inventory item + */ + public InventoryItem releaseDate(String releaseDate) { + this.releaseDate = releaseDate; + return this; + } + + /** + * Get releaseDate + * + * @return releaseDate release date + */ + @Schema(example = "2016-08-29T09:12:33.001Z", required = true) + @NotNull + + public String getReleaseDate() { + return releaseDate; + } + + /** + * Sets release date. + * + * @param releaseDate the release date + */ + public void setReleaseDate(String releaseDate) { + this.releaseDate = releaseDate; + } + + /** + * Manufacturer inventory item. + * + * @param manufacturer the manufacturer + * @return the inventory item + */ + public InventoryItem manufacturer(Manufacturer manufacturer) { + this.manufacturer = manufacturer; + return this; + } + + /** + * Get manufacturer + * + * @return manufacturer manufacturer + */ + @Schema(required = true) + @NotNull + + @Valid + public Manufacturer getManufacturer() { + return manufacturer; + } + + /** + * Sets manufacturer. + * + * @param manufacturer the manufacturer + */ + public void setManufacturer(Manufacturer manufacturer) { + this.manufacturer = manufacturer; + } + + + /** + * Equals boolean. + * + * @param o the o + * @return the boolean + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + InventoryItem inventoryItem = (InventoryItem) o; + return Objects.equals(this.id, inventoryItem.id) && + Objects.equals(this.name, inventoryItem.name) && + Objects.equals(this.releaseDate, inventoryItem.releaseDate) && + Objects.equals(this.manufacturer, inventoryItem.manufacturer); + } + + /** + * Hash code int. + * + * @return the int + */ + @Override + public int hashCode() { + return Objects.hash(id, name, releaseDate, manufacturer); + } + + /** + * To string string. + * + * @return the string + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class InventoryItem {\n"); + + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" releaseDate: ").append(toIndentedString(releaseDate)).append("\n"); + sb.append(" manufacturer: ").append(toIndentedString(manufacturer)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + * @param o the o + * @return the string + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app1/ItemController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app1/ItemController.java new file mode 100644 index 000000000..40de6bb1e --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app1/ItemController.java @@ -0,0 +1,89 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app1; + +import java.net.URI; +import java.time.Instant; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; + +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.enums.Explode; +import io.swagger.v3.oas.annotations.enums.ParameterIn; +import io.swagger.v3.oas.annotations.media.ArraySchema; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.validation.Valid; +import jakarta.validation.constraints.Size; + +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.servlet.support.ServletUriComponentsBuilder; + +/** + * The type Item controller. + */ +@RestController +@Tag(name = "items") +class ItemController { + + /** + * Show items list. + * + * @param customerID the customer id + * @param toto the toto + * @param startDate the start date + * @param filterIds the filter ids + * @return the list + */ + @GetMapping("/items") + public List showItems(@RequestParam("cusID") @Size(min = 4, max = 6) final String customerID, + @Size(min = 4, max = 6) int toto, + @Parameter(name = "start", in = ParameterIn.QUERY, required = false, schema = @Schema(type = "string", format = "date-time", required = false, example = "1970-01-01T00:00:00.000Z")) @RequestParam(value = "start", required = false) Instant startDate, + @Parameter(name = "filterIds", in = ParameterIn.QUERY, array = @ArraySchema(schema = @Schema(type = "string")), explode = Explode.FALSE) @RequestParam(required = false) List filterIds) { + return new ArrayList(); + } + + /** + * Add item response entity. + * + * @param itemDTO the item dto + * @return the response entity + */ + @PostMapping("/items") + public ResponseEntity addItem(@Valid @RequestBody final ItemLightDTO itemDTO) { + final URI location = ServletUriComponentsBuilder.fromCurrentRequest().path("/{id}") + .buildAndExpand(UUID.randomUUID()).toUri(); + return ResponseEntity.created(location).build(); + } + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app1/ItemDTO.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app1/ItemDTO.java new file mode 100644 index 000000000..84bfe48e1 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app1/ItemDTO.java @@ -0,0 +1,164 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app1; + +import java.io.Serializable; + +/** + * The type Item dto. + * @author bnasslahsen + */ +class ItemDTO implements Serializable { + + /** + * serialVersionUID of type long + */ + private static final long serialVersionUID = 1L; + + /** + * itemID of type String + */ + private String itemID; + + /** + * description of type String + */ + private String description; + + /** + * price of type int + */ + private int price; + + /** + * The Deprecated price. + */ + @Deprecated + private int deprecatedPrice; + + /** + * Instantiates a new Item dto. + */ + public ItemDTO() { + } + + /** + * Instantiates a new Item dto. + * + * @param description description + * @param price price + */ + public ItemDTO(final String description, final int price) { + this.description = description; + this.price = price; + } + + /** + * Instantiates a new Item dto. + * + * @param itemID itemID + * @param description description + * @param price price + */ + public ItemDTO(final String itemID, final String description, final int price) { + this.itemID = itemID; + this.description = description; + this.price = price; + } + + /** + * Gets description. + * + * @return description description + */ + public String getDescription() { + return description; + } + + /** + * Sets description. + * + * @param description description + */ + public void setDescription(final String description) { + this.description = description; + } + + /** + * Gets item id. + * + * @return item id + */ + public String getItemID() { + return itemID; + } + + /** + * Sets item id. + * + * @param itemID itemID + */ + public void setItemID(final String itemID) { + this.itemID = itemID; + } + + /** + * Gets price. + * + * @return price price + */ + public int getPrice() { + return price; + } + + /** + * Sets price. + * + * @param price price + */ + public void setPrice(final int price) { + this.price = price; + } + + /** + * Gets deprecated price. + * + * @return the deprecated price + */ + public int getDeprecatedPrice() { + return deprecatedPrice; + } + + /** + * Sets deprecated price. + * + * @param deprecatedPrice the deprecated price + */ + public void setDeprecatedPrice(int deprecatedPrice) { + this.deprecatedPrice = deprecatedPrice; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app1/ItemLightDTO.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app1/ItemLightDTO.java new file mode 100644 index 000000000..3e8cf7dd4 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app1/ItemLightDTO.java @@ -0,0 +1,129 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app1; + +import java.io.Serializable; + +/** + * The type Item light dto. + * @author bnasslahsen + */ +class ItemLightDTO implements Serializable { + + /** + * serialVersionUID of type long + */ + private static final long serialVersionUID = 1L; + + /** + * description of type String + */ + private String description; + + /** + * price of type int + */ + private int price; + + /** + * The Deprecated price. + */ + @Deprecated + private int deprecatedPrice; + + /** + * Instantiates a new Item light dto. + */ + public ItemLightDTO() { + } + + /** + * Instantiates a new Item light dto. + * + * @param description the description + * @param price the price + */ + public ItemLightDTO(String description, int price) { + super(); + this.description = description; + this.price = price; + } + + /** + * Gets description. + * + * @return description description + */ + public String getDescription() { + return description; + } + + /** + * Sets description. + * + * @param description description + */ + public void setDescription(final String description) { + this.description = description; + } + + /** + * Gets price. + * + * @return price price + */ + public int getPrice() { + return price; + } + + /** + * Sets price. + * + * @param price price + */ + public void setPrice(final int price) { + this.price = price; + } + + /** + * Gets deprecated price. + * + * @return the deprecated price + */ + public int getDeprecatedPrice() { + return deprecatedPrice; + } + + /** + * Sets deprecated price. + * + * @param deprecatedPrice the deprecated price + */ + public void setDeprecatedPrice(int deprecatedPrice) { + this.deprecatedPrice = deprecatedPrice; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app1/Manufacturer.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app1/Manufacturer.java new file mode 100644 index 000000000..bcc1b1382 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app1/Manufacturer.java @@ -0,0 +1,215 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app1; + +import java.util.Objects; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotNull; + +import org.springframework.validation.annotation.Validated; + + +/** + * Manufacturer + */ +@Validated +@jakarta.annotation.Generated(value = "io.swagger.codegen.v3.generators.java.SpringCodegen", date = "2019-07-08T09:37:36.546Z[GMT]") +class Manufacturer { + /** + * The Name. + */ + @JsonProperty("name") + private String name = null; + + /** + * The Home page. + */ + @JsonProperty("homePage") + private String homePage = null; + + /** + * The Phone. + */ + @JsonProperty("phone") + private String phone = null; + + /** + * Name manufacturer. + * + * @param name the name + * @return the manufacturer + */ + public Manufacturer name(String name) { + this.name = name; + return this; + } + + /** + * Get name + * + * @return name name + */ + @Schema(example = "ACME Corporation", required = true) + @NotNull + + public String getName() { + return name; + } + + /** + * Sets name. + * + * @param name the name + */ + public void setName(String name) { + this.name = name; + } + + /** + * Home page manufacturer. + * + * @param homePage the home page + * @return the manufacturer + */ + public Manufacturer homePage(String homePage) { + this.homePage = homePage; + return this; + } + + /** + * Get homePage + * + * @return homePage home page + */ + @Schema(example = "https://www.acme-corp.com") + + public String getHomePage() { + return homePage; + } + + /** + * Sets home page. + * + * @param homePage the home page + */ + public void setHomePage(String homePage) { + this.homePage = homePage; + } + + /** + * Phone manufacturer. + * + * @param phone the phone + * @return the manufacturer + */ + public Manufacturer phone(String phone) { + this.phone = phone; + return this; + } + + /** + * Get phone + * + * @return phone phone + */ + @Schema(example = "408-867-5309") + public String getPhone() { + return phone; + } + + /** + * Sets phone. + * + * @param phone the phone + */ + public void setPhone(String phone) { + this.phone = phone; + } + + + /** + * Equals boolean. + * + * @param o the o + * @return the boolean + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Manufacturer manufacturer = (Manufacturer) o; + return Objects.equals(this.name, manufacturer.name) && + Objects.equals(this.homePage, manufacturer.homePage) && + Objects.equals(this.phone, manufacturer.phone); + } + + /** + * Hash code int. + * + * @return the int + */ + @Override + public int hashCode() { + return Objects.hash(name, homePage, phone); + } + + /** + * To string string. + * + * @return the string + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Manufacturer {\n"); + + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" homePage: ").append(toIndentedString(homePage)).append("\n"); + sb.append(" phone: ").append(toIndentedString(phone)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + * @param o the o + * @return the string + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app1/PeopleRestService.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app1/PeopleRestService.java new file mode 100644 index 000000000..3d6e71f24 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app1/PeopleRestService.java @@ -0,0 +1,146 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app1; + +import java.net.URI; +import java.util.Collection; +import java.util.Map; +import java.util.UUID; +import java.util.concurrent.ConcurrentHashMap; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.headers.Header; +import io.swagger.v3.oas.annotations.media.ArraySchema; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.tags.Tag; + +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.servlet.support.ServletUriComponentsBuilder; + +/** + * The type People rest service. + */ +@RestController +@Tag(name = "people") +class PeopleRestService { + /** + * The People. + */ + private Map people = new ConcurrentHashMap<>(); + + /** + * Gets people. + * + * @return the people + */ + @GetMapping(value = "/people", produces = MediaType.APPLICATION_JSON_VALUE) + @Operation(description = "List all people", responses = { + @ApiResponse(content = @Content(array = @ArraySchema(schema = @Schema(implementation = PersonDTO.class))), responseCode = "200") }) + public Collection getPeople() { + return people.values(); + } + + /** + * Find person person dto. + * + * @param email the email + * @return the person dto + */ + @Operation(description = "Find person by e-mail", responses = { + @ApiResponse(content = @Content(schema = @Schema(implementation = PersonDTO.class)), responseCode = "200"), + @ApiResponse(responseCode = "404", description = "Person with such e-mail doesn't exists") }) + @GetMapping(value = "/{email}", produces = MediaType.APPLICATION_JSON_VALUE) + public PersonDTO findPerson( + @Parameter(description = "E-Mail address to lookup for", required = true) @PathVariable("email") final String email) { + + final PersonDTO person = people.get(email); + + if (person == null) { + throw new RuntimeException("Person with such e-mail doesn't exists"); + } + + return person; + } + + /** + * Add person response entity. + * + * @param email the email + * @param firstName the first name + * @param lastName the last name + * @return the response entity + */ + @PostMapping(value = "/{email}", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) + @Operation(description = "Create new person", responses = { + @ApiResponse(content = @Content(schema = @Schema(implementation = PersonDTO.class), mediaType = MediaType.APPLICATION_JSON_VALUE), headers = @Header(name = "Location"), responseCode = "201"), + @ApiResponse(responseCode = "409", description = "Person with such e-mail already exists") }) + public ResponseEntity addPerson( + @Parameter(description = "E-Mail", required = true) @PathVariable("email") final String email, + @Parameter(description = "First Name", required = true) @RequestParam("firstName") final String firstName, + @Parameter(description = "Last Name", required = true) @RequestParam("lastName") final String lastName) { + + final PersonDTO person = people.get(email); + + if (person != null) { + return ResponseEntity.status(HttpStatus.CONFLICT).body("Person with such e-mail already exists"); + } + + people.put(email, new PersonDTO(email, firstName, lastName)); + final URI location = ServletUriComponentsBuilder.fromCurrentRequest().path("/{id}") + .buildAndExpand(UUID.randomUUID()).toUri(); + return ResponseEntity.created(location).build(); + } + + /** + * Delete person response entity. + * + * @param email the email + * @return the response entity + */ + @DeleteMapping(value = "/{email}") + @Operation(description = "Delete existing person", responses = { + @ApiResponse(responseCode = "204", description = "Person has been deleted"), + @ApiResponse(responseCode = "404", description = "Person with such e-mail doesn't exists") }) + public ResponseEntity deletePerson( + @Parameter(description = "E-Mail address to lookup for", required = true) @PathVariable("email") final String email) { + if (people.remove(email) == null) { + throw new RuntimeException("Person with such e-mail doesn't exists"); + } + return ResponseEntity.noContent().build(); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app1/PersonDTO.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app1/PersonDTO.java new file mode 100644 index 000000000..175db8fba --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app1/PersonDTO.java @@ -0,0 +1,120 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app1; + +/** + * The type Person dto. + */ +class PersonDTO { + /** + * The Email. + */ + private String email; + + /** + * The First name. + */ + private String firstName; + + /** + * The Last name. + */ + private String lastName; + + /** + * Instantiates a new Person dto. + */ + public PersonDTO() { + } + + /** + * Instantiates a new Person dto. + * + * @param email the email + * @param firstName the first name + * @param lastName the last name + */ + public PersonDTO(final String email, final String firstName, final String lastName) { + this.email = email; + this.firstName = firstName; + this.lastName = lastName; + } + + /** + * Gets email. + * + * @return the email + */ + public String getEmail() { + return email; + } + + /** + * Sets email. + * + * @param email the email + */ + public void setEmail(final String email) { + this.email = email; + } + + /** + * Gets first name. + * + * @return the first name + */ + public String getFirstName() { + return firstName; + } + + /** + * Sets first name. + * + * @param firstName the first name + */ + public void setFirstName(final String firstName) { + this.firstName = firstName; + } + + /** + * Gets last name. + * + * @return the last name + */ + public String getLastName() { + return lastName; + } + + /** + * Sets last name. + * + * @param lastName the last name + */ + public void setLastName(final String lastName) { + this.lastName = lastName; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app1/SpringDocApp1Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app1/SpringDocApp1Test.java new file mode 100644 index 000000000..9ede493c8 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app1/SpringDocApp1Test.java @@ -0,0 +1,65 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app1; + +import io.swagger.v3.oas.models.Components; +import io.swagger.v3.oas.models.OpenAPI; +import io.swagger.v3.oas.models.info.Info; +import io.swagger.v3.oas.models.info.License; +import io.swagger.v3.oas.models.security.SecurityScheme; +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; +import org.springframework.test.context.TestPropertySource; + +/** + * The type Spring doc app 1 test. + */ +@TestPropertySource(properties = "springdoc.default-produces-media-type=application/json") +class SpringDocApp1Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp { + /** + * Custom open api open api. + * + * @return the open api + */ + @Bean + public OpenAPI customOpenAPI() { + return new OpenAPI() + .components(new Components().addSecuritySchemes("basicScheme", + new SecurityScheme().type(SecurityScheme.Type.HTTP).scheme("basic"))) + .info(new Info().title("SpringShop API").version("v0") + .license(new License().name("Apache 2.0").url("http://springdoc.org"))); + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app10/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app10/HelloController.java new file mode 100644 index 000000000..48a47847e --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app10/HelloController.java @@ -0,0 +1,69 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app10; + +import java.util.Locale; + +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; +import jakarta.servlet.http.HttpSession; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestAttribute; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * Test. + * + * @param header the header + * @param request the request + * @param response the response + * @param locale the locale + * @param hello the hello + */ + @GetMapping("/test") + public void test(HttpSession header, HttpServletRequest request, HttpServletResponse response, Locale locale, + String hello) { + } + + /** + * Test request attribute. + * + * @param sample the sample + * @param s the s + */ + @GetMapping("/testreq") + public void testRequestAttribute(@RequestAttribute String sample, String s) { + + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app10/SpringDocApp10Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app10/SpringDocApp10Test.java new file mode 100644 index 000000000..5ad2dcd97 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app10/SpringDocApp10Test.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app10; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 10 test. + */ +class SpringDocApp10Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app100/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app100/HelloController.java new file mode 100644 index 000000000..33d254e74 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app100/HelloController.java @@ -0,0 +1,55 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app100; + +import io.swagger.v3.oas.annotations.tags.Tag; +import io.swagger.v3.oas.annotations.tags.Tags; +import jakarta.validation.constraints.NotNull; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +@Tags(value = @Tag(name = "hello-ap1")) +class HelloController { + + /** + * Gets all pets. + * + * @param toto the toto + * @return the all pets + */ + @GetMapping(value = "/search", produces = { "application/xml", "application/json" }) + @Tags(value = @Tag(name = "hello-ap2")) + public PersonDTO getAllPets(@NotNull String toto) { + return null; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app100/PersonDTO.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app100/PersonDTO.java new file mode 100644 index 000000000..aa9c3767b --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app100/PersonDTO.java @@ -0,0 +1,123 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app100; + +import io.swagger.v3.oas.annotations.media.Schema; + +/** + * The type Person dto. + */ +@Schema +class PersonDTO { + /** + * The Email. + */ + private String email; + + /** + * The First name. + */ + private String firstName; + + /** + * The Last name. + */ + private String lastName; + + /** + * Instantiates a new Person dto. + */ + public PersonDTO() { + } + + /** + * Instantiates a new Person dto. + * + * @param email the email + * @param firstName the first name + * @param lastName the last name + */ + public PersonDTO(final String email, final String firstName, final String lastName) { + this.email = email; + this.firstName = firstName; + this.lastName = lastName; + } + + /** + * Gets email. + * + * @return the email + */ + public String getEmail() { + return email; + } + + /** + * Sets email. + * + * @param email the email + */ + public void setEmail(final String email) { + this.email = email; + } + + /** + * Gets first name. + * + * @return the first name + */ + public String getFirstName() { + return firstName; + } + + /** + * Sets first name. + * + * @param firstName the first name + */ + public void setFirstName(final String firstName) { + this.firstName = firstName; + } + + /** + * Gets last name. + * + * @return the last name + */ + public String getLastName() { + return lastName; + } + + /** + * Sets last name. + * + * @param lastName the last name + */ + public void setLastName(final String lastName) { + this.lastName = lastName; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app100/SpringDocApp100Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app100/SpringDocApp100Test.java new file mode 100644 index 000000000..63c3c0c3a --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app100/SpringDocApp100Test.java @@ -0,0 +1,45 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app100; + + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 100 test. + */ +class SpringDocApp100Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app101/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app101/HelloController.java new file mode 100644 index 000000000..3e3aed723 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app101/HelloController.java @@ -0,0 +1,57 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app101; + +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +@RequestMapping("/hello") +class HelloController { + + /** + * Hello hello dto. + * + * @return the hello dto + */ + @GetMapping + @ApiResponse(content = @Content(schema = @Schema( + description = "${test.app101.operation.hello.response.schema.description}", + implementation = HelloDTO.class))) + public HelloDTO hello() { + return new HelloDTO(); + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app101/HelloDTO.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app101/HelloDTO.java new file mode 100644 index 000000000..67fac5268 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app101/HelloDTO.java @@ -0,0 +1,63 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app101; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.v3.oas.annotations.media.Schema; + +/** + * The type Hello dto. + */ +@Schema(description = "${test.app101.schema.hello.description}") +class HelloDTO { + + /** + * The Id. + */ + @Schema(description = "${test.app101.schema.hello.param.id.description}") + private String id; + + /** + * Gets id. + * + * @return the id + */ + @JsonProperty("id") + public String getId() { + return id; + } + + /** + * Sets id. + * + * @param id the id + */ + public void setId(String id) { + this.id = id; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app101/SpringDocApp101Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app101/SpringDocApp101Test.java new file mode 100644 index 000000000..02cd66864 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app101/SpringDocApp101Test.java @@ -0,0 +1,47 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app101; + + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.test.context.ActiveProfiles; + +/** + * The type Spring doc app 101 test. + */ +@ActiveProfiles("101") +class SpringDocApp101Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app102/InheritedRequestParams.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app102/InheritedRequestParams.java new file mode 100644 index 000000000..b108c4264 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app102/InheritedRequestParams.java @@ -0,0 +1,60 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app102; + +import io.swagger.v3.oas.annotations.Parameter; +import jakarta.validation.constraints.NotBlank; + +/** + * The type Inherited request params. + */ +class InheritedRequestParams extends RequestParams { + /** + * The Child param. + */ + @Parameter(description = "parameter from child of RequestParams") + @NotBlank + private String childParam; + + /** + * Gets child param. + * + * @return the child param + */ + public String getChildParam() { + return childParam; + } + + /** + * Sets child param. + * + * @param childParam the child param + */ + public void setChildParam(String childParam) { + this.childParam = childParam; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app102/RequestParams.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app102/RequestParams.java new file mode 100644 index 000000000..158e49fdf --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app102/RequestParams.java @@ -0,0 +1,284 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app102; + +import java.math.BigInteger; +import java.util.List; +import java.util.Optional; + +import io.swagger.v3.oas.annotations.Parameter; + +import org.springframework.lang.Nullable; + +/** + * The type Request params. + */ +class RequestParams { + + /** + * The String param. + */ + @Parameter(description = "string parameter") + private String stringParam; + + /** + * The String param 1. + */ + @Deprecated + private String stringParam1; + + /** + * The String param 2. + */ + @Parameter(description = "string parameter2", required = true) + private String stringParam2; + + /** + * The Int param. + */ + @Parameter(description = "int parameter") + private int intParam; + + /** + * The Int param 2. + */ + private Optional intParam2; + + /** + * The Int param 3. + */ + @Nullable + private String intParam3; + + /** + * The Nested. + */ + private Nested nested; + + /** + * The Nested list. + */ + private List nestedList; + + /** + * Gets string param. + * + * @return the string param + */ + public String getStringParam() { + return stringParam; + } + + /** + * Sets string param. + * + * @param stringParam the string param + */ + public void setStringParam(String stringParam) { + this.stringParam = stringParam; + } + + /** + * Gets int param. + * + * @return the int param + */ + public int getIntParam() { + return intParam; + } + + /** + * Sets int param. + * + * @param intParam the int param + */ + public void setIntParam(int intParam) { + this.intParam = intParam; + } + + /** + * Gets int param 2. + * + * @return the int param 2 + */ + public Optional getIntParam2() { + return intParam2; + } + + /** + * Sets int param 2. + * + * @param intParam2 the int param 2 + */ + public void setIntParam2(Optional intParam2) { + this.intParam2 = intParam2; + } + + /** + * Gets int param 3. + * + * @return the int param 3 + */ + @Nullable + public String getIntParam3() { + return intParam3; + } + + /** + * Sets int param 3. + * + * @param intParam3 the int param 3 + */ + public void setIntParam3(@Nullable String intParam3) { + this.intParam3 = intParam3; + } + + /** + * Gets string param 1. + * + * @return the string param 1 + */ + public String getStringParam1() { + return stringParam1; + } + + /** + * Sets string param 1. + * + * @param stringParam1 the string param 1 + */ + public void setStringParam1(String stringParam1) { + this.stringParam1 = stringParam1; + } + + /** + * Gets string param 2. + * + * @return the string param 2 + */ + public String getStringParam2() { + return stringParam2; + } + + /** + * Sets string param 2. + * + * @param stringParam2 the string param 2 + */ + public void setStringParam2(String stringParam2) { + this.stringParam2 = stringParam2; + } + + /** + * Gets nested. + * + * @return the nested + */ + public Nested getNested() { + return nested; + } + + /** + * Sets nested. + * + * @param nested the nested + */ + public void setNested(Nested nested) { + this.nested = nested; + } + + /** + * Gets nested list. + * + * @return the nested list + */ + public List getNestedList() { + return nestedList; + } + + /** + * Sets nested list. + * + * @param nestedList the nested list + */ + public void setNestedList(List nestedList) { + this.nestedList = nestedList; + } + + /** + * The type Nested. + */ + public static class Nested { + /** + * The Param 1. + */ + private String param1; + + /** + * The Param 2. + */ + private BigInteger param2; + + /** + * Gets param 1. + * + * @return the param 1 + */ + @Parameter(description = "nested string parameter") + public String getParam1() { + return param1; + } + + /** + * Sets param 1. + * + * @param param1 the param 1 + */ + public void setParam1(String param1) { + this.param1 = param1; + } + + /** + * Gets param 2. + * + * @return the param 2 + */ + @Parameter(description = "nested BigInteger parameter") + public BigInteger getParam2() { + return param2; + } + + /** + * Sets param 2. + * + * @param param2 the param 2 + */ + public void setParam2(BigInteger param2) { + this.param2 = param2; + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app102/SpringDocApp102Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app102/SpringDocApp102Test.java new file mode 100644 index 000000000..b2ea1347f --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app102/SpringDocApp102Test.java @@ -0,0 +1,42 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app102; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 102 test. + */ +class SpringDocApp102Test extends AbstractSpringDocTest { + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app102/TestController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app102/TestController.java new file mode 100644 index 000000000..4347f44d4 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app102/TestController.java @@ -0,0 +1,50 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app102; + +import org.springdoc.core.annotations.ParameterObject; + +import org.springframework.lang.Nullable; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Test controller. + */ +@RestController +class TestController { + /** + * Gets test. + * + * @param param the param + * @param requestParams the request params + */ + @GetMapping("test") + public void getTest(@RequestParam @Nullable String param, @ParameterObject InheritedRequestParams requestParams) { + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app103/ExampleBody.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app103/ExampleBody.java new file mode 100644 index 000000000..be96d9581 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app103/ExampleBody.java @@ -0,0 +1,78 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app103; + +/** + * The type Example body. + */ +class ExampleBody { + /** + * The String param. + */ + private String stringParam; + + /** + * The Int param. + */ + private int intParam; + + /** + * Gets string param. + * + * @return the string param + */ + public String getStringParam() { + return stringParam; + } + + /** + * Sets string param. + * + * @param stringParam the string param + */ + public void setStringParam(String stringParam) { + this.stringParam = stringParam; + } + + /** + * Gets int param. + * + * @return the int param + */ + public int getIntParam() { + return intParam; + } + + /** + * Sets int param. + * + * @param intParam the int param + */ + public void setIntParam(int intParam) { + this.intParam = intParam; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app103/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app103/HelloController.java new file mode 100644 index 000000000..eeb08d164 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app103/HelloController.java @@ -0,0 +1,69 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app103; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Encoding; +import io.swagger.v3.oas.annotations.parameters.RequestBody; + +import org.springframework.http.MediaType; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.multipart.MultipartFile; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * Post my request body string. + * + * @param body the body + * @param file the file + * @return the string + */ + @PostMapping(value = "/test/103", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) + @Operation( + requestBody = @RequestBody( + content = @Content( + encoding = @Encoding(name = "body", contentType = "application/json") + ) + ) + ) + public String postMyRequestBody( + @RequestPart("body") ExampleBody body, + @RequestParam("file") MultipartFile file + ) { + return null; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app103/SpringDocApp103Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app103/SpringDocApp103Test.java new file mode 100644 index 000000000..7cae09b43 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app103/SpringDocApp103Test.java @@ -0,0 +1,42 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app103; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 103 test. + */ +class SpringDocApp103Test extends AbstractSpringDocTest { + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app104/CrudController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app104/CrudController.java new file mode 100644 index 000000000..e12a74785 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app104/CrudController.java @@ -0,0 +1,73 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app104; + +import java.util.List; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.ResponseBody; + +/** + * The type Crud controller. + * + * @param the type parameter + */ +@Controller +@SuppressWarnings("rawtypes") +public abstract class CrudController { + + /** + * Get t. + * + * @param id the id + * @return the t + */ + @GetMapping(path = "{id}") + @ResponseBody + @Operation(description = "Get single object") + public T get( // + @Parameter(description = "The id to get.", required = true) @PathVariable("id") int id) { + return null; + } + + /** + * List list. + * + * @return the list + */ + @GetMapping(path = "") + @ResponseBody + @Operation(description = "Receive a list of objects") + public List list() { + return null; + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app104/Design.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app104/Design.java new file mode 100644 index 000000000..a062261fd --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app104/Design.java @@ -0,0 +1,33 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app104; + +/** + * The type Design. + */ +class Design extends HavingPK { +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app104/DesignController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app104/DesignController.java new file mode 100644 index 000000000..c7f5097d2 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app104/DesignController.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app104; + +import io.swagger.v3.oas.annotations.tags.Tag; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; + +/** + * The type Design controller. + */ +@Tag(name = "design") +@Controller +@RequestMapping("/design") +class DesignController extends CrudController { + + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app104/HavingPK.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app104/HavingPK.java new file mode 100644 index 000000000..58cae1773 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app104/HavingPK.java @@ -0,0 +1,33 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app104; + +/** + * The type Having pk. + */ +class HavingPK { +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app104/SpringDocApp104Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app104/SpringDocApp104Test.java new file mode 100644 index 000000000..2f20b5ff4 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app104/SpringDocApp104Test.java @@ -0,0 +1,42 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app104; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 104 test. + */ +class SpringDocApp104Test extends AbstractSpringDocTest { + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app105/SpringDocApp105Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app105/SpringDocApp105Test.java new file mode 100644 index 000000000..74e764d07 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app105/SpringDocApp105Test.java @@ -0,0 +1,144 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app105; + +import io.swagger.v3.oas.models.Components; +import io.swagger.v3.oas.models.OpenAPI; +import io.swagger.v3.oas.models.info.Info; +import io.swagger.v3.oas.models.info.License; +import io.swagger.v3.oas.models.security.SecurityScheme; +import org.junit.jupiter.api.Test; +import org.springdoc.core.utils.Constants; +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; +import org.springframework.test.context.TestPropertySource; + +import static org.hamcrest.Matchers.is; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + +/** + * The type Spring doc app 105 test. + */ +@TestPropertySource(properties = { + "springdoc.group-configs[0].group=stores", + "springdoc.group-configs[0].paths-to-match=/store/**", + "springdoc.group-configs[1].group=users", + "springdoc.group-configs[1].packages-to-scan=test.org.springdoc.api.v31.app105.api.user", + "springdoc.group-configs[2].group=pets", + "springdoc.group-configs[2].paths-to-match=/pet/**", + "springdoc.group-configs[3].group=groups test", + "springdoc.group-configs[3].paths-to-match=/v1/**", + "springdoc.group-configs[3].paths-to-exclude=/v1/users", + "springdoc.group-configs[3].packages-to-scan=test.org.springdoc.api.v31.app105.api.user,test.org.springdoc.api.v31.app105.api.store", +}) +class SpringDocApp105Test extends AbstractSpringDocTest { + + /** + * The constant className. + */ + public static String className; + + /** + * Test app. + * + * @throws Exception the exception + */ + @Test + protected void testApp() throws Exception { + mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL + "/stores")) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.openapi", is("3.1.0"))) + .andExpect(content().json(getContent("results/3.1.0/app105-1.json"), true)); + } + + /** + * Test app 2. + * + * @throws Exception the exception + */ + @Test + void testApp2() throws Exception { + mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL + "/users")) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.openapi", is("3.1.0"))) + .andExpect(content().json(getContent("results/3.1.0/app105-2.json"), true)); + } + + /** + * Test app 3. + * + * @throws Exception the exception + */ + @Test + void testApp3() throws Exception { + mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL + "/pets")) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.openapi", is("3.1.0"))) + .andExpect(content().json(getContent("results/3.1.0/app105-3.json"), true)); + } + + /** + * Test app 4. + * + * @throws Exception the exception + */ + @Test + void testApp4() throws Exception { + mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL + "/groups test")) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.openapi", is("3.1.0"))) + .andExpect(content().json(getContent("results/3.1.0/app105-4.json"), true)); + } + + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp { + /** + * Custom open api open api. + * + * @return the open api + */ + @Bean + public OpenAPI customOpenAPI() { + return new OpenAPI() + .components(new Components().addSecuritySchemes("basicScheme", + new SecurityScheme().type(SecurityScheme.Type.HTTP).scheme("basic"))) + .info(new Info().title("Petstore API").version("v0").description( + "This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.") + .termsOfService("http://swagger.io/terms/") + .license(new License().name("Apache 2.0").url("http://springdoc.org"))); + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app105/api/ApiUtil.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app105/api/ApiUtil.java new file mode 100644 index 000000000..b87168d0f --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app105/api/ApiUtil.java @@ -0,0 +1,69 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app105.api; + +import java.io.IOException; + +import jakarta.servlet.http.HttpServletResponse; + +import org.springframework.http.HttpStatus; +import org.springframework.web.context.request.NativeWebRequest; +import org.springframework.web.server.ResponseStatusException; + +/** + * The type Api util. + */ +public class ApiUtil { + + /** + * Sets example response. + * + * @param req the req + * @param contentType the content type + * @param example the example + */ + public static void setExampleResponse(NativeWebRequest req, String contentType, String example) { + try { + req.getNativeResponse(HttpServletResponse.class).addHeader("Content-Type", contentType); + req.getNativeResponse(HttpServletResponse.class).getOutputStream().print(example); + } + catch (IOException e) { + throw new RuntimeException(e); + } + } + + /** + * Check api key. + * + * @param req the req + */ + public static void checkApiKey(NativeWebRequest req) { + if (!"1".equals(System.getenv("DISABLE_API_KEY")) && !"special-key".equals(req.getHeader("api_key"))) { + throw new ResponseStatusException(HttpStatus.UNAUTHORIZED, "Missing API key!"); + } + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app105/api/ExceptionTranslator.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app105/api/ExceptionTranslator.java new file mode 100644 index 000000000..11c5f1364 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app105/api/ExceptionTranslator.java @@ -0,0 +1,74 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app105.api; + +import java.util.Map; + +import jakarta.validation.ConstraintViolationException; + +import org.springframework.boot.web.error.ErrorAttributeOptions; +import org.springframework.boot.web.servlet.error.ErrorAttributes; +import org.springframework.http.HttpStatus; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.ResponseStatus; +import org.springframework.web.bind.annotation.RestControllerAdvice; +import org.springframework.web.context.request.RequestAttributes; +import org.springframework.web.context.request.WebRequest; + +/** + * The type Exception translator. + */ +@RestControllerAdvice +class ExceptionTranslator { + + /** + * The Error attributes. + */ + private final ErrorAttributes errorAttributes; + + /** + * Instantiates a new Exception translator. + * + * @param errorAttributes the error attributes + */ + public ExceptionTranslator(ErrorAttributes errorAttributes) { + this.errorAttributes = errorAttributes; + } + + /** + * Process constraint violation exception map. + * + * @param request the request + * @return the map + */ + @ExceptionHandler(ConstraintViolationException.class) + @ResponseStatus(HttpStatus.BAD_REQUEST) + public Map processConstraintViolationException(WebRequest request) { + request.setAttribute("jakarta.servlet.error.status_code", HttpStatus.BAD_REQUEST.value(), RequestAttributes.SCOPE_REQUEST); + return errorAttributes.getErrorAttributes(request, ErrorAttributeOptions.defaults()); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app105/api/HomeController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app105/api/HomeController.java new file mode 100644 index 000000000..69a4d2cf8 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app105/api/HomeController.java @@ -0,0 +1,58 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app105.api; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.GetMapping; + +import static org.springdoc.core.utils.Constants.SWAGGER_UI_PATH; +import static org.springframework.util.AntPathMatcher.DEFAULT_PATH_SEPARATOR; +import static org.springframework.web.servlet.view.UrlBasedViewResolver.REDIRECT_URL_PREFIX; + +/** + * Home redirection to swagger api documentation + */ +@Controller +class HomeController { + + /** + * The Swagger ui path. + */ + @Value(SWAGGER_UI_PATH) + private String swaggerUiPath; + + /** + * Index string. + * + * @return the string + */ + @GetMapping(DEFAULT_PATH_SEPARATOR) + public String index() { + return REDIRECT_URL_PREFIX + swaggerUiPath; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app105/api/pet/PetApi.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app105/api/pet/PetApi.java new file mode 100644 index 000000000..36ce9c43a --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app105/api/pet/PetApi.java @@ -0,0 +1,227 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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. + * * * * * + * * * * + * * * + * * + * + */ + +/** + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (3.0.0). + * https://openapi-generator.tech + * Do not edit the class manually. + */ +package test.org.springdoc.api.v31.app105.api.pet; + +import java.util.List; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.enums.SecuritySchemeType; +import io.swagger.v3.oas.annotations.media.ArraySchema; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; +import io.swagger.v3.oas.annotations.security.OAuthFlow; +import io.swagger.v3.oas.annotations.security.OAuthFlows; +import io.swagger.v3.oas.annotations.security.OAuthScope; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.security.SecurityScheme; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.validation.Valid; +import jakarta.validation.constraints.NotNull; +import test.org.springdoc.api.v31.app105.model.ModelApiResponse; +import test.org.springdoc.api.v31.app105.model.Pet; + +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestHeader; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.multipart.MultipartFile; + +/** + * The interface Pet api. + */ +@SecurityScheme(name = "petstore_auth", type = SecuritySchemeType.OAUTH2, flows = @OAuthFlows(implicit = @OAuthFlow(authorizationUrl = "http://petstore.swagger.io/oauth/dialog", scopes = { + @OAuthScope(name = "write:pets", description = "modify pets in your account"), + @OAuthScope(name = "read:pets", description = "read your pets") }))) +@Tag(name = "pet", description = "the pet API") +public interface PetApi { + + /** + * Gets delegate. + * + * @return the delegate + */ + default PetApiDelegate getDelegate() { + return new PetApiDelegate() { + }; + } + + /** + * Add pet. + * + * @param pet the pet + */ + @Operation(summary = "Add a new pet to the store", description = "", security = { + @SecurityRequirement(name = "petstore_auth", scopes = { "write:pets", "read:pets" }) }, tags = { "pet" }) + @ApiResponses(value = { @ApiResponse(responseCode = "405", description = "Invalid input") }) + @PostMapping(value = "/pet", consumes = { "application/json", "application/xml" }) + default void addPet( + @io.swagger.v3.oas.annotations.parameters.RequestBody(description = "Pet object that needs to be added to the store", required = true) @Valid @RequestBody Pet pet) { + // return getDelegate().addPet(pet); + } + + /** + * Delete pet response entity. + * + * @param petId the pet id + * @param apiKey the api key + * @return the response entity + */ + @Operation(summary = "Deletes a pet", description = "", security = { + @SecurityRequirement(name = "petstore_auth", scopes = { "write:pets", "read:pets" }) }, tags = { "pet" }) + @ApiResponses(value = { @ApiResponse(responseCode = "400", description = "Invalid ID supplied"), + @ApiResponse(responseCode = "404", description = "Pet not found") }) + @DeleteMapping(value = "/pet/{petId}") + default ResponseEntity deletePet( + @Parameter(description = "Pet id to delete", required = true) @PathVariable("petId") Long petId, + @Parameter(description = "") @RequestHeader(value = "api_key", required = false) String apiKey) { + return getDelegate().deletePet(petId, apiKey); + } + + /** + * Find pets by status response entity. + * + * @param status the status + * @return the response entity + */ + @Operation(summary = "Finds Pets by status", description = "Multiple status values can be provided with comma separated strings", security = { + @SecurityRequirement(name = "petstore_auth", scopes = { "write:pets", "read:pets" }) }, tags = { "pet" }) + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(array = @ArraySchema(schema = @Schema(implementation = Pet.class)))), + @ApiResponse(responseCode = "400", description = "Invalid status value") }) + @GetMapping(value = "/pet/findByStatus", produces = { "application/xml", "application/json" }) + default ResponseEntity> findPetsByStatus( + @NotNull @Parameter(description = "Status values that need to be considered for filter", required = true) @Valid @RequestParam(value = "status", required = true) List status) { + return getDelegate().findPetsByStatus(status); + } + + /** + * Find pets by tags response entity. + * + * @param tags the tags + * @return the response entity + */ + @Operation(summary = "Finds Pets by tags", description = "Muliple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.", security = { + @SecurityRequirement(name = "petstore_auth", scopes = { "write:pets", "read:pets" }) }, tags = { "pet" }) + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(array = @ArraySchema(schema = @Schema(implementation = Pet.class)))), + @ApiResponse(responseCode = "400", description = "Invalid tag value") }) + @GetMapping(value = "/pet/findByTags", produces = { "application/xml", "application/json" }) + default ResponseEntity> findPetsByTags( + @NotNull @Parameter(description = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) List tags) { + return getDelegate().findPetsByTags(tags); + } + + /** + * Gets pet by id. + * + * @param petId the pet id + * @return the pet by id + */ + @Operation(summary = "Find pet by ID", description = "Returns a single pet", security = { + @SecurityRequirement(name = "api_key") }, tags = { "pet" }) + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(schema = @Schema(implementation = Pet.class))), + @ApiResponse(responseCode = "400", description = "Invalid ID supplied"), + @ApiResponse(responseCode = "404", description = "Pet not found") }) + @GetMapping(value = "/pet/{petId}", produces = { "application/xml", "application/json" }) + default ResponseEntity getPetById( + @Parameter(description = "ID of pet to return", required = true) @PathVariable("petId") Long petId) { + return getDelegate().getPetById(petId); + } + + /** + * Update pet response entity. + * + * @param pet the pet + * @return the response entity + */ + @Operation(summary = "Update an existing pet", description = "", security = { + @SecurityRequirement(name = "petstore_auth", scopes = { "write:pets", "read:pets" }) }, tags = { "pet" }) + @ApiResponses(value = { @ApiResponse(responseCode = "400", description = "Invalid ID supplied"), + @ApiResponse(responseCode = "404", description = "Pet not found"), + @ApiResponse(responseCode = "405", description = "Validation exception") }) + @PutMapping(value = "/pet", consumes = { "application/json", "application/xml" }) + default ResponseEntity updatePet( + @io.swagger.v3.oas.annotations.parameters.RequestBody(description = "Pet object that needs to be added to the store", required = true) @Valid @RequestBody Pet pet) { + return getDelegate().updatePet(pet); + } + + /** + * Update pet with form response entity. + * + * @param petId the pet id + * @param name the name + * @param status the status + * @return the response entity + */ + @Operation(summary = "Updates a pet in the store with form data", description = "", security = { + @SecurityRequirement(name = "petstore_auth", scopes = { "write:pets", "read:pets" }) }, tags = { "pet" }) + @ApiResponses(value = { @ApiResponse(responseCode = "405", description = "Invalid input") }) + @PostMapping(value = "/pet/{petId}", consumes = { "application/x-www-form-urlencoded" }) + default ResponseEntity updatePetWithForm( + @Parameter(description = "ID of pet that needs to be updated", required = true) @PathVariable("petId") Long petId, + @Parameter(description = "Updated name of the pet") @RequestParam(value = "name", required = false) String name, + @Parameter(description = "Updated status of the pet") @RequestParam(value = "status", required = false) String status) { + return getDelegate().updatePetWithForm(petId, name, status); + } + + /** + * Upload file response entity. + * + * @param petId the pet id + * @param additionalMetadata the additional metadata + * @param file the file + * @return the response entity + */ + @Operation(summary = "uploads an image", description = "", security = { + @SecurityRequirement(name = "petstore_auth", scopes = { "write:pets", "read:pets" }) }, tags = { "pet" }) + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(schema = @Schema(implementation = ModelApiResponse.class))) }) + @PostMapping(value = "/pet/{petId}/uploadImage", produces = { "application/json" }, consumes = { + "multipart/form-data" }) + default ResponseEntity uploadFile( + @Parameter(description = "ID of pet to update", required = true) @PathVariable("petId") Long petId, + @Parameter(description = "Additional data to pass to server") @RequestParam(value = "additionalMetadata", required = false) String additionalMetadata, + @Parameter(description = "file detail") @Valid @RequestPart("file") MultipartFile file) { + return getDelegate().uploadFile(petId, additionalMetadata, file); + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app105/api/pet/PetApiController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app105/api/pet/PetApiController.java new file mode 100644 index 000000000..d12e3f0f7 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app105/api/pet/PetApiController.java @@ -0,0 +1,68 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app105.api.pet; + +import java.util.Optional; + +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Pet api controller. + */ +@jakarta.annotation.Generated(value = "org.springdoc.demo.app2.codegen.languages.SpringCodegen", date = "2019-07-11T00:09:29.839+02:00[Europe/Paris]") + +@RestController +@RequestMapping("${openapi.openAPIPetstore.base-path:/}") +class PetApiController implements PetApi { + + /** + * The Delegate. + */ + private final PetApiDelegate delegate; + + /** + * Instantiates a new Pet api controller. + * + * @param delegate the delegate + */ + public PetApiController(@org.springframework.beans.factory.annotation.Autowired(required = false) PetApiDelegate delegate) { + this.delegate = Optional.ofNullable(delegate).orElse(new PetApiDelegate() { + }); + } + + /** + * Gets delegate. + * + * @return the delegate + */ + @Override + public PetApiDelegate getDelegate() { + return delegate; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app105/api/pet/PetApiDelegate.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app105/api/pet/PetApiDelegate.java new file mode 100644 index 000000000..fad4feab6 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app105/api/pet/PetApiDelegate.java @@ -0,0 +1,193 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app105.api.pet; + +import java.util.List; +import java.util.Optional; + +import jakarta.validation.Valid; +import test.org.springdoc.api.v31.app105.api.ApiUtil; +import test.org.springdoc.api.v31.app105.model.ModelApiResponse; +import test.org.springdoc.api.v31.app105.model.Pet; + +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.web.context.request.NativeWebRequest; +import org.springframework.web.multipart.MultipartFile; + +/** + * A delegate to be called by the {@link PetApiController}}. + * Implement this interface with a {@link org.springframework.stereotype.Service} annotated class. + */ +@jakarta.annotation.Generated(value = "org.springdoc.demo.app2.codegen.languages.SpringCodegen", date = "2019-07-11T00:09:29.839+02:00[Europe/Paris]") + +public interface PetApiDelegate { + + /** + * Gets request. + * + * @return the request + */ + default Optional getRequest() { + return Optional.empty(); + } + + /** + * Add pet. + * + * @param pet the pet + * @see PetApi#addPet PetApi#addPet + */ + default void addPet(Pet pet) { + + } + + /** + * Delete pet response entity. + * + * @param petId the pet id + * @param apiKey the api key + * @return the response entity + * @see PetApi#deletePet PetApi#deletePet + */ + default ResponseEntity deletePet(Long petId, + String apiKey) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * Find pets by status response entity. + * + * @param status the status + * @return the response entity + * @see PetApi#findPetsByStatus PetApi#findPetsByStatus + */ + default ResponseEntity> findPetsByStatus(List status) { + extract(); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * Extract. + */ + default void extract() { + getRequest().ifPresent(request -> { + for (MediaType mediaType : MediaType.parseMediaTypes(request.getHeader("Accept"))) { + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + ApiUtil.setExampleResponse(request, "application/json", "{ \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\"}"); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/xml"))) { + ApiUtil.setExampleResponse(request, "application/xml", " 123456789 doggie aeiou aeiou"); + break; + } + } + }); + } + + /** + * Find pets by tags response entity. + * + * @param tags the tags + * @return the response entity + * @see PetApi#findPetsByTags PetApi#findPetsByTags + */ + default ResponseEntity> findPetsByTags(List tags) { + extract(); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * Gets pet by id. + * + * @param petId the pet id + * @return the pet by id + * @see PetApi#getPetById PetApi#getPetById + */ + default ResponseEntity getPetById(Long petId) { + extract(); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * Update pet response entity. + * + * @param pet the pet + * @return the response entity + * @see PetApi#updatePet PetApi#updatePet + */ + default ResponseEntity updatePet(Pet pet) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * Update pet with form response entity. + * + * @param petId the pet id + * @param name the name + * @param status the status + * @return the response entity + * @see PetApi#updatePetWithForm PetApi#updatePetWithForm + */ + default ResponseEntity updatePetWithForm(Long petId, + String name, + String status) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * Upload file response entity. + * + * @param petId the pet id + * @param additionalMetadata the additional metadata + * @param file the file + * @return the response entity + * @see PetApi#uploadFile PetApi#uploadFile + */ + default ResponseEntity uploadFile(Long petId, + String additionalMetadata, + @Valid MultipartFile file) { + getRequest().ifPresent(request -> { + for (MediaType mediaType : MediaType.parseMediaTypes(request.getHeader("Accept"))) { + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + ApiUtil.setExampleResponse(request, "application/json", "{ \"code\" : 0, \"type\" : \"type\", \"message\" : \"message\"}"); + break; + } + } + }); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app105/api/pet/PetApiDelegateImpl.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app105/api/pet/PetApiDelegateImpl.java new file mode 100644 index 000000000..d35f0c526 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app105/api/pet/PetApiDelegateImpl.java @@ -0,0 +1,38 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app105.api.pet; + +import org.springframework.stereotype.Service; + +/** + * The type Pet api delegate. + */ +@Service +class PetApiDelegateImpl implements PetApiDelegate { + + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app105/api/store/StoreApi.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app105/api/store/StoreApi.java new file mode 100644 index 000000000..b3a4f1976 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app105/api/store/StoreApi.java @@ -0,0 +1,148 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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. + * * * * * + * * * * + * * * + * * + * + */ + +/** + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (3.0.0). + * https://openapi-generator.tech + * Do not edit the class manually. + */ +package test.org.springdoc.api.v31.app105.api.store; + +import java.util.Map; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.media.ArraySchema; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.validation.Valid; +import jakarta.validation.constraints.Max; +import jakarta.validation.constraints.Min; +import jakarta.validation.constraints.NotBlank; +import test.org.springdoc.api.v31.app105.model.Order; + +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; + +/** + * The interface Store api. + */ +@jakarta.annotation.Generated(value = "org.springdoc.demo.app2.codegen.languages.SpringCodegen", date = "2019-07-11T00:09:29.839+02:00[Europe/Paris]") + +@Tag(name = "store", description = "the store API") +public interface StoreApi { + + /** + * Gets delegate. + * + * @return the delegate + */ + default StoreApiDelegate getDelegate() { + return new StoreApiDelegate() { + }; + } + + /** + * Delete order response entity. + * + * @param orderId the order id + * @return the response entity + */ + @Operation(summary = "Delete purchase order by ID", tags = { "store" }) + @ApiResponses(value = { @ApiResponse(responseCode = "400", description = "Invalid ID supplied"), + @ApiResponse(responseCode = "404", description = "Order not found") }) + @DeleteMapping(value = "/store/order/{orderId}") + default ResponseEntity deleteOrder( + @Parameter(description = "ID of the order that needs to be deleted", required = true) @PathVariable("orderId") String orderId) { + return getDelegate().deleteOrder(orderId); + } + + /** + * Gets inventory. + * + * @return the inventory + */ + @Operation(summary = "Returns pet inventories by status", description = "Returns a map of status codes to quantities", security = { + @SecurityRequirement(name = "api_key") }, tags = { "store" }) + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(array = @ArraySchema(schema = @Schema(implementation = Map.class)))) }) + @GetMapping(value = "/store/inventory", produces = { "application/json" }) + default ResponseEntity> getInventory() { + return getDelegate().getInventory(); + } + + /** + * Gets order by id. + * + * @param orderId the order id + * @return the order by id + */ + @Operation(summary = "Find purchase order by ID", tags = { "store" }) + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(schema = @Schema(implementation = Order.class))), + @ApiResponse(responseCode = "400", description = "Invalid ID supplied"), + @ApiResponse(responseCode = "404", description = "Order not found") }) + @GetMapping(value = "/store/order/{orderId}", produces = { "application/xml", "application/json" }) + default ResponseEntity getOrderById( + @Min(1L) @Max(5L) @Parameter(description = "ID of pet that needs to be fetched", required = true) @PathVariable("orderId") Long orderId) { + return getDelegate().getOrderById(orderId); + } + + /** + * Place order response entity. + * + * @param order the order + * @return the response entity + */ + @Operation(summary = "Place an order for a pet", tags = { "store" }) + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(schema = @Schema(implementation = Order.class))), + @ApiResponse(responseCode = "400", description = "Invalid Order") }) + @PostMapping(value = "/store/order", produces = { "application/xml", "application/json" }, consumes = { + "application/json" }) + default ResponseEntity placeOrder( + @Parameter(description = "order placed for purchasing the pet", required = true) @Valid @RequestBody Order order) { + return getDelegate().placeOrder(order); + } + + /** + * Stores. + * + * @param name the name + */ + @GetMapping(value = "/v1/stores") + default void stores(@Valid @NotBlank String name) { + + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app105/api/store/StoreApiController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app105/api/store/StoreApiController.java new file mode 100644 index 000000000..7e1e5bd16 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app105/api/store/StoreApiController.java @@ -0,0 +1,68 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app105.api.store; + +import java.util.Optional; + +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Store api controller. + */ +@jakarta.annotation.Generated(value = "org.springdoc.demo.app2.codegen.languages.SpringCodegen", date = "2019-07-11T00:09:29.839+02:00[Europe/Paris]") + +@RestController +@RequestMapping("${openapi.openAPIPetstore.base-path:/}") +class StoreApiController implements StoreApi { + + /** + * The Delegate. + */ + private final StoreApiDelegate delegate; + + /** + * Instantiates a new Store api controller. + * + * @param delegate the delegate + */ + public StoreApiController(@org.springframework.beans.factory.annotation.Autowired(required = false) StoreApiDelegate delegate) { + this.delegate = Optional.ofNullable(delegate).orElse(new StoreApiDelegate() { + }); + } + + /** + * Gets delegate. + * + * @return the delegate + */ + @Override + public StoreApiDelegate getDelegate() { + return delegate; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app105/api/store/StoreApiDelegate.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app105/api/store/StoreApiDelegate.java new file mode 100644 index 000000000..d56c2f330 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app105/api/store/StoreApiDelegate.java @@ -0,0 +1,124 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app105.api.store; + +import java.util.Map; +import java.util.Optional; + +import test.org.springdoc.api.v31.app105.api.ApiUtil; +import test.org.springdoc.api.v31.app105.model.Order; + +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.web.context.request.NativeWebRequest; + +/** + * A delegate to be called by the {@link StoreApiController}}. + * Implement this interface with a {@link org.springframework.stereotype.Service} annotated class. + */ +@jakarta.annotation.Generated(value = "org.springdoc.demo.app2.codegen.languages.SpringCodegen", date = "2019-07-11T00:09:29.839+02:00[Europe/Paris]") + +public interface StoreApiDelegate { + + /** + * Gets request. + * + * @return the request + */ + default Optional getRequest() { + return Optional.empty(); + } + + /** + * Delete order response entity. + * + * @param orderId the order id + * @return the response entity + * @see StoreApi#deleteOrder StoreApi#deleteOrder + */ + default ResponseEntity deleteOrder(String orderId) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * Gets inventory. + * + * @return the inventory + * @see StoreApi#getInventory StoreApi#getInventory + */ + default ResponseEntity> getInventory() { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * Gets order by id. + * + * @param orderId the order id + * @return the order by id + * @see StoreApi#getOrderById StoreApi#getOrderById + */ + default ResponseEntity getOrderById(Long orderId) { + extract(); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * Extract. + */ + default void extract() { + getRequest().ifPresent(request -> { + for (MediaType mediaType : MediaType.parseMediaTypes(request.getHeader("Accept"))) { + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + ApiUtil.setExampleResponse(request, "application/json", "{ \"petId\" : 6, \"quantity\" : 1, \"id\" : 0, \"shipDate\" : \"2000-01-23T04:56:07.000+00:00\", \"complete\" : false, \"status\" : \"placed\"}"); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/xml"))) { + ApiUtil.setExampleResponse(request, "application/xml", " 123456789 123456789 123 2000-01-23T04:56:07.000Z aeiou true"); + break; + } + } + }); + } + + /** + * Place order response entity. + * + * @param order the order + * @return the response entity + * @see StoreApi#placeOrder StoreApi#placeOrder + */ + default ResponseEntity placeOrder(Order order) { + extract(); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app105/api/store/StoreApiDelegateImpl.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app105/api/store/StoreApiDelegateImpl.java new file mode 100644 index 000000000..6695b9602 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app105/api/store/StoreApiDelegateImpl.java @@ -0,0 +1,38 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app105.api.store; + +import org.springframework.stereotype.Service; + +/** + * The type Store api delegate. + */ +@Service +class StoreApiDelegateImpl implements StoreApiDelegate { + + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app105/api/user/UserApi.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app105/api/user/UserApi.java new file mode 100644 index 000000000..5625cb956 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app105/api/user/UserApi.java @@ -0,0 +1,197 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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. + * * * * * + * * * * + * * * + * * + * + */ + +/** + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (3.0.0). + * https://openapi-generator.tech + * Do not edit the class manually. + */ +package test.org.springdoc.api.v31.app105.api.user; + +import java.util.List; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.validation.Valid; +import jakarta.validation.constraints.NotNull; +import test.org.springdoc.api.v31.app105.model.User; + +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestParam; + +/** + * The interface User api. + */ +@jakarta.annotation.Generated(value = "org.springdoc.demo.app2.codegen.languages.SpringCodegen", date = "2019-07-11T00:09:29.839+02:00[Europe/Paris]") + +@Tag(name = "user", description = "the user API") +public interface UserApi { + + /** + * Gets delegate. + * + * @return the delegate + */ + default UserApiDelegate getDelegate() { + return new UserApiDelegate() { + }; + } + + /** + * Create user response entity. + * + * @param user the user + * @return the response entity + */ + @Operation(summary = "Create user", tags = { "user" }) + @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "successful operation") }) + @PostMapping(value = "/user", consumes = { "application/json" }) + default ResponseEntity createUser( + @io.swagger.v3.oas.annotations.parameters.RequestBody(description = "Created user object", required = true) @Valid @RequestBody User user) { + return getDelegate().createUser(user); + } + + /** + * Create users with array input response entity. + * + * @param user the user + * @return the response entity + */ + @Operation(summary = "Creates list of users with given input array", tags = { "user" }) + @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "successful operation") }) + + @PostMapping(value = "/user/createWithArray", consumes = { "application/json" }) + default ResponseEntity createUsersWithArrayInput( + @io.swagger.v3.oas.annotations.parameters.RequestBody(description = "List of user object", required = true) @Valid @RequestBody List user) { + return getDelegate().createUsersWithArrayInput(user); + } + + /** + * Create users with list input response entity. + * + * @param user the user + * @return the response entity + */ + @Operation(summary = "Creates list of users with given input array", tags = { "user" }) + @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "successful operation") }) + @PostMapping(value = "/user/createWithList", consumes = { "application/json" }) + default ResponseEntity createUsersWithListInput( + @io.swagger.v3.oas.annotations.parameters.RequestBody(description = "List of user object", required = true) @Valid @RequestBody List user) { + return getDelegate().createUsersWithListInput(user); + } + + /** + * Delete user response entity. + * + * @param username the username + * @return the response entity + */ + @Operation(summary = "Creates list of users with given input array", tags = { "user" }) + @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "successful operation") }) + + @DeleteMapping(value = "/user/{username}") + default ResponseEntity deleteUser( + @io.swagger.v3.oas.annotations.parameters.RequestBody(description = "The name that needs to be deleted", required = true) @PathVariable("username") String username) { + return getDelegate().deleteUser(username); + } + + /** + * Gets user by name. + * + * @param username the username + * @return the user by name + */ + @Operation(summary = "Get user by user name", tags = { "user" }) + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(schema = @Schema(implementation = User.class))), + @ApiResponse(responseCode = "400", description = "Invalid username supplied"), + @ApiResponse(responseCode = "404", description = "User not found") }) + + @GetMapping(value = "/user/{username}", produces = { "application/xml", "application/json" }) + default ResponseEntity getUserByName( + @Parameter(description = "The name that needs to be fetched. Use user1 for testing.", required = true) @PathVariable("username") String username) { + return getDelegate().getUserByName(username); + } + + /** + * Login user response entity. + * + * @param username the username + * @param password the password + * @return the response entity + */ + @Operation(summary = "Logs user into the system", tags = { "user" }) + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(schema = @Schema(implementation = String.class))), + @ApiResponse(responseCode = "400", description = "Invalid username/password supplied") }) + @GetMapping(value = "/user/login", produces = { "application/xml", "application/json" }) + default ResponseEntity loginUser( + @NotNull @Parameter(description = "The user name for login", required = true) @Valid @RequestParam(value = "username", required = true) String username, + @NotNull @Parameter(description = "The password for login in clear text", required = true) @Valid @RequestParam(value = "password", required = true) String password) { + return getDelegate().loginUser(username, password); + } + + /** + * Logout user response entity. + * + * @return the response entity + */ + @Operation(summary = "Logs out current logged in user session", tags = { "user" }) + @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "successful operation") }) + @GetMapping(value = "/user/logout") + default ResponseEntity logoutUser() { + return getDelegate().logoutUser(); + } + + /** + * Update user response entity. + * + * @param username the username + * @param user the user + * @return the response entity + */ + @Operation(summary = "Updated user", tags = { "user" }) + @ApiResponses(value = { @ApiResponse(responseCode = "400", description = "Invalid user supplied"), + @ApiResponse(responseCode = "404", description = "User not found") }) + @PutMapping(value = "/user/{username}", consumes = { "application/json" }) + default ResponseEntity updateUser( + @Parameter(description = "name that need to be deleted", required = true) @PathVariable("username") String username, + @io.swagger.v3.oas.annotations.parameters.RequestBody(description = "Updated user object", required = true) @Valid @RequestBody User user) { + return getDelegate().updateUser(username, user); + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app105/api/user/UserApiController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app105/api/user/UserApiController.java new file mode 100644 index 000000000..6dcad17c7 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app105/api/user/UserApiController.java @@ -0,0 +1,68 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app105.api.user; + +import java.util.Optional; + +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type User api controller. + */ +@jakarta.annotation.Generated(value = "org.springdoc.demo.app2.codegen.languages.SpringCodegen", date = "2019-07-11T00:09:29.839+02:00[Europe/Paris]") + +@RestController +@RequestMapping("${openapi.openAPIPetstore.base-path:/}") +class UserApiController implements UserApi { + + /** + * The Delegate. + */ + private final UserApiDelegate delegate; + + /** + * Instantiates a new User api controller. + * + * @param delegate the delegate + */ + public UserApiController(@org.springframework.beans.factory.annotation.Autowired(required = false) UserApiDelegate delegate) { + this.delegate = Optional.ofNullable(delegate).orElse(new UserApiDelegate() { + }); + } + + /** + * Gets delegate. + * + * @return the delegate + */ + @Override + public UserApiDelegate getDelegate() { + return delegate; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app105/api/user/UserApiDelegate.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app105/api/user/UserApiDelegate.java new file mode 100644 index 000000000..35d51c6d6 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app105/api/user/UserApiDelegate.java @@ -0,0 +1,168 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app105.api.user; + +import java.util.List; +import java.util.Optional; + +import test.org.springdoc.api.v31.app105.api.ApiUtil; +import test.org.springdoc.api.v31.app105.model.User; + +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.web.context.request.NativeWebRequest; + +/** + * A delegate to be called by the {@link UserApiController}}. + * Implement this interface with a {@link org.springframework.stereotype.Service} annotated class. + */ +@jakarta.annotation.Generated(value = "org.springdoc.demo.app2.codegen.languages.SpringCodegen", date = "2019-07-11T00:09:29.839+02:00[Europe/Paris]") + +public interface UserApiDelegate { + + /** + * Gets request. + * + * @return the request + */ + default Optional getRequest() { + return Optional.empty(); + } + + /** + * Create user response entity. + * + * @param user the user + * @return the response entity + * @see UserApi#createUser UserApi#createUser + */ + default ResponseEntity createUser(User user) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * Create users with array input response entity. + * + * @param user the user + * @return the response entity + * @see UserApi#createUsersWithArrayInput UserApi#createUsersWithArrayInput + */ + default ResponseEntity createUsersWithArrayInput(List user) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * Create users with list input response entity. + * + * @param user the user + * @return the response entity + * @see UserApi#createUsersWithListInput UserApi#createUsersWithListInput + */ + default ResponseEntity createUsersWithListInput(List user) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * Delete user response entity. + * + * @param username the username + * @return the response entity + * @see UserApi#deleteUser UserApi#deleteUser + */ + default ResponseEntity deleteUser(String username) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * Gets user by name. + * + * @param username the username + * @return the user by name + * @see UserApi#getUserByName UserApi#getUserByName + */ + default ResponseEntity getUserByName(String username) { + getRequest().ifPresent(request -> { + for (MediaType mediaType : MediaType.parseMediaTypes(request.getHeader("Accept"))) { + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + ApiUtil.setExampleResponse(request, "application/json", "{ \"firstName\" : \"firstName\", \"lastName\" : \"lastName\", \"password\" : \"password\", \"userStatus\" : 6, \"phone\" : \"phone\", \"id\" : 0, \"email\" : \"email\", \"username\" : \"username\"}"); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/xml"))) { + ApiUtil.setExampleResponse(request, "application/xml", " 123456789 aeiou aeiou aeiou aeiou aeiou aeiou 123"); + break; + } + } + }); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * Login user response entity. + * + * @param username the username + * @param password the password + * @return the response entity + * @see UserApi#loginUser UserApi#loginUser + */ + default ResponseEntity loginUser(String username, + String password) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * Logout user response entity. + * + * @return the response entity + * @see UserApi#logoutUser UserApi#logoutUser + */ + default ResponseEntity logoutUser() { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * Update user response entity. + * + * @param username the username + * @param user the user + * @return the response entity + * @see UserApi#updateUser UserApi#updateUser + */ + default ResponseEntity updateUser(String username, + User user) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app105/api/user/UserApiDelegateImpl.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app105/api/user/UserApiDelegateImpl.java new file mode 100644 index 000000000..1482be035 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app105/api/user/UserApiDelegateImpl.java @@ -0,0 +1,38 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app105.api.user; + +import org.springframework.stereotype.Service; + +/** + * The type User api delegate. + */ +@Service +class UserApiDelegateImpl implements UserApiDelegate { + + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app105/model/Category.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app105/model/Category.java new file mode 100644 index 000000000..e45fc486b --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app105/model/Category.java @@ -0,0 +1,137 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app105.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.v3.oas.annotations.media.Schema; + +/** + * The type Category. + */ +class Category { + + /** + * The Id. + */ + @Schema(description = "") + private Long id = null; + + /** + * The Name. + */ + @Schema(description = "") + private String name = null; + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + * @param o the o + * @return the string + */ + private static String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Get id + * + * @return id id + */ + @JsonProperty("id") + public Long getId() { + return id; + } + + /** + * Sets id. + * + * @param id the id + */ + public void setId(Long id) { + this.id = id; + } + + /** + * Id category. + * + * @param id the id + * @return the category + */ + public Category id(Long id) { + this.id = id; + return this; + } + + /** + * Get name + * + * @return name name + */ + @JsonProperty("name") + public String getName() { + return name; + } + + /** + * Sets name. + * + * @param name the name + */ + public void setName(String name) { + this.name = name; + } + + /** + * Name category. + * + * @param name the name + * @return the category + */ + public Category name(String name) { + this.name = name; + return this; + } + + /** + * To string string. + * + * @return the string + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Category {\n"); + + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append("}"); + return sb.toString(); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app105/model/ModelApiResponse.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app105/model/ModelApiResponse.java new file mode 100644 index 000000000..dbec36222 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app105/model/ModelApiResponse.java @@ -0,0 +1,174 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app105.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.v3.oas.annotations.media.Schema; + +/** + * The type Model api response. + */ +public class ModelApiResponse { + + /** + * The Code. + */ + @Schema(description = "") + private Integer code = null; + + /** + * The Type. + */ + @Schema(description = "") + private String type = null; + + /** + * The Message. + */ + @Schema(description = "") + private String message = null; + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + * @param o the o + * @return the string + */ + private static String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Get code + * + * @return code code + */ + @JsonProperty("code") + public Integer getCode() { + return code; + } + + /** + * Sets code. + * + * @param code the code + */ + public void setCode(Integer code) { + this.code = code; + } + + /** + * Code model api response. + * + * @param code the code + * @return the model api response + */ + public ModelApiResponse code(Integer code) { + this.code = code; + return this; + } + + /** + * Get type + * + * @return type type + */ + @JsonProperty("type") + public String getType() { + return type; + } + + /** + * Sets type. + * + * @param type the type + */ + public void setType(String type) { + this.type = type; + } + + /** + * Type model api response. + * + * @param type the type + * @return the model api response + */ + public ModelApiResponse type(String type) { + this.type = type; + return this; + } + + /** + * Get message + * + * @return message message + */ + @JsonProperty("message") + public String getMessage() { + return message; + } + + /** + * Sets message. + * + * @param message the message + */ + public void setMessage(String message) { + this.message = message; + } + + /** + * Message model api response. + * + * @param message the message + * @return the model api response + */ + public ModelApiResponse message(String message) { + this.message = message; + return this; + } + + /** + * To string string. + * + * @return the string + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ModelApiResponse {\n"); + + sb.append(" code: ").append(toIndentedString(code)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" message: ").append(toIndentedString(message)).append("\n"); + sb.append("}"); + return sb.toString(); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app105/model/Order.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app105/model/Order.java new file mode 100644 index 000000000..3f03494f0 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app105/model/Order.java @@ -0,0 +1,364 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app105.model; + +import java.util.Date; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.v3.oas.annotations.media.Schema; + +/** + * The type Order. + */ +public class Order { + + /** + * The Id. + */ + @Schema(description = "") + private Long id = null; + + /** + * The Pet id. + */ + @Schema(description = "") + private Long petId = null; + + /** + * The Quantity. + */ + @Schema(description = "") + private Integer quantity = null; + + /** + * The Ship date. + */ + @Schema(description = "") + private Date shipDate = null; + + /** + * The Status. + */ + @Schema(description = "Order Status") + /** + * Order Status + **/ + private StatusEnum status = null; + + /** + * The Complete. + */ + @Schema(description = "") + private Boolean complete = false; + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + * @param o the o + * @return the string + */ + private static String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Get id + * + * @return id id + */ + @JsonProperty("id") + public Long getId() { + return id; + } + + /** + * Sets id. + * + * @param id the id + */ + public void setId(Long id) { + this.id = id; + } + + /** + * Id order. + * + * @param id the id + * @return the order + */ + public Order id(Long id) { + this.id = id; + return this; + } + + /** + * Get petId + * + * @return petId pet id + */ + @JsonProperty("petId") + public Long getPetId() { + return petId; + } + + /** + * Sets pet id. + * + * @param petId the pet id + */ + public void setPetId(Long petId) { + this.petId = petId; + } + + /** + * Pet id order. + * + * @param petId the pet id + * @return the order + */ + public Order petId(Long petId) { + this.petId = petId; + return this; + } + + /** + * Get quantity + * + * @return quantity quantity + */ + @JsonProperty("quantity") + public Integer getQuantity() { + return quantity; + } + + /** + * Sets quantity. + * + * @param quantity the quantity + */ + public void setQuantity(Integer quantity) { + this.quantity = quantity; + } + + /** + * Quantity order. + * + * @param quantity the quantity + * @return the order + */ + public Order quantity(Integer quantity) { + this.quantity = quantity; + return this; + } + + /** + * Get shipDate + * + * @return shipDate ship date + */ + @JsonProperty("shipDate") + public Date getShipDate() { + return shipDate; + } + + /** + * Sets ship date. + * + * @param shipDate the ship date + */ + public void setShipDate(Date shipDate) { + this.shipDate = shipDate; + } + + /** + * Ship date order. + * + * @param shipDate the ship date + * @return the order + */ + public Order shipDate(Date shipDate) { + this.shipDate = shipDate; + return this; + } + + /** + * Order Status + * + * @return status status + */ + @JsonProperty("status") + public String getStatus() { + if (status == null) { + return null; + } + return status.getValue(); + } + + /** + * Sets status. + * + * @param status the status + */ + public void setStatus(StatusEnum status) { + this.status = status; + } + + /** + * Status order. + * + * @param status the status + * @return the order + */ + public Order status(StatusEnum status) { + this.status = status; + return this; + } + + /** + * Get complete + * + * @return complete boolean + */ + @JsonProperty("complete") + public Boolean isisComplete() { + return complete; + } + + /** + * Sets complete. + * + * @param complete the complete + */ + public void setComplete(Boolean complete) { + this.complete = complete; + } + + /** + * Complete order. + * + * @param complete the complete + * @return the order + */ + public Order complete(Boolean complete) { + this.complete = complete; + return this; + } + + + /** + * To string string. + * + * @return the string + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Order {\n"); + + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" petId: ").append(toIndentedString(petId)).append("\n"); + sb.append(" quantity: ").append(toIndentedString(quantity)).append("\n"); + sb.append(" shipDate: ").append(toIndentedString(shipDate)).append("\n"); + sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append(" complete: ").append(toIndentedString(complete)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * The enum Status enum. + */ + public enum StatusEnum { + /** + *Placed status enum. + */ + PLACED("placed"), + /** + *Approved status enum. + */ + APPROVED("approved"), + /** + *Delivered status enum. + */ + DELIVERED("delivered"); + + /** + * The Value. + */ + private String value; + + /** + * Instantiates a new Status enum. + * + * @param value the value + */ + StatusEnum(String value) { + this.value = value; + } + + /** + * From value status enum. + * + * @param text the text + * @return the status enum + */ + @JsonCreator + public static StatusEnum fromValue(String text) { + for (StatusEnum b : StatusEnum.values()) { + if (String.valueOf(b.value).equals(text)) { + return b; + } + } + return null; + } + + /** + * Gets value. + * + * @return the value + */ + @JsonValue + public String getValue() { + return value; + } + + /** + * To string string. + * + * @return the string + */ + @Override + public String toString() { + return String.valueOf(value); + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app105/model/Pet.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app105/model/Pet.java new file mode 100644 index 000000000..69def5ee0 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app105/model/Pet.java @@ -0,0 +1,392 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app105.model; + +import java.util.ArrayList; +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotNull; + +/** + * The type Pet. + */ +public class Pet { + + /** + * The Id. + */ + @Schema(description = "") + private Long id = null; + + /** + * The Category. + */ + @Schema(description = "") + private Category category = null; + + /** + * The Name. + */ + @Schema(example = "doggie", required = true, description = "") + private String name = null; + + /** + * The Photo urls. + */ + @Schema(required = true, description = "") + private List photoUrls = new ArrayList(); + + /** + * The Tags. + */ + @Schema(description = "") + private List tags = null; + + /** + * The Status. + */ + @Schema(description = "pet status in the store") + /** + * pet status in the store + **/ + private StatusEnum status = null; + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + * @param o the o + * @return the string + */ + private static String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Get id + * + * @return id id + */ + @JsonProperty("id") + public Long getId() { + return id; + } + + /** + * Sets id. + * + * @param id the id + */ + public void setId(Long id) { + this.id = id; + } + + /** + * Id pet. + * + * @param id the id + * @return the pet + */ + public Pet id(Long id) { + this.id = id; + return this; + } + + /** + * Get category + * + * @return category category + */ + @JsonProperty("category") + public Category getCategory() { + return category; + } + + /** + * Sets category. + * + * @param category the category + */ + public void setCategory(Category category) { + this.category = category; + } + + /** + * Category pet. + * + * @param category the category + * @return the pet + */ + public Pet category(Category category) { + this.category = category; + return this; + } + + /** + * Get name + * + * @return name name + */ + @JsonProperty("name") + @NotNull + public String getName() { + return name; + } + + /** + * Sets name. + * + * @param name the name + */ + public void setName(String name) { + this.name = name; + } + + /** + * Name pet. + * + * @param name the name + * @return the pet + */ + public Pet name(String name) { + this.name = name; + return this; + } + + /** + * Get photoUrls + * + * @return photoUrls photo urls + */ + @JsonProperty("photoUrls") + @NotNull + public List getPhotoUrls() { + return photoUrls; + } + + /** + * Sets photo urls. + * + * @param photoUrls the photo urls + */ + public void setPhotoUrls(List photoUrls) { + this.photoUrls = photoUrls; + } + + /** + * Photo urls pet. + * + * @param photoUrls the photo urls + * @return the pet + */ + public Pet photoUrls(List photoUrls) { + this.photoUrls = photoUrls; + return this; + } + + /** + * Add photo urls item pet. + * + * @param photoUrlsItem the photo urls item + * @return the pet + */ + public Pet addPhotoUrlsItem(String photoUrlsItem) { + this.photoUrls.add(photoUrlsItem); + return this; + } + + /** + * Get tags + * + * @return tags tags + */ + @JsonProperty("tags") + public List getTags() { + return tags; + } + + /** + * Sets tags. + * + * @param tags the tags + */ + public void setTags(List tags) { + this.tags = tags; + } + + /** + * Tags pet. + * + * @param tags the tags + * @return the pet + */ + public Pet tags(List tags) { + this.tags = tags; + return this; + } + + /** + * Add tags item pet. + * + * @param tagsItem the tags item + * @return the pet + */ + public Pet addTagsItem(Tag tagsItem) { + if (this.tags == null) { + this.tags = new ArrayList<>(); + } + this.tags.add(tagsItem); + return this; + } + + /** + * pet status in the store + * + * @return status status + */ + @JsonProperty("status") + public StatusEnum getStatus() { + if (status == null) { + return null; + } + return status; + } + + /** + * Sets status. + * + * @param status the status + */ + public void setStatus(StatusEnum status) { + this.status = status; + } + + /** + * Status pet. + * + * @param status the status + * @return the pet + */ + public Pet status(StatusEnum status) { + this.status = status; + return this; + } + + /** + * To string string. + * + * @return the string + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Pet {\n"); + + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" category: ").append(toIndentedString(category)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" photoUrls: ").append(toIndentedString(photoUrls)).append("\n"); + sb.append(" tags: ").append(toIndentedString(tags)).append("\n"); + sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * The enum Status enum. + */ + public enum StatusEnum { + /** + *Available status enum. + */ + AVAILABLE("available"), + /** + *Pending status enum. + */ + PENDING("pending"), + /** + *Sold status enum. + */ + SOLD("sold"); + + /** + * The Value. + */ + private String value; + + /** + * Instantiates a new Status enum. + * + * @param value the value + */ + StatusEnum(String value) { + this.value = value; + } + + /** + * From value status enum. + * + * @param text the text + * @return the status enum + */ + @JsonCreator + public static StatusEnum fromValue(String text) { + for (StatusEnum b : StatusEnum.values()) { + if (String.valueOf(b.value).equals(text)) { + return b; + } + } + return null; + } + + /** + * Gets value. + * + * @return the value + */ + @JsonValue + public String getValue() { + return value; + } + + /** + * To string string. + * + * @return the string + */ + @Override + public String toString() { + return String.valueOf(value); + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app105/model/Tag.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app105/model/Tag.java new file mode 100644 index 000000000..56e1f4c50 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app105/model/Tag.java @@ -0,0 +1,137 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app105.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.v3.oas.annotations.media.Schema; + +/** + * The type Tag. + */ +class Tag { + + /** + * The Id. + */ + @Schema(description = "") + private Long id = null; + + /** + * The Name. + */ + @Schema(description = "") + private String name = null; + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + * @param o the o + * @return the string + */ + private static String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Get id + * + * @return id id + */ + @JsonProperty("id") + public Long getId() { + return id; + } + + /** + * Sets id. + * + * @param id the id + */ + public void setId(Long id) { + this.id = id; + } + + /** + * Id tag. + * + * @param id the id + * @return the tag + */ + public Tag id(Long id) { + this.id = id; + return this; + } + + /** + * Get name + * + * @return name name + */ + @JsonProperty("name") + public String getName() { + return name; + } + + /** + * Sets name. + * + * @param name the name + */ + public void setName(String name) { + this.name = name; + } + + /** + * Name tag. + * + * @param name the name + * @return the tag + */ + public Tag name(String name) { + this.name = name; + return this; + } + + /** + * To string string. + * + * @return the string + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Tag {\n"); + + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append("}"); + return sb.toString(); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app105/model/User.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app105/model/User.java new file mode 100644 index 000000000..ac272ef57 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app105/model/User.java @@ -0,0 +1,362 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app105.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.v3.oas.annotations.media.Schema; + +/** + * The type User. + */ +public class User { + + /** + * The Id. + */ + @Schema(description = "") + private Long id = null; + + /** + * The Username. + */ + @Schema(description = "") + private String username = null; + + /** + * The First name. + */ + @Schema(description = "") + private String firstName = null; + + /** + * The Last name. + */ + @Schema(description = "") + private String lastName = null; + + /** + * The Email. + */ + @Schema(description = "") + private String email = null; + + /** + * The Password. + */ + @Schema(description = "") + private String password = null; + + /** + * The Phone. + */ + @Schema(description = "") + private String phone = null; + + /** + * The User status. + */ + @Schema(description = "User Status") + /** + * User Status + **/ + private Integer userStatus = null; + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + * @param o the o + * @return the string + */ + private static String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Get id + * + * @return id id + */ + @JsonProperty("id") + public Long getId() { + return id; + } + + /** + * Sets id. + * + * @param id the id + */ + public void setId(Long id) { + this.id = id; + } + + /** + * Id user. + * + * @param id the id + * @return the user + */ + public User id(Long id) { + this.id = id; + return this; + } + + /** + * Get username + * + * @return username username + */ + @JsonProperty("username") + public String getUsername() { + return username; + } + + /** + * Sets username. + * + * @param username the username + */ + public void setUsername(String username) { + this.username = username; + } + + /** + * Username user. + * + * @param username the username + * @return the user + */ + public User username(String username) { + this.username = username; + return this; + } + + /** + * Get firstName + * + * @return firstName first name + */ + @JsonProperty("firstName") + public String getFirstName() { + return firstName; + } + + /** + * Sets first name. + * + * @param firstName the first name + */ + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + /** + * First name user. + * + * @param firstName the first name + * @return the user + */ + public User firstName(String firstName) { + this.firstName = firstName; + return this; + } + + /** + * Get lastName + * + * @return lastName last name + */ + @JsonProperty("lastName") + public String getLastName() { + return lastName; + } + + /** + * Sets last name. + * + * @param lastName the last name + */ + public void setLastName(String lastName) { + this.lastName = lastName; + } + + /** + * Last name user. + * + * @param lastName the last name + * @return the user + */ + public User lastName(String lastName) { + this.lastName = lastName; + return this; + } + + /** + * Get email + * + * @return email email + */ + @JsonProperty("email") + public String getEmail() { + return email; + } + + /** + * Sets email. + * + * @param email the email + */ + public void setEmail(String email) { + this.email = email; + } + + /** + * Email user. + * + * @param email the email + * @return the user + */ + public User email(String email) { + this.email = email; + return this; + } + + /** + * Get password + * + * @return password password + */ + @JsonProperty("password") + public String getPassword() { + return password; + } + + /** + * Sets password. + * + * @param password the password + */ + public void setPassword(String password) { + this.password = password; + } + + /** + * Password user. + * + * @param password the password + * @return the user + */ + public User password(String password) { + this.password = password; + return this; + } + + /** + * Get phone + * + * @return phone phone + */ + @JsonProperty("phone") + public String getPhone() { + return phone; + } + + /** + * Sets phone. + * + * @param phone the phone + */ + public void setPhone(String phone) { + this.phone = phone; + } + + /** + * Phone user. + * + * @param phone the phone + * @return the user + */ + public User phone(String phone) { + this.phone = phone; + return this; + } + + /** + * User Status + * + * @return userStatus user status + */ + @JsonProperty("userStatus") + public Integer getUserStatus() { + return userStatus; + } + + /** + * Sets user status. + * + * @param userStatus the user status + */ + public void setUserStatus(Integer userStatus) { + this.userStatus = userStatus; + } + + /** + * User status user. + * + * @param userStatus the user status + * @return the user + */ + public User userStatus(Integer userStatus) { + this.userStatus = userStatus; + return this; + } + + /** + * To string string. + * + * @return the string + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class User {\n"); + + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" username: ").append(toIndentedString(username)).append("\n"); + sb.append(" firstName: ").append(toIndentedString(firstName)).append("\n"); + sb.append(" lastName: ").append(toIndentedString(lastName)).append("\n"); + sb.append(" email: ").append(toIndentedString(email)).append("\n"); + sb.append(" password: ").append(toIndentedString(password)).append("\n"); + sb.append(" phone: ").append(toIndentedString(phone)).append("\n"); + sb.append(" userStatus: ").append(toIndentedString(userStatus)).append("\n"); + sb.append("}"); + return sb.toString(); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app106/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app106/HelloController.java new file mode 100644 index 000000000..458143bac --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app106/HelloController.java @@ -0,0 +1,66 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app106; + +import java.time.Instant; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.enums.ParameterIn; +import io.swagger.v3.oas.annotations.media.Schema; + +import org.springframework.http.HttpHeaders; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestHeader; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * Find articles response entity. + * + * @param modifiedSince the modified since + * @return the response entity + */ + @Operation(summary = "find-articles") + @GetMapping + @Parameter(name = HttpHeaders.IF_MODIFIED_SINCE, + description = "DateTime", + in = ParameterIn.HEADER, + schema = @Schema(type = "string", format = "date-time"), + example = "2020-01-01T00:00:00.000Z" + ) + public ResponseEntity findArticles(@RequestHeader(value = HttpHeaders.IF_MODIFIED_SINCE, required = false) Instant modifiedSince) { + return null; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app106/SpringDocApp106Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app106/SpringDocApp106Test.java new file mode 100644 index 000000000..e3097524a --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app106/SpringDocApp106Test.java @@ -0,0 +1,42 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app106; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 106 test. + */ +class SpringDocApp106Test extends AbstractSpringDocTest { + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app107/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app107/HelloController.java new file mode 100644 index 000000000..3acf6f970 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app107/HelloController.java @@ -0,0 +1,85 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app107; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.v3.oas.annotations.media.Schema; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * Gets entity b. + * + * @return the entity b + */ + @GetMapping(path = "/entity-b", produces = { "application/json", "application/xml" }) + public EntityB getEntityB() { + return new EntityB(); + } + + /** + * The type Entity b. + */ + class EntityB { + + /** + * The Field b. + */ + @Schema(required = true) + @JsonProperty("fieldB") + private String fieldB; + + /** + * The Entity a. + */ + @Schema(required = true) + @JsonProperty("entityA") + private EntityA entityA; + //Getters and setters... + } + + /** + * The type Entity a. + */ + class EntityA { + /** + * The Field a. + */ + @Schema(required = true) + @JsonProperty("fieldA") + private String fieldA; + //Getters and setters... + } +} + diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app107/SpringDocApp107Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app107/SpringDocApp107Test.java new file mode 100644 index 000000000..6d3dfd3e4 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app107/SpringDocApp107Test.java @@ -0,0 +1,42 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app107; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 107 test. + */ +class SpringDocApp107Test extends AbstractSpringDocTest { + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app108/ActionResult.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app108/ActionResult.java new file mode 100644 index 000000000..b760324da --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app108/ActionResult.java @@ -0,0 +1,173 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app108; + +/** + * The type Action result. + * + * @param the type parameter + */ +class ActionResult { + + /** + * The Value. + */ + protected T value; + + /** + * The Success. + */ + protected boolean success; + + /** + * The Error code. + */ + protected String errorCode; + + /** + * The Message. + */ + protected String message; + + /** + * The Error value. + */ + protected Object errorValue; + + /** + * The Target url. + */ + protected String targetUrl; + + /** + * Gets value. + * + * @return the value + */ + public T getValue() { + return value; + } + + /** + * Sets value. + * + * @param value the value + */ + public void setValue(T value) { + this.value = value; + } + + /** + * Is success boolean. + * + * @return the boolean + */ + public boolean isSuccess() { + return success; + } + + /** + * Sets success. + * + * @param success the success + */ + public void setSuccess(boolean success) { + this.success = success; + } + + /** + * Gets error code. + * + * @return the error code + */ + public String getErrorCode() { + return errorCode; + } + + /** + * Sets error code. + * + * @param errorCode the error code + */ + public void setErrorCode(String errorCode) { + this.errorCode = errorCode; + } + + /** + * Gets message. + * + * @return the message + */ + public String getMessage() { + return message; + } + + /** + * Sets message. + * + * @param message the message + */ + public void setMessage(String message) { + this.message = message; + } + + /** + * Gets error value. + * + * @return the error value + */ + public Object getErrorValue() { + return errorValue; + } + + /** + * Sets error value. + * + * @param errorValue the error value + */ + public void setErrorValue(Object errorValue) { + this.errorValue = errorValue; + } + + /** + * Gets target url. + * + * @return the target url + */ + public String getTargetUrl() { + return targetUrl; + } + + /** + * Sets target url. + * + * @param targetUrl the target url + */ + public void setTargetUrl(String targetUrl) { + this.targetUrl = targetUrl; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app108/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app108/HelloController.java new file mode 100644 index 000000000..1f10eddda --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app108/HelloController.java @@ -0,0 +1,49 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app108; + +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * Update action result. + * + * @param toto the toto + * @return the action result + */ + @PostMapping + public ActionResult update(String toto) { + return null; + } +} + diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app108/SpringDocApp108Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app108/SpringDocApp108Test.java new file mode 100644 index 000000000..e591a82eb --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app108/SpringDocApp108Test.java @@ -0,0 +1,42 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app108; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 108 test. + */ +class SpringDocApp108Test extends AbstractSpringDocTest { + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app109/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app109/HelloController.java new file mode 100644 index 000000000..a2c93e7c7 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app109/HelloController.java @@ -0,0 +1,64 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app109; + +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; + +import org.springframework.core.io.ByteArrayResource; +import org.springframework.core.io.Resource; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * Gets resource. + * + * @return the resource + */ + @GetMapping("/api/v1/resource") + public Resource getResource() { + return new ByteArrayResource(new byte[] {}); + } + + /** + * Get byte array byte [ ]. + * + * @return the byte [ ] + */ + @GetMapping("/api/v1/bytearray") + @ApiResponse(content = @Content(schema = @Schema(type = "string", format = "binary"))) + public byte[] getByteArray() { + return new byte[] {}; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app109/SpringDocApp109Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app109/SpringDocApp109Test.java new file mode 100644 index 000000000..a26df7e27 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app109/SpringDocApp109Test.java @@ -0,0 +1,42 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app109; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 109 test. + */ +class SpringDocApp109Test extends AbstractSpringDocTest { + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app11/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app11/HelloController.java new file mode 100644 index 000000000..6205298ca --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app11/HelloController.java @@ -0,0 +1,71 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app11; + +import java.util.List; + +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.multipart.MultipartFile; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * Upload documents response entity. + * + * @param multipartFiles the multipart files + * @return the response entity + */ + @PostMapping(path = "/documents", consumes = "multipart/form-data") + public ResponseEntity uploadDocuments(@RequestPart("doc") List multipartFiles) { + return null; + } + + /** + * Post track string. + * + * @param file the file + * @return the string + */ + @RequestMapping(value = "/tracks", method = RequestMethod.POST, consumes = { MediaType.MULTIPART_FORM_DATA_VALUE }) + public @ResponseBody + String postTrack(@RequestParam("file") MultipartFile file) { + return "redirect:/"; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app11/SpringDocApp11Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app11/SpringDocApp11Test.java new file mode 100644 index 000000000..642923ed9 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app11/SpringDocApp11Test.java @@ -0,0 +1,44 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app11; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 11 test. + */ +class SpringDocApp11Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app110/ErrorMessage.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app110/ErrorMessage.java new file mode 100644 index 000000000..b47429778 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app110/ErrorMessage.java @@ -0,0 +1,94 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app110; + +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + + +/** + * The type Error message. + */ +class ErrorMessage { + + /** + * The Errors. + */ + private List errors; + + /** + * Instantiates a new Error message. + */ + public ErrorMessage() { + } + + /** + * Instantiates a new Error message. + * + * @param errors the errors + */ + public ErrorMessage(List errors) { + this.errors = errors; + } + + /** + * Instantiates a new Error message. + * + * @param error the error + */ + public ErrorMessage(String error) { + this(Collections.singletonList(error)); + } + + /** + * Instantiates a new Error message. + * + * @param errors the errors + */ + public ErrorMessage(String... errors) { + this(Arrays.asList(errors)); + } + + /** + * Gets errors. + * + * @return the errors + */ + public List getErrors() { + return errors; + } + + /** + * Sets errors. + * + * @param errors the errors + */ + public void setErrors(List errors) { + this.errors = errors; + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app110/GlobalControllerAdvice.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app110/GlobalControllerAdvice.java new file mode 100644 index 000000000..8bad96bff --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app110/GlobalControllerAdvice.java @@ -0,0 +1,192 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app110; + +import java.util.ArrayList; +import java.util.List; +import java.util.Set; +import java.util.UUID; + +import jakarta.validation.ConstraintViolation; +import jakarta.validation.ConstraintViolationException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.http.converter.HttpMessageNotReadableException; +import org.springframework.validation.FieldError; +import org.springframework.validation.ObjectError; +import org.springframework.web.HttpMediaTypeNotSupportedException; +import org.springframework.web.bind.MethodArgumentNotValidException; +import org.springframework.web.bind.MissingServletRequestParameterException; +import org.springframework.web.bind.annotation.ControllerAdvice; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.ResponseStatus; + + +/** + * The type Global controller advice. + */ +@ControllerAdvice(assignableTypes = PersonController.class) +class GlobalControllerAdvice //extends ResponseEntityExceptionHandler +{ + /** + * Note use base class if you wish to leverage its handling. + * Some code will need changing. + */ + private static final Logger logger = LoggerFactory.getLogger(GlobalControllerAdvice.class); + + /** + * Problem response entity. + * + * @param e the e + * @return the response entity + */ + @ExceptionHandler(Throwable.class) + @ResponseStatus(code = HttpStatus.INTERNAL_SERVER_ERROR) + public ResponseEntity problem(final Throwable e) { + String message = "Problem occured"; + UUID uuid = UUID.randomUUID(); + String logRef = uuid.toString(); + logger.error("logRef=" + logRef, message, e); + return new ResponseEntity(new Problem(logRef, message), HttpStatus.INTERNAL_SERVER_ERROR); + } + + + /** + * Handle method argument not valid response entity. + * + * @param ex the ex + * @return the response entity + */ + @ExceptionHandler(MethodArgumentNotValidException.class) + @ResponseStatus(code = HttpStatus.BAD_REQUEST) + public ResponseEntity handleMethodArgumentNotValid(MethodArgumentNotValidException ex + ) { + List fieldErrors = ex.getBindingResult().getFieldErrors(); + List globalErrors = ex.getBindingResult().getGlobalErrors(); + List errors = new ArrayList<>(fieldErrors.size() + globalErrors.size()); + String error; + for (FieldError fieldError : fieldErrors) { + error = fieldError.getField() + ", " + fieldError.getDefaultMessage(); + errors.add(error); + } + for (ObjectError objectError : globalErrors) { + error = objectError.getObjectName() + ", " + objectError.getDefaultMessage(); + errors.add(error); + } + ErrorMessage errorMessage = new ErrorMessage(errors); + + //Object result=ex.getBindingResult();//instead of above can allso pass the more detailed bindingResult + return new ResponseEntity(errorMessage, HttpStatus.BAD_REQUEST); + } + + /** + * Handle constraint violated exception response entity. + * + * @param ex the ex + * @return the response entity + */ + @ExceptionHandler(ConstraintViolationException.class) + @ResponseStatus(code = HttpStatus.BAD_REQUEST) + public ResponseEntity handleConstraintViolatedException(ConstraintViolationException ex + ) { + Set> constraintViolations = ex.getConstraintViolations(); + + + List errors = new ArrayList<>(constraintViolations.size()); + String error; + for (ConstraintViolation constraintViolation : constraintViolations) { + + error = constraintViolation.getMessage(); + errors.add(error); + } + + ErrorMessage errorMessage = new ErrorMessage(errors); + return new ResponseEntity(errorMessage, HttpStatus.BAD_REQUEST); + } + + /** + * Handle missing servlet request parameter exception response entity. + * + * @param ex the ex + * @return the response entity + */ + @ExceptionHandler(MissingServletRequestParameterException.class) + @ResponseStatus(code = HttpStatus.BAD_REQUEST) + public ResponseEntity handleMissingServletRequestParameterException(MissingServletRequestParameterException ex + ) { + + List errors = new ArrayList<>(); + String error = ex.getParameterName() + ", " + ex.getMessage(); + errors.add(error); + ErrorMessage errorMessage = new ErrorMessage(errors); + return new ResponseEntity(errorMessage, HttpStatus.BAD_REQUEST); + } + + + /** + * Handle http media type not supported response entity. + * + * @param ex the ex + * @return the response entity + */ + @ExceptionHandler(HttpMediaTypeNotSupportedException.class) + @ResponseStatus(code = HttpStatus.UNSUPPORTED_MEDIA_TYPE) + public ResponseEntity handleHttpMediaTypeNotSupported(HttpMediaTypeNotSupportedException ex + ) { + String unsupported = "Unsupported content type: " + ex.getContentType(); + String supported = "Supported content types: " + MediaType.toString(ex.getSupportedMediaTypes()); + ErrorMessage errorMessage = new ErrorMessage(unsupported, supported); + return new ResponseEntity(errorMessage, HttpStatus.UNSUPPORTED_MEDIA_TYPE); + } + + /** + * Handle http message not readable response entity. + * + * @param ex the ex + * @return the response entity + */ + @ExceptionHandler(HttpMessageNotReadableException.class) + @ResponseStatus(code = HttpStatus.BAD_REQUEST) + public ResponseEntity handleHttpMessageNotReadable(HttpMessageNotReadableException ex) { + Throwable mostSpecificCause = ex.getMostSpecificCause(); + ErrorMessage errorMessage; + if (mostSpecificCause != null) { + String exceptionName = mostSpecificCause.getClass().getName(); + String message = mostSpecificCause.getMessage(); + errorMessage = new ErrorMessage(exceptionName, message); + } + else { + errorMessage = new ErrorMessage(ex.getMessage()); + } + return new ResponseEntity(errorMessage, HttpStatus.BAD_REQUEST); + } + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app110/Person.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app110/Person.java new file mode 100644 index 000000000..82baf9544 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app110/Person.java @@ -0,0 +1,212 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app110; + +import jakarta.validation.constraints.Email; +import jakarta.validation.constraints.Max; +import jakarta.validation.constraints.Min; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; +import jakarta.validation.constraints.Pattern; +import jakarta.validation.constraints.Size; +import org.hibernate.validator.constraints.CreditCardNumber; + + +/** + * The type Person. + */ +class Person { + /** + * The Id. + */ + private long id; + + /** + * The First name. + */ + private String firstName; + + /** + * The Last name. + */ + @NotNull + @NotBlank + @Size(max = 10) + private String lastName; + + /** + * The Email. + */ + @Pattern(regexp = ".+@.+\\..+", message = "Please provide a valid email address") + private String email; + + /** + * The Email 1. + */ + @Email() + private String email1; + + /** + * The Age. + */ + @Min(18) + @Max(30) + private int age; + + /** + * The Credit card number. + */ + @CreditCardNumber + private String creditCardNumber; + + /** + * Gets credit card number. + * + * @return the credit card number + */ + public String getCreditCardNumber() { + return creditCardNumber; + } + + /** + * Sets credit card number. + * + * @param creditCardNumber the credit card number + */ + public void setCreditCardNumber(String creditCardNumber) { + this.creditCardNumber = creditCardNumber; + } + + /** + * Gets id. + * + * @return the id + */ + public long getId() { + return id; + } + + /** + * Sets id. + * + * @param id the id + */ + public void setId(long id) { + this.id = id; + } + + /** + * Gets email 1. + * + * @return the email 1 + */ + public String getEmail1() { + return email1; + } + + /** + * Sets email 1. + * + * @param email1 the email 1 + */ + public void setEmail1(String email1) { + this.email1 = email1; + } + + /** + * Gets first name. + * + * @return the first name + */ + @Size(min = 2) + public String getFirstName() { + return firstName; + } + + /** + * Sets first name. + * + * @param firstName the first name + */ + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + /** + * Gets last name. + * + * @return the last name + */ + public String getLastName() { + return lastName; + } + + /** + * Sets last name. + * + * @param lastName the last name + */ + public void setLastName(String lastName) { + this.lastName = lastName; + } + + /** + * Gets email. + * + * @return the email + */ + public String getEmail() { + return email; + } + + /** + * Sets email. + * + * @param email the email + */ + public void setEmail(String email) { + this.email = email; + } + + /** + * Gets age. + * + * @return the age + */ + public int getAge() { + return age; + } + + /** + * Sets age. + * + * @param age the age + */ + public void setAge(int age) { + this.age = age; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app110/PersonController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app110/PersonController.java new file mode 100644 index 000000000..ffcae50a6 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app110/PersonController.java @@ -0,0 +1,96 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app110; + +import java.util.ArrayList; +import java.util.List; +import java.util.Random; + +import jakarta.validation.Valid; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; +import jakarta.validation.constraints.Size; + +import org.springframework.validation.annotation.Validated; +import org.springframework.web.HttpMediaTypeNotSupportedException; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Person controller. + */ +@RestController +@Validated +class PersonController { + /** + * The Ran. + */ + private Random ran = new Random(); + + /** + * Person person. + * + * @param person the person + * @return the person + */ + @RequestMapping(path = "/person", method = RequestMethod.POST) + public Person person(@Valid @RequestBody Person person) throws HttpMediaTypeNotSupportedException { + + int nxt = ran.nextInt(10); + if (nxt >= 5) { + throw new RuntimeException("Breaking logic"); + } + return person; + } + + /** + * Find by last name list. + * + * @param lastName the last name + * @return the list + */ + @RequestMapping(path = "/personByLastName", method = RequestMethod.GET) + public List findByLastName(@RequestParam(name = "lastName", required = true) @NotNull + @NotBlank + @Size(max = 10) String lastName) throws HttpMediaTypeNotSupportedException { + List hardCoded = new ArrayList<>(); + Person person = new Person(); + person.setAge(20); + person.setCreditCardNumber("4111111111111111"); + person.setEmail("abc@abc.com"); + person.setEmail1("abc1@abc.com"); + person.setFirstName("Somefirstname"); + person.setLastName(lastName); + person.setId(1); + hardCoded.add(person); + return hardCoded; + + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app110/PersonController2.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app110/PersonController2.java new file mode 100644 index 000000000..42f12befd --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app110/PersonController2.java @@ -0,0 +1,95 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app110; + +import java.util.ArrayList; +import java.util.List; +import java.util.Random; + +import jakarta.validation.Valid; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; +import jakarta.validation.constraints.Size; + +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Person controller 2. + */ +@RestController +@Validated +class PersonController2 { + /** + * The Ran. + */ + private Random ran = new Random(); + + /** + * Person person. + * + * @param person the person + * @return the person + */ + @RequestMapping(path = "/person2", method = RequestMethod.POST) + public Person person(@Valid @RequestBody Person person) { + + int nxt = ran.nextInt(10); + if (nxt >= 5) { + throw new RuntimeException("Breaking logic"); + } + return person; + } + + /** + * Find by last name list. + * + * @param lastName the last name + * @return the list + */ + @RequestMapping(path = "/personByLastName2", method = RequestMethod.GET) + public List findByLastName(@RequestParam(name = "lastName", required = true) @NotNull + @NotBlank + @Size(max = 10) String lastName) { + List hardCoded = new ArrayList<>(); + Person person = new Person(); + person.setAge(20); + person.setCreditCardNumber("4111111111111111"); + person.setEmail("abc@abc.com"); + person.setEmail1("abc1@abc.com"); + person.setFirstName("Somefirstname"); + person.setLastName(lastName); + person.setId(1); + hardCoded.add(person); + return hardCoded; + + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app110/Problem.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app110/Problem.java new file mode 100644 index 000000000..7261c88ee --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app110/Problem.java @@ -0,0 +1,99 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app110; + +/** + * The type Problem. + */ +class Problem { + + /** + * The Log ref. + */ + private String logRef; + + /** + * The Message. + */ + private String message; + + /** + * Instantiates a new Problem. + * + * @param logRef the log ref + * @param message the message + */ + public Problem(String logRef, String message) { + super(); + this.logRef = logRef; + this.message = message; + } + + /** + * Instantiates a new Problem. + */ + public Problem() { + super(); + + } + + /** + * Gets log ref. + * + * @return the log ref + */ + public String getLogRef() { + return logRef; + } + + /** + * Sets log ref. + * + * @param logRef the log ref + */ + public void setLogRef(String logRef) { + this.logRef = logRef; + } + + /** + * Gets message. + * + * @return the message + */ + public String getMessage() { + return message; + } + + /** + * Sets message. + * + * @param message the message + */ + public void setMessage(String message) { + this.message = message; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app110/SpringDocApp110Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app110/SpringDocApp110Test.java new file mode 100644 index 000000000..347c96f54 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app110/SpringDocApp110Test.java @@ -0,0 +1,72 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app110; + +import io.swagger.v3.oas.models.OpenAPI; +import io.swagger.v3.oas.models.info.Info; +import io.swagger.v3.oas.models.info.License; +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; +import org.springframework.test.context.TestPropertySource; + +/** + * The type Spring doc app 110 test. + */ +@TestPropertySource(properties = { + "application-description=description", + "application-version=v1" }) +class SpringDocApp110Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp { + + /** + * Custom open api open api. + * + * @param appDesciption the app desciption + * @param appVersion the app version + * @return the open api + */ + @Bean + public OpenAPI customOpenAPI(@Value("${application-description}") String appDesciption, @Value("${application-version}") String appVersion) { + + return new OpenAPI() + .info(new Info() + .title("sample application API") + .version(appVersion) + .description(appDesciption) + .termsOfService("http://swagger.io/terms/") + .license(new License().name("Apache 2.0").url("http://springdoc.org"))); + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app111/ErrorMessage.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app111/ErrorMessage.java new file mode 100644 index 000000000..72b7b278c --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app111/ErrorMessage.java @@ -0,0 +1,94 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app111; + +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + + +/** + * The type Error message. + */ +class ErrorMessage { + + /** + * The Errors. + */ + private List errors; + + /** + * Instantiates a new Error message. + */ + public ErrorMessage() { + } + + /** + * Instantiates a new Error message. + * + * @param errors the errors + */ + public ErrorMessage(List errors) { + this.errors = errors; + } + + /** + * Instantiates a new Error message. + * + * @param error the error + */ + public ErrorMessage(String error) { + this(Collections.singletonList(error)); + } + + /** + * Instantiates a new Error message. + * + * @param errors the errors + */ + public ErrorMessage(String... errors) { + this(Arrays.asList(errors)); + } + + /** + * Gets errors. + * + * @return the errors + */ + public List getErrors() { + return errors; + } + + /** + * Sets errors. + * + * @param errors the errors + */ + public void setErrors(List errors) { + this.errors = errors; + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app111/GlobalControllerAdvice.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app111/GlobalControllerAdvice.java new file mode 100644 index 000000000..29876131d --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app111/GlobalControllerAdvice.java @@ -0,0 +1,192 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app111; + +import java.util.ArrayList; +import java.util.List; +import java.util.Set; +import java.util.UUID; + +import jakarta.validation.ConstraintViolation; +import jakarta.validation.ConstraintViolationException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.http.converter.HttpMessageNotReadableException; +import org.springframework.validation.FieldError; +import org.springframework.validation.ObjectError; +import org.springframework.web.HttpMediaTypeNotSupportedException; +import org.springframework.web.bind.MethodArgumentNotValidException; +import org.springframework.web.bind.MissingServletRequestParameterException; +import org.springframework.web.bind.annotation.ControllerAdvice; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.ResponseStatus; + + +/** + * The type Global controller advice. + */ +@ControllerAdvice(basePackages = "test.org.springdoc.api.appzzz") +class GlobalControllerAdvice //extends ResponseEntityExceptionHandler +{ + /** + * Note use base class if you wish to leverage its handling. + * Some code will need changing. + */ + private static final Logger logger = LoggerFactory.getLogger(GlobalControllerAdvice.class); + + /** + * Problem response entity. + * + * @param e the e + * @return the response entity + */ + @ExceptionHandler(Throwable.class) + @ResponseStatus(code = HttpStatus.INTERNAL_SERVER_ERROR) + public ResponseEntity problem(final Throwable e) { + String message = "Problem occured"; + UUID uuid = UUID.randomUUID(); + String logRef = uuid.toString(); + logger.error("logRef=" + logRef, message, e); + return new ResponseEntity(new Problem(logRef, message), HttpStatus.INTERNAL_SERVER_ERROR); + } + + + /** + * Handle method argument not valid response entity. + * + * @param ex the ex + * @return the response entity + */ + @ExceptionHandler(MethodArgumentNotValidException.class) + @ResponseStatus(code = HttpStatus.BAD_REQUEST) + public ResponseEntity handleMethodArgumentNotValid(MethodArgumentNotValidException ex + ) { + List fieldErrors = ex.getBindingResult().getFieldErrors(); + List globalErrors = ex.getBindingResult().getGlobalErrors(); + List errors = new ArrayList<>(fieldErrors.size() + globalErrors.size()); + String error; + for (FieldError fieldError : fieldErrors) { + error = fieldError.getField() + ", " + fieldError.getDefaultMessage(); + errors.add(error); + } + for (ObjectError objectError : globalErrors) { + error = objectError.getObjectName() + ", " + objectError.getDefaultMessage(); + errors.add(error); + } + ErrorMessage errorMessage = new ErrorMessage(errors); + + //Object result=ex.getBindingResult();//instead of above can allso pass the more detailed bindingResult + return new ResponseEntity(errorMessage, HttpStatus.BAD_REQUEST); + } + + /** + * Handle constraint violated exception response entity. + * + * @param ex the ex + * @return the response entity + */ + @ExceptionHandler(ConstraintViolationException.class) + @ResponseStatus(code = HttpStatus.BAD_REQUEST) + public ResponseEntity handleConstraintViolatedException(ConstraintViolationException ex + ) { + Set> constraintViolations = ex.getConstraintViolations(); + + + List errors = new ArrayList<>(constraintViolations.size()); + String error; + for (ConstraintViolation constraintViolation : constraintViolations) { + + error = constraintViolation.getMessage(); + errors.add(error); + } + + ErrorMessage errorMessage = new ErrorMessage(errors); + return new ResponseEntity(errorMessage, HttpStatus.BAD_REQUEST); + } + + /** + * Handle missing servlet request parameter exception response entity. + * + * @param ex the ex + * @return the response entity + */ + @ExceptionHandler(MissingServletRequestParameterException.class) + @ResponseStatus(code = HttpStatus.BAD_REQUEST) + public ResponseEntity handleMissingServletRequestParameterException(MissingServletRequestParameterException ex + ) { + + List errors = new ArrayList<>(); + String error = ex.getParameterName() + ", " + ex.getMessage(); + errors.add(error); + ErrorMessage errorMessage = new ErrorMessage(errors); + return new ResponseEntity(errorMessage, HttpStatus.BAD_REQUEST); + } + + + /** + * Handle http media type not supported response entity. + * + * @param ex the ex + * @return the response entity + */ + @ExceptionHandler(HttpMediaTypeNotSupportedException.class) + @ResponseStatus(code = HttpStatus.UNSUPPORTED_MEDIA_TYPE) + public ResponseEntity handleHttpMediaTypeNotSupported(HttpMediaTypeNotSupportedException ex + ) { + String unsupported = "Unsupported content type: " + ex.getContentType(); + String supported = "Supported content types: " + MediaType.toString(ex.getSupportedMediaTypes()); + ErrorMessage errorMessage = new ErrorMessage(unsupported, supported); + return new ResponseEntity(errorMessage, HttpStatus.UNSUPPORTED_MEDIA_TYPE); + } + + /** + * Handle http message not readable response entity. + * + * @param ex the ex + * @return the response entity + */ + @ExceptionHandler(HttpMessageNotReadableException.class) + @ResponseStatus(code = HttpStatus.BAD_REQUEST) + public ResponseEntity handleHttpMessageNotReadable(HttpMessageNotReadableException ex) { + Throwable mostSpecificCause = ex.getMostSpecificCause(); + ErrorMessage errorMessage; + if (mostSpecificCause != null) { + String exceptionName = mostSpecificCause.getClass().getName(); + String message = mostSpecificCause.getMessage(); + errorMessage = new ErrorMessage(exceptionName, message); + } + else { + errorMessage = new ErrorMessage(ex.getMessage()); + } + return new ResponseEntity(errorMessage, HttpStatus.BAD_REQUEST); + } + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app111/Person.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app111/Person.java new file mode 100644 index 000000000..5dff6e9df --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app111/Person.java @@ -0,0 +1,212 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app111; + +import jakarta.validation.constraints.Email; +import jakarta.validation.constraints.Max; +import jakarta.validation.constraints.Min; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; +import jakarta.validation.constraints.Pattern; +import jakarta.validation.constraints.Size; +import org.hibernate.validator.constraints.CreditCardNumber; + + +/** + * The type Person. + */ +class Person { + /** + * The Id. + */ + private long id; + + /** + * The First name. + */ + private String firstName; + + /** + * The Last name. + */ + @NotNull + @NotBlank + @Size(max = 10) + private String lastName; + + /** + * The Email. + */ + @Pattern(regexp = ".+@.+\\..+", message = "Please provide a valid email address") + private String email; + + /** + * The Email 1. + */ + @Email() + private String email1; + + /** + * The Age. + */ + @Min(18) + @Max(30) + private int age; + + /** + * The Credit card number. + */ + @CreditCardNumber + private String creditCardNumber; + + /** + * Gets credit card number. + * + * @return the credit card number + */ + public String getCreditCardNumber() { + return creditCardNumber; + } + + /** + * Sets credit card number. + * + * @param creditCardNumber the credit card number + */ + public void setCreditCardNumber(String creditCardNumber) { + this.creditCardNumber = creditCardNumber; + } + + /** + * Gets id. + * + * @return the id + */ + public long getId() { + return id; + } + + /** + * Sets id. + * + * @param id the id + */ + public void setId(long id) { + this.id = id; + } + + /** + * Gets email 1. + * + * @return the email 1 + */ + public String getEmail1() { + return email1; + } + + /** + * Sets email 1. + * + * @param email1 the email 1 + */ + public void setEmail1(String email1) { + this.email1 = email1; + } + + /** + * Gets first name. + * + * @return the first name + */ + @Size(min = 2) + public String getFirstName() { + return firstName; + } + + /** + * Sets first name. + * + * @param firstName the first name + */ + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + /** + * Gets last name. + * + * @return the last name + */ + public String getLastName() { + return lastName; + } + + /** + * Sets last name. + * + * @param lastName the last name + */ + public void setLastName(String lastName) { + this.lastName = lastName; + } + + /** + * Gets email. + * + * @return the email + */ + public String getEmail() { + return email; + } + + /** + * Sets email. + * + * @param email the email + */ + public void setEmail(String email) { + this.email = email; + } + + /** + * Gets age. + * + * @return the age + */ + public int getAge() { + return age; + } + + /** + * Sets age. + * + * @param age the age + */ + public void setAge(int age) { + this.age = age; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app111/PersonController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app111/PersonController.java new file mode 100644 index 000000000..39d373733 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app111/PersonController.java @@ -0,0 +1,95 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app111; + +import java.util.ArrayList; +import java.util.List; +import java.util.Random; + +import jakarta.validation.Valid; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; +import jakarta.validation.constraints.Size; + +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Person controller. + */ +@RestController +@Validated +class PersonController { + /** + * The Ran. + */ + private Random ran = new Random(); + + /** + * Person person. + * + * @param person the person + * @return the person + */ + @RequestMapping(path = "/person", method = RequestMethod.POST) + public Person person(@Valid @RequestBody Person person) { + + int nxt = ran.nextInt(10); + if (nxt >= 5) { + throw new RuntimeException("Breaking logic"); + } + return person; + } + + /** + * Find by last name list. + * + * @param lastName the last name + * @return the list + */ + @RequestMapping(path = "/personByLastName", method = RequestMethod.GET) + public List findByLastName(@RequestParam(name = "lastName", required = true) @NotNull + @NotBlank + @Size(max = 10) String lastName) { + List hardCoded = new ArrayList<>(); + Person person = new Person(); + person.setAge(20); + person.setCreditCardNumber("4111111111111111"); + person.setEmail("abc@abc.com"); + person.setEmail1("abc1@abc.com"); + person.setFirstName("Somefirstname"); + person.setLastName(lastName); + person.setId(1); + hardCoded.add(person); + return hardCoded; + + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app111/PersonController2.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app111/PersonController2.java new file mode 100644 index 000000000..65ea4a129 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app111/PersonController2.java @@ -0,0 +1,95 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app111; + +import java.util.ArrayList; +import java.util.List; +import java.util.Random; + +import jakarta.validation.Valid; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; +import jakarta.validation.constraints.Size; + +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Person controller 2. + */ +@RestController +@Validated +class PersonController2 { + /** + * The Ran. + */ + private Random ran = new Random(); + + /** + * Person person. + * + * @param person the person + * @return the person + */ + @RequestMapping(path = "/person2", method = RequestMethod.POST) + public Person person(@Valid @RequestBody Person person) { + + int nxt = ran.nextInt(10); + if (nxt >= 5) { + throw new RuntimeException("Breaking logic"); + } + return person; + } + + /** + * Find by last name list. + * + * @param lastName the last name + * @return the list + */ + @RequestMapping(path = "/personByLastName2", method = RequestMethod.GET) + public List findByLastName(@RequestParam(name = "lastName", required = true) @NotNull + @NotBlank + @Size(max = 10) String lastName) { + List hardCoded = new ArrayList<>(); + Person person = new Person(); + person.setAge(20); + person.setCreditCardNumber("4111111111111111"); + person.setEmail("abc@abc.com"); + person.setEmail1("abc1@abc.com"); + person.setFirstName("Somefirstname"); + person.setLastName(lastName); + person.setId(1); + hardCoded.add(person); + return hardCoded; + + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app111/Problem.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app111/Problem.java new file mode 100644 index 000000000..4a044c014 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app111/Problem.java @@ -0,0 +1,99 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app111; + +/** + * The type Problem. + */ +class Problem { + + /** + * The Log ref. + */ + private String logRef; + + /** + * The Message. + */ + private String message; + + /** + * Instantiates a new Problem. + * + * @param logRef the log ref + * @param message the message + */ + public Problem(String logRef, String message) { + super(); + this.logRef = logRef; + this.message = message; + } + + /** + * Instantiates a new Problem. + */ + public Problem() { + super(); + + } + + /** + * Gets log ref. + * + * @return the log ref + */ + public String getLogRef() { + return logRef; + } + + /** + * Sets log ref. + * + * @param logRef the log ref + */ + public void setLogRef(String logRef) { + this.logRef = logRef; + } + + /** + * Gets message. + * + * @return the message + */ + public String getMessage() { + return message; + } + + /** + * Sets message. + * + * @param message the message + */ + public void setMessage(String message) { + this.message = message; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app111/SpringDocApp111Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app111/SpringDocApp111Test.java new file mode 100644 index 000000000..edb95c812 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app111/SpringDocApp111Test.java @@ -0,0 +1,71 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app111; + +import io.swagger.v3.oas.models.OpenAPI; +import io.swagger.v3.oas.models.info.Info; +import io.swagger.v3.oas.models.info.License; +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; +import org.springframework.test.context.TestPropertySource; + +/** + * The type Spring doc app 111 test. + */ +@TestPropertySource(properties = { + "application-description=description", + "application-version=v1" }) +class SpringDocApp111Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp { + + /** + * Custom open api open api. + * + * @param appDesciption the app desciption + * @param appVersion the app version + * @return the open api + */ + @Bean + public OpenAPI customOpenAPI(@Value("${application-description}") String appDesciption, @Value("${application-version}") String appVersion) { + return new OpenAPI() + .info(new Info() + .title("sample application API") + .version(appVersion) + .description(appDesciption) + .termsOfService("http://swagger.io/terms/") + .license(new License().name("Apache 2.0").url("http://springdoc.org"))); + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app112/ErrorMessage.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app112/ErrorMessage.java new file mode 100644 index 000000000..5eab1a068 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app112/ErrorMessage.java @@ -0,0 +1,94 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app112; + +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + + +/** + * The type Error message. + */ +class ErrorMessage { + + /** + * The Errors. + */ + private List errors; + + /** + * Instantiates a new Error message. + */ + public ErrorMessage() { + } + + /** + * Instantiates a new Error message. + * + * @param errors the errors + */ + public ErrorMessage(List errors) { + this.errors = errors; + } + + /** + * Instantiates a new Error message. + * + * @param error the error + */ + public ErrorMessage(String error) { + this(Collections.singletonList(error)); + } + + /** + * Instantiates a new Error message. + * + * @param errors the errors + */ + public ErrorMessage(String... errors) { + this(Arrays.asList(errors)); + } + + /** + * Gets errors. + * + * @return the errors + */ + public List getErrors() { + return errors; + } + + /** + * Sets errors. + * + * @param errors the errors + */ + public void setErrors(List errors) { + this.errors = errors; + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app112/GlobalControllerAdvice.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app112/GlobalControllerAdvice.java new file mode 100644 index 000000000..5b271e298 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app112/GlobalControllerAdvice.java @@ -0,0 +1,192 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app112; + +import java.util.ArrayList; +import java.util.List; +import java.util.Set; +import java.util.UUID; + +import jakarta.validation.ConstraintViolation; +import jakarta.validation.ConstraintViolationException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.http.converter.HttpMessageNotReadableException; +import org.springframework.validation.FieldError; +import org.springframework.validation.ObjectError; +import org.springframework.web.HttpMediaTypeNotSupportedException; +import org.springframework.web.bind.MethodArgumentNotValidException; +import org.springframework.web.bind.MissingServletRequestParameterException; +import org.springframework.web.bind.annotation.ControllerAdvice; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.ResponseStatus; + + +/** + * The type Global controller advice. + */ +@ControllerAdvice(basePackages = "test.org.springdoc.api.v31.app112.sample") +class GlobalControllerAdvice //extends ResponseEntityExceptionHandler +{ + /** + * Note use base class if you wish to leverage its handling. + * Some code will need changing. + */ + private static final Logger logger = LoggerFactory.getLogger(GlobalControllerAdvice.class); + + /** + * Problem response entity. + * + * @param e the e + * @return the response entity + */ + @ExceptionHandler(Throwable.class) + @ResponseStatus(code = HttpStatus.INTERNAL_SERVER_ERROR) + public ResponseEntity problem(final Throwable e) { + String message = "Problem occured"; + UUID uuid = UUID.randomUUID(); + String logRef = uuid.toString(); + logger.error("logRef=" + logRef, message, e); + return new ResponseEntity(new Problem(logRef, message), HttpStatus.INTERNAL_SERVER_ERROR); + } + + + /** + * Handle method argument not valid response entity. + * + * @param ex the ex + * @return the response entity + */ + @ExceptionHandler(MethodArgumentNotValidException.class) + @ResponseStatus(code = HttpStatus.BAD_REQUEST) + public ResponseEntity handleMethodArgumentNotValid(MethodArgumentNotValidException ex + ) { + List fieldErrors = ex.getBindingResult().getFieldErrors(); + List globalErrors = ex.getBindingResult().getGlobalErrors(); + List errors = new ArrayList<>(fieldErrors.size() + globalErrors.size()); + String error; + for (FieldError fieldError : fieldErrors) { + error = fieldError.getField() + ", " + fieldError.getDefaultMessage(); + errors.add(error); + } + for (ObjectError objectError : globalErrors) { + error = objectError.getObjectName() + ", " + objectError.getDefaultMessage(); + errors.add(error); + } + ErrorMessage errorMessage = new ErrorMessage(errors); + + //Object result=ex.getBindingResult();//instead of above can allso pass the more detailed bindingResult + return new ResponseEntity(errorMessage, HttpStatus.BAD_REQUEST); + } + + /** + * Handle constraint violated exception response entity. + * + * @param ex the ex + * @return the response entity + */ + @ExceptionHandler(ConstraintViolationException.class) + @ResponseStatus(code = HttpStatus.BAD_REQUEST) + public ResponseEntity handleConstraintViolatedException(ConstraintViolationException ex + ) { + Set> constraintViolations = ex.getConstraintViolations(); + + + List errors = new ArrayList<>(constraintViolations.size()); + String error; + for (ConstraintViolation constraintViolation : constraintViolations) { + + error = constraintViolation.getMessage(); + errors.add(error); + } + + ErrorMessage errorMessage = new ErrorMessage(errors); + return new ResponseEntity(errorMessage, HttpStatus.BAD_REQUEST); + } + + /** + * Handle missing servlet request parameter exception response entity. + * + * @param ex the ex + * @return the response entity + */ + @ExceptionHandler(MissingServletRequestParameterException.class) + @ResponseStatus(code = HttpStatus.BAD_REQUEST) + public ResponseEntity handleMissingServletRequestParameterException(MissingServletRequestParameterException ex + ) { + + List errors = new ArrayList<>(); + String error = ex.getParameterName() + ", " + ex.getMessage(); + errors.add(error); + ErrorMessage errorMessage = new ErrorMessage(errors); + return new ResponseEntity(errorMessage, HttpStatus.BAD_REQUEST); + } + + + /** + * Handle http media type not supported response entity. + * + * @param ex the ex + * @return the response entity + */ + @ExceptionHandler(HttpMediaTypeNotSupportedException.class) + @ResponseStatus(code = HttpStatus.UNSUPPORTED_MEDIA_TYPE) + public ResponseEntity handleHttpMediaTypeNotSupported(HttpMediaTypeNotSupportedException ex + ) { + String unsupported = "Unsupported content type: " + ex.getContentType(); + String supported = "Supported content types: " + MediaType.toString(ex.getSupportedMediaTypes()); + ErrorMessage errorMessage = new ErrorMessage(unsupported, supported); + return new ResponseEntity(errorMessage, HttpStatus.UNSUPPORTED_MEDIA_TYPE); + } + + /** + * Handle http message not readable response entity. + * + * @param ex the ex + * @return the response entity + */ + @ExceptionHandler(HttpMessageNotReadableException.class) + @ResponseStatus(code = HttpStatus.BAD_REQUEST) + public ResponseEntity handleHttpMessageNotReadable(HttpMessageNotReadableException ex) { + Throwable mostSpecificCause = ex.getMostSpecificCause(); + ErrorMessage errorMessage; + if (mostSpecificCause != null) { + String exceptionName = mostSpecificCause.getClass().getName(); + String message = mostSpecificCause.getMessage(); + errorMessage = new ErrorMessage(exceptionName, message); + } + else { + errorMessage = new ErrorMessage(ex.getMessage()); + } + return new ResponseEntity(errorMessage, HttpStatus.BAD_REQUEST); + } + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app112/Person.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app112/Person.java new file mode 100644 index 000000000..5d56c6e15 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app112/Person.java @@ -0,0 +1,212 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app112; + +import jakarta.validation.constraints.Email; +import jakarta.validation.constraints.Max; +import jakarta.validation.constraints.Min; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; +import jakarta.validation.constraints.Pattern; +import jakarta.validation.constraints.Size; +import org.hibernate.validator.constraints.CreditCardNumber; + + +/** + * The type Person. + */ +public class Person { + /** + * The Id. + */ + private long id; + + /** + * The First name. + */ + private String firstName; + + /** + * The Last name. + */ + @NotNull + @NotBlank + @Size(max = 10) + private String lastName; + + /** + * The Email. + */ + @Pattern(regexp = ".+@.+\\..+", message = "Please provide a valid email address") + private String email; + + /** + * The Email 1. + */ + @Email() + private String email1; + + /** + * The Age. + */ + @Min(18) + @Max(30) + private int age; + + /** + * The Credit card number. + */ + @CreditCardNumber + private String creditCardNumber; + + /** + * Gets credit card number. + * + * @return the credit card number + */ + public String getCreditCardNumber() { + return creditCardNumber; + } + + /** + * Sets credit card number. + * + * @param creditCardNumber the credit card number + */ + public void setCreditCardNumber(String creditCardNumber) { + this.creditCardNumber = creditCardNumber; + } + + /** + * Gets id. + * + * @return the id + */ + public long getId() { + return id; + } + + /** + * Sets id. + * + * @param id the id + */ + public void setId(long id) { + this.id = id; + } + + /** + * Gets email 1. + * + * @return the email 1 + */ + public String getEmail1() { + return email1; + } + + /** + * Sets email 1. + * + * @param email1 the email 1 + */ + public void setEmail1(String email1) { + this.email1 = email1; + } + + /** + * Gets first name. + * + * @return the first name + */ + @Size(min = 2) + public String getFirstName() { + return firstName; + } + + /** + * Sets first name. + * + * @param firstName the first name + */ + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + /** + * Gets last name. + * + * @return the last name + */ + public String getLastName() { + return lastName; + } + + /** + * Sets last name. + * + * @param lastName the last name + */ + public void setLastName(String lastName) { + this.lastName = lastName; + } + + /** + * Gets email. + * + * @return the email + */ + public String getEmail() { + return email; + } + + /** + * Sets email. + * + * @param email the email + */ + public void setEmail(String email) { + this.email = email; + } + + /** + * Gets age. + * + * @return the age + */ + public int getAge() { + return age; + } + + /** + * Sets age. + * + * @param age the age + */ + public void setAge(int age) { + this.age = age; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app112/PersonController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app112/PersonController.java new file mode 100644 index 000000000..80a4052a0 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app112/PersonController.java @@ -0,0 +1,95 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app112; + +import java.util.ArrayList; +import java.util.List; +import java.util.Random; + +import jakarta.validation.Valid; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; +import jakarta.validation.constraints.Size; + +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Person controller. + */ +@RestController +@Validated +class PersonController { + /** + * The Ran. + */ + private Random ran = new Random(); + + /** + * Person person. + * + * @param person the person + * @return the person + */ + @RequestMapping(path = "/person", method = RequestMethod.POST) + public Person person(@Valid @RequestBody Person person) { + + int nxt = ran.nextInt(10); + if (nxt >= 5) { + throw new RuntimeException("Breaking logic"); + } + return person; + } + + /** + * Find by last name list. + * + * @param lastName the last name + * @return the list + */ + @RequestMapping(path = "/personByLastName", method = RequestMethod.GET) + public List findByLastName(@RequestParam(name = "lastName", required = true) @NotNull + @NotBlank + @Size(max = 10) String lastName) { + List hardCoded = new ArrayList<>(); + Person person = new Person(); + person.setAge(20); + person.setCreditCardNumber("4111111111111111"); + person.setEmail("abc@abc.com"); + person.setEmail1("abc1@abc.com"); + person.setFirstName("Somefirstname"); + person.setLastName(lastName); + person.setId(1); + hardCoded.add(person); + return hardCoded; + + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app112/Problem.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app112/Problem.java new file mode 100644 index 000000000..76979b170 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app112/Problem.java @@ -0,0 +1,99 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app112; + +/** + * The type Problem. + */ +class Problem { + + /** + * The Log ref. + */ + private String logRef; + + /** + * The Message. + */ + private String message; + + /** + * Instantiates a new Problem. + * + * @param logRef the log ref + * @param message the message + */ + public Problem(String logRef, String message) { + super(); + this.logRef = logRef; + this.message = message; + } + + /** + * Instantiates a new Problem. + */ + public Problem() { + super(); + + } + + /** + * Gets log ref. + * + * @return the log ref + */ + public String getLogRef() { + return logRef; + } + + /** + * Sets log ref. + * + * @param logRef the log ref + */ + public void setLogRef(String logRef) { + this.logRef = logRef; + } + + /** + * Gets message. + * + * @return the message + */ + public String getMessage() { + return message; + } + + /** + * Sets message. + * + * @param message the message + */ + public void setMessage(String message) { + this.message = message; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app112/SpringDocApp112Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app112/SpringDocApp112Test.java new file mode 100644 index 000000000..273f9ab8b --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app112/SpringDocApp112Test.java @@ -0,0 +1,71 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app112; + +import io.swagger.v3.oas.models.OpenAPI; +import io.swagger.v3.oas.models.info.Info; +import io.swagger.v3.oas.models.info.License; +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; +import org.springframework.test.context.TestPropertySource; + +/** + * The type Spring doc app 112 test. + */ +@TestPropertySource(properties = { + "application-description=description", + "application-version=v1" }) +class SpringDocApp112Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp { + + /** + * Custom open api open api. + * + * @param appDesciption the app desciption + * @param appVersion the app version + * @return the open api + */ + @Bean + public OpenAPI customOpenAPI(@Value("${application-description}") String appDesciption, @Value("${application-version}") String appVersion) { + return new OpenAPI() + .info(new Info() + .title("sample application API") + .version(appVersion) + .description(appDesciption) + .termsOfService("http://swagger.io/terms/") + .license(new License().name("Apache 2.0").url("http://springdoc.org"))); + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app112/sample/PersonController2.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app112/sample/PersonController2.java new file mode 100644 index 000000000..e9671ca32 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app112/sample/PersonController2.java @@ -0,0 +1,97 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app112.sample; + +import java.util.ArrayList; +import java.util.List; +import java.util.Random; + +import jakarta.validation.Valid; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; +import jakarta.validation.constraints.Size; +import test.org.springdoc.api.v31.app112.Person; + +import org.springframework.validation.annotation.Validated; +import org.springframework.web.HttpMediaTypeNotSupportedException; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Person controller 2. + */ +@RestController +@Validated +class PersonController2 { + /** + * The Ran. + */ + private Random ran = new Random(); + + /** + * Person person. + * + * @param person the person + * @return the person + */ + @RequestMapping(path = "/person2", method = RequestMethod.POST) + public Person person(@Valid @RequestBody Person person) throws HttpMediaTypeNotSupportedException { + + int nxt = ran.nextInt(10); + if (nxt >= 5) { + throw new RuntimeException("Breaking logic"); + } + return person; + } + + /** + * Find by last name list. + * + * @param lastName the last name + * @return the list + */ + @RequestMapping(path = "/personByLastName2", method = RequestMethod.GET) + public List findByLastName(@RequestParam(name = "lastName", required = true) @NotNull + @NotBlank + @Size(max = 10) String lastName) throws HttpMediaTypeNotSupportedException { + List hardCoded = new ArrayList<>(); + Person person = new Person(); + person.setAge(20); + person.setCreditCardNumber("4111111111111111"); + person.setEmail("abc@abc.com"); + person.setEmail1("abc1@abc.com"); + person.setFirstName("Somefirstname"); + person.setLastName(lastName); + person.setId(1); + hardCoded.add(person); + return hardCoded; + + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app113/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app113/HelloController.java new file mode 100644 index 000000000..54367c21e --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app113/HelloController.java @@ -0,0 +1,68 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app113; + +import java.util.Optional; + +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * Test. + * + * @param body the body + */ + @PostMapping("/lol") + public void test(@RequestBody(required = false) Body body) { + } + + /** + * Test 2. + * + * @param body the body + */ + @PostMapping("/lol2") + public void test2(@RequestBody Optional body) { + } + + /** + * The type Body. + */ + class Body { + /** + * The Field. + */ + public String field; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app113/SpringDocApp113Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app113/SpringDocApp113Test.java new file mode 100644 index 000000000..6257df6cf --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app113/SpringDocApp113Test.java @@ -0,0 +1,44 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app113; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + + +/** + * The type Spring doc app 113 test. + */ +class SpringDocApp113Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app114/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app114/HelloController.java new file mode 100644 index 000000000..835a68f85 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app114/HelloController.java @@ -0,0 +1,66 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app114; + +import javax.money.MonetaryAmount; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import org.springframework.http.MediaType; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * Gets currency. + * + * @param carDTO the car dto + * @return the currency + */ + @PostMapping(value = "/foos1", consumes = MediaType.APPLICATION_JSON_VALUE) + MonetaryAmount getCurrency(@RequestBody CarDTO carDTO) { + return carDTO.price; + } + + /** + * The type Car dto. + */ + class CarDTO { + /** + * The Price. + */ + @JsonProperty("price") + MonetaryAmount price; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app114/SpringDocApp114Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app114/SpringDocApp114Test.java new file mode 100644 index 000000000..559c6c985 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app114/SpringDocApp114Test.java @@ -0,0 +1,51 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app114; + +import javax.money.MonetaryAmount; + +import org.springdoc.core.utils.SpringDocUtils; +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + + +/** + * The type Spring doc app 114 test. + */ +class SpringDocApp114Test extends AbstractSpringDocTest { + + static { + SpringDocUtils.getConfig().replaceWithClass(MonetaryAmount.class, org.springdoc.core.converters.models.MonetaryAmount.class); + } + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app115/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app115/HelloController.java new file mode 100644 index 000000000..e17ecaa17 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app115/HelloController.java @@ -0,0 +1,53 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app115; + +import java.time.Duration; + +import org.springframework.http.MediaType; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * Timeouts duration. + * + * @return the duration + */ + @GetMapping(value = "/api/v2/timeout", + consumes = { MediaType.ALL_VALUE }, + produces = { MediaType.APPLICATION_JSON_VALUE }) + public Duration timeouts() { + return Duration.ofSeconds(5); + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app115/JavaTimeOperationCustomizer.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app115/JavaTimeOperationCustomizer.java new file mode 100644 index 000000000..161d18bd4 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app115/JavaTimeOperationCustomizer.java @@ -0,0 +1,69 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app115; + +import java.time.Duration; +import java.util.Map; +import java.util.Set; + +import io.swagger.v3.oas.models.Operation; +import io.swagger.v3.oas.models.media.Content; +import io.swagger.v3.oas.models.media.Schema; +import org.springdoc.core.customizers.OperationCustomizer; + +import org.springframework.http.MediaType; +import org.springframework.stereotype.Component; +import org.springframework.web.method.HandlerMethod; + +/** + * The type Java time operation customizer. + */ +@Component +class JavaTimeOperationCustomizer implements OperationCustomizer { + /** + * Customize operation. + * + * @param operation the operation + * @param handlerMethod the handler method + * @return the operation + */ + @Override + public Operation customize(Operation operation, HandlerMethod handlerMethod) { + if (handlerMethod.getReturnType().getParameterType().isAssignableFrom(Duration.class)) { + for (Map.Entry entry : operation.getResponses().entrySet()) { + io.swagger.v3.oas.models.responses.ApiResponse response = entry.getValue(); + Content content = response.getContent(); + if (content.containsKey(MediaType.APPLICATION_JSON_VALUE)) { + Schema schema = content.get(MediaType.APPLICATION_JSON_VALUE).getSchema(); + schema.types(Set.of("string")); + schema.getProperties().clear(); + } + } + } + return operation; + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app115/SpringDocApp115Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app115/SpringDocApp115Test.java new file mode 100644 index 000000000..3565fd02f --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app115/SpringDocApp115Test.java @@ -0,0 +1,45 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app115; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + + +/** + * The type Spring doc app 115 test. + */ +class SpringDocApp115Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app116/FooErrorHandler.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app116/FooErrorHandler.java new file mode 100644 index 000000000..f3e5fd944 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app116/FooErrorHandler.java @@ -0,0 +1,50 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app116; + +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.ControllerAdvice; +import org.springframework.web.bind.annotation.ExceptionHandler; + +/** + * The type Foo error handler. + */ +@ControllerAdvice(assignableTypes = HelloController.class) +class FooErrorHandler { + + /** + * Store assignment publishing error response entity. + * + * @param e the e + * @return the response entity + */ + @ExceptionHandler + public ResponseEntity storeAssignmentPublishingError(Exception e) { + return new ResponseEntity<>("foo", HttpStatus.INTERNAL_SERVER_ERROR); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app116/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app116/HelloController.java new file mode 100644 index 000000000..358875905 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app116/HelloController.java @@ -0,0 +1,58 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app116; + +import io.swagger.v3.oas.annotations.OpenAPIDefinition; +import io.swagger.v3.oas.annotations.info.Info; +import io.swagger.v3.oas.annotations.tags.Tag; + +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +@RequestMapping("/api") +@OpenAPIDefinition(info = @Info(title = "API Examples", version = "1.0"), tags = @Tag(name = "Operations")) +class HelloController { + + /** + * Create string. + * + * @param foo the foo + * @return the string + */ + @PostMapping("/foo") + public String create(@RequestBody String foo) { + return "foo"; + } +} + + diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app116/SpringDocApp116Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app116/SpringDocApp116Test.java new file mode 100644 index 000000000..b72c20e0f --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app116/SpringDocApp116Test.java @@ -0,0 +1,45 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app116; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + + +/** + * The type Spring doc app 116 test. + */ +class SpringDocApp116Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app117/HelloApplication.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app117/HelloApplication.java new file mode 100644 index 000000000..354c45a84 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app117/HelloApplication.java @@ -0,0 +1,304 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app117; + +import java.io.IOException; +import java.net.URI; +import java.util.HashSet; +import java.util.Set; +import java.util.concurrent.atomic.AtomicLong; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.enums.ParameterIn; +import jakarta.servlet.FilterChain; +import jakarta.servlet.GenericFilter; +import jakarta.servlet.ServletException; +import jakarta.servlet.ServletRequest; +import jakarta.servlet.ServletResponse; +import org.springdoc.core.annotations.RouterOperation; +import org.springdoc.core.annotations.RouterOperations; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.stereotype.Component; +import org.springframework.stereotype.Service; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.servlet.function.RouterFunction; +import org.springframework.web.servlet.function.ServerRequest; +import org.springframework.web.servlet.function.ServerResponse; + +import static org.springframework.web.servlet.function.RouterFunctions.route; +import static org.springframework.web.servlet.function.ServerResponse.ok; + +/** + * The type Hello application. + */ +@Configuration +class HelloApplication { + + /** + * Routes router function. + * + * @param ph the ph + * @return the router function + */ + @Bean + @RouterOperations({ @RouterOperation(path = "/people", method = RequestMethod.GET, beanClass = PersonService.class, beanMethod = "all"), + @RouterOperation(path = "/people/{id}", beanClass = PersonService.class, beanMethod = "byId"), + @RouterOperation(path = "/people", method = RequestMethod.POST, beanClass = PersonService.class, beanMethod = "save") }) + RouterFunction routes(PersonHandler ph) { + String root = ""; + return route() + .GET(root + "/people", ph::handleGetAllPeople) + .GET(root + "/people/{id}", ph::handleGetPersonById) + .POST(root + "/people", ph::handlePostPerson) + .filter((serverRequest, handlerFunction) -> { + return handlerFunction.handle(serverRequest); + }) + .build(); + } +} + +/** + * The type Simple filter. + */ +@Component +class SimpleFilter extends GenericFilter { + + /** + * Do filter. + * + * @param req the req + * @param res the res + * @param filterChain the filter chain + * @throws IOException the io exception + * @throws ServletException the servlet exception + */ + @Override + public void doFilter(ServletRequest req, ServletResponse res, + FilterChain filterChain) throws IOException, ServletException { + filterChain.doFilter(req, res); + } +} + +/** + * The type Person handler. + */ +@Component +class PersonHandler { + + /** + * The Person service. + */ + private final PersonService personService; + + /** + * Instantiates a new Person handler. + * + * @param personService the person service + */ + PersonHandler(PersonService personService) { + this.personService = personService; + } + + /** + * Handle get all people server response. + * + * @param serverRequest the server request + * @return the server response + */ + ServerResponse handleGetAllPeople(ServerRequest serverRequest) { + return ok().body(personService.all()); + } + + /** + * Handle post person server response. + * + * @param r the r + * @return the server response + * @throws ServletException the servlet exception + * @throws IOException the io exception + */ + ServerResponse handlePostPerson(ServerRequest r) throws ServletException, IOException { + Person result = personService.save(new Person(null, r.body(Person.class).getName())); + URI uri = URI.create("/people/" + result.getId()); + return ServerResponse.created(uri).body(result); + } + + /** + * Handle get person by id server response. + * + * @param r the r + * @return the server response + */ + ServerResponse handleGetPersonById(ServerRequest r) { + return ok().body(personService.byId(Long.parseLong(r.pathVariable("id")))); + } +} + +/** + * The type Greetings rest controller. + */ +@RestController +class GreetingsRestController { + + /** + * Greet string. + * + * @param name the name + * @return the string + */ + @GetMapping("/greet/{name}") + String greet(@PathVariable String name) { + return "hello " + name + "!"; + } +} + +/** + * The type Person service. + */ +@Service +class PersonService { + + /** + * The Counter. + */ + private final AtomicLong counter = new AtomicLong(); + + /** + * The People. + */ + private final Set people = Stream.of( + new Person(counter.incrementAndGet(), "Jane"), + new Person(counter.incrementAndGet(), "Josh"), + new Person(counter.incrementAndGet(), "Gordon")) + .collect(Collectors.toCollection(HashSet::new)); + + + /** + * Save person. + * + * @param p the p + * @return the person + */ + Person save(Person p) { + Person person = new Person(counter.incrementAndGet(), p.getName()); + this.people.add(person); + return person; + } + + /** + * All set. + * + * @return the set + */ + Set all() { + return this.people; + } + + /** + * By id person. + * + * @param id the id + * @return the person + */ + Person byId(@Parameter(in = ParameterIn.PATH) Long id) { + return this.people.stream() + .filter(p -> p.getId().equals(id)) + .findFirst() + .orElseThrow(() -> new IllegalArgumentException("no " + Person.class.getName() + " with that ID found!")); + } + +} + +/** + * The type Person. + */ +class Person { + + /** + * The Id. + */ + private Long id; + + /** + * The Name. + */ + private String name; + + /** + * Instantiates a new Person. + * + * @param id the id + * @param name the name + */ + public Person(Long id, String name) { + this.id = id; + this.name = name; + } + + /** + * Gets id. + * + * @return the id + */ + public Long getId() { + return id; + } + + /** + * Sets id. + * + * @param id the id + */ + public void setId(Long id) { + this.id = id; + } + + /** + * Gets name. + * + * @return the name + */ + public String getName() { + return name; + } + + /** + * Sets name. + * + * @param name the name + */ + public void setName(String name) { + this.name = name; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app117/SpringDocApp117Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app117/SpringDocApp117Test.java new file mode 100644 index 000000000..2b33aba3c --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app117/SpringDocApp117Test.java @@ -0,0 +1,44 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app117; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + + +/** + * The type Spring doc app 117 test. + */ +class SpringDocApp117Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app118/AbstractParent.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app118/AbstractParent.java new file mode 100644 index 000000000..e5791e3f3 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app118/AbstractParent.java @@ -0,0 +1,121 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app118; + +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonSubTypes.Type; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeInfo.Id; + +/** + * The type Abstract parent. + */ +@JsonTypeInfo(use = Id.NAME, property = "type") +@JsonSubTypes({ + @Type(ChildOfAbstract1.class), + @Type(ChildOfAbstract2.class) +}) +public abstract class AbstractParent { + /** + * The Id. + */ + private int id; + + /** + * Gets id. + * + * @return the id + */ + public int getId() { + return id; + } + + /** + * Sets id. + * + * @param id the id + */ + public void setId(int id) { + this.id = id; + } +} + +/** + * The type Child of abstract 1. + */ +class ChildOfAbstract1 extends AbstractParent { + /** + * The Abstrach child 1 param. + */ + private String abstrachChild1Param; + + /** + * Gets abstrach child 1 param. + * + * @return the abstrach child 1 param + */ + public String getAbstrachChild1Param() { + return abstrachChild1Param; + } + + /** + * Sets abstrach child 1 param. + * + * @param abstrachChild1Param the abstrach child 1 param + */ + public void setAbstrachChild1Param(String abstrachChild1Param) { + this.abstrachChild1Param = abstrachChild1Param; + } +} + +/** + * The type Child of abstract 2. + */ +class ChildOfAbstract2 extends AbstractParent { + /** + * The Abstract child 2 param. + */ + private String abstractChild2Param; + + /** + * Gets abstract child 2 param. + * + * @return the abstract child 2 param + */ + public String getAbstractChild2Param() { + return abstractChild2Param; + } + + /** + * Sets abstract child 2 param. + * + * @param abstractChild2Param the abstract child 2 param + */ + public void setAbstractChild2Param(String abstractChild2Param) { + this.abstractChild2Param = abstractChild2Param; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app118/ConcreteParent.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app118/ConcreteParent.java new file mode 100644 index 000000000..40b62736b --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app118/ConcreteParent.java @@ -0,0 +1,121 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app118; + +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonSubTypes.Type; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeInfo.Id; + +/** + * The type Concrete parent. + */ +@JsonTypeInfo(use = Id.NAME, property = "type") +@JsonSubTypes({ + @Type(ChildOfConcrete1.class), + @Type(ChildOfConcrete2.class) +}) +class ConcreteParent { + /** + * The Id. + */ + private int id; + + /** + * Gets id. + * + * @return the id + */ + public int getId() { + return id; + } + + /** + * Sets id. + * + * @param id the id + */ + public void setId(int id) { + this.id = id; + } +} + +/** + * The type Child of concrete 1. + */ +class ChildOfConcrete1 extends ConcreteParent { + /** + * The Concrete child 1 param. + */ + private String concreteChild1Param; + + /** + * Gets concrete child 1 param. + * + * @return the concrete child 1 param + */ + public String getConcreteChild1Param() { + return concreteChild1Param; + } + + /** + * Sets concrete child 1 param. + * + * @param concreteChild1Param the concrete child 1 param + */ + public void setConcreteChild1Param(String concreteChild1Param) { + this.concreteChild1Param = concreteChild1Param; + } +} + +/** + * The type Child of concrete 2. + */ +class ChildOfConcrete2 extends ConcreteParent { + /** + * The Concrete child 2 param. + */ + private String concreteChild2Param; + + /** + * Gets concrete child 2 param. + * + * @return the concrete child 2 param + */ + public String getConcreteChild2Param() { + return concreteChild2Param; + } + + /** + * Sets concrete child 2 param. + * + * @param concreteChild2Param the concrete child 2 param + */ + public void setConcreteChild2Param(String concreteChild2Param) { + this.concreteChild2Param = concreteChild2Param; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app118/Controller.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app118/Controller.java new file mode 100644 index 000000000..f4178cae8 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app118/Controller.java @@ -0,0 +1,114 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app118; + +import java.util.List; + +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Controller. + */ +@RestController +@RequestMapping("class-hierarchy") +class Controller { + /** + * Abstract parent response. + * + * @param payload the payload + * @return the response + */ + @PostMapping("abstract-parent") + public Response abstractParent(@RequestBody AbstractParent payload) { + return null; + } + + /** + * Concrete parent response. + * + * @param payload the payload + * @return the response + */ + @PostMapping("concrete-parent") + public Response concreteParent(@RequestBody ConcreteParent payload) { + return null; + } +} + +/** + * The type Response. + */ +class Response { + /** + * The Abstract parent. + */ + AbstractParent abstractParent; + + /** + * The Concrete parents. + */ + List concreteParents; + + /** + * Gets abstract parent. + * + * @return the abstract parent + */ + public AbstractParent getAbstractParent() { + return abstractParent; + } + + /** + * Sets abstract parent. + * + * @param abstractParent the abstract parent + */ + public void setAbstractParent(AbstractParent abstractParent) { + this.abstractParent = abstractParent; + } + + /** + * Gets concrete parents. + * + * @return the concrete parents + */ + public List getConcreteParents() { + return concreteParents; + } + + /** + * Sets concrete parents. + * + * @param concreteParents the concrete parents + */ + public void setConcreteParents(List concreteParents) { + this.concreteParents = concreteParents; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app118/SpringDocApp118Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app118/SpringDocApp118Test.java new file mode 100644 index 000000000..c73c4624d --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app118/SpringDocApp118Test.java @@ -0,0 +1,44 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app118; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + + +/** + * The type Spring doc app 118 test. + */ +class SpringDocApp118Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app119/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app119/HelloController.java new file mode 100644 index 000000000..4e62767ad --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app119/HelloController.java @@ -0,0 +1,67 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app119; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.media.Content; + +import org.springframework.http.MediaType; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.multipart.MultipartFile; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * Multi files in multi part string. + * + * @param jsonRequest the json request + * @param file1 the file 1 + * @param file2 the file 2 + * @return the string + */ + @Operation(summary = "Multiple files and JSON payloads as multi part request") + @PostMapping( + value = "multi", + consumes = MediaType.MULTIPART_FORM_DATA_VALUE, + produces = MediaType.TEXT_PLAIN_VALUE) + public String multiFilesInMultiPart( + @RequestPart("params") + @Parameter( + description = "This is the configuration", + content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE)) final JsonRequest jsonRequest, + @RequestPart(value = "file1", required = false) @Parameter(description = "This is file1") final MultipartFile file1, + @RequestPart(value = "file2", required = false) @Parameter(description = "This is file2") final MultipartFile file2) { + return "Hello World " + jsonRequest.getName(); + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app119/JsonRequest.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app119/JsonRequest.java new file mode 100644 index 000000000..23283d513 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app119/JsonRequest.java @@ -0,0 +1,56 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app119; + +/** + * The type Json request. + */ +class JsonRequest { + + /** + * The Name. + */ + private String name; + + /** + * Gets name. + * + * @return the name + */ + public String getName() { + return name; + } + + /** + * Sets name. + * + * @param name the name + */ + public void setName(String name) { + this.name = name; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app119/SpringDocApp119Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app119/SpringDocApp119Test.java new file mode 100644 index 000000000..179d5c641 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app119/SpringDocApp119Test.java @@ -0,0 +1,44 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app119; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + + +/** + * The type Spring doc app 119 test. + */ +class SpringDocApp119Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app12/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app12/HelloController.java new file mode 100644 index 000000000..9b54d3ea1 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app12/HelloController.java @@ -0,0 +1,55 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app12; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.enums.ParameterIn; +import io.swagger.v3.oas.annotations.media.Schema; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * Persons string. + * + * @return the string + */ + @GetMapping(value = "/persons") + @Operation(parameters = { + @Parameter(name = "name", in = ParameterIn.QUERY, schema = @Schema(implementation = String.class)) }) + public String persons() { + return "OK"; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app12/SpringDocApp12Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app12/SpringDocApp12Test.java new file mode 100644 index 000000000..af6fd5085 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app12/SpringDocApp12Test.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app12; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 12 test. + */ +class SpringDocApp12Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app120/AccountId.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app120/AccountId.java new file mode 100644 index 000000000..cd7a0ede9 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app120/AccountId.java @@ -0,0 +1,81 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app120; + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.enums.ParameterIn; +import io.swagger.v3.oas.annotations.media.Schema; + +import org.springframework.core.annotation.AliasFor; + +import static java.lang.annotation.ElementType.ANNOTATION_TYPE; +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.ElementType.PARAMETER; + +/** + * The interface Account id. + */ +@Target({ PARAMETER, METHOD, ANNOTATION_TYPE }) +@Retention(RetentionPolicy.RUNTIME) +@Parameter(description = "non alias description") +public @interface AccountId { + + /** + * Name string. + * + * @return the string + */ + @AliasFor(annotation = Parameter.class, value = "name") + String name() default ""; + + /** + * Example string. + * + * @return the string + */ + @AliasFor(annotation = Parameter.class, value = "example") + String example() default "123456"; + + /** + * In parameter in. + * + * @return the parameter in + */ + @AliasFor(annotation = Parameter.class, value = "in") + ParameterIn in() default ParameterIn.DEFAULT; + + /** + * Schema schema. + * + * @return the schema + */ + @AliasFor(annotation = Parameter.class, value = "schema") + Schema schema() default @Schema(); +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app120/MetaAnnotationController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app120/MetaAnnotationController.java new file mode 100644 index 000000000..677f7c3b5 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app120/MetaAnnotationController.java @@ -0,0 +1,301 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app120; + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.enums.Explode; +import io.swagger.v3.oas.annotations.enums.ParameterIn; +import io.swagger.v3.oas.annotations.enums.ParameterStyle; +import io.swagger.v3.oas.annotations.extensions.Extension; +import io.swagger.v3.oas.annotations.media.ArraySchema; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.ExampleObject; +import io.swagger.v3.oas.annotations.media.Schema; + +import org.springframework.core.annotation.AliasFor; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import static java.lang.annotation.ElementType.ANNOTATION_TYPE; +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.ElementType.PARAMETER; + +/** + * The type Meta annotation controller. + */ +@RestController +class MetaAnnotationController { + + /** + * Simple test string. + * + * @param accountId the account id + * @return the string + */ + @GetMapping(value = "/simpleTest/{accountId}") + String simpleTest(@PathVariable @AccountId String accountId) { + return accountId; + } + + /** + * When there is a top level {@code @Parameter} annotation it has precedence over the meta-annotation + * So the id parameter should have all the defaults, with a name of "id" + * @param accountId the account id + * @return the string + */ + @GetMapping(value = "/testTopLevelParamAnnotationOverrides/{id}") + String testTopLevelParamAnnotationOverrides(@PathVariable @AccountId @Parameter(name = "id") String accountId) { + return accountId; + } + + /** + * Test query param string. + * + * @param accountId the account id + * @return the string + */ + @GetMapping(value = "/testQueryParam") + String testQueryParam(@RequestParam @AccountId String accountId) { + return accountId; + } + + /** + * {@code @AliasFor} in the {@code @AccountId} annotation allows us to override the default it provides. + * @param accountId the account id + * @return the string + */ + @GetMapping(value = "/testAliasFor") + String testAliasFor(@RequestParam @AccountId(example = "OVERRIDDEN EXAMPLE") String accountId) { + return accountId; + } + + /** + * Test meta meta annotation string. + * + * @param queryAccountId the query account id + * @param accountId the account id + * @return the string + */ + @GetMapping(value = "/testMetaMetaAnnotation/{accountId}") + String testMetaMetaAnnotation( + @RequestParam @QueryAccountId String queryAccountId, + @PathVariable @AccountId String accountId) { + return accountId; + } + + /** + * Test all attributes as alias string. + * + * @param name the name + * @return the string + */ + @GetMapping(value = "/testAllAttributesAsAlias/") + String testAllAttributesAsAlias( + @RequestParam @TestAllAttributesAsAlias String name) { + return name; + } + + /** + * Test no alias fors string. + * + * @param name the name + * @return the string + */ + @GetMapping(value = "/testNoAliasFors/") + String testNoAliasFors( + @RequestParam @TestAllAttributesAsAlias String name) { + return name; + } + + /** + * This should inherent all the attributes of {@code @AccountId}, but give it a different name + */ + @Target({ PARAMETER, METHOD, ANNOTATION_TYPE }) + @Retention(RetentionPolicy.RUNTIME) + @AccountId(name = "queryAccountId") + @interface QueryAccountId { + } + + /** + * The interface Test all attributes as alias. + */ + @Target({ PARAMETER, METHOD, ANNOTATION_TYPE }) + @Retention(RetentionPolicy.RUNTIME) + @Parameter + @interface TestAllAttributesAsAlias { + + /** + * Name string. + * + * @return the string + */ + @AliasFor(annotation = Parameter.class, attribute = "name") + String name() default "name"; + + /** + * In parameter in. + * + * @return the parameter in + */ + @AliasFor(annotation = Parameter.class, attribute = "in") + ParameterIn in() default ParameterIn.QUERY; + + /** + * Description string. + * + * @return the string + */ + @AliasFor(annotation = Parameter.class, attribute = "description") + String description() default "desc"; + + /** + * Required boolean. + * + * @return the boolean + */ + @AliasFor(annotation = Parameter.class, attribute = "required") + boolean required() default true; + + /** + * Deprecated boolean. + * + * @return the boolean + */ + @AliasFor(annotation = Parameter.class, attribute = "deprecated") + boolean deprecated() default true; + + /** + * Allow empty value boolean. + * + * @return the boolean + */ + @AliasFor(annotation = Parameter.class, attribute = "allowEmptyValue") + boolean allowEmptyValue() default true; + + /** + * Style parameter style. + * + * @return the parameter style + */ + @AliasFor(annotation = Parameter.class, attribute = "style") + ParameterStyle style() default ParameterStyle.DEEPOBJECT; + + /** + * Explode explode. + * + * @return the explode + */ + @AliasFor(annotation = Parameter.class, attribute = "explode") + Explode explode() default Explode.TRUE; + + /** + * Allow reserved boolean. + * + * @return the boolean + */ + @AliasFor(annotation = Parameter.class, attribute = "allowReserved") + boolean allowReserved() default true; + + /** + * Schema schema. + * + * @return the schema + */ + @AliasFor(annotation = Parameter.class, attribute = "schema") + Schema schema() default @Schema(name = "special schema", implementation = Boolean.class); + + /** + * Array array schema. + * + * @return the array schema + */ + @AliasFor(annotation = Parameter.class, attribute = "array") + ArraySchema array() default @ArraySchema(); + + /** + * Content content [ ]. + * + * @return the content [ ] + */ + @AliasFor(annotation = Parameter.class, attribute = "content") + Content[] content() default {}; + + /** + * Hidden boolean. + * + * @return the boolean + */ + @AliasFor(annotation = Parameter.class, attribute = "hidden") + boolean hidden() default false; + + /** + * Examples example object [ ]. + * + * @return the example object [ ] + */ + @AliasFor(annotation = Parameter.class, attribute = "examples") + ExampleObject[] examples() default {}; + + /** + * Example string. + * + * @return the string + */ + @AliasFor(annotation = Parameter.class, attribute = "example") + String example() default "1234"; + + /** + * Extensions extension [ ]. + * + * @return the extension [ ] + */ + @AliasFor(annotation = Parameter.class, attribute = "extensions") + Extension[] extensions() default {}; + + /** + * Ref string. + * + * @return the string + */ + @AliasFor(annotation = Parameter.class, attribute = "ref") + String ref() default ""; + } + + /** + * The interface Test no alias fors. + */ + @Target({ PARAMETER, METHOD, ANNOTATION_TYPE }) + @Retention(RetentionPolicy.RUNTIME) + @Parameter(name = "name", description = "desc", schema = @Schema(implementation = Boolean.class)) + @interface TestNoAliasFors { + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app120/SpringDocApp120Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app120/SpringDocApp120Test.java new file mode 100644 index 000000000..af28211a8 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app120/SpringDocApp120Test.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app120; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + + +/** + * Tests Spring meta-annotations as method parameters + */ +class SpringDocApp120Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app121/InheritedRequestParams.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app121/InheritedRequestParams.java new file mode 100644 index 000000000..b9d8d0394 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app121/InheritedRequestParams.java @@ -0,0 +1,59 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app121; + +import jakarta.validation.constraints.NotBlank; + +/** + * The type Inherited request params. + */ +class InheritedRequestParams extends RequestParams { + + /** + * parameter from child of RequestParams + */ + @NotBlank + private String childParam; + + /** + * Gets child param. + * + * @return the child param + */ + public String getChildParam() { + return childParam; + } + + /** + * Sets child param. + * + * @param childParam the child param + */ + public void setChildParam(String childParam) { + this.childParam = childParam; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app121/RequestParams.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app121/RequestParams.java new file mode 100644 index 000000000..1b095570b --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app121/RequestParams.java @@ -0,0 +1,281 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app121; + +import java.math.BigInteger; +import java.util.List; +import java.util.Optional; + +import io.swagger.v3.oas.annotations.Parameter; + + +/** + * The type Request params. + */ +class RequestParams { + + /** + * The String param. + */ + @Parameter(description = "string parameter") + private String stringParam; + + /** + * The String param 1. + */ + @Deprecated + private String stringParam1; + + /** + * The String param 2. + */ + @Parameter(description = "string parameter2", required = true) + private String stringParam2; + + /** + * The Int param. + */ + @Parameter(description = "int parameter") + private int intParam; + + /** + * The Int param 2. + */ + private Optional intParam2; + + /** + * The Int param 3. + */ + private String intParam3; + + /** + * The Nested. + */ + private Nested nested; + + /** + * The Nested list. + */ + private List nestedList; + + /** + * Gets string param. + * + * @return the string param + */ + public String getStringParam() { + return stringParam; + } + + /** + * Sets string param. + * + * @param stringParam the string param + */ + public void setStringParam(String stringParam) { + this.stringParam = stringParam; + } + + /** + * Gets int param. + * + * @return the int param + */ + public int getIntParam() { + return intParam; + } + + /** + * Sets int param. + * + * @param intParam the int param + */ + public void setIntParam(int intParam) { + this.intParam = intParam; + } + + /** + * Gets int param 2. + * + * @return the int param 2 + */ + public Optional getIntParam2() { + return intParam2; + } + + /** + * Sets int param 2. + * + * @param intParam2 the int param 2 + */ + public void setIntParam2(Optional intParam2) { + this.intParam2 = intParam2; + } + + /** + * Gets int param 3. + * + * @return the int param 3 + */ + public String getIntParam3() { + return intParam3; + } + + /** + * Sets int param 3. + * + * @param intParam3 the int param 3 + */ + public void setIntParam3(String intParam3) { + this.intParam3 = intParam3; + } + + /** + * Gets string param 1. + * + * @return the string param 1 + */ + public String getStringParam1() { + return stringParam1; + } + + /** + * Sets string param 1. + * + * @param stringParam1 the string param 1 + */ + public void setStringParam1(String stringParam1) { + this.stringParam1 = stringParam1; + } + + /** + * Gets string param 2. + * + * @return the string param 2 + */ + public String getStringParam2() { + return stringParam2; + } + + /** + * Sets string param 2. + * + * @param stringParam2 the string param 2 + */ + public void setStringParam2(String stringParam2) { + this.stringParam2 = stringParam2; + } + + /** + * Gets nested. + * + * @return the nested + */ + public Nested getNested() { + return nested; + } + + /** + * Sets nested. + * + * @param nested the nested + */ + public void setNested(Nested nested) { + this.nested = nested; + } + + /** + * Gets nested list. + * + * @return the nested list + */ + public List getNestedList() { + return nestedList; + } + + /** + * Sets nested list. + * + * @param nestedList the nested list + */ + public void setNestedList(List nestedList) { + this.nestedList = nestedList; + } + + /** + * The type Nested. + */ + public static class Nested { + /** + * The Param 1. + */ + private String param1; + + /** + * The Param 2. + */ + private BigInteger param2; + + /** + * Gets param 1. + * + * @return the param 1 + */ + @Parameter(description = "nested string parameter") + public String getParam1() { + return param1; + } + + /** + * Sets param 1. + * + * @param param1 the param 1 + */ + public void setParam1(String param1) { + this.param1 = param1; + } + + /** + * Gets param 2. + * + * @return the param 2 + */ + @Parameter(description = "nested BigInteger parameter") + public BigInteger getParam2() { + return param2; + } + + /** + * Sets param 2. + * + * @param param2 the param 2 + */ + public void setParam2(BigInteger param2) { + this.param2 = param2; + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app121/SpringDocApp121Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app121/SpringDocApp121Test.java new file mode 100644 index 000000000..3d1fd7d92 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app121/SpringDocApp121Test.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app121; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + + +/** + * Tests Spring meta-annotations as method parameters + */ +class SpringDocApp121Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app121/TestController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app121/TestController.java new file mode 100644 index 000000000..790e56222 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app121/TestController.java @@ -0,0 +1,52 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app121; + +import org.springdoc.core.annotations.ParameterObject; + +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Test controller. + */ +@RestController +class TestController { + + /** + * Gets test. + * + * @param param the param + * @param requestParams the request params + * @return the test + */ + @PostMapping("test") + public InheritedRequestParams getTest(@RequestParam String param, @ParameterObject InheritedRequestParams requestParams) { + return requestParams; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app122/BaseController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app122/BaseController.java new file mode 100644 index 000000000..e15877baf --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app122/BaseController.java @@ -0,0 +1,55 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app122; + +import io.swagger.v3.oas.annotations.Operation; + +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Base controller. + * + * @param the type parameter + */ +@RestController +public abstract class BaseController { + + /** + * Create response entity. + * + * @param payload the payload + * @return the response entity + */ + @PostMapping + @Operation(summary = "create") + public ResponseEntity create(@RequestBody Wrapper payload) { + return null; + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app122/BaseObject.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app122/BaseObject.java new file mode 100644 index 000000000..3c315d623 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app122/BaseObject.java @@ -0,0 +1,41 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app122; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The type Base object. + */ +class BaseObject { + + /** + * The Base str. + */ + @JsonProperty("baseStr") + private String baseStr; +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app122/CustomerDto.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app122/CustomerDto.java new file mode 100644 index 000000000..bc537139b --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app122/CustomerDto.java @@ -0,0 +1,41 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app122; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The type Customer dto. + */ +class CustomerDto extends BaseObject { + + /** + * The Customer name. + */ + @JsonProperty("customerName") + private String customerName; +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app122/FirstController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app122/FirstController.java new file mode 100644 index 000000000..7eb2dcaa7 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app122/FirstController.java @@ -0,0 +1,40 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app122; + +import io.swagger.v3.oas.annotations.tags.Tag; + +import org.springframework.web.bind.annotation.RestController; + +/** + * The type First controller. + */ +@RestController +@Tag(name = "example") +class FirstController extends BaseController { + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app122/SpringDocApp122Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app122/SpringDocApp122Test.java new file mode 100644 index 000000000..49a49a132 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app122/SpringDocApp122Test.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app122; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + + +/** + * Tests Spring meta-annotations as method parameters + */ +class SpringDocApp122Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app122/Wrapper.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app122/Wrapper.java new file mode 100644 index 000000000..2b1d94b3a --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app122/Wrapper.java @@ -0,0 +1,45 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app122; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The type Wrapper. + * + * @param the type parameter + */ +class Wrapper { + + + /** + * The Wrapper. + */ + @JsonProperty("wrapper") + private String wrapper; + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app123/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app123/HelloController.java new file mode 100644 index 000000000..514534398 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app123/HelloController.java @@ -0,0 +1,56 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app123; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.responses.ApiResponse; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + * + * @param the type parameter + */ +@RestController +class HelloController { + + /** + * Index t. + * + * @param numTel the num tel + * @param adresse the adresse + * @return the t + */ + @GetMapping(value = "/hello/{numTelco}") + @Operation(summary = "GET Persons", responses = @ApiResponse(responseCode = "418")) + public T index(@PathVariable("numTelco") String numTel, String adresse) { + return null; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app123/MyExceptionHandler.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app123/MyExceptionHandler.java new file mode 100644 index 000000000..3cddf30e4 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app123/MyExceptionHandler.java @@ -0,0 +1,66 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app123; + +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.responses.ApiResponse; + +import org.springframework.http.HttpStatus; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.ResponseStatus; +import org.springframework.web.bind.annotation.RestControllerAdvice; + +/** + * The type My exception handler. + */ +@RestControllerAdvice +class MyExceptionHandler { + + /** + * Bad. + * + * @param e the e + */ + @ExceptionHandler(IllegalArgumentException.class) + @ApiResponse(responseCode = "404", description = "Not here", content = @Content) + @ResponseStatus(HttpStatus.NOT_FOUND) + public void bad(IllegalArgumentException e) { + + } + + /** + * Gateway object. + * + * @param e the e + * @return the object + */ + @ExceptionHandler(RuntimeException.class) + @ResponseStatus(HttpStatus.BAD_GATEWAY) + public Object gateway(RuntimeException e) { + return null; + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app123/SpringDocApp123Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app123/SpringDocApp123Test.java new file mode 100644 index 000000000..c9e769330 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app123/SpringDocApp123Test.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app123; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + + +/** + * Tests Spring meta-annotations as method parameters + */ +class SpringDocApp123Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app124/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app124/HelloController.java new file mode 100644 index 000000000..c894f9255 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app124/HelloController.java @@ -0,0 +1,73 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app124; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.responses.ApiResponse; + +import org.springframework.http.HttpStatus; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.ResponseStatus; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + * + * @param the type parameter + */ +@RestController +class HelloController { + + /** + * Bad. + * + * @param e the e + */ + @ExceptionHandler(IllegalArgumentException.class) + @ApiResponse(responseCode = "404", description = "Not here", content = @Content) + @ResponseStatus(HttpStatus.NOT_FOUND) + public void bad(IllegalArgumentException e) { + + } + + /** + * Index t. + * + * @param numTel the num tel + * @param adresse the adresse + * @return the t + */ + @GetMapping(value = "/hello/{numTelco}") + @Operation(summary = "GET Persons", responses = @ApiResponse(responseCode = "418")) + public T index(@PathVariable("numTelco") String numTel, String adresse) { + throw new IllegalArgumentException(); + + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app124/MyExceptionHandler.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app124/MyExceptionHandler.java new file mode 100644 index 000000000..d94b1ddcb --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app124/MyExceptionHandler.java @@ -0,0 +1,51 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app124; + +import org.springframework.http.HttpStatus; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.ResponseStatus; +import org.springframework.web.bind.annotation.RestControllerAdvice; + +/** + * The type My exception handler. + */ +@RestControllerAdvice +class MyExceptionHandler { + + /** + * Gateway object. + * + * @param e the e + * @return the object + */ + @ExceptionHandler(RuntimeException.class) + @ResponseStatus(HttpStatus.BAD_GATEWAY) + public Object gateway(RuntimeException e) { + return null; + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app124/SpringDocApp124Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app124/SpringDocApp124Test.java new file mode 100644 index 000000000..a77177c79 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app124/SpringDocApp124Test.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app124; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + + +/** + * Tests Spring meta-annotations as method parameters + */ +class SpringDocApp124Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app125/DeprecatedEntity.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app125/DeprecatedEntity.java new file mode 100644 index 000000000..41a29eb3c --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app125/DeprecatedEntity.java @@ -0,0 +1,86 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app125; + +import io.swagger.v3.oas.annotations.media.Schema; + +/** + * The type Deprecated entity. + * @author bnasslahsen + */ +class DeprecatedEntity { + /** + * The My non deprecated field. + */ + @Schema(deprecated = false) + private String myNonDeprecatedField; + + /** + * The Mydeprecated field. + */ + @Schema(deprecated = true) + private String mydeprecatedField; + + /** + * Gets my non deprecated field. + * + * @return the my non deprecated field + */ + public String getMyNonDeprecatedField() { + return myNonDeprecatedField; + } + + /** + * Sets my non deprecated field. + * + * @param myNonDeprecatedField the my non deprecated field + * @return the my non deprecated field + */ + @Deprecated + public DeprecatedEntity setMyNonDeprecatedField(String myNonDeprecatedField) { + this.myNonDeprecatedField = myNonDeprecatedField; + return this; + } + + /** + * Gets mydeprecated field. + * + * @return the mydeprecated field + */ + public String getMydeprecatedField() { + return mydeprecatedField; + } + + /** + * Sets mydeprecated field. + * + * @param mydeprecatedField the mydeprecated field + */ + public void setMydeprecatedField(String mydeprecatedField) { + this.mydeprecatedField = mydeprecatedField; + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app125/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app125/HelloController.java new file mode 100644 index 000000000..cdce5b128 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app125/HelloController.java @@ -0,0 +1,52 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app125; + +import jakarta.validation.constraints.NotNull; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + * @author bnasslahsen + */ +@RestController +class HelloController { + + /** + * Gets all pets. + * + * @param toto the toto + * @return the all pets + */ + @GetMapping(value = "/search", produces = { "application/xml", "application/json" }) + public DeprecatedEntity getAllPets(@NotNull String toto) { + return null; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app125/SpringDocApp125Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app125/SpringDocApp125Test.java new file mode 100644 index 000000000..7e6380c6d --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app125/SpringDocApp125Test.java @@ -0,0 +1,58 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app125; + +import java.util.Optional; + +import io.swagger.v3.core.converter.ModelConverter; +import io.swagger.v3.core.converter.ModelConverters; +import org.springdoc.core.converters.SchemaPropertyDeprecatingConverter; +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.test.context.TestPropertySource; + + +/** + * Tests Spring meta-annotations as method parameters + */ +@TestPropertySource(properties = "springdoc.model-converters.deprecating-converter.enabled=false") +class SpringDocApp125Test extends AbstractSpringDocTest { + + static { + Optional deprecatingConverterOptional = + ModelConverters.getInstance(true).getConverters() + .stream().filter(modelConverter -> modelConverter instanceof SchemaPropertyDeprecatingConverter).findAny(); + deprecatingConverterOptional.ifPresent(ModelConverters.getInstance(true)::removeConverter); + } + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app126/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app126/HelloController.java new file mode 100644 index 000000000..a696c3cf1 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app126/HelloController.java @@ -0,0 +1,80 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app126; + +import java.util.ArrayList; +import java.util.Collection; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; + +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +import static org.springframework.http.ResponseEntity.ok; + +/** + * The type Hello controller. + * + * @param the type parameter + */ +@RestController +@ApiResponses(value = { + @ApiResponse(responseCode = "401", ref = SecurityProblemResponsesConfiguration.UNAUTHORIZED_401_NO_TOKEN_RESPONSE_REF), + @ApiResponse(responseCode = "401", ref = SecurityProblemResponsesConfiguration.UNAUTHORIZED_401_BAD_TOKEN_RESPONSE_REF), + @ApiResponse(responseCode = "403", ref = SecurityProblemResponsesConfiguration.FORBIDDEN_403_RESPONSE_REF) }) +//@ApiResponses(value = { +// @ApiResponse(responseCode = "401", description = "Invalid authentication.", content = {@Content(schema = @Schema(implementation = Problem.class), mediaType = APPLICATION_PROBLEM_JSON_VALUE)}), +// @ApiResponse(responseCode = "401", description = "Invalid authentication.",content = {@Content(schema = @Schema(implementation = Problem.class), mediaType = APPLICATION_PROBLEM_JSON_VALUE)}), +// @ApiResponse(responseCode = "403", description = "Missing authorities.",content = {@Content(schema = @Schema(implementation = Problem.class), mediaType = APPLICATION_PROBLEM_JSON_VALUE)}) }) +class HelloController { + + /** + * The constant CURRENCIES. + */ + private static final Collection CURRENCIES = new ArrayList<>(); + + static { + CURRENCIES.add("EUR"); + CURRENCIES.add("USD"); + } + + /** + * Gets all currencies. + * + * @return the all currencies + */ + @GetMapping + @Operation(description = "Get all currencies", summary = "getAllCurrencies") + @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "All currencies returned") }) + public ResponseEntity> getAllCurrencies() { + return ok(CURRENCIES); + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app126/Problem.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app126/Problem.java new file mode 100644 index 000000000..c2bd815ec --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app126/Problem.java @@ -0,0 +1,105 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app126; + +import java.net.URI; +import java.util.Collections; +import java.util.Map; + +/** + * The interface Problem. + */ +public interface Problem { + + /** + * The constant DEFAULT_TYPE. + */ + URI DEFAULT_TYPE = URI.create("about:blank"); + + /** + * An absolute URI that identifies the problem type. When dereferenced, + * it SHOULD provide human-readable documentation for the problem type + * (e.g., using HTML). When this member is not present, its value is + * assumed to be "about:blank". + * + * @return an absolute URI that identifies this problem's type + */ + default URI getType() { + return DEFAULT_TYPE; + } + + /** + * A short, human-readable summary of the problem type. It SHOULD NOT + * change from occurrence to occurrence of the problem, except for + * purposes of localisation. + * + * @return a short, human-readable summary of this problem + */ + default String getTitle() { + return null; + } + + /** + * The HTTP status code generated by the origin server for this + * occurrence of the problem. + * + * @return the HTTP status code + */ + default Integer getStatus() { + return null; + } + + /** + * A human readable explanation specific to this occurrence of the problem. + * + * @return A human readable explaination of this problem + */ + default String getDetail() { + return null; + } + + /** + * An absolute URI that identifies the specific occurrence of the problem. + * It may or may not yield further information if dereferenced. + * + * @return an absolute URI that identifies this specific problem + */ + default URI getInstance() { + return null; + } + + /** + * Optional, additional attributes of the problem. Implementations can choose to ignore this in favor of concrete, + * typed fields. + * + * @return additional parameters + */ + default Map getParameters() { + return Collections.emptyMap(); + } + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app126/SecurityProblemResponsesConfiguration.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app126/SecurityProblemResponsesConfiguration.java new file mode 100644 index 000000000..e833187b2 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app126/SecurityProblemResponsesConfiguration.java @@ -0,0 +1,129 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app126; + +import java.io.IOException; +import java.util.AbstractMap; +import java.util.Map; + +import io.swagger.v3.oas.models.media.Content; +import io.swagger.v3.oas.models.media.MediaType; +import io.swagger.v3.oas.models.media.Schema; +import io.swagger.v3.oas.models.responses.ApiResponse; + +import org.springframework.beans.factory.parsing.Problem; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +import static org.springframework.http.MediaType.APPLICATION_PROBLEM_JSON_VALUE; + +/** + * Configuration class defining standard OpenAPI Specification for operations + */ +@Configuration +class SecurityProblemResponsesConfiguration { + + /** + * The constant HTTP_401_NO_TOKEN. + */ + private static final String HTTP_401_NO_TOKEN = "http401NoToken"; + + /** + * The constant UNAUTHORIZED_401_NO_TOKEN_RESPONSE_REF. + */ + public static final String UNAUTHORIZED_401_NO_TOKEN_RESPONSE_REF = "#/components/responses/" + HTTP_401_NO_TOKEN; + + /** + * The constant HTTP_401_BAD_TOKEN. + */ + private static final String HTTP_401_BAD_TOKEN = "http401BadToken"; + + /** + * The constant UNAUTHORIZED_401_BAD_TOKEN_RESPONSE_REF. + */ + public static final String UNAUTHORIZED_401_BAD_TOKEN_RESPONSE_REF = "#/components/responses/" + HTTP_401_BAD_TOKEN; + + /** + * The constant HTTP_403. + */ + private static final String HTTP_403 = "http403"; + + /** + * The constant FORBIDDEN_403_RESPONSE_REF. + */ + public static final String FORBIDDEN_403_RESPONSE_REF = "#/components/responses/" + HTTP_403; + + /** + * Http 401 no token response map . entry. + * + * @return the map . entry + * @throws IOException the io exception + */ + @Bean + public Map.Entry http401NoTokenResponse() throws IOException { + return simpleResponse(HTTP_401_NO_TOKEN, "Invalid authentication."); + } + + /** + * Http 401 bad token response map . entry. + * + * @return the map . entry + * @throws IOException the io exception + */ + @Bean + public Map.Entry http401BadTokenResponse() throws IOException { + return simpleResponse(HTTP_401_BAD_TOKEN, "Invalid authentication."); + } + + /** + * Http 403 example map . entry. + * + * @return the map . entry + * @throws IOException the io exception + */ + @Bean + public Map.Entry http403Example() throws IOException { + return simpleResponse(HTTP_403, "Missing authorities."); + } + + /** + * Simple response map . entry. + * + * @param code the code + * @param description the description + * @return the map . entry + * @throws IOException the io exception + */ + private Map.Entry simpleResponse(String code, String description) throws IOException { + ApiResponse response = new ApiResponse().description(description).content(new Content().addMediaType( + APPLICATION_PROBLEM_JSON_VALUE, + new MediaType() + .schema(new Schema().$ref("#/components/schemas/Problem")))); + return new AbstractMap.SimpleEntry<>(code, response); + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app126/SpringDocApp126Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app126/SpringDocApp126Test.java new file mode 100644 index 000000000..ddb92c0be --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app126/SpringDocApp126Test.java @@ -0,0 +1,70 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app126; + +import java.util.List; +import java.util.Map; + +import io.swagger.v3.core.converter.AnnotatedType; +import io.swagger.v3.core.converter.ModelConverters; +import io.swagger.v3.core.converter.ResolvedSchema; +import io.swagger.v3.oas.models.responses.ApiResponse; +import org.springdoc.core.customizers.OpenApiCustomizer; +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; + + +/** + * Tests Spring meta-annotations as method parameters + */ +class SpringDocApp126Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp { + + /** + * Response registration customizer open api customiser. + * + * @param responsesToRegister the responses to register + * @return the open api customiser + */ + @Bean + public OpenApiCustomizer responseRegistrationCustomizer(List> responsesToRegister) { + ResolvedSchema resolvedSchema = ModelConverters.getInstance(true) + .resolveAsResolvedSchema(new AnnotatedType(Problem.class)); + return openApi -> { + openApi.getComponents().addSchemas("Problem", resolvedSchema.schema); + responsesToRegister.forEach(entry -> openApi.getComponents().addResponses(entry.getKey(), entry.getValue())); + }; + } + + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app127/AbstractObject.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app127/AbstractObject.java new file mode 100644 index 000000000..6dfeafb8e --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app127/AbstractObject.java @@ -0,0 +1,83 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app127; + +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; + +/** + * The type Abstract object. + */ +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, + include = JsonTypeInfo.As.EXISTING_PROPERTY, + property = "type", + visible = true +) +@JsonSubTypes({ + @JsonSubTypes.Type(value = ConcreteObjectA.class, name = "Type A") +}) +public abstract class AbstractObject { + + /** + * The Type. + */ + private final ConcreteType type; + + /** + * The Name. + */ + private final String name; + + /** + * Instantiates a new Abstract object. + * + * @param type the type + * @param name the name + */ + protected AbstractObject(ConcreteType type, String name) { + this.type = type; + this.name = name; + } + + /** + * Gets type. + * + * @return the type + */ + public ConcreteType getType() { + return type; + } + + /** + * Gets name. + * + * @return the name + */ + public String getName() { + return name; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app127/ConcreteObjectA.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app127/ConcreteObjectA.java new file mode 100644 index 000000000..23006a170 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app127/ConcreteObjectA.java @@ -0,0 +1,58 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app127; + +/** + * The type Concrete object a. + */ +class ConcreteObjectA extends AbstractObject { + + /** + * The Description. + */ + private final String description; + + /** + * Instantiates a new Concrete object a. + * + * @param name the name + * @param description the description + */ + public ConcreteObjectA(String name, String description) { + super(ConcreteType.TYPE_A, name); + this.description = description; + } + + /** + * Gets description. + * + * @return the description + */ + public String getDescription() { + return description; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app127/ConcreteType.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app127/ConcreteType.java new file mode 100644 index 000000000..dd15b5ddd --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app127/ConcreteType.java @@ -0,0 +1,64 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app127; + +/** + * The enum Concrete type. + */ +public enum ConcreteType { + /** + * The Type a. + */ + TYPE_A("Type A"), + /** + * The Type b. + */ + TYPE_B("Type B"); + + /** + * The Name. + */ + private final String name; + + /** + * Instantiates a new Concrete type. + * + * @param name the name + */ + ConcreteType(String name) { + this.name = name; + } + + /** + * Gets name. + * + * @return the name + */ + public String getName() { + return name; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app127/Controller.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app127/Controller.java new file mode 100644 index 000000000..f75109cd5 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app127/Controller.java @@ -0,0 +1,62 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app127; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.ExampleObject; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; + +import org.springframework.http.MediaType; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Controller. + */ +@RestController +class Controller { + + /** + * Bug umbrella. + * + * @return the umbrella + */ + @Operation(summary = "Test Bug", responses = { + @ApiResponse(responseCode = "200", description = "OK", + content = @Content( + schema = @Schema(implementation = Umbrella.class), + examples = @ExampleObject(ref = "#/components/examples/umbrellaExample", name = "Example with weird YAML tag") + ) + ) + }) + @GetMapping(value = "/bug", produces = MediaType.APPLICATION_JSON_VALUE) + public Umbrella bug() { + return new Umbrella(new ConcreteObjectA("a", "b")); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app127/SpringDocApp127Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app127/SpringDocApp127Test.java new file mode 100644 index 000000000..49ba546b8 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app127/SpringDocApp127Test.java @@ -0,0 +1,64 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app127; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; +import org.springdoc.core.utils.Constants; +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.test.web.servlet.MvcResult; + +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + + +/** + * Tests Spring meta-annotations as method parameters + */ +class SpringDocApp127Test extends AbstractSpringDocTest { + + /** + * Test app. + * + * @throws Exception the exception + */ + @Test + protected void testApp() throws Exception { + className = getClass().getSimpleName(); + String testNumber = className.replaceAll("[^0-9]", ""); + MvcResult mockMvcResult = mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL + ".yaml")).andExpect(status().isOk()).andReturn(); + String result = mockMvcResult.getResponse().getContentAsString(); + Assertions.assertTrue(!result.contains("!")); + } + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app127/Umbrella.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app127/Umbrella.java new file mode 100644 index 000000000..6c226d19d --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app127/Umbrella.java @@ -0,0 +1,59 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app127; + +import io.swagger.v3.oas.annotations.media.Schema; + +/** + * The type Umbrella. + */ +class Umbrella { + + /** + * The Object. + */ + @Schema(description = "This reference to abstract class causes weird YAML tag to be added", anyOf = ConcreteObjectA.class) + private final AbstractObject object; + + /** + * Instantiates a new Umbrella. + * + * @param object the object + */ + public Umbrella(AbstractObject object) { + this.object = object; + } + + /** + * Gets object. + * + * @return the object + */ + public AbstractObject getObject() { + return object; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app129/ActualReturnedEntity.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app129/ActualReturnedEntity.java new file mode 100644 index 000000000..deae7559f --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app129/ActualReturnedEntity.java @@ -0,0 +1,42 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app129; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The type Actual returned entity. + */ +class ActualReturnedEntity { + + /** + * The Result. + */ + @JsonProperty + String result; + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app129/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app129/HelloController.java new file mode 100644 index 000000000..66d386c2b --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app129/HelloController.java @@ -0,0 +1,58 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app129; + +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; + +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.context.request.async.DeferredResult; + +/** + * The type Hello controller. + */ +@RestController +@RequestMapping(path = "/api", headers = { "userId", "registrationId" }) +class HelloController { + + /** + * Update deferred result. + * + * @param entity the entity + * @return the deferred result + * @throws Exception the exception + */ + @PostMapping("/test") + @ApiResponses({ @ApiResponse(responseCode = "200") }) + public DeferredResult> update( + @RequestBody ActualReturnedEntity entity) throws Exception { + return null; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app129/OperationResponse.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app129/OperationResponse.java new file mode 100644 index 000000000..deeebd750 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app129/OperationResponse.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app129; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The type Operation response. + * + * @param the type parameter + */ +class OperationResponse { + + /** + * The Operation result. + */ + @JsonProperty + String operationResult; +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app129/SpringDocApp129Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app129/SpringDocApp129Test.java new file mode 100644 index 000000000..71c8abbec --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app129/SpringDocApp129Test.java @@ -0,0 +1,44 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app129; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + + +/** + * Tests Spring meta-annotations as method parameters + */ +class SpringDocApp129Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app13/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app13/HelloController.java new file mode 100644 index 000000000..eb0b07e62 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app13/HelloController.java @@ -0,0 +1,49 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app13; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * Persons string. + * + * @param dto the dto + * @return the string + */ + @GetMapping(value = "/persons") + public String persons(final PersonDTO dto) { + return "OK"; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app13/PersonDTO.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app13/PersonDTO.java new file mode 100644 index 000000000..98db80622 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app13/PersonDTO.java @@ -0,0 +1,124 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app13; + +import com.fasterxml.jackson.databind.PropertyNamingStrategies; +import com.fasterxml.jackson.databind.annotation.JsonNaming; + +/** + * The type Person dto. + */ +@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class) +class PersonDTO { + /** + * The Email. + */ + private String email; + + /** + * The First name. + */ + private String firstName; + + /** + * The Last name. + */ + private String lastName; + + /** + * Instantiates a new Person dto. + */ + public PersonDTO() { + } + + /** + * Instantiates a new Person dto. + * + * @param email the email + * @param firstName the first name + * @param lastName the last name + */ + public PersonDTO(final String email, final String firstName, final String lastName) { + this.email = email; + this.firstName = firstName; + this.lastName = lastName; + } + + /** + * Gets email. + * + * @return the email + */ + public String getEmail() { + return email; + } + + /** + * Sets email. + * + * @param email the email + */ + public void setEmail(final String email) { + this.email = email; + } + + /** + * Gets first name. + * + * @return the first name + */ + public String getFirstName() { + return firstName; + } + + /** + * Sets first name. + * + * @param firstName the first name + */ + public void setFirstName(final String firstName) { + this.firstName = firstName; + } + + /** + * Gets last name. + * + * @return the last name + */ + public String getLastName() { + return lastName; + } + + /** + * Sets last name. + * + * @param lastName the last name + */ + public void setLastName(final String lastName) { + this.lastName = lastName; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app13/SpringDocApp13Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app13/SpringDocApp13Test.java new file mode 100644 index 000000000..3065d5464 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app13/SpringDocApp13Test.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app13; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 13 test. + */ +class SpringDocApp13Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app130/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app130/HelloController.java new file mode 100644 index 000000000..afba85c71 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app130/HelloController.java @@ -0,0 +1,60 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app130; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * List tracker data. + * + * @param toto the toto + * @return the tracker data + */ + @PostMapping(value = "/values/data") + TrackerData list(TrackerData toto) { + return toto; + } + + /** + * Get tracker data. + * + * @param toto the toto + * @return the tracker data + */ + @GetMapping(value = "/values/datakk") + TrackerData get(TrackerData toto) { + return toto; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app130/SpringDocApp130Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app130/SpringDocApp130Test.java new file mode 100644 index 000000000..885be4f01 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app130/SpringDocApp130Test.java @@ -0,0 +1,44 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app130; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + + +/** + * Tests Spring meta-annotations as method parameters + */ +class SpringDocApp130Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app130/TrackerData.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app130/TrackerData.java new file mode 100644 index 000000000..dd09c0402 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app130/TrackerData.java @@ -0,0 +1,61 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app130; + +import java.time.Instant; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.v3.oas.annotations.Hidden; +import io.swagger.v3.oas.annotations.media.Schema; + +/** + * The type Tracker data. + */ +@Hidden +class TrackerData { + + /** + * The Tracker id. + */ + @JsonProperty("trackerId") + String trackerId; + + /** + * The Timestamp. + */ + @Schema(name = "timestamp", type = "string", format = "date-time", required = true, example = "2018-01-01T00:00:00Z") + @JsonProperty("timestamp") + Instant timestamp; + + /** + * The Value. + */ + @Schema(name = "value", type = "number", format = "double", description = "The data value", required = true, example = "19.0") + @JsonProperty("value") + Double value; + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app131/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app131/HelloController.java new file mode 100644 index 000000000..0c1045994 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app131/HelloController.java @@ -0,0 +1,99 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app131; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; + +import org.springframework.http.HttpStatus; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.ResponseStatus; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + * + * @param the type parameter + */ +@RestController +class HelloController { + + + /** + * Create organization. + * + * @param organization the organization + */ + @Operation(summary = "Create the organization", description = "Create the organization") + @ApiResponses( + value = { + @ApiResponse( + responseCode = "204", + description = "The organization was created successfully"), + @ApiResponse( + responseCode = "400", + description = "Invalid argument", + content = + @Content( + mediaType = "application/json", + schema = @Schema(implementation = RestControllerError.class))), + @ApiResponse( + responseCode = "409", + description = "An organization with the specified ID already exists", + content = + @Content( + mediaType = "application/json", + schema = @Schema(implementation = RestControllerError.class))), + @ApiResponse( + responseCode = "500", + description = + "An error has occurred and the request could not be processed at this time", + content = + @Content( + mediaType = "application/json", + schema = @Schema(implementation = RestControllerError.class))) + }) + @RequestMapping( + value = "/organizations", + method = RequestMethod.POST, + produces = "application/json") + @ResponseStatus(HttpStatus.NO_CONTENT) + public void createOrganization( + @Parameter(name = "organization", required = true) + @RequestBody + Organization organization) { + + + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app131/Organization.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app131/Organization.java new file mode 100644 index 000000000..309e3b55d --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app131/Organization.java @@ -0,0 +1,104 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app131; + + +import java.util.UUID; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import io.swagger.v3.oas.annotations.media.Schema; + +/** + * The type Organization. + */ +@Schema(description = + "This is the description being overwritten") +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ "id", "name" }) +class Organization { + + /** + * The Id. + */ + @Schema( + description = + "The Universally Unique Identifier (UUID) uniquely identifying the organization", + required = true) + @JsonProperty(required = true) + private UUID id; + + /** + * The Name. + */ + @Schema(description = "The name of the organization", required = true) + @JsonProperty(required = true) + private String name; + + /** + * Instantiates a new Organization. + */ + public Organization() { + } + + /** + * Gets id. + * + * @return the id + */ + public UUID getId() { + return id; + } + + /** + * Sets id. + * + * @param id the id + */ + public void setId(UUID id) { + this.id = id; + } + + /** + * Gets name. + * + * @return the name + */ + public String getName() { + return name; + } + + /** + * Sets name. + * + * @param name the name + */ + public void setName(String name) { + this.name = name; + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app131/RestControllerError.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app131/RestControllerError.java new file mode 100644 index 000000000..9d258443f --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app131/RestControllerError.java @@ -0,0 +1,48 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app131; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The type Rest controller error. + */ +class RestControllerError { + + /** + * The Id. + */ + @JsonProperty + private String id; + + /** + * The Message. + */ + @JsonProperty + private String message; + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app131/SpringDocApp131Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app131/SpringDocApp131Test.java new file mode 100644 index 000000000..ada5828ce --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app131/SpringDocApp131Test.java @@ -0,0 +1,44 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app131; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + + +/** + * Tests Spring meta-annotations as method parameters + */ +class SpringDocApp131Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app132/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app132/HelloController.java new file mode 100644 index 000000000..74e80592d --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app132/HelloController.java @@ -0,0 +1,99 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app132; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; + +import org.springframework.http.HttpStatus; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.ResponseStatus; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + * + * @param the type parameter + */ +@RestController +class HelloController { + + + /** + * Create organization. + * + * @param organization the organization + */ + @Operation(summary = "Create the organization", description = "Create the organization") + @ApiResponses( + value = { + @ApiResponse( + responseCode = "204", + description = "The organization was created successfully"), + @ApiResponse( + responseCode = "400", + description = "Invalid argument", + content = + @Content( + mediaType = "application/json", + schema = @Schema(implementation = RestControllerError.class))), + @ApiResponse( + responseCode = "409", + description = "An organization with the specified ID already exists", + content = + @Content( + mediaType = "application/json", + schema = @Schema(implementation = RestControllerError.class))), + @ApiResponse( + responseCode = "500", + description = + "An error has occurred and the request could not be processed at this time", + content = + @Content( + mediaType = "application/json", + schema = @Schema(implementation = RestControllerError.class))) + }) + @RequestMapping( + value = "/organizations", + method = RequestMethod.POST, + produces = "application/json") + @ResponseStatus(HttpStatus.NO_CONTENT) + public void createOrganization( + @Parameter(name = "organization", description = "i want to override the description of this object", required = true) + @RequestBody + Organization organization) { + + + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app132/Organization.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app132/Organization.java new file mode 100644 index 000000000..46bb692fd --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app132/Organization.java @@ -0,0 +1,104 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app132; + + +import java.util.UUID; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import io.swagger.v3.oas.annotations.media.Schema; + +/** + * The type Organization. + */ +@Schema(description = + "This is the description being overwritten") +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({ "id", "name" }) +class Organization { + + /** + * The Id. + */ + @Schema( + description = + "The Universally Unique Identifier (UUID) uniquely identifying the organization", + required = true) + @JsonProperty(required = true) + private UUID id; + + /** + * The Name. + */ + @Schema(description = "The name of the organization", required = true) + @JsonProperty(required = true) + private String name; + + /** + * Instantiates a new Organization. + */ + public Organization() { + } + + /** + * Gets id. + * + * @return the id + */ + public UUID getId() { + return id; + } + + /** + * Sets id. + * + * @param id the id + */ + public void setId(UUID id) { + this.id = id; + } + + /** + * Gets name. + * + * @return the name + */ + public String getName() { + return name; + } + + /** + * Sets name. + * + * @param name the name + */ + public void setName(String name) { + this.name = name; + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app132/RestControllerError.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app132/RestControllerError.java new file mode 100644 index 000000000..ff831d670 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app132/RestControllerError.java @@ -0,0 +1,48 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app132; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The type Rest controller error. + */ +class RestControllerError { + + /** + * The Id. + */ + @JsonProperty + private String id; + + /** + * The Message. + */ + @JsonProperty + private String message; + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app132/SpringDocApp132Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app132/SpringDocApp132Test.java new file mode 100644 index 000000000..090a7d364 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app132/SpringDocApp132Test.java @@ -0,0 +1,44 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app132; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + + +/** + * Tests Spring meta-annotations as method parameters + */ +class SpringDocApp132Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app133/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app133/HelloController.java new file mode 100644 index 000000000..986668df6 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app133/HelloController.java @@ -0,0 +1,83 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app133; + +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.media.Schema; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestHeader; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * Gets message from header 1. + * + * @param header the header + * @return the message from header 1 + */ + @GetMapping(path = "/test1", headers = { "myHeader" }) + public String getMessageFromHeader1( + @Parameter(name = "myHeader", description = "A header", schema = @Schema(allowableValues = { "foo", "bar" })) + @RequestHeader("myHeader") String header + ) { + return "bar " + header; + } + + /** + * Gets message from header 2. + * + * @param header the header + * @return the message from header 2 + */ + @GetMapping("/test2") + public String getMessageFromHeader2( + @Parameter(name = "myHeader", description = "A header", schema = @Schema(type = "integer")) + @RequestHeader("myHeader") Integer header + ) { + return "bar " + header; + } + + /** + * Gets message from header 3. + * + * @param header the header + * @return the message from header 3 + */ + @GetMapping(path = "/test3", headers = { "myHeader" }) + public String getMessageFromHeader3( + @Parameter(name = "myHeader", description = "A header", schema = @Schema(type = "integer")) + @RequestHeader("myHeader") Integer header + ) { + return "bar " + header; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app133/SpringDocApp133Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app133/SpringDocApp133Test.java new file mode 100644 index 000000000..f0448d855 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app133/SpringDocApp133Test.java @@ -0,0 +1,44 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app133; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + + +/** + * Tests Spring meta-annotations as method parameters + */ +class SpringDocApp133Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app134/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app134/HelloController.java new file mode 100644 index 000000000..82da5f9ba --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app134/HelloController.java @@ -0,0 +1,228 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app134; + +import java.util.Collections; +import java.util.List; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.media.ArraySchema; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.tags.Tag; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.http.HttpStatus; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.ResponseStatus; +import org.springframework.web.bind.annotation.RestController; + + +/** + * The type Hello controller. + */ +@SpringBootApplication +@RestController +@Tag(name = "The sample resource") +class HelloController { + + // ----------------------------------------------------------------------------------------------------------------- + + /** + * The constant VERSION_1. + */ + public static final String VERSION_1 = "application/vnd.samples.v1+json"; + + /** + * The constant VERSION_2. + */ + public static final String VERSION_2 = "application/vnd.samples.v2+json"; + + /** + * The constant HEADER_1. + */ + public static final String HEADER_1 = "X-API-VERSION=1"; + + /** + * The constant HEADER_2. + */ + public static final String HEADER_2 = "Accept-version=v2"; + + /** + * Gets sample v 1. + * + * @param id the id + * @return the sample v 1 + */ + @GetMapping(value = "/{id}", produces = VERSION_1, headers = HEADER_1) + @ResponseStatus(HttpStatus.OK) + @Operation(operationId = "getSampleV1", deprecated = true, description = "Get the sample by its id." + ) + @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = SampleV1.class))) + public SampleV1 getSampleV1(@Parameter(description = "The sample's id", required = true) + @PathVariable final String id) { + return new SampleV1(id); + } + + /** + * Gets sample v 2. + * + * @param id the id + * @return the sample v 2 + */ + @GetMapping(value = "/{id}", produces = VERSION_2, headers = { HEADER_2, HEADER_1 }) + @ResponseStatus(HttpStatus.OK) + @Operation(operationId = "getSampleV2", description = "Get the sample by its id. This represents V2.") + @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = SampleV1.class))) + public SampleV2 getSampleV2(@Parameter(description = "The sample's id", required = true) + @PathVariable final Long id) { + return new SampleV2(id); + } + + /** + * Search samples list. + * + * @param searchRequest the search request + * @return the list + */ + @PostMapping(path = "/search", consumes = VERSION_2, produces = VERSION_2) + @Operation(description = "Searches for sample objects using the given search request.") + @ApiResponse(responseCode = "200", + content = @Content(array = @ArraySchema(schema = @Schema(implementation = SampleV2.class)))) + public List searchSamples(@RequestBody final SampleSearchRequest searchRequest) { + return Collections.singletonList(new SampleV2(searchRequest.getId())); + } + + + /** + * The type Sample v 1. + */ + private class SampleV1 { + + /** + * The Id. + */ + private String id; + + /** + * Instantiates a new Sample v 1. + * + * @param id the id + */ + public SampleV1(String id) { + this.id = id; + } + + /** + * Gets id. + * + * @return the id + */ + public String getId() { + return id; + } + + /** + * Sets id. + * + * @param id the id + */ + public void setId(String id) { + this.id = id; + } + } + + /** + * The type Sample v 2. + */ + private class SampleV2 { + /** + * The Id. + */ + private long id; + + /** + * Instantiates a new Sample v 2. + * + * @param id the id + */ + public SampleV2(long id) { + this.id = id; + } + + /** + * Gets id. + * + * @return the id + */ + public long getId() { + return id; + } + + /** + * Sets id. + * + * @param id the id + */ + public void setId(long id) { + this.id = id; + } + } + + /** + * The type Sample search request. + */ + private class SampleSearchRequest { + /** + * The Id. + */ + private final long id; + + /** + * Instantiates a new Sample search request. + * + * @param id the id + */ + public SampleSearchRequest(long id) { + this.id = id; + } + + /** + * Gets id. + * + * @return the id + */ + public long getId() { + return id; + } + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app134/OpenApiConfig.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app134/OpenApiConfig.java new file mode 100644 index 000000000..fd20ab7c6 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app134/OpenApiConfig.java @@ -0,0 +1,99 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app134; + +import org.springdoc.core.models.GroupedOpenApi; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +/** + * The type Open api config. + */ +@Configuration +class OpenApiConfig { + + /** + * Group v 1 open api grouped open api. + * + * @return the grouped open api + */ + @Bean + public GroupedOpenApi groupV1OpenApi() { + return GroupedOpenApi.builder() + .group("v1-group").producesToMatch(HelloController.VERSION_1) + .build(); + } + + /** + * Group v 2 open api grouped open api. + * + * @return the grouped open api + */ + @Bean + public GroupedOpenApi groupV2OpenApi() { + return GroupedOpenApi.builder() + .group("v2-group").producesToMatch(HelloController.VERSION_2) + .build(); + } + + /** + * Group v 3 open api grouped open api. + * + * @return the grouped open api + */ + @Bean + public GroupedOpenApi groupV3OpenApi() { + return GroupedOpenApi.builder() + .group("v2-consumes-group").consumesToMatch(HelloController.VERSION_2) + .build(); + } + + /** + * Group v 4 open api grouped open api. + * + * @return the grouped open api + */ + @Bean + public GroupedOpenApi groupV4OpenApi() { + return GroupedOpenApi.builder() + .group("v1-headers-group").headersToMatch(HelloController.HEADER_1) + .build(); + } + + /** + * Group v 5 open api grouped open api. + * + * @return the grouped open api + */ + @Bean + public GroupedOpenApi groupV5OpenApi() { + return GroupedOpenApi.builder() + .group("v1-v2-headers-group").headersToMatch(HelloController.HEADER_1, HelloController.HEADER_2) + .build(); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app134/SpringDocApp134Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app134/SpringDocApp134Test.java new file mode 100644 index 000000000..ef2f9bbb8 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app134/SpringDocApp134Test.java @@ -0,0 +1,116 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app134; + +import org.junit.jupiter.api.Test; +import org.springdoc.core.utils.Constants; +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +import static org.hamcrest.Matchers.is; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + + +/** + * Tests Spring meta-annotations as method parameters + */ +class SpringDocApp134Test extends AbstractSpringDocTest { + + /** + * Test app. + * + * @throws Exception the exception + */ + @Test + protected void testApp() throws Exception { + mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL + "/v1-group")) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.openapi", is("3.1.0"))) + .andExpect(content().json(getContent("results/3.1.0/app134-1.json"), true)); + } + + /** + * Test app 2. + * + * @throws Exception the exception + */ + @Test + void testApp2() throws Exception { + mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL + "/v2-group")) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.openapi", is("3.1.0"))) + .andExpect(content().json(getContent("results/3.1.0/app134-2.json"), true)); + } + + /** + * Test app 3. + * + * @throws Exception the exception + */ + @Test + void testApp3() throws Exception { + mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL + "/v1-headers-group")) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.openapi", is("3.1.0"))) + .andExpect(content().json(getContent("results/3.1.0/app134-3.json"), true)); + } + + /** + * Test app 4. + * + * @throws Exception the exception + */ + @Test + void testApp4() throws Exception { + mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL + "/v1-v2-headers-group")) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.openapi", is("3.1.0"))) + .andExpect(content().json(getContent("results/3.1.0/app134-4.json"), true)); + } + + /** + * Test app 5. + * + * @throws Exception the exception + */ + @Test + void testApp5() throws Exception { + mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL + "/v2-consumes-group")) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.openapi", is("3.1.0"))) + .andExpect(content().json(getContent("results/3.1.0/app134-5.json"), true)); + } + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app135/Book.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app135/Book.java new file mode 100644 index 000000000..3d7d48333 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app135/Book.java @@ -0,0 +1,115 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app135; + +/** + * The type Book. + */ +class Book { + + /** + * The Id. + */ + private String id; + + /** + * The Title. + */ + private String title; + + /** + * The Author. + */ + private String author; + + /** + * Instantiates a new Book. + * + * @param id the id + * @param title the title + * @param author the author + */ + public Book(String id, String title, String author) { + this.id = id; + this.title = title; + this.author = author; + } + + /** + * Gets id. + * + * @return the id + */ + public String getId() { + return id; + } + + /** + * Sets id. + * + * @param id the id + */ + public void setId(String id) { + this.id = id; + } + + /** + * Gets title. + * + * @return the title + */ + public String getTitle() { + return title; + } + + /** + * Sets title. + * + * @param title the title + */ + public void setTitle(String title) { + this.title = title; + } + + /** + * Gets author. + * + * @return the author + */ + public String getAuthor() { + return author; + } + + /** + * Sets author. + * + * @param author the author + */ + public void setAuthor(String author) { + this.author = author; + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app135/BookRepository.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app135/BookRepository.java new file mode 100644 index 000000000..91c3a4ea9 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app135/BookRepository.java @@ -0,0 +1,60 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app135; + +import java.util.Arrays; +import java.util.List; + +import org.springframework.stereotype.Component; + +/** + * The type Book repository. + */ +@Component +class BookRepository { + + /** + * Find by author list. + * + * @param author the author + * @return the list + */ + List findByAuthor(String author) { + Book[] books = { new Book("1", "title1", "author1") }; + return Arrays.asList(books); + } + + /** + * Find all list. + * + * @return the list + */ + List findAll() { + Book[] books = { new Book("2", "title2", "author2") }; + return Arrays.asList(books); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app135/BookRouter.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app135/BookRouter.java new file mode 100644 index 000000000..008d3939f --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app135/BookRouter.java @@ -0,0 +1,140 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app135; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.enums.ParameterIn; +import org.springdoc.core.annotations.RouterOperation; +import org.springdoc.core.annotations.RouterOperations; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.http.MediaType; +import org.springframework.web.servlet.function.RequestPredicates; +import org.springframework.web.servlet.function.RouterFunction; +import org.springframework.web.servlet.function.RouterFunctions; +import org.springframework.web.servlet.function.ServerResponse; + +import static org.springframework.web.servlet.function.RouterFunctions.nest; +import static org.springframework.web.servlet.function.RouterFunctions.route; +import static org.springframework.web.servlet.function.ServerResponse.ok; + +/** + * The type Book router. + */ +@Configuration +class BookRouter { + + /** + * Routes router function. + * + * @param br the br + * @return the router function + */ + @Bean + @RouterOperations({ + @RouterOperation(path = "/greeter/greeter2/books", produces = { MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE }, beanClass = BookRepository.class, beanMethod = "findAll"), + @RouterOperation(path = "/greeter/greeter2/books", produces = { MediaType.TEXT_PLAIN_VALUE, MediaType.APPLICATION_XML_VALUE }, beanClass = BookRepository.class, beanMethod = "findAll"), + @RouterOperation(path = "/greeter/greeter2/books/{author}", beanClass = BookRepository.class, beanMethod = "findByAuthor", + operation = @Operation(operationId = "findByAuthor" + , parameters = { @Parameter(in = ParameterIn.PATH, name = "author") })) }) + RouterFunction routes(BookRepository br) { + return + RouterFunctions.nest(RequestPredicates.path("/greeter").and(RequestPredicates.path("/greeter2")), + RouterFunctions.route(RequestPredicates.GET("/books").and(RequestPredicates.accept(MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML)), req -> ok().body(br.findAll())) + .and(route(RequestPredicates.GET("/books").and(RequestPredicates.accept(MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN)), req -> ok().body(br.findAll()))) + .andRoute(RequestPredicates.GET("/books/{author}"), req -> ok().body(br.findByAuthor(req.pathVariable("author"))))); + } + + /** + * Routes 1 router function. + * + * @param br the br + * @return the router function + */ + @Bean + @RouterOperations({ + @RouterOperation(path = "/books", produces = { MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE }, beanClass = BookRepository.class, beanMethod = "findAll"), + @RouterOperation(path = "/books/{author}", beanClass = BookRepository.class, beanMethod = "findByAuthor", + operation = @Operation(operationId = "findByAuthor" + , parameters = { @Parameter(in = ParameterIn.PATH, name = "author") })) }) + RouterFunction routes1(BookRepository br) { + return + RouterFunctions.nest(RequestPredicates.accept(MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML), + RouterFunctions.route(RequestPredicates.GET("/books"), req -> ServerResponse.ok().body(br.findAll())) + .andRoute(RequestPredicates.GET("/books/{author}"), req -> ServerResponse.ok().body(br.findByAuthor(req.pathVariable("author"))))); + } + + /** + * Routes 3 router function. + * + * @param br the br + * @return the router function + */ + @Bean + @RouterOperations({ + @RouterOperation(path = "/greeter/books", produces = { MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE }, beanClass = BookRepository.class, beanMethod = "findAll"), + @RouterOperation(path = "/greeter/books", produces = { MediaType.TEXT_PLAIN_VALUE, MediaType.APPLICATION_XML_VALUE }, beanClass = BookRepository.class, beanMethod = "findAll"), + @RouterOperation(path = "/greeter/books/{author}", beanClass = BookRepository.class, beanMethod = "findByAuthor", + operation = @Operation(operationId = "findByAuthor" + , parameters = { @Parameter(in = ParameterIn.PATH, name = "author") })), + @RouterOperation(path = "/greeter2/books", produces = { MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE }, beanClass = BookRepository.class, beanMethod = "findAll"), + @RouterOperation(path = "/greeter2/books", produces = { MediaType.TEXT_PLAIN_VALUE, MediaType.APPLICATION_XML_VALUE }, beanClass = BookRepository.class, beanMethod = "findAll"), + @RouterOperation(path = "/greeter2/books/{author}", beanClass = BookRepository.class, beanMethod = "findByAuthor", + operation = @Operation(operationId = "findByAuthor" + , parameters = { @Parameter(in = ParameterIn.PATH, name = "author") })) }) + RouterFunction routes3(BookRepository br) { + return + nest(RequestPredicates.path("/greeter").or(RequestPredicates.path("/greeter2")), + route(RequestPredicates.GET("/books").and(RequestPredicates.accept(MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML)), req -> ok().body(br.findAll())) + .and(route(RequestPredicates.GET("/books").and(RequestPredicates.accept(MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN)), req -> ok().body(br.findAll()))) + .andRoute(RequestPredicates.GET("/books/{author}"), req -> ok().body(br.findByAuthor(req.pathVariable("author"))))); + } + + /** + * Routes 4 router function. + * + * @param br the br + * @return the router function + */ + @Bean + @RouterOperations({ + @RouterOperation(path = "/test/greeter/greeter2/books", produces = { MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE }, beanClass = BookRepository.class, beanMethod = "findAll"), + @RouterOperation(path = "/test/greeter/greeter2/books", produces = { MediaType.TEXT_PLAIN_VALUE, MediaType.APPLICATION_XML_VALUE }, beanClass = BookRepository.class, beanMethod = "findAll"), + @RouterOperation(path = "/test/greeter/greeter2/books/{author}", beanClass = BookRepository.class, beanMethod = "findByAuthor", + operation = @Operation(operationId = "findByAuthor" + , parameters = { @Parameter(in = ParameterIn.PATH, name = "author") })) }) + RouterFunction routes4(BookRepository br) { + return + nest(RequestPredicates.path("/test"), + nest(RequestPredicates.path("/greeter").and(RequestPredicates.path("/greeter2")), + route(RequestPredicates.GET("/books").and(RequestPredicates.accept(MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML)), req -> ok().body(br.findAll())) + .and(route(RequestPredicates.GET("/books").and(RequestPredicates.accept(MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN)), req -> ok().body(br.findAll()))) + .andRoute(RequestPredicates.GET("/books/{author}"), req -> ok().body(br.findByAuthor(req.pathVariable("author")))))); + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app135/SpringDocApp135Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app135/SpringDocApp135Test.java new file mode 100644 index 000000000..3d0ada9da --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app135/SpringDocApp135Test.java @@ -0,0 +1,44 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app135; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + + +/** + * Tests Spring meta-annotations as method parameters + */ +class SpringDocApp135Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app137/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app137/HelloController.java new file mode 100644 index 000000000..fcef107a9 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app137/HelloController.java @@ -0,0 +1,49 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app137; + +import io.swagger.v3.oas.annotations.security.SecurityRequirement; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +@SecurityRequirement(name = "security_auth") +class HelloController { + + /** + * Test. + * + * @param hello the hello + */ + @GetMapping("/test") + public void test(String hello) { + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app137/OpenApiConfig.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app137/OpenApiConfig.java new file mode 100644 index 000000000..f14230f86 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app137/OpenApiConfig.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.app137; + +import io.swagger.v3.oas.annotations.OpenAPIDefinition; +import io.swagger.v3.oas.annotations.enums.SecuritySchemeType; +import io.swagger.v3.oas.annotations.info.Info; +import io.swagger.v3.oas.annotations.security.OAuthFlow; +import io.swagger.v3.oas.annotations.security.OAuthFlows; +import io.swagger.v3.oas.annotations.security.SecurityScheme; +import io.swagger.v3.oas.annotations.servers.Server; + +/** + * The type Open api config. + */ +@OpenAPIDefinition(servers = @Server(url = "${test.server}", description = "${test.desc}"), info = @Info(title = "My App", + description = "Some long and useful description", version = "v1")) +@SecurityScheme(name = "security_auth", type = SecuritySchemeType.OAUTH2, + flows = @OAuthFlows(authorizationCode = @OAuthFlow( + authorizationUrl = "http://authorization.url" + , tokenUrl = "http://token.url", scopes = {}))) +class OpenApiConfig {} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app137/SpringDocApp137Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app137/SpringDocApp137Test.java new file mode 100644 index 000000000..038156fe8 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app137/SpringDocApp137Test.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.app137; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.test.context.TestPropertySource; + + +/** + * Tests Spring meta-annotations as method parameters + */ +@TestPropertySource(properties = { "test.server=http://test.toto.com", "test.desc=toto desc" }) +class SpringDocApp137Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app138/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app138/HelloController.java new file mode 100644 index 000000000..2748bb6b1 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app138/HelloController.java @@ -0,0 +1,55 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app138; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * Test a. + * + * @param hello the hello + */ + @GetMapping("/testA") + public void testA(String hello) { + } + + /** + * Test b. + * + * @param hello the hello + */ + @GetMapping("/testB") + public void testB(String hello) { + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app138/SpringDocApp138Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app138/SpringDocApp138Test.java new file mode 100644 index 000000000..05758f756 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app138/SpringDocApp138Test.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.app138; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.test.context.TestPropertySource; + + +/** + * Tests Spring meta-annotations as method parameters + */ +@TestPropertySource(properties = "springdoc.writer-with-order-by-keys=true") +class SpringDocApp138Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app139/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app139/HelloController.java new file mode 100644 index 000000000..63d6a28a2 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app139/HelloController.java @@ -0,0 +1,62 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app139; + +import org.springframework.http.MediaType; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * Echo 1 string. + * + * @param text the text + * @return the string + */ + @GetMapping(produces = MediaType.TEXT_PLAIN_VALUE, path = "/test1") + public String echo1(@RequestParam(name = "${test.name}", defaultValue = "${test.default-value}") String text) { + return text; + } + + /** + * Echo 2 string. + * + * @param text the text + * @return the string + */ + @GetMapping(produces = MediaType.TEXT_PLAIN_VALUE, path = "/test2") + public String echo2(@RequestParam(value = "${test.value}", defaultValue = "${test.default-value}") String text) { + return text; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app139/SpringDocApp139Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app139/SpringDocApp139Test.java new file mode 100644 index 000000000..0c016018e --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app139/SpringDocApp139Test.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.app139; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.test.context.TestPropertySource; + + +/** + * Tests Spring meta-annotations as method parameters + */ +@TestPropertySource(properties = { "test.name=text", "test.value=text", "test.default-value=default-text" }) +class SpringDocApp139Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app14/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app14/HelloController.java new file mode 100644 index 000000000..fdcad2187 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app14/HelloController.java @@ -0,0 +1,61 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app14; + +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; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * Persons. + * + * @param name the name + */ + @GetMapping("/persons") + public void persons(@Valid @NotBlank String name) { + + } + + /** + * Demo 2 http entity. + * + * @return the http entity + */ + @GetMapping("/test") + public HttpEntity demo2() { + return null; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app14/SpringDocApp14Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app14/SpringDocApp14Test.java new file mode 100644 index 000000000..f2a341dc9 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app14/SpringDocApp14Test.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app14; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 14 test. + */ +class SpringDocApp14Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app140/HelloApplication.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app140/HelloApplication.java new file mode 100644 index 000000000..1870c2deb --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app140/HelloApplication.java @@ -0,0 +1,314 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app140; + +import java.io.IOException; +import java.net.URI; +import java.util.HashSet; +import java.util.Set; +import java.util.concurrent.atomic.AtomicLong; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.enums.ParameterIn; +import jakarta.servlet.FilterChain; +import jakarta.servlet.GenericFilter; +import jakarta.servlet.ServletException; +import jakarta.servlet.ServletRequest; +import jakarta.servlet.ServletResponse; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.stereotype.Component; +import org.springframework.stereotype.Service; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.servlet.function.HandlerFunction; +import org.springframework.web.servlet.function.RouterFunction; +import org.springframework.web.servlet.function.ServerRequest; +import org.springframework.web.servlet.function.ServerResponse; + +import static org.springdoc.core.fn.builders.operation.Builder.operationBuilder; +import static org.springdoc.core.utils.Constants.OPERATION_ATTRIBUTE; +import static org.springframework.web.servlet.function.RouterFunctions.route; +import static org.springframework.web.servlet.function.ServerResponse.ok; + +/** + * The type Hello application. + */ +@Configuration +class HelloApplication { + + /** + * Filter server response. + * + * @param serverRequest the server request + * @param handlerFunction the handler function + * @return the server response + * @throws Exception the exception + */ + private static ServerResponse filter(ServerRequest serverRequest, HandlerFunction handlerFunction) throws Exception { + return handlerFunction.handle(serverRequest); + } + + /** + * Routes router function. + * + * @param ph the ph + * @return the router function + */ + @Bean + RouterFunction routes(PersonHandler ph) { + String root = ""; + return route() + .GET(root + "/people", ph::handleGetAllPeople) + .withAttribute(OPERATION_ATTRIBUTE, operationBuilder().beanClass(PersonService.class).beanMethod("all")) + .GET(root + "/people/{id}", ph::handleGetPersonById) + .withAttribute(OPERATION_ATTRIBUTE, operationBuilder().beanClass(PersonService.class).beanMethod("byId")) + .POST(root + "/people", ph::handlePostPerson) + .withAttribute(OPERATION_ATTRIBUTE, operationBuilder().beanClass(PersonService.class).beanMethod("save")) + .filter(HelloApplication::filter) + .build(); + } +} + +/** + * The type Simple filter. + */ +@Component +class SimpleFilter extends GenericFilter { + + /** + * Do filter. + * + * @param req the req + * @param res the res + * @param filterChain the filter chain + * @throws IOException the io exception + * @throws ServletException the servlet exception + */ + @Override + public void doFilter(ServletRequest req, ServletResponse res, + FilterChain filterChain) throws IOException, ServletException { + filterChain.doFilter(req, res); + } +} + +/** + * The type Person handler. + */ +@Component +class PersonHandler { + + /** + * The Person service. + */ + private final PersonService personService; + + /** + * Instantiates a new Person handler. + * + * @param personService the person service + */ + PersonHandler(PersonService personService) { + this.personService = personService; + } + + /** + * Handle get all people server response. + * + * @param serverRequest the server request + * @return the server response + */ + ServerResponse handleGetAllPeople(ServerRequest serverRequest) { + return ok().body(personService.all()); + } + + /** + * Handle post person server response. + * + * @param r the r + * @return the server response + * @throws ServletException the servlet exception + * @throws IOException the io exception + */ + ServerResponse handlePostPerson(ServerRequest r) throws ServletException, IOException { + Person result = personService.save(new Person(null, r.body(Person.class).getName())); + URI uri = URI.create("/people/" + result.getId()); + return ServerResponse.created(uri).body(result); + } + + /** + * Handle get person by id server response. + * + * @param r the r + * @return the server response + */ + ServerResponse handleGetPersonById(ServerRequest r) { + return ok().body(personService.byId(Long.parseLong(r.pathVariable("id")))); + } +} + +/** + * The type Greetings rest controller. + */ +@RestController +class GreetingsRestController { + + /** + * Greet string. + * + * @param name the name + * @return the string + */ + @GetMapping("/greet/{name}") + String greet(@PathVariable String name) { + return "hello " + name + "!"; + } +} + +/** + * The type Person service. + */ +@Service +class PersonService { + + /** + * The Counter. + */ + private final AtomicLong counter = new AtomicLong(); + + /** + * The People. + */ + private final Set people = Stream.of( + new Person(counter.incrementAndGet(), "Jane"), + new Person(counter.incrementAndGet(), "Josh"), + new Person(counter.incrementAndGet(), "Gordon")) + .collect(Collectors.toCollection(HashSet::new)); + + + /** + * Save person. + * + * @param p the p + * @return the person + */ + Person save(Person p) { + Person person = new Person(counter.incrementAndGet(), p.getName()); + this.people.add(person); + return person; + } + + /** + * All set. + * + * @return the set + */ + Set all() { + return this.people; + } + + /** + * By id person. + * + * @param id the id + * @return the person + */ + Person byId(@Parameter(in = ParameterIn.PATH) Long id) { + return this.people.stream() + .filter(p -> p.getId().equals(id)) + .findFirst() + .orElseThrow(() -> new IllegalArgumentException("no " + Person.class.getName() + " with that ID found!")); + } + +} + +/** + * The type Person. + */ +class Person { + + /** + * The Id. + */ + private Long id; + + /** + * The Name. + */ + private String name; + + /** + * Instantiates a new Person. + * + * @param id the id + * @param name the name + */ + public Person(Long id, String name) { + this.id = id; + this.name = name; + } + + /** + * Gets id. + * + * @return the id + */ + public Long getId() { + return id; + } + + /** + * Sets id. + * + * @param id the id + */ + public void setId(Long id) { + this.id = id; + } + + /** + * Gets name. + * + * @return the name + */ + public String getName() { + return name; + } + + /** + * Sets name. + * + * @param name the name + */ + public void setName(String name) { + this.name = name; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app140/SpringDocApp140Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app140/SpringDocApp140Test.java new file mode 100644 index 000000000..d694b7b65 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app140/SpringDocApp140Test.java @@ -0,0 +1,44 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app140; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + + +/** + * The type Spring doc app 140 test. + */ +class SpringDocApp140Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app141/Book.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app141/Book.java new file mode 100644 index 000000000..53d34e09e --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app141/Book.java @@ -0,0 +1,115 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app141; + +/** + * The type Book. + */ +class Book { + + /** + * The Id. + */ + private String id; + + /** + * The Title. + */ + private String title; + + /** + * The Author. + */ + private String author; + + /** + * Instantiates a new Book. + * + * @param id the id + * @param title the title + * @param author the author + */ + public Book(String id, String title, String author) { + this.id = id; + this.title = title; + this.author = author; + } + + /** + * Gets id. + * + * @return the id + */ + public String getId() { + return id; + } + + /** + * Sets id. + * + * @param id the id + */ + public void setId(String id) { + this.id = id; + } + + /** + * Gets title. + * + * @return the title + */ + public String getTitle() { + return title; + } + + /** + * Sets title. + * + * @param title the title + */ + public void setTitle(String title) { + this.title = title; + } + + /** + * Gets author. + * + * @return the author + */ + public String getAuthor() { + return author; + } + + /** + * Sets author. + * + * @param author the author + */ + public void setAuthor(String author) { + this.author = author; + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app141/BookRepository.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app141/BookRepository.java new file mode 100644 index 000000000..e71f2630d --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app141/BookRepository.java @@ -0,0 +1,60 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app141; + +import java.util.Arrays; +import java.util.List; + +import org.springframework.stereotype.Component; + +/** + * The type Book repository. + */ +@Component +class BookRepository { + + /** + * Find by author list. + * + * @param author the author + * @return the list + */ + List findByAuthor(String author) { + Book[] books = { new Book("1", "title1", "author1") }; + return Arrays.asList(books); + } + + /** + * Find all list. + * + * @return the list + */ + List findAll() { + Book[] books = { new Book("2", "title2", "author2") }; + return Arrays.asList(books); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app141/BookRouter.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app141/BookRouter.java new file mode 100644 index 000000000..9058bc606 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app141/BookRouter.java @@ -0,0 +1,135 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app141; + +import io.swagger.v3.oas.annotations.enums.ParameterIn; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.http.MediaType; +import org.springframework.web.servlet.function.RouterFunction; + +import static org.springdoc.core.fn.builders.operation.Builder.operationBuilder; +import static org.springdoc.core.fn.builders.parameter.Builder.parameterBuilder; +import static org.springdoc.core.utils.Constants.OPERATION_ATTRIBUTE; +import static org.springframework.web.servlet.function.RequestPredicates.GET; +import static org.springframework.web.servlet.function.RequestPredicates.accept; +import static org.springframework.web.servlet.function.RequestPredicates.path; +import static org.springframework.web.servlet.function.RouterFunctions.nest; +import static org.springframework.web.servlet.function.RouterFunctions.route; +import static org.springframework.web.servlet.function.ServerResponse.ok; + +/** + * The type Book router. + */ +@Configuration +class BookRouter { + + + /** + * Routes router function. + * + * @param br the br + * @return the router function + */ + @Bean + RouterFunction routes(BookRepository br) { + return nest(path("/greeter").and(path("/greeter2")), + route(GET("/books").and(accept(MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML)), req -> ok().body(br.findAll())) + .withAttribute(OPERATION_ATTRIBUTE, operationBuilder().beanClass(BookRepository.class).beanMethod("findAll")) + + .and(route(GET("/books").and(accept(MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN)), req -> ok().body(br.findAll())) + .withAttribute(OPERATION_ATTRIBUTE, operationBuilder().beanClass(BookRepository.class).beanMethod("findAll"))) + + .and(route(GET("/books/{author}"), req -> ok().body(br.findByAuthor(req.pathVariable("author")))) + .withAttribute(OPERATION_ATTRIBUTE, operationBuilder() + .operationId("findByAuthor").parameter(parameterBuilder().name("author").in(ParameterIn.PATH)) + .beanClass(BookRepository.class).beanMethod("findByAuthor"))) + ); + } + + /** + * Routes 1 router function. + * + * @param br the br + * @return the router function + */ + @Bean + RouterFunction routes1(BookRepository br) { + return nest(accept(MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML), + route(GET("/books"), req -> ok().body(br.findAll())) + .withAttribute(OPERATION_ATTRIBUTE, operationBuilder().beanClass(BookRepository.class).beanMethod("findAll")) + + .and(route(GET("/books/{author}"), req -> ok().body(br.findByAuthor(req.pathVariable("author")))) + .withAttribute(OPERATION_ATTRIBUTE, operationBuilder() + .operationId("findByAuthor").parameter(parameterBuilder().name("author").in(ParameterIn.PATH)) + .beanClass(BookRepository.class).beanMethod("findByAuthor")))); + } + + /** + * Routes 3 router function. + * + * @param br the br + * @return the router function + */ + @Bean + RouterFunction routes3(BookRepository br) { + return nest(path("/greeter").or(path("/greeter2")), + route(GET("/books").and(accept(MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML)), req -> ok().body(br.findAll())) + .withAttribute(OPERATION_ATTRIBUTE, operationBuilder().beanClass(BookRepository.class).beanMethod("findAll")) + + + .and(route(GET("/books").and(accept(MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN)), req -> ok().body(br.findAll())) + .withAttribute(OPERATION_ATTRIBUTE, operationBuilder().beanClass(BookRepository.class).beanMethod("findAll"))) + + .and(route(GET("/books/{author}"), req -> ok().body(br.findByAuthor(req.pathVariable("author")))) + .withAttribute(OPERATION_ATTRIBUTE, operationBuilder() + .operationId("findByAuthor").parameter(parameterBuilder().name("author").in(ParameterIn.PATH)) + .beanClass(BookRepository.class).beanMethod("findByAuthor")))); + } + + /** + * Routes 4 router function. + * + * @param br the br + * @return the router function + */ + @Bean + RouterFunction routes4(BookRepository br) { + return nest(path("/test"), nest(path("/greeter").and(path("/greeter2")), + route(GET("/books").and(accept(MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML)), req -> ok().body(br.findAll())) + .withAttribute(OPERATION_ATTRIBUTE, operationBuilder().beanClass(BookRepository.class).beanMethod("findAll")) + + .and(route(GET("/books").and(accept(MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN)), req -> ok().body(br.findAll())) + .withAttribute(OPERATION_ATTRIBUTE, operationBuilder().beanClass(BookRepository.class).beanMethod("findAll"))) + + .and(route(GET("/books/{author}"), req -> ok().body(br.findByAuthor(req.pathVariable("author")))) + .withAttribute(OPERATION_ATTRIBUTE, operationBuilder() + .operationId("findByAuthor").parameter(parameterBuilder().name("author").in(ParameterIn.PATH)) + .beanClass(BookRepository.class).beanMethod("findByAuthor"))))); + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app141/SpringDocApp141Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app141/SpringDocApp141Test.java new file mode 100644 index 000000000..b73704df6 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app141/SpringDocApp141Test.java @@ -0,0 +1,44 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app141; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + + +/** + * Tests Spring meta-annotations as method parameters + */ +class SpringDocApp141Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app142/HelloApplication.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app142/HelloApplication.java new file mode 100644 index 000000000..60efd2058 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app142/HelloApplication.java @@ -0,0 +1,296 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app142; + +import java.io.IOException; +import java.net.URI; +import java.util.HashSet; +import java.util.Set; +import java.util.concurrent.atomic.AtomicLong; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.enums.ParameterIn; +import jakarta.servlet.FilterChain; +import jakarta.servlet.GenericFilter; +import jakarta.servlet.ServletException; +import jakarta.servlet.ServletRequest; +import jakarta.servlet.ServletResponse; +import org.springdoc.webmvc.core.fn.SpringdocRouteBuilder; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.stereotype.Component; +import org.springframework.stereotype.Service; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.servlet.function.RouterFunction; +import org.springframework.web.servlet.function.ServerRequest; +import org.springframework.web.servlet.function.ServerResponse; + +import static org.springframework.web.servlet.function.ServerResponse.ok; + +/** + * The type Hello application. + */ +@Configuration +class HelloApplication { + + + /** + * Routes router function. + * + * @param ph the ph + * @return the router function + */ + @Bean + RouterFunction routes(PersonHandler ph) { + String root = ""; + return SpringdocRouteBuilder.route() + .GET(root + "/people", ph::handleGetAllPeople, ops -> ops.beanClass(PersonService.class).beanMethod("all")) + .GET(root + "/people/{id}", ph::handleGetPersonById, ops -> ops.beanClass(PersonService.class).beanMethod("byId")) + .POST(root + "/people", ph::handlePostPerson, ops -> ops.beanClass(PersonService.class).beanMethod("save")).build(); + } + +} + +/** + * The type Simple filter. + */ +@Component +class SimpleFilter extends GenericFilter { + + /** + * Do filter. + * + * @param req the req + * @param res the res + * @param filterChain the filter chain + * @throws IOException the io exception + * @throws ServletException the servlet exception + */ + @Override + public void doFilter(ServletRequest req, ServletResponse res, + FilterChain filterChain) throws IOException, ServletException { + filterChain.doFilter(req, res); + } +} + +/** + * The type Person handler. + */ +@Component +class PersonHandler { + + /** + * The Person service. + */ + private final PersonService personService; + + /** + * Instantiates a new Person handler. + * + * @param personService the person service + */ + PersonHandler(PersonService personService) { + this.personService = personService; + } + + /** + * Handle get all people server response. + * + * @param serverRequest the server request + * @return the server response + */ + ServerResponse handleGetAllPeople(ServerRequest serverRequest) { + return ok().body(personService.all()); + } + + /** + * Handle post person server response. + * + * @param r the r + * @return the server response + * @throws ServletException the servlet exception + * @throws IOException the io exception + */ + ServerResponse handlePostPerson(ServerRequest r) throws ServletException, IOException { + Person result = personService.save(new Person(null, r.body(Person.class).getName())); + URI uri = URI.create("/people/" + result.getId()); + return ServerResponse.created(uri).body(result); + } + + /** + * Handle get person by id server response. + * + * @param r the r + * @return the server response + */ + ServerResponse handleGetPersonById(ServerRequest r) { + return ok().body(personService.byId(Long.parseLong(r.pathVariable("id")))); + } +} + +/** + * The type Greetings rest controller. + */ +@RestController +class GreetingsRestController { + + /** + * Greet string. + * + * @param name the name + * @return the string + */ + @GetMapping("/greet/{name}") + String greet(@PathVariable String name) { + return "hello " + name + "!"; + } +} + +/** + * The type Person service. + */ +@Service +class PersonService { + + /** + * The Counter. + */ + private final AtomicLong counter = new AtomicLong(); + + /** + * The People. + */ + private final Set people = Stream.of( + new Person(counter.incrementAndGet(), "Jane"), + new Person(counter.incrementAndGet(), "Josh"), + new Person(counter.incrementAndGet(), "Gordon")) + .collect(Collectors.toCollection(HashSet::new)); + + + /** + * Save person. + * + * @param p the p + * @return the person + */ + Person save(Person p) { + Person person = new Person(counter.incrementAndGet(), p.getName()); + this.people.add(person); + return person; + } + + /** + * All set. + * + * @return the set + */ + Set all() { + return this.people; + } + + /** + * By id person. + * + * @param id the id + * @return the person + */ + Person byId(@Parameter(in = ParameterIn.PATH) Long id) { + return this.people.stream() + .filter(p -> p.getId().equals(id)) + .findFirst() + .orElseThrow(() -> new IllegalArgumentException("no " + Person.class.getName() + " with that ID found!")); + } + +} + +/** + * The type Person. + */ +class Person { + + /** + * The Id. + */ + private Long id; + + /** + * The Name. + */ + private String name; + + /** + * Instantiates a new Person. + * + * @param id the id + * @param name the name + */ + public Person(Long id, String name) { + this.id = id; + this.name = name; + } + + /** + * Gets id. + * + * @return the id + */ + public Long getId() { + return id; + } + + /** + * Sets id. + * + * @param id the id + */ + public void setId(Long id) { + this.id = id; + } + + /** + * Gets name. + * + * @return the name + */ + public String getName() { + return name; + } + + /** + * Sets name. + * + * @param name the name + */ + public void setName(String name) { + this.name = name; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app142/SpringDocApp142Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app142/SpringDocApp142Test.java new file mode 100644 index 000000000..f81558d98 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app142/SpringDocApp142Test.java @@ -0,0 +1,44 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app142; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + + +/** + * The type Spring doc app 142 test. + */ +class SpringDocApp142Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app149/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app149/HelloController.java new file mode 100644 index 000000000..b3e9fdaba --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app149/HelloController.java @@ -0,0 +1,91 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app149; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.servlet.ModelAndView; + +/** + * To test the case a user does not use @RestController but puts @Operation on handler methods + * and wants these methods to be exposed. + * + * @author Azige + */ +@Controller +class HelloController { + + /** + * Hello string. + * + * @return the string + */ + @GetMapping("/hello") + @Operation(responses = @ApiResponse( + responseCode = "200", + description = "OK", + content = @Content(schema = @Schema(implementation = HelloMessage.class)) + )) + public String hello() { + return "forward:/message"; + } + + /** + * Message hello message. + * + * @return the hello message + */ + @GetMapping("/message") + @Operation + @ResponseBody + public HelloMessage message() { + return new HelloMessage("Lucky numbers!", 777); + } + + /** + * Hello model and view model and view. + * + * @return the model and view + */ + @GetMapping("/helloModelAndView") + @Operation(responses = @ApiResponse( + responseCode = "200", + description = "OK", + content = @Content(schema = @Schema(implementation = HelloMessage.class)) + )) + public ModelAndView helloModelAndView() { + ModelAndView mav = new ModelAndView(); + mav.setViewName("forward:/message"); + return mav; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app149/HelloMessage.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app149/HelloMessage.java new file mode 100644 index 000000000..8592c6b1e --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app149/HelloMessage.java @@ -0,0 +1,53 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app149; + +/** + * The type Hello message. + */ +class HelloMessage { + /** + * The Text. + */ + public String text; + + /** + * The Number. + */ + public int number; + + /** + * Instantiates a new Hello message. + * + * @param text the text + * @param number the number + */ + public HelloMessage(String text, int number) { + this.text = text; + this.number = number; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app149/SpringDocApp149Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app149/SpringDocApp149Test.java new file mode 100644 index 000000000..978fccec9 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app149/SpringDocApp149Test.java @@ -0,0 +1,45 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app149; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.test.context.TestPropertySource; + +/** + * The type Spring doc app 149 test. + */ +@TestPropertySource(properties = "springdoc.model-and-view-allowed=true") +class SpringDocApp149Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app15/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app15/HelloController.java new file mode 100644 index 000000000..557c22542 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app15/HelloController.java @@ -0,0 +1,55 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app15; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import org.json.JSONObject; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * Persons json object. + * + * @return the json object + */ + @GetMapping(value = "/persons") + @Operation(description = "${springdoc.operation-descriptions.myOperation}", responses = @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(hidden = true)))) + public JSONObject persons() { + return new JSONObject(); + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app15/SpringDocApp15Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app15/SpringDocApp15Test.java new file mode 100644 index 000000000..497473a55 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app15/SpringDocApp15Test.java @@ -0,0 +1,75 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app15; + +import io.swagger.v3.oas.annotations.OpenAPIDefinition; +import io.swagger.v3.oas.annotations.info.Contact; +import io.swagger.v3.oas.annotations.info.Info; +import io.swagger.v3.oas.annotations.info.License; +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.test.context.TestPropertySource; + +/** + * The type Spring doc app 15 test. + */ +@TestPropertySource(properties = { + "springdoc.operation-descriptions.myOperation=My Desc", + "springdoc.openapidefinition.info.title=My title", + "springdoc.openapidefinition.info.desc=My description", + "springdoc.openapidefinition.info.version=My version", + "springdoc.openapidefinition.info.terms=My terms", + "springdoc.openapidefinition.info.license.name=My license name", + "springdoc.openapidefinition.info.license.url=My license url", + "springdoc.openapidefinition.info.contact.name=My contact name", + "springdoc.openapidefinition.info.contact.email=My contact email", + "springdoc.openapidefinition.info.contact.url=My contact url" +}) +class SpringDocApp15Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + @OpenAPIDefinition(info = @Info( + title = "${springdoc.openapidefinition.info.title}", + description = "${springdoc.openapidefinition.info.desc}", + version = "${springdoc.openapidefinition.info.version}", + termsOfService = "${springdoc.openapidefinition.info.terms}", + license = @License( + name = "${springdoc.openapidefinition.info.license.name}", + url = "${springdoc.openapidefinition.info.license.url}" + ), + contact = @Contact( + name = "${springdoc.openapidefinition.info.contact.name}", + email = "${springdoc.openapidefinition.info.contact.email}", + url = "${springdoc.openapidefinition.info.contact.url}" + ) + )) + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app150/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app150/HelloController.java new file mode 100644 index 000000000..16830e515 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app150/HelloController.java @@ -0,0 +1,99 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app150; + +import java.time.LocalDate; +import java.util.List; + +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; + +import org.springframework.format.annotation.DateTimeFormat; +import org.springframework.http.HttpStatus; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.ResponseStatus; +import org.springframework.web.bind.annotation.RestController; + +import static org.springframework.format.annotation.DateTimeFormat.ISO.DATE; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * Test. + * + * @param toto the toto + */ + @GetMapping("/test/") + @ApiResponse(responseCode = "204", description = "No content") + @ResponseStatus(value = HttpStatus.NO_CONTENT) + public void test(@RequestParam(defaultValue = "1") Integer toto) { + + } + + /** + * Test 1. + * + * @param toto the toto + */ + @GetMapping("/test1") + @ApiResponse(responseCode = "204", description = "No content") + @ResponseStatus(value = HttpStatus.NO_CONTENT) + public void test1(@RequestParam @Parameter(schema = @Schema(defaultValue = "false", type = "boolean")) boolean toto) { + + } + + /** + * Test 3. + * + * @param toto the toto + */ + @GetMapping("/test3") + @ApiResponse(responseCode = "204", description = "No content") + @ResponseStatus(value = HttpStatus.NO_CONTENT) + public void test3(@RequestParam(defaultValue = "users,123") List toto) { + + } + + /** + * Test 4. + * + * @param localDate the local date + */ + @GetMapping("/test4") + @ApiResponse(responseCode = "204", description = "No content") + @ResponseStatus(value = HttpStatus.NO_CONTENT) + public void test4(@DateTimeFormat(iso = DATE) @RequestParam(defaultValue = "2021-03-08") LocalDate localDate) { + + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app150/SpringDocApp150Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app150/SpringDocApp150Test.java new file mode 100644 index 000000000..954253b08 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app150/SpringDocApp150Test.java @@ -0,0 +1,45 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app150; + + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * Tests Spring meta-annotations as method parameters + */ +class SpringDocApp150Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app151/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app151/HelloController.java new file mode 100644 index 000000000..9cd5c001e --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app151/HelloController.java @@ -0,0 +1,53 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app151; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +@RequestMapping("/test") +class HelloController { + + /** + * Test int. + * + * @return the int + */ + @GetMapping("") + /** + * A test endpoint mounted under `/test` + * @return 0 + */ + public int test() { + return 0; + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app151/SpringDocApp151Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app151/SpringDocApp151Test.java new file mode 100644 index 000000000..c62e734ac --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app151/SpringDocApp151Test.java @@ -0,0 +1,45 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app151; + + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * Tests Spring meta-annotations as method parameters + */ +class SpringDocApp151Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app152/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app152/HelloController.java new file mode 100644 index 000000000..65eeda26c --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app152/HelloController.java @@ -0,0 +1,72 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app152; + +import org.springframework.context.annotation.Configuration; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.servlet.config.annotation.PathMatchConfigurer; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; +import org.springframework.web.util.pattern.PathPatternParser; + +/** + * The type Hello controller. + */ +@RestController +@RequestMapping("/api") +class HelloController { + + /** + * Hello world string. + * + * @return the string + */ + @GetMapping + public String helloWorld() { + return "ok"; + } + + /** + * The type Web config. + */ + @Configuration + class WebConfig implements WebMvcConfigurer { + + /** + * Configure path match. + * + * @param configurer the configurer + */ + @Override + public void configurePathMatch(PathMatchConfigurer configurer) { + configurer.setPatternParser(new PathPatternParser()); + } + + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app152/SpringDocApp152Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app152/SpringDocApp152Test.java new file mode 100644 index 000000000..96a82a7d7 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app152/SpringDocApp152Test.java @@ -0,0 +1,45 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app152; + + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * Tests Spring meta-annotations as method parameters + */ +class SpringDocApp152Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app153/OrderState.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app153/OrderState.java new file mode 100644 index 000000000..b18293602 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app153/OrderState.java @@ -0,0 +1,68 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app153; + +import io.swagger.v3.oas.annotations.media.Schema; + + +/** + * The enum Order state. + */ +@Schema(type = "string", allowableValues = { "finished", "new" }) +public enum OrderState { + /** + *Finished order state. + */ + FINISHED("finished"), + /** + *New order state. + */ + NEW("new"); + + /** + * The Value. + */ + private final String value; + + /** + * Instantiates a new Order state. + * + * @param value the value + */ + OrderState(String value) { + this.value = value; + } + + /** + * Gets value. + * + * @return the value + */ + public String getValue() { + return value; + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app153/OrderStateMapper.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app153/OrderStateMapper.java new file mode 100644 index 000000000..06f70cdee --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app153/OrderStateMapper.java @@ -0,0 +1,53 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app153; + +import java.beans.PropertyEditorSupport; +import java.util.Arrays; + +import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException; + +/** + * The type Order state mapper. + */ +class OrderStateMapper extends PropertyEditorSupport { + + /** + * Sets as text. + * + * @param text the text + */ + @Override + public void setAsText(String text) { + setValue( + Arrays.stream(OrderState.class.getEnumConstants()) + .filter(e -> e.getValue().equals(text)) + .findFirst() + .orElseThrow(() -> new MethodArgumentTypeMismatchException( + text, OrderState.class, "orderState", null, null))); + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app153/SpringDocApp153Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app153/SpringDocApp153Test.java new file mode 100644 index 000000000..9d2d97321 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app153/SpringDocApp153Test.java @@ -0,0 +1,45 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app153; + + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * Tests Spring meta-annotations as method parameters + */ +class SpringDocApp153Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app153/TestController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app153/TestController.java new file mode 100644 index 000000000..3771e2e3f --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app153/TestController.java @@ -0,0 +1,62 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app153; + +import org.springframework.web.bind.WebDataBinder; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.InitBinder; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Test controller. + */ +@RestController +class TestController { + + /** + * Init binder. + * + * @param dataBinder the data binder + */ + @InitBinder + public void initBinder(WebDataBinder dataBinder) { + dataBinder.registerCustomEditor(OrderState.class, new OrderStateMapper()); + } + + /** + * Method object. + * + * @param orderState the order state + * @return the object + */ + @GetMapping(value = { "/orders" }) + public Object method( + @RequestParam(value = "state", defaultValue = "finished") OrderState orderState) { + return null; + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app154/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app154/HelloController.java new file mode 100644 index 000000000..974ac26be --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app154/HelloController.java @@ -0,0 +1,97 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app154; + +import java.time.Instant; + +import org.springdoc.core.annotations.ParameterObject; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + + /** + * Hello string. + * + * @return the string + */ + @GetMapping(path = "/") + public String hello() { + return "Hello world at " + Instant.now().toString(); + } + + /** + * Create. + * + * @param id the id + * @param o the o + */ + @PostMapping(value = "/persons") + public void create(@ParameterObject Long id, @RequestBody Object o) { + + } + + /** + * Createone. + * + * @param id the id + * @param o the o + */ + @PostMapping(value = "/personsone") + public void createone(Long id, @RequestBody Object o) { + + } + + /** + * Createtwo. + * + * @param id the id + */ + @PostMapping(value = "/createtwo") + public void createtwo(int id) { + + } + + /** + * Createthree. + * + * @param id the id + */ + @PostMapping(value = "/createthree") + public void createthree(Integer id) { + + } + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app154/OpenApiConfiguration.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app154/OpenApiConfiguration.java new file mode 100644 index 000000000..59b8554cf --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app154/OpenApiConfiguration.java @@ -0,0 +1,56 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app154; + +import io.swagger.v3.oas.annotations.OpenAPIDefinition; +import io.swagger.v3.oas.annotations.enums.SecuritySchemeType; +import io.swagger.v3.oas.annotations.info.Info; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.security.SecurityScheme; +import io.swagger.v3.oas.annotations.security.SecuritySchemes; + +/** + * The type Open api configuration. + */ +@OpenAPIDefinition(info = @Info(title = "toto", version = "1.0"), + security = { @SecurityRequirement(name = "basicAuth"), @SecurityRequirement(name = "bearerToken") } +) +@SecuritySchemes({ + @SecurityScheme( + name = "basicAuth", + type = SecuritySchemeType.HTTP, + scheme = "basic" + ), + @SecurityScheme( + name = "bearerToken", + type = SecuritySchemeType.HTTP, + scheme = "bearer", + bearerFormat = "JWT" + ) +}) +class OpenApiConfiguration { +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app154/SpringDocApp154Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app154/SpringDocApp154Test.java new file mode 100644 index 000000000..f058ba119 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app154/SpringDocApp154Test.java @@ -0,0 +1,45 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app154; + + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * Tests Spring meta-annotations as method parameters + */ +class SpringDocApp154Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app155/AbstractIntParameterObject.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app155/AbstractIntParameterObject.java new file mode 100644 index 000000000..21722d79a --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app155/AbstractIntParameterObject.java @@ -0,0 +1,81 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app155; + +/** + * The type Abstract int parameter object. + * + * @param the type parameter + */ +class AbstractIntParameterObject { + + /** + * The Primitive base field. + */ + int primitiveBaseField; + + /** + * The Generic field. + */ + T genericField; + + /** + * Gets primitive base field. + * + * @return the primitive base field + */ + public int getPrimitiveBaseField() { + return primitiveBaseField; + } + + /** + * Sets primitive base field. + * + * @param primitiveBaseField the primitive base field + */ + public void setPrimitiveBaseField(int primitiveBaseField) { + this.primitiveBaseField = primitiveBaseField; + } + + /** + * Gets generic field. + * + * @return the generic field + */ + public T getGenericField() { + return genericField; + } + + /** + * Sets generic field. + * + * @param genericField the generic field + */ + public void setGenericField(T genericField) { + this.genericField = genericField; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app155/AbstractParameterObject.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app155/AbstractParameterObject.java new file mode 100644 index 000000000..641ae9161 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app155/AbstractParameterObject.java @@ -0,0 +1,85 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app155; + +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.media.Schema; + +/** + * The type Abstract parameter object. + * + * @param the type parameter + */ +class AbstractParameterObject> { + + /** + * The Primitive base field. + */ + int primitiveBaseField; + + /** + * The Generic field. + */ + @Parameter(schema = @Schema(type = "string", allowableValues = { "ONE", "TWO" })) + T genericField; + + /** + * Gets primitive base field. + * + * @return the primitive base field + */ + public int getPrimitiveBaseField() { + return primitiveBaseField; + } + + /** + * Sets primitive base field. + * + * @param primitiveBaseField the primitive base field + */ + public void setPrimitiveBaseField(int primitiveBaseField) { + this.primitiveBaseField = primitiveBaseField; + } + + /** + * Gets generic field. + * + * @return the generic field + */ + public T getGenericField() { + return genericField; + } + + /** + * Sets generic field. + * + * @param genericField the generic field + */ + public void setGenericField(T genericField) { + this.genericField = genericField; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app155/ConcreteEnum.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app155/ConcreteEnum.java new file mode 100644 index 000000000..dd1545bc5 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app155/ConcreteEnum.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app155; + + +/** + * The enum Concrete enum. + */ +enum ConcreteEnum { + /** + *One concrete enum. + */ + ONE, + /** + *Two concrete enum. + */ + TWO + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app155/ConcreteIntParameterObject.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app155/ConcreteIntParameterObject.java new file mode 100644 index 000000000..6dd625e79 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app155/ConcreteIntParameterObject.java @@ -0,0 +1,56 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app155; + +/** + * The type Concrete int parameter object. + */ +class ConcreteIntParameterObject extends AbstractIntParameterObject { + + /** + * The Primitive concrete field. + */ + int primitiveConcreteField; + + /** + * Gets primitive concrete field. + * + * @return the primitive concrete field + */ + public int getPrimitiveConcreteField() { + return primitiveConcreteField; + } + + /** + * Sets primitive concrete field. + * + * @param primitiveConcreteField the primitive concrete field + */ + public void setPrimitiveConcreteField(int primitiveConcreteField) { + this.primitiveConcreteField = primitiveConcreteField; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app155/ConcreteParameterObject.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app155/ConcreteParameterObject.java new file mode 100644 index 000000000..d42bc8242 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app155/ConcreteParameterObject.java @@ -0,0 +1,56 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app155; + +/** + * The type Concrete parameter object. + */ +class ConcreteParameterObject extends AbstractParameterObject { + + /** + * The Primitive concrete field. + */ + int primitiveConcreteField; + + /** + * Gets primitive concrete field. + * + * @return the primitive concrete field + */ + public int getPrimitiveConcreteField() { + return primitiveConcreteField; + } + + /** + * Sets primitive concrete field. + * + * @param primitiveConcreteField the primitive concrete field + */ + public void setPrimitiveConcreteField(int primitiveConcreteField) { + this.primitiveConcreteField = primitiveConcreteField; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app155/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app155/HelloController.java new file mode 100644 index 000000000..713fb1679 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app155/HelloController.java @@ -0,0 +1,66 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app155; + +import org.springdoc.core.annotations.ParameterObject; + +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * Say hello response entity. + * + * @param test the test + * @return the response entity + */ + @GetMapping("/test1") + public ResponseEntity sayHello(@ParameterObject final ConcreteParameterObject test) { + System.out.println("Field B = " + test); + return new ResponseEntity("{\"Say\": \"Hello\"}", HttpStatus.OK); + } + + /** + * Say hello response entity. + * + * @param test the test + * @return the response entity + */ + @GetMapping("/test2") + public ResponseEntity sayHello(@ParameterObject final ConcreteIntParameterObject test) { + System.out.println("Field B = " + test); + return new ResponseEntity("{\"Say\": \"Hello\"}", HttpStatus.OK); + } + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app155/SpringDocApp155Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app155/SpringDocApp155Test.java new file mode 100644 index 000000000..597ddf730 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app155/SpringDocApp155Test.java @@ -0,0 +1,45 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app155; + + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * Tests Spring meta-annotations as method parameters + */ +class SpringDocApp155Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app156/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app156/HelloController.java new file mode 100644 index 000000000..c158e0eb4 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app156/HelloController.java @@ -0,0 +1,80 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app156; + +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.media.ArraySchema; +import io.swagger.v3.oas.annotations.media.Schema; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +import static io.swagger.v3.oas.annotations.enums.ParameterIn.QUERY; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + /** + * Hello string. + * + * @param user the user + * @return the string + */ + @GetMapping("/hello") + @Parameter(name = "someEnums", in = QUERY, description = "SomeEum decs", + array = @ArraySchema(schema = @Schema(implementation = SomeEnum.class))) + @Parameter(name = "textSet", in = QUERY, description = "First decs", + array = @ArraySchema(schema = @Schema(implementation = String.class))) + @Parameter(name = "someText", in = QUERY, description = "Second decs", + schema = @Schema(type = "string")) + public String hello(@Parameter(hidden = true) User user) { + String forReturn = "Hello "; + StringBuilder stringBuilder = new StringBuilder(forReturn); + + if (user.getSomeEnums() != null) { + for (SomeEnum some : user.getSomeEnums()) { + stringBuilder.append(some); + stringBuilder.append(" "); + } + } + + if (user.getSomeText() != null) { + for (String text : user.getTextSet()) { + stringBuilder.append(text); + stringBuilder.append(" "); + } + } + + if (user.getSomeText() != null) { + stringBuilder.append(user.getSomeText()); + } + + return stringBuilder.toString(); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app156/SomeEnum.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app156/SomeEnum.java new file mode 100644 index 000000000..c2b70fc2e --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app156/SomeEnum.java @@ -0,0 +1,41 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app156; + +/** + * The enum Some enum. + */ +public enum SomeEnum { + /** + *First some enum. + */ + FIRST, + /** + *Second some enum. + */ + SECOND +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app156/SpringDocApp156Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app156/SpringDocApp156Test.java new file mode 100644 index 000000000..c21e1b30a --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app156/SpringDocApp156Test.java @@ -0,0 +1,45 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app156; + + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * Tests Spring meta-annotations as method parameters + */ +class SpringDocApp156Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app156/User.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app156/User.java new file mode 100644 index 000000000..b9c97aec4 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app156/User.java @@ -0,0 +1,103 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app156; + +import java.util.Set; + +/** + * The type User. + */ +class User { + /** + * The Some text. + */ + private String someText; + + /** + * The Text set. + */ + private Set textSet; + + /** + * The Some enums. + */ + private Set someEnums; + + /** + * Gets some text. + * + * @return the some text + */ + public String getSomeText() { + return someText; + } + + /** + * Sets some text. + * + * @param someText the some text + */ + public void setSomeText(String someText) { + this.someText = someText; + } + + /** + * Gets text set. + * + * @return the text set + */ + public Set getTextSet() { + return textSet; + } + + /** + * Sets text set. + * + * @param textSet the text set + */ + public void setTextSet(Set textSet) { + this.textSet = textSet; + } + + /** + * Gets some enums. + * + * @return the some enums + */ + public Set getSomeEnums() { + return someEnums; + } + + /** + * Sets some enums. + * + * @param someEnums the some enums + */ + public void setSomeEnums(Set someEnums) { + this.someEnums = someEnums; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app157/Bar.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app157/Bar.java new file mode 100644 index 000000000..60f2b7722 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app157/Bar.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.app157; + +/** + * A class without a String in it + */ +class Bar { + /** + * The Child. + */ + private Object child; + + /** + * Gets child. + * + * @return the child + */ + public Object getChild() { + return this.child; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app157/Foo.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app157/Foo.java new file mode 100644 index 000000000..d46daa3d6 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app157/Foo.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.app157; + +/** + * A class with a String in it + */ +class Foo { + /** + * The Child. + */ + private String child; + + /** + * Gets child. + * + * @return the child + */ + public String getChild() { + return this.child; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app157/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app157/HelloController.java new file mode 100644 index 000000000..2dba96357 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app157/HelloController.java @@ -0,0 +1,61 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app157; + +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * Put Foo and Bar in the schema's components, make sure there is an ignored wrapper + * ({@code ResponseEntity}). + */ +@RestController +class HelloController { + + /** + * Gets foo. + * + * @return the foo + */ + @GetMapping("/foo") + public ResponseEntity getFoo() { + return new ResponseEntity(HttpStatus.OK); + } + + /** + * Gets bar. + * + * @return the bar + */ + @GetMapping("/bar") + public ResponseEntity getBar() { + return new ResponseEntity(HttpStatus.OK); + } + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app157/SpringDocApp157Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app157/SpringDocApp157Test.java new file mode 100644 index 000000000..029eac331 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app157/SpringDocApp157Test.java @@ -0,0 +1,91 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app157; + +import java.util.ArrayList; + +import io.swagger.v3.core.converter.ModelConverters; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Test; +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 static org.hamcrest.Matchers.hasProperty; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.not; +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; + +/** + * This test is to make sure that a new model converter can access the parent of a type, even if + * the type is enclosed in an ignored wrapper. We test this by setting up a model converter which + * adds "stringy" to the "required" property of a schema's parent, when the sub schema is a String. + */ +class SpringDocApp157Test extends AbstractSpringDocTest { + + /** + * The Converters. + */ + private final ModelConverters converters = ModelConverters.getInstance(true); + + @Autowired + private StringyConverter stringyConverter; + + /** + * Unregister converter. + */ + @AfterEach + public void unregisterConverter() { + converters.removeConverter(stringyConverter); + } + + /** + * Test app. + * + * @throws Exception the exception + */ + @Test + protected void testApp() throws Exception { + mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL)) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.openapi", is("3.1.0"))) + .andExpect(jsonPath("$.components.schemas.Foo.required", is(new ArrayList() {{ + add("stringy"); + }}))) + .andExpect(jsonPath("$.components.schemas.Bar", not(hasProperty("required")))); + } + + /** + * The type Spring boot app. + */ + @SpringBootApplication + static class SpringBootApp {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app157/StringyConverter.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app157/StringyConverter.java new file mode 100644 index 000000000..a3faba2a1 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app157/StringyConverter.java @@ -0,0 +1,64 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app157; + +import java.util.Iterator; + +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.oas.models.media.Schema; +import org.springdoc.core.providers.ObjectMapperProvider; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + + +@Component +class StringyConverter implements ModelConverter { + + @Autowired + ObjectMapperProvider objectMapperProvider; + + public StringyConverter(ObjectMapperProvider objectMapperProvider) { + this.objectMapperProvider = objectMapperProvider; + } + + + @Override + public Schema resolve(AnnotatedType type, ModelConverterContext context, + Iterator chain) { + + JavaType javaType = objectMapperProvider.jsonMapper().constructType(type.getType()); + + if (javaType.getRawClass().equals(String.class)) { + type.getParent().addRequiredItem("stringy"); + } + return chain.next().resolve(type, context, chain); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app158/CommonFooErrorHandler.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app158/CommonFooErrorHandler.java new file mode 100644 index 000000000..1c04b3c82 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app158/CommonFooErrorHandler.java @@ -0,0 +1,49 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app158; + +import org.springframework.http.HttpStatus; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.ResponseStatus; + +/** + * The type Common foo error handler. + */ +class CommonFooErrorHandler { + + /** + * On exception error dto. + * + * @param e the e + * @return the error dto + */ + @ExceptionHandler + @ResponseStatus(HttpStatus.CONFLICT) + public ErrorDTO onException(Exception e) { + return new ErrorDTO("Something wrong has happened"); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app158/ErrorDTO.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app158/ErrorDTO.java new file mode 100644 index 000000000..1dad3f006 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app158/ErrorDTO.java @@ -0,0 +1,70 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app158; + +/** + * The type Error dto. + */ +class ErrorDTO { + /** + * The Message. + */ + private String message; + + /** + * Instantiates a new Error dto. + */ + public ErrorDTO() { + } + + /** + * Instantiates a new Error dto. + * + * @param message the message + */ + public ErrorDTO(String message) { + this.message = message; + } + + /** + * Gets message. + * + * @return the message + */ + public String getMessage() { + return message; + } + + /** + * Sets message. + * + * @param message the message + */ + public void setMessage(String message) { + this.message = message; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app158/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app158/HelloController.java new file mode 100644 index 000000000..990de2b1d --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app158/HelloController.java @@ -0,0 +1,54 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app158; + +import io.swagger.v3.oas.annotations.OpenAPIDefinition; +import io.swagger.v3.oas.annotations.info.Info; +import io.swagger.v3.oas.annotations.tags.Tag; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +@RequestMapping("/api") +@OpenAPIDefinition(info = @Info(title = "API Examples", version = "1.0"), tags = @Tag(name = "Operations")) +class HelloController { + + /** + * Hello simple dto. + * + * @return the simple dto + */ + @GetMapping("/foo") + public SimpleDTO hello() { + return new SimpleDTO("foo"); + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app158/SimpleDTO.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app158/SimpleDTO.java new file mode 100644 index 000000000..075abc466 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app158/SimpleDTO.java @@ -0,0 +1,72 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app158; + +/** + * The type Simple dto. + */ +class SimpleDTO { + + /** + * The Payload. + */ + private String payload; + + /** + * Instantiates a new Simple dto. + */ + public SimpleDTO() { + } + + /** + * Instantiates a new Simple dto. + * + * @param payload the payload + */ + public SimpleDTO(String payload) { + this.payload = payload; + } + + /** + * Gets payload. + * + * @return the payload + */ + public String getPayload() { + return payload; + } + + /** + * Sets payload. + * + * @param payload the payload + */ + public void setPayload(String payload) { + this.payload = payload; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app158/SpecificFooErrorHandler.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app158/SpecificFooErrorHandler.java new file mode 100644 index 000000000..0aa94ff4f --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app158/SpecificFooErrorHandler.java @@ -0,0 +1,36 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app158; + +import org.springframework.web.bind.annotation.ControllerAdvice; + +/** + * The type Specific foo error handler. + */ +@ControllerAdvice(assignableTypes = HelloController.class) +class SpecificFooErrorHandler extends CommonFooErrorHandler { +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app158/SpringDocApp158Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app158/SpringDocApp158Test.java new file mode 100644 index 000000000..e23eb73c4 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app158/SpringDocApp158Test.java @@ -0,0 +1,44 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app158; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 158 test. + */ +class SpringDocApp158Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app159/CustomException.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app159/CustomException.java new file mode 100644 index 000000000..fdc74dbc0 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app159/CustomException.java @@ -0,0 +1,41 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app159; + +/** + * The type Custom exception. + */ +class CustomException extends RuntimeException { + /** + * Instantiates a new Custom exception. + * + * @param message the message + */ + public CustomException(String message) { + super(message); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app159/FooBean.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app159/FooBean.java new file mode 100644 index 000000000..c9b722b99 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app159/FooBean.java @@ -0,0 +1,93 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app159; + +import com.fasterxml.jackson.annotation.JsonView; + +/** + * The type Foo bean. + */ +class FooBean { + /** + * The Message. + */ + @JsonView(Views.View2.class) + private String message; + + /** + * The Code. + */ + @JsonView(Views.View1.class) + private int code; + + /** + * Instantiates a new Foo bean. + * + * @param message the message + * @param code the code + */ + public FooBean(String message, int code) { + this.message = message; + this.code = code; + } + + /** + * Gets message. + * + * @return the message + */ + public String getMessage() { + return message; + } + + /** + * Sets message. + * + * @param message the message + */ + public void setMessage(String message) { + this.message = message; + } + + /** + * Gets code. + * + * @return the code + */ + public int getCode() { + return code; + } + + /** + * Sets code. + * + * @param code the code + */ + public void setCode(int code) { + this.code = code; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app159/FooErrorHandler.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app159/FooErrorHandler.java new file mode 100644 index 000000000..7e6939ebc --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app159/FooErrorHandler.java @@ -0,0 +1,68 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app159; + +import com.fasterxml.jackson.annotation.JsonView; + +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.ControllerAdvice; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.ResponseStatus; + +/** + * The type Foo error handler. + */ +@ControllerAdvice(assignableTypes = HelloController.class) +class FooErrorHandler { + + /** + * Store assignment publishing error response entity. + * + * @param e the e + * @return the response entity + */ + @ExceptionHandler + @ResponseStatus(value = HttpStatus.INTERNAL_SERVER_ERROR) + @JsonView(Views.View1.class) + public ResponseEntity storeAssignmentPublishingError(Exception e) { + return new ResponseEntity<>(new FooBean("INTERNAL_SERVER_ERROR", 500), HttpStatus.INTERNAL_SERVER_ERROR); + } + + /** + * Store assignment publishing error response entity. + * + * @param e the e + * @return the response entity + */ + @ExceptionHandler + @ResponseStatus(value = HttpStatus.BAD_REQUEST) + @JsonView(Views.View2.class) + public ResponseEntity storeAssignmentPublishingError(CustomException e) { + return new ResponseEntity<>(new FooBean("BAD Request", 400), HttpStatus.BAD_REQUEST); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app159/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app159/HelloController.java new file mode 100644 index 000000000..65dc96c49 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app159/HelloController.java @@ -0,0 +1,57 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app159; + +import io.swagger.v3.oas.annotations.OpenAPIDefinition; +import io.swagger.v3.oas.annotations.info.Info; +import io.swagger.v3.oas.annotations.tags.Tag; + +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +@RequestMapping("/api") +@OpenAPIDefinition(info = @Info(title = "API Examples", version = "1.0"), tags = @Tag(name = "Operations")) +class HelloController { + + /** + * Create string. + * + * @param foo the foo + * @return the string + */ + @PostMapping("/foo") + public String create(@RequestBody String foo) { + return "foo"; + } +} + diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app159/SpringDocApp159Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app159/SpringDocApp159Test.java new file mode 100644 index 000000000..52307664d --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app159/SpringDocApp159Test.java @@ -0,0 +1,44 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app159; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 159 test. + */ +class SpringDocApp159Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app159/Views.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app159/Views.java new file mode 100644 index 000000000..d8cac5486 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app159/Views.java @@ -0,0 +1,44 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app159; + +/** + * The type Views. + */ +class Views { + /** + * The type View 1. + */ + public static class View1 { + } + + /** + * The type View 2. + */ + public static class View2 extends View1 { + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app16/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app16/HelloController.java new file mode 100644 index 000000000..0d65d30b8 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app16/HelloController.java @@ -0,0 +1,48 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app16; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * Persons string. + * + * @return the string + */ + @GetMapping("/persons") + public String persons() { + return "OK"; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app16/SpringDocApp16Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app16/SpringDocApp16Test.java new file mode 100644 index 000000000..47e6ab3f8 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app16/SpringDocApp16Test.java @@ -0,0 +1,61 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app16; + +import org.junit.jupiter.api.Test; +import org.springdoc.core.utils.Constants; +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.SpringBootConfiguration; +import org.springframework.test.context.TestPropertySource; + +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + +/** + * The type Spring doc app 16 test. + */ +@TestPropertySource(properties = "springdoc.api-docs.enabled=false") +class SpringDocApp16Test extends AbstractSpringDocTest { + + /** + * Test app. + * + * @throws Exception the exception + */ + @Test + protected void testApp() throws Exception { + mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL)) + .andExpect(status().isNotFound()); + } + + /** + * The type Spring doc test app. + */ + @SpringBootConfiguration + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app160/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app160/HelloController.java new file mode 100644 index 000000000..4bb82def1 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app160/HelloController.java @@ -0,0 +1,111 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app160; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.v3.oas.annotations.media.Schema; +import org.springdoc.core.models.GroupedOpenApi; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.PropertySource; +import org.springframework.context.support.ResourceBundleMessageSource; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * Do something interesting error response. + * + * @return the error response + */ + @PostMapping("test") + public ErrorResponse doSomethingInteresting() { + return null; + } + + /** + * Bundle api grouped open api. + * + * @return the grouped open api + */ + @Bean + public GroupedOpenApi bundleApi() { + return GroupedOpenApi.builder() + .group("test") + .pathsToMatch("/**") + .build(); + } + + /** + * Translator resource bundle message source. + * + * @return the resource bundle message source + */ + @Bean + public ResourceBundleMessageSource translator() { + ResourceBundleMessageSource source = new ResourceBundleMessageSource(); + source.setBasenames("swagger-message-160"); + source.setUseCodeAsDefaultMessage(true); + source.setDefaultEncoding("utf-8"); + return source; + } + + /** + * The type Swagger message. + */ + @PropertySource("classpath:swagger-message-160.properties") + @Configuration + class SwaggerMessage {} + + /** + * The type Error response. + */ + @Schema(description = "${ErrorResponse}") + class ErrorResponse { + + /** + * The Error code. + */ + @Schema(description = "${ErrorCode}", required = true) + @JsonProperty + private Integer errorCode; + + /** + * The Error message. + */ + @Schema(description = "${ErrorMessage}") + @JsonProperty + private String errorMessage; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app160/SpringDocApp160Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app160/SpringDocApp160Test.java new file mode 100644 index 000000000..77aad6817 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app160/SpringDocApp160Test.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.app160; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.test.context.TestPropertySource; + +/** + * The type Spring doc app 160 test. + */ +@TestPropertySource(properties = "springdoc.api-docs.resolve-schema-properties=true") +class SpringDocApp160Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app161/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app161/HelloController.java new file mode 100644 index 000000000..640a7ba8c --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app161/HelloController.java @@ -0,0 +1,86 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app161; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; + +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + + /** + * Add response entity. + * + * @param content the content + * @return the response entity + * @throws Exception the exception + */ + @Operation(summary = "add") + @PostMapping(value = "/add", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.MULTIPART_FORM_DATA_VALUE) + public ResponseEntity add(@Parameter(description = "content") @RequestPart(value = "content") String content) throws Exception { + return null; + } + + + /** + * Add 2 response entity. + * + * @param content the content + * @param type the type + * @return the response entity + */ + @Operation(summary = "add2") + @PostMapping(value = "/add2", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.MULTIPART_FORM_DATA_VALUE) + public ResponseEntity add2( + @Parameter(description = "content") @RequestPart(value = "content") String content, + @RequestPart(value = "type") String type + ) { + return null; + } + + /** + * Test. + * + * @param strValue the str value + * @param intValue the int value + */ + @PostMapping(produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.MULTIPART_FORM_DATA_VALUE) + @Operation(summary = "test") + public void test(@RequestPart("strValue") String strValue, + @RequestPart("intValue") Integer intValue) { + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app161/SpringDocApp161Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app161/SpringDocApp161Test.java new file mode 100644 index 000000000..93a326b63 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app161/SpringDocApp161Test.java @@ -0,0 +1,44 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app161; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 161 test. + */ +class SpringDocApp161Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app162/SpringDocApp162Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app162/SpringDocApp162Test.java new file mode 100644 index 000000000..cc45b56be --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app162/SpringDocApp162Test.java @@ -0,0 +1,64 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app162; + +import io.swagger.v3.oas.models.OpenAPI; +import io.swagger.v3.oas.models.info.Info; +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; +import org.springframework.test.context.TestPropertySource; + +/** + * The type Spring doc app 162 test. + */ +@TestPropertySource(properties = "springdoc.override-with-generic-response=true") +class SpringDocApp162Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp { + /** + * Custom open api open api. + * + * @return the open api + */ + @Bean + public OpenAPI customOpenAPI() { + return new OpenAPI() + .info(new Info() + .title("SpringShop API") + .version("v1") + .description("The description of the api")); + } + + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app162/exception/NoResultException.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app162/exception/NoResultException.java new file mode 100644 index 000000000..057134aa4 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app162/exception/NoResultException.java @@ -0,0 +1,30 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app162.exception; + +public class NoResultException extends RuntimeException { +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app162/exception/NonUniqueResultException.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app162/exception/NonUniqueResultException.java new file mode 100644 index 000000000..4dbb567ce --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app162/exception/NonUniqueResultException.java @@ -0,0 +1,33 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app162.exception; + +/** + * Multiple results found instead of a unique result. + */ +public class NonUniqueResultException extends RuntimeException { +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app162/rest/JavadocOnlyRestController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app162/rest/JavadocOnlyRestController.java new file mode 100644 index 000000000..acabc68b6 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app162/rest/JavadocOnlyRestController.java @@ -0,0 +1,116 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app162.rest; + +import java.util.List; + +import test.org.springdoc.api.v31.app162.exception.NoResultException; +import test.org.springdoc.api.v31.app162.exception.NonUniqueResultException; +import test.org.springdoc.api.v31.app162.rest.dto.JavadocOnlyRestDto; + +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseStatus; +import org.springframework.web.bind.annotation.RestController; + +/** + * This is the {@code JavadocOnlyRestController} class javadoc. + */ +@RestController +@RequestMapping("/javadoc-only") +class JavadocOnlyRestController { + /** + * This is the create method's javadoc. + * The method's signature: {@code #create(JavadocOnlyRestDto)} + * + * @param input the {@code @param input} javadoc for the {@code #create(JavadocOnlyRestDto)} method + * @return the {@code @return} javadoc for the {@code #create(JavadocOnlyRestDto)} method + */ + @PostMapping(consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) + @ResponseStatus(HttpStatus.CREATED) + public ResponseEntity create(@RequestBody JavadocOnlyRestDto input) { + return new ResponseEntity<>(HttpStatus.CREATED); + } + + /** + * This is the update method's javadoc. + * The method's signature: {@code #update(String, JavadocOnlyRestDto)} + * + * @param guid the {@code @param input} javadoc for the {@code #update(String, JavadocOnlyRestDto)} method + * @return the {@code @return} javadoc for the {@code #update(String, JavadocOnlyRestDto)} method + */ + @PutMapping(path = "{guid}", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) + @ResponseStatus(HttpStatus.OK) + public ResponseEntity update(@PathVariable String guid, @RequestBody JavadocOnlyRestDto input) throws NoResultException { + return new ResponseEntity<>(HttpStatus.CREATED); + } + + /** + * This is the list method's javadoc. + * The method's signature: {@code #list()} + * + * @return the {@code @return} javadoc for the {@code #list()} method + */ + @GetMapping(produces = MediaType.APPLICATION_JSON_VALUE) + public ResponseEntity> list() { + return new ResponseEntity<>(HttpStatus.OK); + } + + /** + * This is the find method's javadoc. + * The method's signature: {@code #find(String)} + * + * @param guid the {@code @param guid} javadoc for the {@code #find(String)} method + * @return the {@code @return} javadoc for the {@code #find(String)} method + * @throws NoResultException the {@code @throws NoResultException} javadoc for the {@code #find(String)} method + */ + @GetMapping(path = "{guid}", produces = MediaType.APPLICATION_JSON_VALUE) + public ResponseEntity find(@PathVariable String guid) throws NoResultException { + return new ResponseEntity<>(HttpStatus.OK); + } + + /** + * This is the findStartsBy method's javadoc. + * The method's signature: {@code #findStartsBy(String)} + * + * @param prefix the {@code @param prefix} javadoc for the {@code #findStartsBy(String)} method + * @return the {@code @return} javadoc for the {@code #findStartsBy(String)} method + * @throws NoResultException the {@code @throws NoResultException} javadoc for the {@code #findStartsBy(String)} method + * @throws NonUniqueResultException the {@code @throws NonUniqueResultException} javadoc for the {@code #findStartsBy(String)} method + */ + @GetMapping(path = "startsBy/{prefix}", produces = MediaType.APPLICATION_JSON_VALUE) + public ResponseEntity findStartsBy(@PathVariable String prefix) throws NoResultException, NonUniqueResultException { + return new ResponseEntity<>(HttpStatus.OK); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app162/rest/dto/JavadocOnlyRestDto.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app162/rest/dto/JavadocOnlyRestDto.java new file mode 100644 index 000000000..aaeb78393 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app162/rest/dto/JavadocOnlyRestDto.java @@ -0,0 +1,85 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app162.rest.dto; + +/** + * This is the {@code JavadocOnlyRestDto} class javadoc. + */ +public class JavadocOnlyRestDto { + /** + * This is the private {@code #guid} field's javadoc. + */ + private String guid; + + /** + * This is the private {@code #inner} field's javadoc. + * + * This javadoc description is ignored by the REST documentation: + * the {@code $ref} can't have a description as any sibling elements of a $ref are ignored. + */ + private JavadocOnlyStaticInnerRestDto inner; + + public JavadocOnlyRestDto() { + } + + public String getGuid() { + return guid; + } + + public void setGuid(String guid) { + this.guid = guid; + } + + public JavadocOnlyStaticInnerRestDto getInner() { + return inner; + } + + public void setInner(JavadocOnlyStaticInnerRestDto inner) { + this.inner = inner; + } + + /** + * This is the {@code JavadocOnlyStaticInnerRestDto} class javadoc. + */ + public static class JavadocOnlyStaticInnerRestDto { + /** + * This is the private {@code #content} field's javadoc. + */ + private String content; + + public JavadocOnlyStaticInnerRestDto() { + } + + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app162/rest/util/RestExceptionHandler.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app162/rest/util/RestExceptionHandler.java new file mode 100644 index 000000000..24a644d57 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app162/rest/util/RestExceptionHandler.java @@ -0,0 +1,71 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app162.rest.util; + +import test.org.springdoc.api.v31.app162.exception.NoResultException; +import test.org.springdoc.api.v31.app162.exception.NonUniqueResultException; + +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.ResponseStatus; +import org.springframework.web.bind.annotation.RestControllerAdvice; + +/** + * REST exception handlers. + * + * This javadoc description is ignored by the REST documentation. + */ +@RestControllerAdvice +class RestExceptionHandler { + /** + * REST exception handler for {@code NoResultException}. + * + * This javadoc description is ignored by the REST documentation. + * + * @return the {@code return} javadoc for the {@code #handleNotFoundException(NoResultException)} method + */ + @ExceptionHandler(NoResultException.class) + @ResponseStatus(code = HttpStatus.NOT_FOUND) + public ResponseEntity handleNotFoundException(NoResultException exception) { + return new ResponseEntity<>("No result for the arguments.", HttpStatus.NOT_FOUND); + } + + /** + * REST exception handler for {@code NonUniqueResultException}. + * + * This javadoc description is ignored by the REST documentation. + * + * @return the {@code return} javadoc for the {@code #handleNonUniqueResultException(NonUniqueResultException)} method + */ + @ExceptionHandler(NonUniqueResultException.class) + @ResponseStatus(code = HttpStatus.BAD_REQUEST) + public ResponseEntity handleNonUniqueResultException(NonUniqueResultException exception) { + return new ResponseEntity<>("No unique result found for the arguments.", HttpStatus.BAD_REQUEST); + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app163/SpringDocApp163Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app163/SpringDocApp163Test.java new file mode 100644 index 000000000..8fe6958b9 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app163/SpringDocApp163Test.java @@ -0,0 +1,64 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app163; + +import io.swagger.v3.oas.models.OpenAPI; +import io.swagger.v3.oas.models.info.Info; +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; +import org.springframework.test.context.TestPropertySource; + +/** + * The type Spring doc app 163 test. + */ +@TestPropertySource(properties = "springdoc.override-with-generic-response=true") +class SpringDocApp163Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp { + /** + * Custom open api open api. + * + * @return the open api + */ + @Bean + public OpenAPI customOpenAPI() { + return new OpenAPI() + .info(new Info() + .title("SpringShop API") + .version("v1") + .description("The description of the api")); + } + + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app163/exception/NoResultException.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app163/exception/NoResultException.java new file mode 100644 index 000000000..1c4fb94e1 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app163/exception/NoResultException.java @@ -0,0 +1,30 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app163.exception; + +public class NoResultException extends RuntimeException { +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app163/exception/NonUniqueResultException.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app163/exception/NonUniqueResultException.java new file mode 100644 index 000000000..4bc6620cb --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app163/exception/NonUniqueResultException.java @@ -0,0 +1,33 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app163.exception; + +/** + * Multiple results found instead of a unique result. + */ +public class NonUniqueResultException extends RuntimeException { +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app163/rest/AnnotationOverrideForJavadocRestController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app163/rest/AnnotationOverrideForJavadocRestController.java new file mode 100644 index 000000000..c2a8968d6 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app163/rest/AnnotationOverrideForJavadocRestController.java @@ -0,0 +1,131 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app163.rest; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.tags.Tag; +import test.org.springdoc.api.v31.app163.exception.NoResultException; +import test.org.springdoc.api.v31.app163.exception.NonUniqueResultException; +import test.org.springdoc.api.v31.app163.rest.dto.AnnotationOverrideForJavadocRestDto; + +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseStatus; +import org.springframework.web.bind.annotation.RestController; + +/** + * This is the {@code AnnotationOverrideForJavadocRestController} class javadoc. + */ +@Tag( + name = "annotation-override", + description = "Description for the tag." +) +@RestController +@RequestMapping("/annotation-override") +class AnnotationOverrideForJavadocRestController { + /** + * This is the update method's javadoc. + * The method's signature: {@code #update(String, AnnotationOverrideForJavadocRestDto)} + * + * @param guid the {@code @param input} javadoc for the {@code #update(String, AnnotationOverrideForJavadocRestDto)} method + * @return the {@code @return} javadoc for the {@code #update(String, AnnotationOverrideForJavadocRestDto)} method + */ + @Operation( + summary = "Summary for #update(String, AnnotationOverrideForJavadocRestDto)" + ) + @PutMapping(path = "{guid}", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) + @ResponseStatus(HttpStatus.OK) + public ResponseEntity update(@PathVariable String guid, @RequestBody AnnotationOverrideForJavadocRestDto input) throws NoResultException { + return new ResponseEntity<>(HttpStatus.CREATED); + } + + /** + * This is the create method's javadoc. + * The method's signature: {@code #create(AnnotationOverrideForJavadocRestDto)} + * + * @param input the {@code @param input} javadoc for the {@code #create(AnnotationOverrideForJavadocRestDto)} method + * @return the {@code @return} javadoc for the {@code #create(AnnotationOverrideForJavadocRestDto)} method + */ + @Operation( + summary = "Summary for #create(AnnotationOverrideForJavadocRestDto)", + description = "Description for #create(AnnotationOverrideForJavadocRestDto)", + requestBody = @io.swagger.v3.oas.annotations.parameters.RequestBody( + description = "Request body for #create(AnnotationOverrideForJavadocRestDto)" + ), + responses = { + @ApiResponse( + description = "API Response 201 for #create(AnnotationOverrideForJavadocRestDto)" + ) + } + ) + @PostMapping(consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) + @ResponseStatus(HttpStatus.CREATED) + public ResponseEntity create(@RequestBody AnnotationOverrideForJavadocRestDto input) { + return new ResponseEntity<>(HttpStatus.CREATED); + } + + /** + * This is the findStartsBy method's javadoc. + * The method's signature: {@code #findStartsBy(String)} + * + * @param prefix the {@code @param prefix} javadoc for the {@code #findStartsBy(String)} method + * @return the {@code @return} javadoc for the {@code #findStartsBy(String)} method + * @throws NoResultException the {@code @throws NoResultException} javadoc for the {@code #findStartsBy(String)} method + * @throws NonUniqueResultException the {@code @throws NonUniqueResultException} javadoc for the {@code #findStartsBy(String)} method + */ + @Operation( + parameters = { + @Parameter( + name = "prefix", + description = "Parameter prefix" + ) + }, + responses = { + @ApiResponse( + responseCode = "200", + description = "API Response 200 for #findStartsBy(prefix)" + ), + @ApiResponse( + responseCode = "400", + description = "API Response 400 for #findStartsBy(prefix)" + ) + } + ) + @GetMapping(path = "startsBy/{prefix}", produces = MediaType.APPLICATION_JSON_VALUE) + public ResponseEntity findStartsBy(@PathVariable String prefix) throws NoResultException, NonUniqueResultException { + return new ResponseEntity<>(HttpStatus.OK); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app163/rest/dto/AnnotationOverrideForJavadocRestDto.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app163/rest/dto/AnnotationOverrideForJavadocRestDto.java new file mode 100644 index 000000000..48eecb048 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app163/rest/dto/AnnotationOverrideForJavadocRestDto.java @@ -0,0 +1,86 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app163.rest.dto; + +import io.swagger.v3.oas.annotations.media.Schema; + +/** + * This is the {@code AnnotationOverrideForJavadocRestDto} class javadoc. + */ +@Schema( + title = "annotation-override-dto", + description = "Description for the tag." +) +public class AnnotationOverrideForJavadocRestDto { + /** + * This is the private {@code #guid} field's javadoc. + */ + @Schema(description = "Description for the #guid field") + private String guid; + + /** + * This is the private {@code #inner} field's javadoc. + *

+ * This javadoc description is ignored by the REST documentation: + * the {@code $ref} can't have a description as any sibling elements of a $ref are ignored. + */ + private AnnotationOverrideForJavadocStaticInnerRestDto inner; + + public String getGuid() { + return guid; + } + + public void setGuid(String guid) { + this.guid = guid; + } + + public AnnotationOverrideForJavadocStaticInnerRestDto getInner() { + return inner; + } + + public void setInner(AnnotationOverrideForJavadocStaticInnerRestDto inner) { + this.inner = inner; + } + + /** + * This is the {@code AnnotationOverrideForJavadocStaticInnerRestDto} class javadoc. + */ + public static class AnnotationOverrideForJavadocStaticInnerRestDto { + /** + * This is the private {@code #content} field's javadoc. + */ + private String content; + + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app163/rest/dto/AnnotationOverrideForJavadocRestDto2.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app163/rest/dto/AnnotationOverrideForJavadocRestDto2.java new file mode 100644 index 000000000..047522cc5 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app163/rest/dto/AnnotationOverrideForJavadocRestDto2.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.app163.rest.dto; + +/** + * This is the {@code AnnotationOverrideForJavadocRestDto2} class javadoc. + */ +class AnnotationOverrideForJavadocRestDto2 { + /** + * This is the private {@code #guid3} field's javadoc. + */ + private String guid3; + + public String getGuid3() { + return guid3; + } + + public void setGuid3(String guid3) { + this.guid3 = guid3; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app163/rest/dto/AnnotationOverrideForJavadocRestDto3.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app163/rest/dto/AnnotationOverrideForJavadocRestDto3.java new file mode 100644 index 000000000..6d476910e --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app163/rest/dto/AnnotationOverrideForJavadocRestDto3.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.app163.rest.dto; + +/** + * This is the {@code AnnotationOverrideForJavadocRestDto3} class javadoc. + */ +class AnnotationOverrideForJavadocRestDto3 { + /** + * This is the private {@code #guid4} field's javadoc. + */ + private String guid4; + + public String getGuid4() { + return guid4; + } + + public void setGuid4(String guid4) { + this.guid4 = guid4; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app163/rest/util/RestExceptionHandler.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app163/rest/util/RestExceptionHandler.java new file mode 100644 index 000000000..980141e06 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app163/rest/util/RestExceptionHandler.java @@ -0,0 +1,71 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app163.rest.util; + +import test.org.springdoc.api.v31.app163.exception.NoResultException; +import test.org.springdoc.api.v31.app163.exception.NonUniqueResultException; + +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.ResponseStatus; +import org.springframework.web.bind.annotation.RestControllerAdvice; + +/** + * REST exception handlers. + * + * This javadoc description is ignored by the REST documentation. + */ +@RestControllerAdvice +class RestExceptionHandler { + /** + * REST exception handler for {@code NoResultException}. + * + * This javadoc description is ignored by the REST documentation. + * + * @return the {@code return} javadoc for the {@code #handleNotFoundException(NoResultException)} method + */ + @ExceptionHandler(NoResultException.class) + @ResponseStatus(code = HttpStatus.NOT_FOUND) + public ResponseEntity handleNotFoundException(NoResultException exception) { + return new ResponseEntity<>("No result for the arguments.", HttpStatus.NOT_FOUND); + } + + /** + * REST exception handler for {@code NonUniqueResultException}. + * + * This javadoc description is ignored by the REST documentation. + * + * @return the {@code return} javadoc for the {@code #handleNonUniqueResultException(NonUniqueResultException)} method + */ + @ExceptionHandler(NonUniqueResultException.class) + @ResponseStatus(code = HttpStatus.BAD_REQUEST) + public ResponseEntity handleNonUniqueResultException(NonUniqueResultException exception) { + return new ResponseEntity<>("No unique result found for the arguments.", HttpStatus.BAD_REQUEST); + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app164/SpringDocApp164Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app164/SpringDocApp164Test.java new file mode 100644 index 000000000..7b1b89953 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app164/SpringDocApp164Test.java @@ -0,0 +1,62 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app164; + +import io.swagger.v3.oas.models.OpenAPI; +import io.swagger.v3.oas.models.info.Info; +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; + +/** + * The type Spring doc app 164 test. + */ +class SpringDocApp164Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp { + /** + * Custom open api open api. + * + * @return the open api + */ + @Bean + public OpenAPI customOpenAPI() { + return new OpenAPI() + .info(new Info() + .title("SpringShop API") + .version("v1") + .description("The description of the api")); + } + + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app164/SpringDocJavadocProviderTest.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app164/SpringDocJavadocProviderTest.java new file mode 100644 index 000000000..7e914307d --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app164/SpringDocJavadocProviderTest.java @@ -0,0 +1,87 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app164; + +import java.util.stream.Stream; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; +import org.springdoc.core.providers.JavadocProvider; +import org.springdoc.core.providers.SpringDocJavadocProvider; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.params.provider.Arguments.arguments; + +class SpringDocJavadocProviderTest { + private JavadocProvider javadocProvider; + + static Stream getFirstSentence() { + return Stream.of( + arguments(null, null), + arguments("", ""), + arguments("A b c. D e f", "A b c."), + arguments("A b c", "A b c"), + arguments("A b c

D e f", "A b c"), + arguments("A b c. D

e f", "A b c"), + arguments("A b c

D. e f", "A b c"), + arguments("

A b c

D e f", "A b c"), + arguments("

A b c. D

e f", "A b c"), + arguments("A b c.d e f", "A b c.d e f") + ); + } + + /** + * Edge cases not handled by the implementation. + */ + static Stream getFirstSentenceNotHandled() { + return Stream.of( + arguments("

A b c

d e f

", "A b c") + ); + } + + @BeforeEach + public void setup() { + javadocProvider = new SpringDocJavadocProvider(); + } + + @ParameterizedTest + @MethodSource + public void getFirstSentence(String javadoc, String expectedFirstSentence) { + assertThat(javadocProvider.getFirstSentence(javadoc)) + .isEqualTo(expectedFirstSentence); + } + + @ParameterizedTest + @MethodSource + public void getFirstSentenceNotHandled(String javadoc, String correctFirstSentence) { + assertThat(javadocProvider.getFirstSentence(javadoc)) + .isNotEqualTo(correctFirstSentence); + } + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app164/exception/NoResultException.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app164/exception/NoResultException.java new file mode 100644 index 000000000..f63a57ef5 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app164/exception/NoResultException.java @@ -0,0 +1,30 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app164.exception; + +public class NoResultException extends RuntimeException { +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app164/exception/NonUniqueResultException.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app164/exception/NonUniqueResultException.java new file mode 100644 index 000000000..7a247ff6e --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app164/exception/NonUniqueResultException.java @@ -0,0 +1,33 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app164.exception; + +/** + * Multiple results found instead of a unique result. + */ +public class NonUniqueResultException extends RuntimeException { +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app164/rest/NoGenericOverrideRestController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app164/rest/NoGenericOverrideRestController.java new file mode 100644 index 000000000..1d4641525 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app164/rest/NoGenericOverrideRestController.java @@ -0,0 +1,75 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app164.rest; + +import test.org.springdoc.api.v31.app164.exception.NoResultException; +import test.org.springdoc.api.v31.app164.exception.NonUniqueResultException; + +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseStatus; +import org.springframework.web.bind.annotation.RestController; + +/** + * This is the {@code JavadocOnlyRestController} class javadoc. + */ +@RestController +@RequestMapping("/no-generic-override") +class NoGenericOverrideRestController { + /** + * This is the create method's javadoc. + * The method's signature: {@code #create(JavadocOnlyRestDto)} + * + * @param input the {@code @param input} javadoc for the {@code #create(JavadocOnlyRestDto)} method + * @return the {@code @return} javadoc for the {@code #create(JavadocOnlyRestDto)} method + */ + @PostMapping(consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) + @ResponseStatus(HttpStatus.CREATED) + public ResponseEntity create(@RequestBody String input) { + return new ResponseEntity<>(HttpStatus.CREATED); + } + + /** + * This is the findStartsBy method's javadoc. + * The method's signature: {@code #findStartsBy(String)} + * + * @param prefix the {@code @param prefix} javadoc for the {@code #findStartsBy(String)} method + * @return the {@code @return} javadoc for the {@code #findStartsBy(String)} method + * @throws NoResultException the {@code @throws NoResultException} javadoc for the {@code #findStartsBy(String)} method + * @throws NonUniqueResultException the {@code @throws NonUniqueResultException} javadoc for the {@code #findStartsBy(String)} method + */ + @GetMapping(path = "startsBy/{prefix}", produces = MediaType.APPLICATION_JSON_VALUE) + public ResponseEntity findStartsBy(@PathVariable String prefix) throws NoResultException, NonUniqueResultException { + return new ResponseEntity<>(HttpStatus.OK); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app164/rest/util/RestExceptionHandler.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app164/rest/util/RestExceptionHandler.java new file mode 100644 index 000000000..9cca4adcc --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app164/rest/util/RestExceptionHandler.java @@ -0,0 +1,71 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app164.rest.util; + +import test.org.springdoc.api.v31.app164.exception.NoResultException; +import test.org.springdoc.api.v31.app164.exception.NonUniqueResultException; + +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.ResponseStatus; +import org.springframework.web.bind.annotation.RestControllerAdvice; + +/** + * REST exception handlers. + * + * This javadoc description is ignored by the REST documentation. + */ +@RestControllerAdvice +class RestExceptionHandler { + /** + * REST exception handler for {@code NoResultException}. + * + * This javadoc description is ignored by the REST documentation. + * + * @return the {@code return} javadoc for the {@code #handleNotFoundException(NoResultException)} method + */ + @ExceptionHandler(NoResultException.class) + @ResponseStatus(code = HttpStatus.NOT_FOUND) + public ResponseEntity handleNotFoundException(NoResultException exception) { + return new ResponseEntity<>("No result for the arguments.", HttpStatus.NOT_FOUND); + } + + /** + * REST exception handler for {@code NonUniqueResultException}. + * + * This javadoc description is ignored by the REST documentation. + * + * @return the {@code return} javadoc for the {@code #handleNonUniqueResultException(NonUniqueResultException)} method + */ + @ExceptionHandler(NonUniqueResultException.class) + @ResponseStatus(code = HttpStatus.BAD_REQUEST) + public ResponseEntity handleNonUniqueResultException(NonUniqueResultException exception) { + return new ResponseEntity<>("No unique result found for the arguments.", HttpStatus.BAD_REQUEST); + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app166/ConcreteSubclassFromGeneric.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app166/ConcreteSubclassFromGeneric.java new file mode 100644 index 000000000..45fb20c50 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app166/ConcreteSubclassFromGeneric.java @@ -0,0 +1,39 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app166; + +class ConcreteSubclassFromGeneric extends SimpleGeneric { + + /** + * Return the top name + */ + private String topName; + + public String getTopName() { + return topName; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app166/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app166/HelloController.java new file mode 100644 index 000000000..9e9a4451b --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app166/HelloController.java @@ -0,0 +1,53 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app166; + + +import org.springdoc.core.annotations.ParameterObject; + +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +class HelloController { + @GetMapping("/nested") + public ResponseEntity nested(@ParameterObject final SimpleOuterClass filter) { + return new ResponseEntity<>("{\"Say\": \"Hello\"}", HttpStatus.OK); + } + + @GetMapping("/nestedTypeErasureGeneric") + public ResponseEntity nestedTypeErasureGeneric(@ParameterObject final SimpleGeneric filter) { + return new ResponseEntity<>("{\"Say\": \"Hello\"}", HttpStatus.OK); + } + + @GetMapping("/nestedReifiableGeneric") + public ResponseEntity nestedReifiableGeneric(@ParameterObject final ConcreteSubclassFromGeneric filter) { + return new ResponseEntity<>("{\"Say\": \"Hello\"}", HttpStatus.OK); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app166/MyData.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app166/MyData.java new file mode 100644 index 000000000..e404105f7 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app166/MyData.java @@ -0,0 +1,48 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app166; + +class MyData { + + /** + * Returns the first name + */ + private String firstName; + + /** + * Returns the max number + */ + private Integer maxNumber; + + public Integer getMaxNumber() { + return maxNumber; + } + + public String getFirstName() { + return firstName; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app166/SimpleGeneric.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app166/SimpleGeneric.java new file mode 100644 index 000000000..28aab7f4a --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app166/SimpleGeneric.java @@ -0,0 +1,48 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app166; + +class SimpleGeneric { + + /** + * Returns name + */ + private String name; + + /** + * Returns the generic child + */ + private T child; + + public T getChild() { + return child; + } + + public String getName() { + return name; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app166/SimpleInnerClass.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app166/SimpleInnerClass.java new file mode 100644 index 000000000..cdf964cb5 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app166/SimpleInnerClass.java @@ -0,0 +1,57 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app166; + +class SimpleInnerClass { + + /** + * Returns the inner inner class + */ + private SimpleInnerInnerClass innerInnerClass; + + /** + * Returns the boolean name + */ + private Boolean name; + + /** + * Returns the max number + */ + private Integer maxNumber; + + public Integer getMaxNumber() { + return maxNumber; + } + + public Boolean getName() { + return name; + } + + public SimpleInnerInnerClass getInnerInnerClass() { + return innerInnerClass; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app166/SimpleInnerInnerClass.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app166/SimpleInnerInnerClass.java new file mode 100644 index 000000000..841adc1d5 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app166/SimpleInnerInnerClass.java @@ -0,0 +1,47 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app166; + +class SimpleInnerInnerClass { + /** + * Returns the name of the inner inner class + */ + Boolean name; + + /** + * Returns the maxNumber of the inner inner class + */ + private Integer maxNumber; + + public Integer getMaxNumber() { + return maxNumber; + } + + public Boolean getName() { + return name; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app166/SimpleOuterClass.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app166/SimpleOuterClass.java new file mode 100644 index 000000000..9d8a462a0 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app166/SimpleOuterClass.java @@ -0,0 +1,48 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app166; + +class SimpleOuterClass { + + /** + * Returns the name of the outer class + */ + private String name; + + /** + * Returns the inner class + */ + private SimpleInnerClass innerClass; + + public String getName() { + return name; + } + + public SimpleInnerClass getInnerClass() { + return innerClass; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app166/SpringDocApp166Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app166/SpringDocApp166Test.java new file mode 100644 index 000000000..79fe0bb03 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app166/SpringDocApp166Test.java @@ -0,0 +1,44 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app166; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 165 test. + */ +class SpringDocApp166Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp { + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app167/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app167/HelloController.java new file mode 100644 index 000000000..e9c986755 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app167/HelloController.java @@ -0,0 +1,42 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app167; + +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController("/api") +class HelloController { + + @RequestMapping("/process") + public void process() { + + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app167/SpringDocApp167Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app167/SpringDocApp167Test.java new file mode 100644 index 000000000..87b08a283 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app167/SpringDocApp167Test.java @@ -0,0 +1,44 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app167; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 167 test. + */ +class SpringDocApp167Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp { + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app168/DescriptionFieldInRequestBodyIsNullController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app168/DescriptionFieldInRequestBodyIsNullController.java new file mode 100644 index 000000000..2eb6efeca --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app168/DescriptionFieldInRequestBodyIsNullController.java @@ -0,0 +1,53 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app168; + +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; + +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * If the RequestBody description field is null, get the description from the javadoc. + */ +@RestController +@RequestMapping("description-in-requestbody-is-null") +class DescriptionFieldInRequestBodyIsNullController { + + /** + * Person person. + * + * @param person the person + */ + @PostMapping + public void person( + @io.swagger.v3.oas.annotations.parameters.RequestBody(content = @Content(schema = @Schema(implementation = Person.class))) @RequestBody Person person) { + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app168/Person.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app168/Person.java new file mode 100644 index 000000000..c7ee1fd9f --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app168/Person.java @@ -0,0 +1,55 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app168; + +/** + * The type Person. + */ +class Person { + /** + * The Id. + */ + private long id; + + /** + * Gets id. + * + * @return the id + */ + public long getId() { + return id; + } + + /** + * Sets id. + * + * @param id the id + */ + public void setId(long id) { + this.id = id; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app168/SpringDocApp168Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app168/SpringDocApp168Test.java new file mode 100644 index 000000000..593383161 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app168/SpringDocApp168Test.java @@ -0,0 +1,44 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app168; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 168 test. + */ +class SpringDocApp168Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp { + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app169/RecordController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app169/RecordController.java new file mode 100644 index 000000000..b42b79b5a --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app169/RecordController.java @@ -0,0 +1,42 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app169; + +import org.springdoc.core.annotations.ParameterObject; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequestMapping("record") +class RecordController { + @GetMapping + public SimpleOuterClass index(@ParameterObject SimpleOuterClass filter) { + return null; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app169/SimpleInnerClass.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app169/SimpleInnerClass.java new file mode 100644 index 000000000..197b464c7 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app169/SimpleInnerClass.java @@ -0,0 +1,36 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app169; + +/** + * simple inner class + * + * @param name the boolean name + * @param maxNumber the max number + */ +public record SimpleInnerClass(Boolean name, Integer maxNumber) { +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app169/SimpleOuterClass.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app169/SimpleOuterClass.java new file mode 100644 index 000000000..c91fa83f1 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app169/SimpleOuterClass.java @@ -0,0 +1,36 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app169; + +/** + * simple outer class + * + * @param name the name of the outer class + * @param simpleInnerClass the inner class + */ +public record SimpleOuterClass(String name, SimpleInnerClass simpleInnerClass) { +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app169/SpringDocApp169Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app169/SpringDocApp169Test.java new file mode 100644 index 000000000..c0d9ea89c --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app169/SpringDocApp169Test.java @@ -0,0 +1,44 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app169; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 169 test. + */ +class SpringDocApp169Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp { + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app17/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app17/HelloController.java new file mode 100644 index 000000000..e2b6bb9c7 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app17/HelloController.java @@ -0,0 +1,52 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app17; + +import jakarta.validation.Valid; +import jakarta.validation.constraints.Size; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * Persons. + * + * @param name the name + */ + @GetMapping(value = "/persons") + public void persons(@Valid @RequestParam @Size(min = 4, max = 6) String name) { + + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app17/SpringDocApp17Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app17/SpringDocApp17Test.java new file mode 100644 index 000000000..9bdca5cd7 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app17/SpringDocApp17Test.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app17; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 17 test. + */ +class SpringDocApp17Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app170/Animal.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app170/Animal.java new file mode 100644 index 000000000..ab8e55e4f --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app170/Animal.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app170; + + +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import io.swagger.v3.oas.annotations.media.Schema; + +/** + * Interface of the Animal. + */ +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.WRAPPER_OBJECT) +@JsonSubTypes({ + @JsonSubTypes.Type(value = Dog.class, name = "dog"), + @JsonSubTypes.Type(value = Cat.class, name = "cat"), +}) +@Schema(description = "Represents an Animal class.") +public interface Animal {} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app170/BasicController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app170/BasicController.java new file mode 100644 index 000000000..cd5141d80 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app170/BasicController.java @@ -0,0 +1,45 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app170; + +import io.swagger.v3.oas.annotations.Operation; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequestMapping(path = "/") +class BasicController { + + @GetMapping("/test1") + @Operation(summary = "get1", description = "Provides an animal.") + public Animal get1() { + + return new Dog("Foo", 12); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app170/Cat.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app170/Cat.java new file mode 100644 index 000000000..d141ceefd --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app170/Cat.java @@ -0,0 +1,48 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app170; + + +import io.swagger.v3.oas.annotations.media.Schema; + +@Schema +class Cat implements Animal { + + private Integer speed; + + public Cat(Integer speed) { + this.speed = speed; + } + + public Integer getSpeed() { + return speed; + } + + public void setSpeed(Integer speed) { + this.speed = speed; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app170/Dog.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app170/Dog.java new file mode 100644 index 000000000..d1b3b5da0 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app170/Dog.java @@ -0,0 +1,59 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app170; + + +import io.swagger.v3.oas.annotations.media.Schema; + +@Schema(description = "Represents a Dog class.") +class Dog implements Animal { + + private String name; + + private Integer age; + + public Dog(String name, Integer age) { + this.name = name; + this.age = age; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Integer getAge() { + return age; + } + + public void setAge(Integer age) { + this.age = age; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app170/SpringDocApp170Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app170/SpringDocApp170Test.java new file mode 100644 index 000000000..8d3c9b2a2 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app170/SpringDocApp170Test.java @@ -0,0 +1,45 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app170; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 193 test. + */ +class SpringDocApp170Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp { + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app171/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app171/HelloController.java new file mode 100644 index 000000000..55dcac2c3 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app171/HelloController.java @@ -0,0 +1,48 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app171; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * PersonProjection interface. + * + * @return the PersonProjection + */ + @GetMapping(value = "/persons") + public PersonProjection persons() { + return new PersonDTO(); + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app171/PersonDTO.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app171/PersonDTO.java new file mode 100644 index 000000000..7aae78084 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app171/PersonDTO.java @@ -0,0 +1,81 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app171; + +/** + * Simulate a dynamically generated class that implements the PersonProjection interface. + */ +class PersonDTO implements PersonProjection { + private String email; + + private String firstName; + + private String lastName; + + /** + * Instantiates a new Person dto. + */ + public PersonDTO() { + } + + /** + * Instantiates a new Person dto. + * + * @param email the email + * @param firstName the first name + * @param lastName the last name + */ + public PersonDTO(final String email, final String firstName, final String lastName) { + this.email = email; + this.firstName = firstName; + this.lastName = lastName; + } + + public String getEmail() { + return email; + } + + public void setEmail(final String email) { + this.email = email; + } + + public String getFirstName() { + return firstName; + } + + public void setFirstName(final String firstName) { + this.firstName = firstName; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(final String lastName) { + this.lastName = lastName; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app171/PersonProjection.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app171/PersonProjection.java new file mode 100644 index 000000000..a84ba422f --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app171/PersonProjection.java @@ -0,0 +1,50 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app171; + +/** + * The type PersonProjection dto interface. + */ +public interface PersonProjection { + /** + * The Email. + * + */ + String getEmail(); + + /** + * The First name. + * + */ + String getFirstName(); + + /** + * The Last name. + * + */ + String getLastName(); +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app171/SpringDocApp171Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app171/SpringDocApp171Test.java new file mode 100644 index 000000000..4d68deca3 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app171/SpringDocApp171Test.java @@ -0,0 +1,45 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app171; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 193 test. + */ +class SpringDocApp171Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp { + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app172/JavadocPropertyCustomizerTest.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app172/JavadocPropertyCustomizerTest.java new file mode 100644 index 000000000..eef428098 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app172/JavadocPropertyCustomizerTest.java @@ -0,0 +1,144 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app172; + +import java.beans.IntrospectionException; +import java.beans.Introspector; +import java.beans.PropertyDescriptor; +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.io.PrintWriter; +import java.lang.reflect.Field; +import java.net.URL; +import java.net.URLClassLoader; +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +import javax.tools.JavaCompiler; +import javax.tools.ToolProvider; + +import io.swagger.v3.oas.models.media.ObjectSchema; +import io.swagger.v3.oas.models.media.Schema; +import io.swagger.v3.oas.models.media.StringSchema; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.condition.EnabledForJreRange; +import org.junit.jupiter.api.condition.JRE; +import org.junit.jupiter.api.io.TempDir; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import org.springdoc.core.customizers.JavadocPropertyCustomizer; +import org.springdoc.core.providers.JavadocProvider; +import org.springdoc.core.providers.ObjectMapperProvider; +import org.springdoc.core.providers.SpringDocJavadocProvider; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +/** + * Tests for {@link JavadocPropertyCustomizer}. + */ +class JavadocPropertyCustomizerTest { + @TempDir + private File tempDir; + + private JavadocProvider javadocProvider; + + @Mock + private ObjectMapperProvider objectMapperProvider; + + private JavadocPropertyCustomizer javadocPropertyCustomizer; + + @BeforeEach + void setup() { + MockitoAnnotations.openMocks(this); + this.javadocProvider = new SpringDocJavadocProvider(); + this.javadocPropertyCustomizer = new JavadocPropertyCustomizer(javadocProvider, objectMapperProvider); + } + + + /** + * Tests for {@link JavadocPropertyCustomizer#setJavadocDescription(Class, List, List, Schema)}. + */ + @Nested + class setJavadocDescription { + @Test + @EnabledForJreRange(min = JRE.JAVA_17) + void ifRecordObjectShouldGetField() throws IOException, ClassNotFoundException, IntrospectionException { + File recordObject = new File(tempDir, "RecordObject.java"); + try (PrintWriter writer = new PrintWriter(new FileWriter(recordObject))) { + writer.println("/**"); + writer.println(" * Record Object"); + writer.println(" *"); + writer.println(" * @param id the id"); + writer.println(" * @param name the name"); + writer.println(" */"); + writer.println("public record RecordObject(String id, String name){"); + writer.println("}"); + } + File recordObjectJavadocJson = new File(tempDir, "RecordObject__Javadoc.json"); + try (PrintWriter writer = new PrintWriter(new FileWriter(recordObjectJavadocJson))) { + writer.print("{"); + writer.print("\"doc\":\"Record Object\\n\\n @param id the id\\n @param name the name\","); + writer.print("\"fields\":[],"); + writer.print("\"methods\":[],"); + writer.print("\"constructors\":[]"); + writer.println("}"); + } + + String[] args = { + recordObject.getAbsolutePath() + }; + JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); + int r = compiler.run(null, null, null, args); + if (r != 0) { + throw new IllegalStateException("Compilation failed"); + } + URL[] urls = { tempDir.toURI().toURL() }; + ClassLoader loader = URLClassLoader.newInstance(urls); + + Class cls = loader.loadClass("RecordObject"); + + List fields = Arrays.asList(cls.getFields()); + + Schema existingSchema = new ObjectSchema().name("RecordObject") + .addProperty("id", new StringSchema().name("id")) + .addProperty("name", new StringSchema().name("name")); + + List propertyDescriptors = Arrays.asList(Introspector.getBeanInfo(cls).getPropertyDescriptors()); + javadocPropertyCustomizer.setJavadocDescription(cls, fields, propertyDescriptors, existingSchema,false); + + assertEquals("Record Object", existingSchema.getDescription()); + Map properties = existingSchema.getProperties(); + assertEquals(2, properties.size()); + assertEquals("the id", properties.get("id").getDescription()); + assertEquals("the name", properties.get("name").getDescription()); + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app173/Example.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app173/Example.java new file mode 100644 index 000000000..5faa64638 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app173/Example.java @@ -0,0 +1,47 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app173; + +import io.swagger.v3.oas.annotations.media.Schema; + +/** + * The Example object + */ +@Schema +class Example { + + private String name; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app173/ExampleController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app173/ExampleController.java new file mode 100644 index 000000000..7b387cfae --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app173/ExampleController.java @@ -0,0 +1,65 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app173; + +import java.util.UUID; + +import io.swagger.v3.oas.annotations.Operation; + +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.PatchMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RestController; + +import static org.springframework.http.HttpStatus.OK; + +/** + * The Example Controller + */ +@RestController +class ExampleController { + + @PostMapping("/example") + @Operation(summary = "insert example", description = "Allows to insert an example") + public ResponseEntity postExample(@io.swagger.v3.oas.annotations.parameters.RequestBody(description = "${example.description}") @RequestBody Example example) { + return new ResponseEntity<>(UUID.randomUUID(), OK); + } + + @PutMapping("/example") + @Operation(summary = "update example", description = "Allows to update an example") + public ResponseEntity putExample(@io.swagger.v3.oas.annotations.parameters.RequestBody(description = "${example2.description:Default description for example}") @RequestBody Example example) { + return new ResponseEntity<>(UUID.randomUUID(), OK); + } + + @PatchMapping("/example") + @Operation(summary = "patch example", description = "Allows to patch an example") + public ResponseEntity patchExample(@io.swagger.v3.oas.annotations.parameters.RequestBody(description = "Description without the use of variables") @RequestBody Example example) { + return new ResponseEntity<>(UUID.randomUUID(), OK); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app173/SpringDocApp173Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app173/SpringDocApp173Test.java new file mode 100644 index 000000000..a65457aa0 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app173/SpringDocApp173Test.java @@ -0,0 +1,47 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app173; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.test.context.TestPropertySource; + +/** + * The type Spring doc app 173 test. + */ +@TestPropertySource(properties = "example.description=The example object") +class SpringDocApp173Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp { + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app174/ExampleController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app174/ExampleController.java new file mode 100644 index 000000000..2bd1b3343 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app174/ExampleController.java @@ -0,0 +1,50 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app174; + +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The Example Controller + */ +@RestController +class ExampleController { + + @PostMapping + public Test post(){ + return null; + } + +} + + + + + + + diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app174/Question.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app174/Question.java new file mode 100644 index 000000000..c75a33fb5 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app174/Question.java @@ -0,0 +1,68 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app174; + +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; + +/** + * The type Question. + * + * @author bnasslahsen base class for all questions in test with polymorphism + */ +@JsonTypeInfo( + use = JsonTypeInfo.Id.NAME, + property = "type") +@JsonSubTypes({ + @JsonSubTypes.Type(value = TestQuestion.class, name = "test"), + @JsonSubTypes.Type(value = TextQuestion.class, name = "text") +}) +public abstract class Question { + private final String question; + private final String type; + + public Question(String question, String type) { + this.question = question; + this.type = type; + } + + public String getQuestion() { + return question; + } + + public String getType() { + return type; + } + + @Override + public String toString() { + return "Question{" + + "question='" + question + '\'' + + ", type='" + type + '\'' + + '}'; + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app174/SpringDocApp174Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app174/SpringDocApp174Test.java new file mode 100644 index 000000000..17aab26dc --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app174/SpringDocApp174Test.java @@ -0,0 +1,45 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app174; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 174 test. + */ +class SpringDocApp174Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp { + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app174/Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app174/Test.java new file mode 100644 index 000000000..2accb3611 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app174/Test.java @@ -0,0 +1,70 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app174; + +import java.io.Serializable; +import java.util.List; + +/** + * The type Test. + * + * @author bnasslahsen + */ + +class Test implements Serializable { + + private static final long serialVersionUID = 1L; // Recommended for Serializable classes + + private List questions; + + // No-argument constructor + public Test() { + } + + // Constructor with arguments + public Test(List questions) { + this.questions = questions; + } + + // Getter method for 'questions' + public List getQuestions() { + return questions; + } + + // Setter method for 'questions' + public void setQuestions(List questions) { + this.questions = questions; + } + + // Optionally, you can override toString, hashCode, equals, etc. + @Override + public String toString() { + return "Test{" + + "questions=" + questions + + '}'; + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app174/TestQuestion.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app174/TestQuestion.java new file mode 100644 index 000000000..d2dfc244a --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app174/TestQuestion.java @@ -0,0 +1,68 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app174; + +import java.util.List; + +/** + * The type Test question. + * + * @author bnasslahsen test question + */ +class TestQuestion extends Question { + /** + * list of variants + */ + private final List variants; + /** + * correct answer + */ + private final int answer; + + public TestQuestion(String question, String type, List variants, int answer) { + super(question, type); + this.variants = variants; + this.answer = answer; + } + + public List getVariants() { + return variants; + } + + public int getAnswer() { + return answer; + } + + @Override + public String toString() { + return "TestQuestion{" + + "question='" + getQuestion() + '\'' + + ", variants=" + variants + + ", answer=" + answer + + '}'; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app174/TextQuestion.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app174/TextQuestion.java new file mode 100644 index 000000000..5e806f3e8 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app174/TextQuestion.java @@ -0,0 +1,54 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app174; + +/** + * The type Text question. + * + * @author bnasslahsen + */ +class TextQuestion extends Question { + private final String answer; + + public TextQuestion(String question, String type, String answer) { + super(question, type); + this.answer = answer; + } + + public String getAnswer() { + return answer; + } + + @Override + public String toString() { + return "TextQuestion{" + + "question='" + getQuestion() + '\'' + + ", type='" + getType() + '\'' + + ", answer='" + answer + '\'' + + '}'; + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app18/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app18/HelloController.java new file mode 100644 index 000000000..f02c5bc52 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app18/HelloController.java @@ -0,0 +1,111 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app18; + +import io.swagger.v3.oas.annotations.Parameter; +import jakarta.validation.constraints.NegativeOrZero; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotEmpty; +import jakarta.validation.constraints.PositiveOrZero; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * Persons string. + * + * @param name the name + * @return the string + */ + @GetMapping(value = "/persons") + public String persons(@NotBlank String name) { + return "OK"; + } + + /** + * Persons 2 string. + * + * @param name the name + * @return the string + */ + @GetMapping(value = "/persons2") + public String persons2(@NotBlank @Parameter(description = "persons name") String name) { + return "OK"; + } + + /** + * Persons 3 string. + * + * @param name the name + * @return the string + */ + @GetMapping(value = "/persons3") + public String persons3(@NotBlank @Parameter(description = "persons name") @RequestParam String name) { + return "OK"; + } + + /** + * Persons 4 string. + * + * @param age the age + * @return the string + */ + @GetMapping(value = "/persons4") + public String persons4(@PositiveOrZero int age) { + return "OK"; + } + + /** + * Persons 5 string. + * + * @param age the age + * @return the string + */ + @GetMapping(value = "/persons5") + public String persons5(@NegativeOrZero int age) { + return "OK"; + } + + /** + * Persons 6 string. + * + * @param name the name + * @return the string + */ + @GetMapping(value = "/persons6") + public String persons6(@NotEmpty @Parameter(description = "persons name") String name) { + return "OK"; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app18/SpringDocApp18Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app18/SpringDocApp18Test.java new file mode 100644 index 000000000..11df9baa0 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app18/SpringDocApp18Test.java @@ -0,0 +1,45 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app18; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.test.context.TestPropertySource; + +/** + * The type Spring doc app 18 test. + */ +@TestPropertySource(properties = "springdoc.pre-loading-enabled=true") +class SpringDocApp18Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app19/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app19/HelloController.java new file mode 100644 index 000000000..34783925d --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app19/HelloController.java @@ -0,0 +1,77 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app19; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.parameters.RequestBody; +import jakarta.validation.constraints.NotBlank; + +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * Persons string. + * + * @param name the name + * @return the string + */ + @PostMapping(value = "/persons") + public String persons(@RequestBody(description = "requestBody description as parameter") String name) { + return "OK"; + } + + /** + * Persons 2 string. + * + * @param name the name + * @return the string + */ + @RequestBody(description = "requestBody description outside") + @PostMapping(value = "/persons2") + public String persons2(String name) { + return "OK"; + } + + /** + * Persons 3 string. + * + * @param name the name + * @return the string + */ + @Operation(requestBody = @RequestBody(description = "requestBody inside operation annotation")) + @PostMapping(value = "/persons3") + public String persons3(@NotBlank String name) { + return "OK"; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app19/SpringDocApp19Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app19/SpringDocApp19Test.java new file mode 100644 index 000000000..ff9d09593 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app19/SpringDocApp19Test.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app19; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 19 test. + */ +class SpringDocApp19Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app2/SpringDocApp2Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app2/SpringDocApp2Test.java new file mode 100644 index 000000000..5d842a40a --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app2/SpringDocApp2Test.java @@ -0,0 +1,65 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app2; + +import io.swagger.v3.oas.models.Components; +import io.swagger.v3.oas.models.OpenAPI; +import io.swagger.v3.oas.models.info.Info; +import io.swagger.v3.oas.models.info.License; +import io.swagger.v3.oas.models.security.SecurityScheme; +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; + +/** + * The type Spring doc app 2 test. + */ +class SpringDocApp2Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp { + /** + * Custom open api open api. + * + * @return the open api + */ + @Bean + public OpenAPI customOpenAPI() { + return new OpenAPI() + .components(new Components().addSecuritySchemes("basicScheme", + new SecurityScheme().type(SecurityScheme.Type.HTTP).scheme("basic"))) + .info(new Info().title("Petstore API").version("v0").description( + "This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.") + .termsOfService("http://swagger.io/terms/") + .license(new License().name("Apache 2.0").url("http://springdoc.org"))); + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app2/api/ApiUtil.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app2/api/ApiUtil.java new file mode 100644 index 000000000..c222e7370 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app2/api/ApiUtil.java @@ -0,0 +1,69 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app2.api; + +import java.io.IOException; + +import jakarta.servlet.http.HttpServletResponse; + +import org.springframework.http.HttpStatus; +import org.springframework.web.context.request.NativeWebRequest; +import org.springframework.web.server.ResponseStatusException; + +/** + * The type Api util. + */ +class ApiUtil { + + /** + * Sets example response. + * + * @param req the req + * @param contentType the content type + * @param example the example + */ + public static void setExampleResponse(NativeWebRequest req, String contentType, String example) { + try { + req.getNativeResponse(HttpServletResponse.class).addHeader("Content-Type", contentType); + req.getNativeResponse(HttpServletResponse.class).getOutputStream().print(example); + } + catch (IOException e) { + throw new RuntimeException(e); + } + } + + /** + * Check api key. + * + * @param req the req + */ + public static void checkApiKey(NativeWebRequest req) { + if (!"1".equals(System.getenv("DISABLE_API_KEY")) && !"special-key".equals(req.getHeader("api_key"))) { + throw new ResponseStatusException(HttpStatus.UNAUTHORIZED, "Missing API key!"); + } + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app2/api/ExceptionTranslator.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app2/api/ExceptionTranslator.java new file mode 100644 index 000000000..4dbf76309 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app2/api/ExceptionTranslator.java @@ -0,0 +1,74 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app2.api; + +import java.util.Map; + +import jakarta.validation.ConstraintViolationException; + +import org.springframework.boot.web.error.ErrorAttributeOptions; +import org.springframework.boot.web.servlet.error.ErrorAttributes; +import org.springframework.http.HttpStatus; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.ResponseStatus; +import org.springframework.web.bind.annotation.RestControllerAdvice; +import org.springframework.web.context.request.RequestAttributes; +import org.springframework.web.context.request.WebRequest; + +/** + * The type Exception translator. + */ +@RestControllerAdvice +class ExceptionTranslator { + + /** + * The Error attributes. + */ + private final ErrorAttributes errorAttributes; + + /** + * Instantiates a new Exception translator. + * + * @param errorAttributes the error attributes + */ + public ExceptionTranslator(ErrorAttributes errorAttributes) { + this.errorAttributes = errorAttributes; + } + + /** + * Process constraint violation exception map. + * + * @param request the request + * @return the map + */ + @ExceptionHandler(ConstraintViolationException.class) + @ResponseStatus(HttpStatus.BAD_REQUEST) + public Map processConstraintViolationException(WebRequest request) { + request.setAttribute("jakarta.servlet.error.status_code", HttpStatus.BAD_REQUEST.value(), RequestAttributes.SCOPE_REQUEST); + return errorAttributes.getErrorAttributes(request, ErrorAttributeOptions.defaults()); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app2/api/HomeController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app2/api/HomeController.java new file mode 100644 index 000000000..8012916e6 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app2/api/HomeController.java @@ -0,0 +1,58 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app2.api; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.GetMapping; + +import static org.springdoc.core.utils.Constants.SWAGGER_UI_PATH; +import static org.springframework.util.AntPathMatcher.DEFAULT_PATH_SEPARATOR; +import static org.springframework.web.servlet.view.UrlBasedViewResolver.REDIRECT_URL_PREFIX; + +/** + * Home redirection to swagger api documentation + */ +@Controller +class HomeController { + + /** + * The Swagger ui path. + */ + @Value(SWAGGER_UI_PATH) + private String swaggerUiPath; + + /** + * Index string. + * + * @return the string + */ + @GetMapping(DEFAULT_PATH_SEPARATOR) + public String index() { + return REDIRECT_URL_PREFIX + swaggerUiPath; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app2/api/PetApi.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app2/api/PetApi.java new file mode 100644 index 000000000..06e129896 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app2/api/PetApi.java @@ -0,0 +1,229 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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. + * * * * * + * * * * + * * * + * * + * + */ + +/** + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (3.0.0). + * https://openapi-generator.tech + * Do not edit the class manually. + */ +package test.org.springdoc.api.v31.app2.api; + +import java.util.List; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.enums.SecuritySchemeType; +import io.swagger.v3.oas.annotations.media.ArraySchema; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; +import io.swagger.v3.oas.annotations.security.OAuthFlow; +import io.swagger.v3.oas.annotations.security.OAuthFlows; +import io.swagger.v3.oas.annotations.security.OAuthScope; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.security.SecurityScheme; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.validation.Valid; +import jakarta.validation.constraints.NotNull; +import test.org.springdoc.api.v31.app2.model.ModelApiResponse; +import test.org.springdoc.api.v31.app2.model.Pet; + +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestHeader; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.multipart.MultipartFile; + +/** + * The interface Pet api. + */ +@SecurityScheme(name = "petstore_auth", type = SecuritySchemeType.OAUTH2, flows = @OAuthFlows(implicit = @OAuthFlow(authorizationUrl = "http://petstore.swagger.io/oauth/dialog", scopes = { + @OAuthScope(name = "write:pets", description = "modify pets in your account"), + @OAuthScope(name = "read:pets", description = "read your pets") }))) +@Tag(name = "pet", description = "the pet API") +@ResponseBody +public interface PetApi { + + /** + * Gets delegate. + * + * @return the delegate + */ + default PetApiDelegate getDelegate() { + return new PetApiDelegate() { + }; + } + + /** + * Add pet. + * + * @param pet the pet + */ + @Operation(summary = "Add a new pet to the store", description = "", security = { + @SecurityRequirement(name = "petstore_auth", scopes = { "write:pets", "read:pets" }) }, tags = { "pet" }) + @ApiResponses(value = { @ApiResponse(responseCode = "405", description = "Invalid input") }) + @PostMapping(value = "/pet", consumes = { "application/json", "application/xml" }) + default void addPet( + @io.swagger.v3.oas.annotations.parameters.RequestBody(description = "Pet object that needs to be added to the store", required = true) @Valid @RequestBody Pet pet) { + // return getDelegate().addPet(pet); + } + + /** + * Delete pet response entity. + * + * @param petId the pet id + * @param apiKey the api key + * @return the response entity + */ + @Operation(summary = "Deletes a pet", description = "", security = { + @SecurityRequirement(name = "petstore_auth", scopes = { "write:pets", "read:pets" }) }, tags = { "pet" }) + @ApiResponses(value = { @ApiResponse(responseCode = "400", description = "Invalid ID supplied"), + @ApiResponse(responseCode = "404", description = "Pet not found") }) + @DeleteMapping(value = "/pet/{petId}") + default ResponseEntity deletePet( + @Parameter(description = "Pet id to delete", required = true) @PathVariable("petId") Long petId, + @Parameter(description = "") @RequestHeader(value = "api_key", required = false) String apiKey) { + return getDelegate().deletePet(petId, apiKey); + } + + /** + * Find pets by status response entity. + * + * @param status the status + * @return the response entity + */ + @Operation(summary = "Finds Pets by status", description = "Multiple status values can be provided with comma separated strings", security = { + @SecurityRequirement(name = "petstore_auth", scopes = { "write:pets", "read:pets" }) }, tags = { "pet" }) + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(array = @ArraySchema(schema = @Schema(implementation = Pet.class)))), + @ApiResponse(responseCode = "400", description = "Invalid status value") }) + @GetMapping(value = "/pet/findByStatus", produces = { "application/xml", "application/json" }) + default ResponseEntity> findPetsByStatus( + @NotNull @Parameter(description = "Status values that need to be considered for filter", required = true) @Valid @RequestParam(value = "status", required = true) List status) { + return getDelegate().findPetsByStatus(status); + } + + /** + * Find pets by tags response entity. + * + * @param tags the tags + * @return the response entity + */ + @Operation(summary = "Finds Pets by tags", description = "Muliple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.", security = { + @SecurityRequirement(name = "petstore_auth", scopes = { "write:pets", "read:pets" }) }, tags = { "pet" }) + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(array = @ArraySchema(schema = @Schema(implementation = Pet.class)))), + @ApiResponse(responseCode = "400", description = "Invalid tag value") }) + @GetMapping(value = "/pet/findByTags", produces = { "application/xml", "application/json" }) + default ResponseEntity> findPetsByTags( + @NotNull @Parameter(description = "Tags to filter by", required = true) @Valid @RequestParam(value = "tags", required = true) List tags) { + return getDelegate().findPetsByTags(tags); + } + + /** + * Gets pet by id. + * + * @param petId the pet id + * @return the pet by id + */ + @Operation(summary = "Find pet by ID", description = "Returns a single pet", security = { + @SecurityRequirement(name = "api_key") }, tags = { "pet" }) + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(schema = @Schema(implementation = Pet.class))), + @ApiResponse(responseCode = "400", description = "Invalid ID supplied"), + @ApiResponse(responseCode = "404", description = "Pet not found") }) + @GetMapping(value = "/pet/{petId}", produces = { "application/xml", "application/json" }) + default ResponseEntity getPetById( + @Parameter(description = "ID of pet to return", required = true) @PathVariable("petId") Long petId) { + return getDelegate().getPetById(petId); + } + + /** + * Update pet response entity. + * + * @param pet the pet + * @return the response entity + */ + @Operation(summary = "Update an existing pet", description = "", security = { + @SecurityRequirement(name = "petstore_auth", scopes = { "write:pets", "read:pets" }) }, tags = { "pet" }) + @ApiResponses(value = { @ApiResponse(responseCode = "400", description = "Invalid ID supplied"), + @ApiResponse(responseCode = "404", description = "Pet not found"), + @ApiResponse(responseCode = "405", description = "Validation exception") }) + @PutMapping(value = "/pet", consumes = { "application/json", "application/xml" }) + default ResponseEntity updatePet( + @io.swagger.v3.oas.annotations.parameters.RequestBody(description = "Pet object that needs to be added to the store", required = true) @Valid @RequestBody Pet pet) { + return getDelegate().updatePet(pet); + } + + /** + * Update pet with form response entity. + * + * @param petId the pet id + * @param name the name + * @param status the status + * @return the response entity + */ + @Operation(summary = "Updates a pet in the store with form data", description = "", security = { + @SecurityRequirement(name = "petstore_auth", scopes = { "write:pets", "read:pets" }) }, tags = { "pet" }) + @ApiResponses(value = { @ApiResponse(responseCode = "405", description = "Invalid input") }) + @PostMapping(value = "/pet/{petId}", consumes = { "application/x-www-form-urlencoded" }) + default ResponseEntity updatePetWithForm( + @Parameter(description = "ID of pet that needs to be updated", required = true) @PathVariable("petId") Long petId, + @Parameter(description = "Updated name of the pet") @RequestParam(value = "name", required = false) String name, + @Parameter(description = "Updated status of the pet") @RequestParam(value = "status", required = false) String status) { + return getDelegate().updatePetWithForm(petId, name, status); + } + + /** + * Upload file response entity. + * + * @param petId the pet id + * @param additionalMetadata the additional metadata + * @param file the file + * @return the response entity + */ + @Operation(summary = "uploads an image", description = "", security = { + @SecurityRequirement(name = "petstore_auth", scopes = { "write:pets", "read:pets" }) }, tags = { "pet" }) + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(schema = @Schema(implementation = ModelApiResponse.class))) }) + @PostMapping(value = "/pet/{petId}/uploadImage", produces = { "application/json" }, consumes = { + "multipart/form-data" }) + default ResponseEntity uploadFile( + @Parameter(description = "ID of pet to update", required = true) @PathVariable("petId") Long petId, + @Parameter(description = "Additional data to pass to server") @RequestParam(value = "additionalMetadata", required = false) String additionalMetadata, + @Parameter(description = "file detail") @Valid @RequestPart("file") MultipartFile file) { + return getDelegate().uploadFile(petId, additionalMetadata, file); + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app2/api/PetApiController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app2/api/PetApiController.java new file mode 100644 index 000000000..69e0d92e4 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app2/api/PetApiController.java @@ -0,0 +1,68 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app2.api; + +import java.util.Optional; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; + +/** + * The type Pet api controller. + */ +@jakarta.annotation.Generated(value = "org.springdoc.demo.app2.codegen.languages.SpringCodegen", date = "2019-07-11T00:09:29.839+02:00[Europe/Paris]") + +@Controller +@RequestMapping("${openapi.openAPIPetstore.base-path:/}") +class PetApiController implements PetApi { + + /** + * The Delegate. + */ + private final PetApiDelegate delegate; + + /** + * Instantiates a new Pet api controller. + * + * @param delegate the delegate + */ + public PetApiController(@org.springframework.beans.factory.annotation.Autowired(required = false) PetApiDelegate delegate) { + this.delegate = Optional.ofNullable(delegate).orElse(new PetApiDelegate() { + }); + } + + /** + * Gets delegate. + * + * @return the delegate + */ + @Override + public PetApiDelegate getDelegate() { + return delegate; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app2/api/PetApiDelegate.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app2/api/PetApiDelegate.java new file mode 100644 index 000000000..dd5c111de --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app2/api/PetApiDelegate.java @@ -0,0 +1,192 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app2.api; + +import java.util.List; +import java.util.Optional; + +import jakarta.validation.Valid; +import test.org.springdoc.api.v31.app2.model.ModelApiResponse; +import test.org.springdoc.api.v31.app2.model.Pet; + +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.web.context.request.NativeWebRequest; +import org.springframework.web.multipart.MultipartFile; + +/** + * A delegate to be called by the {@link PetApiController}}. + * Implement this interface with a {@link org.springframework.stereotype.Service} annotated class. + */ +@jakarta.annotation.Generated(value = "org.springdoc.demo.app2.codegen.languages.SpringCodegen", date = "2019-07-11T00:09:29.839+02:00[Europe/Paris]") + +public interface PetApiDelegate { + + /** + * Gets request. + * + * @return the request + */ + default Optional getRequest() { + return Optional.empty(); + } + + /** + * Add pet. + * + * @param pet the pet + * @see PetApi#addPet PetApi#addPet + */ + default void addPet(Pet pet) { + + } + + /** + * Delete pet response entity. + * + * @param petId the pet id + * @param apiKey the api key + * @return the response entity + * @see PetApi#deletePet PetApi#deletePet + */ + default ResponseEntity deletePet(Long petId, + String apiKey) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * Find pets by status response entity. + * + * @param status the status + * @return the response entity + * @see PetApi#findPetsByStatus PetApi#findPetsByStatus + */ + default ResponseEntity> findPetsByStatus(List status) { + extract(); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * Extract. + */ + default void extract() { + getRequest().ifPresent(request -> { + for (MediaType mediaType : MediaType.parseMediaTypes(request.getHeader("Accept"))) { + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + ApiUtil.setExampleResponse(request, "application/json", "{ \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ], \"name\" : \"doggie\", \"id\" : 0, \"category\" : { \"name\" : \"name\", \"id\" : 6 }, \"tags\" : [ { \"name\" : \"name\", \"id\" : 1 }, { \"name\" : \"name\", \"id\" : 1 } ], \"status\" : \"available\"}"); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/xml"))) { + ApiUtil.setExampleResponse(request, "application/xml", " 123456789 doggie aeiou aeiou"); + break; + } + } + }); + } + + /** + * Find pets by tags response entity. + * + * @param tags the tags + * @return the response entity + * @see PetApi#findPetsByTags PetApi#findPetsByTags + */ + default ResponseEntity> findPetsByTags(List tags) { + extract(); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * Gets pet by id. + * + * @param petId the pet id + * @return the pet by id + * @see PetApi#getPetById PetApi#getPetById + */ + default ResponseEntity getPetById(Long petId) { + extract(); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * Update pet response entity. + * + * @param pet the pet + * @return the response entity + * @see PetApi#updatePet PetApi#updatePet + */ + default ResponseEntity updatePet(Pet pet) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * Update pet with form response entity. + * + * @param petId the pet id + * @param name the name + * @param status the status + * @return the response entity + * @see PetApi#updatePetWithForm PetApi#updatePetWithForm + */ + default ResponseEntity updatePetWithForm(Long petId, + String name, + String status) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * Upload file response entity. + * + * @param petId the pet id + * @param additionalMetadata the additional metadata + * @param file the file + * @return the response entity + * @see PetApi#uploadFile PetApi#uploadFile + */ + default ResponseEntity uploadFile(Long petId, + String additionalMetadata, + @Valid MultipartFile file) { + getRequest().ifPresent(request -> { + for (MediaType mediaType : MediaType.parseMediaTypes(request.getHeader("Accept"))) { + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + ApiUtil.setExampleResponse(request, "application/json", "{ \"code\" : 0, \"type\" : \"type\", \"message\" : \"message\"}"); + break; + } + } + }); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app2/api/PetApiDelegateImpl.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app2/api/PetApiDelegateImpl.java new file mode 100644 index 000000000..655a2b2c0 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app2/api/PetApiDelegateImpl.java @@ -0,0 +1,38 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app2.api; + +import org.springframework.stereotype.Service; + +/** + * The type Pet api delegate. + */ +@Service +class PetApiDelegateImpl implements PetApiDelegate { + + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app2/api/StoreApi.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app2/api/StoreApi.java new file mode 100644 index 000000000..61e8e2533 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app2/api/StoreApi.java @@ -0,0 +1,143 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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. + * * * * * + * * * * + * * * + * * + * + */ + +/** + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (3.0.0). + * https://openapi-generator.tech + * Do not edit the class manually. + */ +package test.org.springdoc.api.v31.app2.api; + +import java.util.Map; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.media.ArraySchema; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.validation.Valid; +import jakarta.validation.constraints.Max; +import jakarta.validation.constraints.Min; +import test.org.springdoc.api.v31.app2.model.Order; + +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.ResponseBody; + +/** + * The interface Store api. + */ +@jakarta.annotation.Generated(value = "org.springdoc.demo.app2.codegen.languages.SpringCodegen", date = "2019-07-11T00:09:29.839+02:00[Europe/Paris]") + +@Tag(name = "store", description = "the store API") +public interface StoreApi { + + /** + * Gets delegate. + * + * @return the delegate + */ + default StoreApiDelegate getDelegate() { + return new StoreApiDelegate() { + }; + } + + /** + * Delete order response entity. + * + * @param orderId the order id + * @return the response entity + */ + @Operation(summary = "Delete purchase order by ID", tags = { "store" }) + @ApiResponses(value = { @ApiResponse(responseCode = "400", description = "Invalid ID supplied"), + @ApiResponse(responseCode = "404", description = "Order not found") }) + @DeleteMapping(value = "/store/order/{orderId}") + @ResponseBody + default ResponseEntity deleteOrder( + @Parameter(description = "ID of the order that needs to be deleted", required = true) @PathVariable("orderId") String orderId) { + return getDelegate().deleteOrder(orderId); + } + + /** + * Gets inventory. + * + * @return the inventory + */ + @Operation(summary = "Returns pet inventories by status", description = "Returns a map of status codes to quantities", security = { + @SecurityRequirement(name = "api_key") }, tags = { "store" }) + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(array = @ArraySchema(schema = @Schema(implementation = Map.class)))) }) + @GetMapping(value = "/store/inventory", produces = { "application/json" }) + @ResponseBody + default ResponseEntity> getInventory() { + return getDelegate().getInventory(); + } + + /** + * Gets order by id. + * + * @param orderId the order id + * @return the order by id + */ + @Operation(summary = "Find purchase order by ID", tags = { "store" }) + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(schema = @Schema(implementation = Order.class))), + @ApiResponse(responseCode = "400", description = "Invalid ID supplied"), + @ApiResponse(responseCode = "404", description = "Order not found") }) + @GetMapping(value = "/store/order/{orderId}", produces = { "application/xml", "application/json" }) + @ResponseBody + default ResponseEntity getOrderById( + @Min(1L) @Max(5L) @Parameter(description = "ID of pet that needs to be fetched", required = true) @PathVariable("orderId") Long orderId) { + return getDelegate().getOrderById(orderId); + } + + /** + * Place order response entity. + * + * @param order the order + * @return the response entity + */ + @Operation(summary = "Place an order for a pet", tags = { "store" }) + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(schema = @Schema(implementation = Order.class))), + @ApiResponse(responseCode = "400", description = "Invalid Order") }) + @PostMapping(value = "/store/order", produces = { "application/xml", "application/json" }, consumes = { + "application/json" }) + @ResponseBody + default ResponseEntity placeOrder( + @Parameter(description = "order placed for purchasing the pet", required = true) @Valid @RequestBody Order order) { + return getDelegate().placeOrder(order); + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app2/api/StoreApiController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app2/api/StoreApiController.java new file mode 100644 index 000000000..e95635ee0 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app2/api/StoreApiController.java @@ -0,0 +1,68 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app2.api; + +import java.util.Optional; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; + +/** + * The type Store api controller. + */ +@jakarta.annotation.Generated(value = "org.springdoc.demo.app2.codegen.languages.SpringCodegen", date = "2019-07-11T00:09:29.839+02:00[Europe/Paris]") + +@Controller +@RequestMapping("${openapi.openAPIPetstore.base-path:/}") +class StoreApiController implements StoreApi { + + /** + * The Delegate. + */ + private final StoreApiDelegate delegate; + + /** + * Instantiates a new Store api controller. + * + * @param delegate the delegate + */ + public StoreApiController(@org.springframework.beans.factory.annotation.Autowired(required = false) StoreApiDelegate delegate) { + this.delegate = Optional.ofNullable(delegate).orElse(new StoreApiDelegate() { + }); + } + + /** + * Gets delegate. + * + * @return the delegate + */ + @Override + public StoreApiDelegate getDelegate() { + return delegate; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app2/api/StoreApiDelegate.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app2/api/StoreApiDelegate.java new file mode 100644 index 000000000..a63e1710d --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app2/api/StoreApiDelegate.java @@ -0,0 +1,123 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app2.api; + +import java.util.Map; +import java.util.Optional; + +import test.org.springdoc.api.v31.app2.model.Order; + +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.web.context.request.NativeWebRequest; + +/** + * A delegate to be called by the {@link StoreApiController}}. + * Implement this interface with a {@link org.springframework.stereotype.Service} annotated class. + */ +@jakarta.annotation.Generated(value = "org.springdoc.demo.app2.codegen.languages.SpringCodegen", date = "2019-07-11T00:09:29.839+02:00[Europe/Paris]") + +public interface StoreApiDelegate { + + /** + * Gets request. + * + * @return the request + */ + default Optional getRequest() { + return Optional.empty(); + } + + /** + * Delete order response entity. + * + * @param orderId the order id + * @return the response entity + * @see StoreApi#deleteOrder StoreApi#deleteOrder + */ + default ResponseEntity deleteOrder(String orderId) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * Gets inventory. + * + * @return the inventory + * @see StoreApi#getInventory StoreApi#getInventory + */ + default ResponseEntity> getInventory() { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * Gets order by id. + * + * @param orderId the order id + * @return the order by id + * @see StoreApi#getOrderById StoreApi#getOrderById + */ + default ResponseEntity getOrderById(Long orderId) { + extract(); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * Extract. + */ + default void extract() { + getRequest().ifPresent(request -> { + for (MediaType mediaType : MediaType.parseMediaTypes(request.getHeader("Accept"))) { + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + ApiUtil.setExampleResponse(request, "application/json", "{ \"petId\" : 6, \"quantity\" : 1, \"id\" : 0, \"shipDate\" : \"2000-01-23T04:56:07.000+00:00\", \"complete\" : false, \"status\" : \"placed\"}"); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/xml"))) { + ApiUtil.setExampleResponse(request, "application/xml", " 123456789 123456789 123 2000-01-23T04:56:07.000Z aeiou true"); + break; + } + } + }); + } + + /** + * Place order response entity. + * + * @param order the order + * @return the response entity + * @see StoreApi#placeOrder StoreApi#placeOrder + */ + default ResponseEntity placeOrder(Order order) { + extract(); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app2/api/StoreApiDelegateImpl.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app2/api/StoreApiDelegateImpl.java new file mode 100644 index 000000000..bc1c56a18 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app2/api/StoreApiDelegateImpl.java @@ -0,0 +1,38 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app2.api; + +import org.springframework.stereotype.Service; + +/** + * The type Store api delegate. + */ +@Service +class StoreApiDelegateImpl implements StoreApiDelegate { + + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app2/api/UserApi.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app2/api/UserApi.java new file mode 100644 index 000000000..2c48d2dd5 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app2/api/UserApi.java @@ -0,0 +1,197 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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. + * * * * * + * * * * + * * * + * * + * + */ + +/** + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech) (3.0.0). + * https://openapi-generator.tech + * Do not edit the class manually. + */ +package test.org.springdoc.api.v31.app2.api; + +import java.util.List; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.validation.Valid; +import jakarta.validation.constraints.NotNull; +import test.org.springdoc.api.v31.app2.model.User; + +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestParam; + +/** + * The interface User api. + */ +@jakarta.annotation.Generated(value = "org.springdoc.demo.app2.codegen.languages.SpringCodegen", date = "2019-07-11T00:09:29.839+02:00[Europe/Paris]") + +@Tag(name = "user", description = "the user API") +public interface UserApi { + + /** + * Gets delegate. + * + * @return the delegate + */ + default UserApiDelegate getDelegate() { + return new UserApiDelegate() { + }; + } + + /** + * Create user response entity. + * + * @param user the user + * @return the response entity + */ + @Operation(summary = "Create user", tags = { "user" }) + @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "successful operation") }) + @PostMapping(value = "/user", consumes = { "application/json" }) + default ResponseEntity createUser( + @io.swagger.v3.oas.annotations.parameters.RequestBody(description = "Created user object", required = true) @Valid @RequestBody User user) { + return getDelegate().createUser(user); + } + + /** + * Create users with array input response entity. + * + * @param user the user + * @return the response entity + */ + @Operation(summary = "Creates list of users with given input array", tags = { "user" }) + @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "successful operation") }) + + @PostMapping(value = "/user/createWithArray", consumes = { "application/json" }) + default ResponseEntity createUsersWithArrayInput( + @io.swagger.v3.oas.annotations.parameters.RequestBody(description = "List of user object", required = true) @Valid @RequestBody List user) { + return getDelegate().createUsersWithArrayInput(user); + } + + /** + * Create users with list input response entity. + * + * @param user the user + * @return the response entity + */ + @Operation(summary = "Creates list of users with given input array", tags = { "user" }) + @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "successful operation") }) + @PostMapping(value = "/user/createWithList", consumes = { "application/json" }) + default ResponseEntity createUsersWithListInput( + @io.swagger.v3.oas.annotations.parameters.RequestBody(description = "List of user object", required = true) @Valid @RequestBody List user) { + return getDelegate().createUsersWithListInput(user); + } + + /** + * Delete user response entity. + * + * @param username the username + * @return the response entity + */ + @Operation(summary = "Creates list of users with given input array", tags = { "user" }) + @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "successful operation") }) + + @DeleteMapping(value = "/user/{username}") + default ResponseEntity deleteUser( + @io.swagger.v3.oas.annotations.parameters.RequestBody(description = "The name that needs to be deleted", required = true) @PathVariable("username") String username) { + return getDelegate().deleteUser(username); + } + + /** + * Gets user by name. + * + * @param username the username + * @return the user by name + */ + @Operation(summary = "Get user by user name", tags = { "user" }) + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(schema = @Schema(implementation = User.class))), + @ApiResponse(responseCode = "400", description = "Invalid username supplied"), + @ApiResponse(responseCode = "404", description = "User not found") }) + + @GetMapping(value = "/user/{username}", produces = { "application/xml", "application/json" }) + default ResponseEntity getUserByName( + @Parameter(description = "The name that needs to be fetched. Use user1 for testing.", required = true) @PathVariable("username") String username) { + return getDelegate().getUserByName(username); + } + + /** + * Login user response entity. + * + * @param username the username + * @param password the password + * @return the response entity + */ + @Operation(summary = "Logs user into the system", tags = { "user" }) + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "successful operation", content = @Content(schema = @Schema(implementation = String.class))), + @ApiResponse(responseCode = "400", description = "Invalid username/password supplied") }) + @GetMapping(value = "/user/login", produces = { "application/xml", "application/json" }) + default ResponseEntity loginUser( + @NotNull @Parameter(description = "The user name for login", required = true) @Valid @RequestParam(value = "username", required = true) String username, + @NotNull @Parameter(description = "The password for login in clear text", required = true) @Valid @RequestParam(value = "password", required = true) String password) { + return getDelegate().loginUser(username, password); + } + + /** + * Logout user response entity. + * + * @return the response entity + */ + @Operation(summary = "Logs out current logged in user session", tags = { "user" }) + @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "successful operation") }) + @GetMapping(value = "/user/logout") + default ResponseEntity logoutUser() { + return getDelegate().logoutUser(); + } + + /** + * Update user response entity. + * + * @param username the username + * @param user the user + * @return the response entity + */ + @Operation(summary = "Updated user", tags = { "user" }) + @ApiResponses(value = { @ApiResponse(responseCode = "400", description = "Invalid user supplied"), + @ApiResponse(responseCode = "404", description = "User not found") }) + @PutMapping(value = "/user/{username}", consumes = { "application/json" }) + default ResponseEntity updateUser( + @Parameter(description = "name that need to be deleted", required = true) @PathVariable("username") String username, + @io.swagger.v3.oas.annotations.parameters.RequestBody(description = "Updated user object", required = true) @Valid @RequestBody User user) { + return getDelegate().updateUser(username, user); + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app2/api/UserApiController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app2/api/UserApiController.java new file mode 100644 index 000000000..de5f376fb --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app2/api/UserApiController.java @@ -0,0 +1,70 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app2.api; + +import java.util.Optional; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; + +/** + * The type User api controller. + */ +@jakarta.annotation.Generated(value = "org.springdoc.demo.app2.codegen.languages.SpringCodegen", date = "2019-07-11T00:09:29.839+02:00[Europe/Paris]") + +@Controller +@ResponseBody +@RequestMapping("${openapi.openAPIPetstore.base-path:/}") +class UserApiController implements UserApi { + + /** + * The Delegate. + */ + private final UserApiDelegate delegate; + + /** + * Instantiates a new User api controller. + * + * @param delegate the delegate + */ + public UserApiController(@org.springframework.beans.factory.annotation.Autowired(required = false) UserApiDelegate delegate) { + this.delegate = Optional.ofNullable(delegate).orElse(new UserApiDelegate() { + }); + } + + /** + * Gets delegate. + * + * @return the delegate + */ + @Override + public UserApiDelegate getDelegate() { + return delegate; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app2/api/UserApiDelegate.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app2/api/UserApiDelegate.java new file mode 100644 index 000000000..7cc7e9245 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app2/api/UserApiDelegate.java @@ -0,0 +1,167 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app2.api; + +import java.util.List; +import java.util.Optional; + +import test.org.springdoc.api.v31.app2.model.User; + +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.web.context.request.NativeWebRequest; + +/** + * A delegate to be called by the {@link UserApiController}}. + * Implement this interface with a {@link org.springframework.stereotype.Service} annotated class. + */ +@jakarta.annotation.Generated(value = "org.springdoc.demo.app2.codegen.languages.SpringCodegen", date = "2019-07-11T00:09:29.839+02:00[Europe/Paris]") + +public interface UserApiDelegate { + + /** + * Gets request. + * + * @return the request + */ + default Optional getRequest() { + return Optional.empty(); + } + + /** + * Create user response entity. + * + * @param user the user + * @return the response entity + * @see UserApi#createUser UserApi#createUser + */ + default ResponseEntity createUser(User user) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * Create users with array input response entity. + * + * @param user the user + * @return the response entity + * @see UserApi#createUsersWithArrayInput UserApi#createUsersWithArrayInput + */ + default ResponseEntity createUsersWithArrayInput(List user) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * Create users with list input response entity. + * + * @param user the user + * @return the response entity + * @see UserApi#createUsersWithListInput UserApi#createUsersWithListInput + */ + default ResponseEntity createUsersWithListInput(List user) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * Delete user response entity. + * + * @param username the username + * @return the response entity + * @see UserApi#deleteUser UserApi#deleteUser + */ + default ResponseEntity deleteUser(String username) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * Gets user by name. + * + * @param username the username + * @return the user by name + * @see UserApi#getUserByName UserApi#getUserByName + */ + default ResponseEntity getUserByName(String username) { + getRequest().ifPresent(request -> { + for (MediaType mediaType : MediaType.parseMediaTypes(request.getHeader("Accept"))) { + if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) { + ApiUtil.setExampleResponse(request, "application/json", "{ \"firstName\" : \"firstName\", \"lastName\" : \"lastName\", \"password\" : \"password\", \"userStatus\" : 6, \"phone\" : \"phone\", \"id\" : 0, \"email\" : \"email\", \"username\" : \"username\"}"); + break; + } + if (mediaType.isCompatibleWith(MediaType.valueOf("application/xml"))) { + ApiUtil.setExampleResponse(request, "application/xml", " 123456789 aeiou aeiou aeiou aeiou aeiou aeiou 123"); + break; + } + } + }); + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * Login user response entity. + * + * @param username the username + * @param password the password + * @return the response entity + * @see UserApi#loginUser UserApi#loginUser + */ + default ResponseEntity loginUser(String username, + String password) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * Logout user response entity. + * + * @return the response entity + * @see UserApi#logoutUser UserApi#logoutUser + */ + default ResponseEntity logoutUser() { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + + /** + * Update user response entity. + * + * @param username the username + * @param user the user + * @return the response entity + * @see UserApi#updateUser UserApi#updateUser + */ + default ResponseEntity updateUser(String username, + User user) { + return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED); + + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app2/api/UserApiDelegateImpl.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app2/api/UserApiDelegateImpl.java new file mode 100644 index 000000000..e28deb1ba --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app2/api/UserApiDelegateImpl.java @@ -0,0 +1,38 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app2.api; + +import org.springframework.stereotype.Service; + +/** + * The type User api delegate. + */ +@Service +class UserApiDelegateImpl implements UserApiDelegate { + + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app2/model/Category.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app2/model/Category.java new file mode 100644 index 000000000..2c6d0cf26 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app2/model/Category.java @@ -0,0 +1,134 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app2.model; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The type Category. + */ +class Category { + + /** + * The Id. + */ + private Long id = null; + + /** + * The Name. + */ + private String name = null; + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + * @param o the o + * @return the string + */ + private static String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Get id + * + * @return id id + */ + @JsonProperty("id") + public Long getId() { + return id; + } + + /** + * Sets id. + * + * @param id the id + */ + public void setId(Long id) { + this.id = id; + } + + /** + * Id category. + * + * @param id the id + * @return the category + */ + public Category id(Long id) { + this.id = id; + return this; + } + + /** + * Get name + * + * @return name name + */ + @JsonProperty("name") + public String getName() { + return name; + } + + /** + * Sets name. + * + * @param name the name + */ + public void setName(String name) { + this.name = name; + } + + /** + * Name category. + * + * @param name the name + * @return the category + */ + public Category name(String name) { + this.name = name; + return this; + } + + /** + * To string string. + * + * @return the string + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Category {\n"); + + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append("}"); + return sb.toString(); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app2/model/ModelApiResponse.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app2/model/ModelApiResponse.java new file mode 100644 index 000000000..f90368566 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app2/model/ModelApiResponse.java @@ -0,0 +1,170 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app2.model; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The type Model api response. + */ +public class ModelApiResponse { + + /** + * The Code. + */ + private Integer code = null; + + /** + * The Type. + */ + private String type = null; + + /** + * The Message. + */ + private String message = null; + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + * @param o the o + * @return the string + */ + private static String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Get code + * + * @return code code + */ + @JsonProperty("code") + public Integer getCode() { + return code; + } + + /** + * Sets code. + * + * @param code the code + */ + public void setCode(Integer code) { + this.code = code; + } + + /** + * Code model api response. + * + * @param code the code + * @return the model api response + */ + public ModelApiResponse code(Integer code) { + this.code = code; + return this; + } + + /** + * Get type + * + * @return type type + */ + @JsonProperty("type") + public String getType() { + return type; + } + + /** + * Sets type. + * + * @param type the type + */ + public void setType(String type) { + this.type = type; + } + + /** + * Type model api response. + * + * @param type the type + * @return the model api response + */ + public ModelApiResponse type(String type) { + this.type = type; + return this; + } + + /** + * Get message + * + * @return message message + */ + @JsonProperty("message") + public String getMessage() { + return message; + } + + /** + * Sets message. + * + * @param message the message + */ + public void setMessage(String message) { + this.message = message; + } + + /** + * Message model api response. + * + * @param message the message + * @return the model api response + */ + public ModelApiResponse message(String message) { + this.message = message; + return this; + } + + /** + * To string string. + * + * @return the string + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ModelApiResponse {\n"); + + sb.append(" code: ").append(toIndentedString(code)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" message: ").append(toIndentedString(message)).append("\n"); + sb.append("}"); + return sb.toString(); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app2/model/Order.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app2/model/Order.java new file mode 100644 index 000000000..3a41f1aeb --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app2/model/Order.java @@ -0,0 +1,360 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app2.model; + +import java.util.Date; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.v3.oas.annotations.media.Schema; + +/** + * The type Order. + */ +public class Order { + + /** + * The Id. + */ + @Schema(description = "") + private Long id = null; + + /** + * The Pet id. + */ + @Schema(description = "") + private Long petId = null; + + /** + * The Quantity. + */ + @Schema(description = "") + private Integer quantity = null; + + /** + * The Ship date. + */ + @Schema(description = "") + private Date shipDate = null; + + /** + * Order Status + */ + private StatusEnum status = null; + + /** + * The Complete. + */ + @Schema(description = "") + private Boolean complete = false; + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + * @param o the o + * @return the string + */ + private static String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Get id + * + * @return id id + */ + @JsonProperty("id") + public Long getId() { + return id; + } + + /** + * Sets id. + * + * @param id the id + */ + public void setId(Long id) { + this.id = id; + } + + /** + * Id order. + * + * @param id the id + * @return the order + */ + public Order id(Long id) { + this.id = id; + return this; + } + + /** + * Get petId + * + * @return petId pet id + */ + @JsonProperty("petId") + public Long getPetId() { + return petId; + } + + /** + * Sets pet id. + * + * @param petId the pet id + */ + public void setPetId(Long petId) { + this.petId = petId; + } + + /** + * Pet id order. + * + * @param petId the pet id + * @return the order + */ + public Order petId(Long petId) { + this.petId = petId; + return this; + } + + /** + * Get quantity + * + * @return quantity quantity + */ + @JsonProperty("quantity") + public Integer getQuantity() { + return quantity; + } + + /** + * Sets quantity. + * + * @param quantity the quantity + */ + public void setQuantity(Integer quantity) { + this.quantity = quantity; + } + + /** + * Quantity order. + * + * @param quantity the quantity + * @return the order + */ + public Order quantity(Integer quantity) { + this.quantity = quantity; + return this; + } + + /** + * Get shipDate + * + * @return shipDate ship date + */ + @JsonProperty("shipDate") + public Date getShipDate() { + return shipDate; + } + + /** + * Sets ship date. + * + * @param shipDate the ship date + */ + public void setShipDate(Date shipDate) { + this.shipDate = shipDate; + } + + /** + * Ship date order. + * + * @param shipDate the ship date + * @return the order + */ + public Order shipDate(Date shipDate) { + this.shipDate = shipDate; + return this; + } + + /** + * Order Status + * + * @return status status + */ + @JsonProperty("status") + public String getStatus() { + if (status == null) { + return null; + } + return status.getValue(); + } + + /** + * Sets status. + * + * @param status the status + */ + public void setStatus(StatusEnum status) { + this.status = status; + } + + /** + * Status order. + * + * @param status the status + * @return the order + */ + public Order status(StatusEnum status) { + this.status = status; + return this; + } + + /** + * Get complete + * + * @return complete boolean + */ + @JsonProperty("complete") + public Boolean isisComplete() { + return complete; + } + + /** + * Sets complete. + * + * @param complete the complete + */ + public void setComplete(Boolean complete) { + this.complete = complete; + } + + /** + * Complete order. + * + * @param complete the complete + * @return the order + */ + public Order complete(Boolean complete) { + this.complete = complete; + return this; + } + + + /** + * To string string. + * + * @return the string + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Order {\n"); + + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" petId: ").append(toIndentedString(petId)).append("\n"); + sb.append(" quantity: ").append(toIndentedString(quantity)).append("\n"); + sb.append(" shipDate: ").append(toIndentedString(shipDate)).append("\n"); + sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append(" complete: ").append(toIndentedString(complete)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * The enum Status enum. + */ + public enum StatusEnum { + /** + *Placed status enum. + */ + PLACED("placed"), + /** + *Approved status enum. + */ + APPROVED("approved"), + /** + *Delivered status enum. + */ + DELIVERED("delivered"); + + /** + * The Value. + */ + private String value; + + /** + * Instantiates a new Status enum. + * + * @param value the value + */ + StatusEnum(String value) { + this.value = value; + } + + /** + * From value status enum. + * + * @param text the text + * @return the status enum + */ + @JsonCreator + public static StatusEnum fromValue(String text) { + for (StatusEnum b : StatusEnum.values()) { + if (String.valueOf(b.value).equals(text)) { + return b; + } + } + return null; + } + + /** + * Gets value. + * + * @return the value + */ + @JsonValue + public String getValue() { + return value; + } + + /** + * To string string. + * + * @return the string + */ + @Override + public String toString() { + return String.valueOf(value); + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app2/model/Pet.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app2/model/Pet.java new file mode 100644 index 000000000..f131d6e77 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app2/model/Pet.java @@ -0,0 +1,392 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app2.model; + +import java.util.ArrayList; +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonValue; +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotNull; + +/** + * The type Pet. + */ +public class Pet { + + /** + * The Id. + */ + @Schema(description = "") + private Long id = null; + + /** + * The Category. + */ + @Schema(description = "") + private Category category = null; + + /** + * The Name. + */ + @Schema(example = "doggie", required = true, description = "") + private String name = null; + + /** + * The Photo urls. + */ + @Schema(required = true, description = "") + private List photoUrls = new ArrayList(); + + /** + * The Tags. + */ + @Schema(description = "") + private List tags = null; + + /** + * The Status. + */ + @Schema(description = "pet status in the store") + /** + * pet status in the store + **/ + private StatusEnum status = null; + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + * @param o the o + * @return the string + */ + private static String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Get id + * + * @return id id + */ + @JsonProperty("id") + public Long getId() { + return id; + } + + /** + * Sets id. + * + * @param id the id + */ + public void setId(Long id) { + this.id = id; + } + + /** + * Id pet. + * + * @param id the id + * @return the pet + */ + public Pet id(Long id) { + this.id = id; + return this; + } + + /** + * Get category + * + * @return category category + */ + @JsonProperty("category") + public Category getCategory() { + return category; + } + + /** + * Sets category. + * + * @param category the category + */ + public void setCategory(Category category) { + this.category = category; + } + + /** + * Category pet. + * + * @param category the category + * @return the pet + */ + public Pet category(Category category) { + this.category = category; + return this; + } + + /** + * Get name + * + * @return name name + */ + @JsonProperty("name") + @NotNull + public String getName() { + return name; + } + + /** + * Sets name. + * + * @param name the name + */ + public void setName(String name) { + this.name = name; + } + + /** + * Name pet. + * + * @param name the name + * @return the pet + */ + public Pet name(String name) { + this.name = name; + return this; + } + + /** + * Get photoUrls + * + * @return photoUrls photo urls + */ + @JsonProperty("photoUrls") + @NotNull + public List getPhotoUrls() { + return photoUrls; + } + + /** + * Sets photo urls. + * + * @param photoUrls the photo urls + */ + public void setPhotoUrls(List photoUrls) { + this.photoUrls = photoUrls; + } + + /** + * Photo urls pet. + * + * @param photoUrls the photo urls + * @return the pet + */ + public Pet photoUrls(List photoUrls) { + this.photoUrls = photoUrls; + return this; + } + + /** + * Add photo urls item pet. + * + * @param photoUrlsItem the photo urls item + * @return the pet + */ + public Pet addPhotoUrlsItem(String photoUrlsItem) { + this.photoUrls.add(photoUrlsItem); + return this; + } + + /** + * Get tags + * + * @return tags tags + */ + @JsonProperty("tags") + public List getTags() { + return tags; + } + + /** + * Sets tags. + * + * @param tags the tags + */ + public void setTags(List tags) { + this.tags = tags; + } + + /** + * Tags pet. + * + * @param tags the tags + * @return the pet + */ + public Pet tags(List tags) { + this.tags = tags; + return this; + } + + /** + * Add tags item pet. + * + * @param tagsItem the tags item + * @return the pet + */ + public Pet addTagsItem(Tag tagsItem) { + if (this.tags == null) { + this.tags = new ArrayList<>(); + } + this.tags.add(tagsItem); + return this; + } + + /** + * pet status in the store + * + * @return status status + */ + @JsonProperty("status") + public StatusEnum getStatus() { + if (status == null) { + return null; + } + return status; + } + + /** + * Sets status. + * + * @param status the status + */ + public void setStatus(StatusEnum status) { + this.status = status; + } + + /** + * Status pet. + * + * @param status the status + * @return the pet + */ + public Pet status(StatusEnum status) { + this.status = status; + return this; + } + + /** + * To string string. + * + * @return the string + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Pet {\n"); + + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" category: ").append(toIndentedString(category)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" photoUrls: ").append(toIndentedString(photoUrls)).append("\n"); + sb.append(" tags: ").append(toIndentedString(tags)).append("\n"); + sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * The enum Status enum. + */ + public enum StatusEnum { + /** + *Available status enum. + */ + AVAILABLE("available"), + /** + *Pending status enum. + */ + PENDING("pending"), + /** + *Sold status enum. + */ + SOLD("sold"); + + /** + * The Value. + */ + private String value; + + /** + * Instantiates a new Status enum. + * + * @param value the value + */ + StatusEnum(String value) { + this.value = value; + } + + /** + * From value status enum. + * + * @param text the text + * @return the status enum + */ + @JsonCreator + public static StatusEnum fromValue(String text) { + for (StatusEnum b : StatusEnum.values()) { + if (String.valueOf(b.value).equals(text)) { + return b; + } + } + return null; + } + + /** + * Gets value. + * + * @return the value + */ + @JsonValue + public String getValue() { + return value; + } + + /** + * To string string. + * + * @return the string + */ + @Override + public String toString() { + return String.valueOf(value); + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app2/model/Tag.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app2/model/Tag.java new file mode 100644 index 000000000..b5f3a80ef --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app2/model/Tag.java @@ -0,0 +1,137 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app2.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.v3.oas.annotations.media.Schema; + +/** + * The type Tag. + */ +class Tag { + + /** + * The Id. + */ + @Schema(description = "") + private Long id = null; + + /** + * The Name. + */ + @Schema(description = "") + private String name = null; + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + * @param o the o + * @return the string + */ + private static String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Get id + * + * @return id id + */ + @JsonProperty("id") + public Long getId() { + return id; + } + + /** + * Sets id. + * + * @param id the id + */ + public void setId(Long id) { + this.id = id; + } + + /** + * Id tag. + * + * @param id the id + * @return the tag + */ + public Tag id(Long id) { + this.id = id; + return this; + } + + /** + * Get name + * + * @return name name + */ + @JsonProperty("name") + public String getName() { + return name; + } + + /** + * Sets name. + * + * @param name the name + */ + public void setName(String name) { + this.name = name; + } + + /** + * Name tag. + * + * @param name the name + * @return the tag + */ + public Tag name(String name) { + this.name = name; + return this; + } + + /** + * To string string. + * + * @return the string + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Tag {\n"); + + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append("}"); + return sb.toString(); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app2/model/User.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app2/model/User.java new file mode 100644 index 000000000..ae89052a3 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app2/model/User.java @@ -0,0 +1,358 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app2.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.v3.oas.annotations.media.Schema; + +/** + * The type User. + */ +public class User { + + /** + * The Id. + */ + @Schema(description = "") + private Long id = null; + + /** + * The Username. + */ + @Schema(description = "") + private String username = null; + + /** + * The First name. + */ + @Schema(description = "") + private String firstName = null; + + /** + * The Last name. + */ + @Schema(description = "") + private String lastName = null; + + /** + * The Email. + */ + @Schema(description = "") + private String email = null; + + /** + * The Password. + */ + @Schema(description = "") + private String password = null; + + /** + * The Phone. + */ + @Schema(description = "") + private String phone = null; + + /** + * User Status + */ + private Integer userStatus = null; + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + * @param o the o + * @return the string + */ + private static String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + /** + * Get id + * + * @return id id + */ + @JsonProperty("id") + public Long getId() { + return id; + } + + /** + * Sets id. + * + * @param id the id + */ + public void setId(Long id) { + this.id = id; + } + + /** + * Id user. + * + * @param id the id + * @return the user + */ + public User id(Long id) { + this.id = id; + return this; + } + + /** + * Get username + * + * @return username username + */ + @JsonProperty("username") + public String getUsername() { + return username; + } + + /** + * Sets username. + * + * @param username the username + */ + public void setUsername(String username) { + this.username = username; + } + + /** + * Username user. + * + * @param username the username + * @return the user + */ + public User username(String username) { + this.username = username; + return this; + } + + /** + * Get firstName + * + * @return firstName first name + */ + @JsonProperty("firstName") + public String getFirstName() { + return firstName; + } + + /** + * Sets first name. + * + * @param firstName the first name + */ + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + /** + * First name user. + * + * @param firstName the first name + * @return the user + */ + public User firstName(String firstName) { + this.firstName = firstName; + return this; + } + + /** + * Get lastName + * + * @return lastName last name + */ + @JsonProperty("lastName") + public String getLastName() { + return lastName; + } + + /** + * Sets last name. + * + * @param lastName the last name + */ + public void setLastName(String lastName) { + this.lastName = lastName; + } + + /** + * Last name user. + * + * @param lastName the last name + * @return the user + */ + public User lastName(String lastName) { + this.lastName = lastName; + return this; + } + + /** + * Get email + * + * @return email email + */ + @JsonProperty("email") + public String getEmail() { + return email; + } + + /** + * Sets email. + * + * @param email the email + */ + public void setEmail(String email) { + this.email = email; + } + + /** + * Email user. + * + * @param email the email + * @return the user + */ + public User email(String email) { + this.email = email; + return this; + } + + /** + * Get password + * + * @return password password + */ + @JsonProperty("password") + public String getPassword() { + return password; + } + + /** + * Sets password. + * + * @param password the password + */ + public void setPassword(String password) { + this.password = password; + } + + /** + * Password user. + * + * @param password the password + * @return the user + */ + public User password(String password) { + this.password = password; + return this; + } + + /** + * Get phone + * + * @return phone phone + */ + @JsonProperty("phone") + public String getPhone() { + return phone; + } + + /** + * Sets phone. + * + * @param phone the phone + */ + public void setPhone(String phone) { + this.phone = phone; + } + + /** + * Phone user. + * + * @param phone the phone + * @return the user + */ + public User phone(String phone) { + this.phone = phone; + return this; + } + + /** + * User Status + * + * @return userStatus user status + */ + @JsonProperty("userStatus") + public Integer getUserStatus() { + return userStatus; + } + + /** + * Sets user status. + * + * @param userStatus the user status + */ + public void setUserStatus(Integer userStatus) { + this.userStatus = userStatus; + } + + /** + * User status user. + * + * @param userStatus the user status + * @return the user + */ + public User userStatus(Integer userStatus) { + this.userStatus = userStatus; + return this; + } + + /** + * To string string. + * + * @return the string + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class User {\n"); + + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" username: ").append(toIndentedString(username)).append("\n"); + sb.append(" firstName: ").append(toIndentedString(firstName)).append("\n"); + sb.append(" lastName: ").append(toIndentedString(lastName)).append("\n"); + sb.append(" email: ").append(toIndentedString(email)).append("\n"); + sb.append(" password: ").append(toIndentedString(password)).append("\n"); + sb.append(" phone: ").append(toIndentedString(phone)).append("\n"); + sb.append(" userStatus: ").append(toIndentedString(userStatus)).append("\n"); + sb.append("}"); + return sb.toString(); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app20/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app20/HelloController.java new file mode 100644 index 000000000..8978a9b0d --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app20/HelloController.java @@ -0,0 +1,53 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app20; + +import io.swagger.v3.oas.annotations.Hidden; +import jakarta.validation.Valid; +import jakarta.validation.constraints.NotBlank; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * Persons. + * + * @param name the name + */ + @GetMapping(value = "/persons") + @Hidden + public void persons(@Valid @NotBlank String name) { + + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app20/SpringDocApp20Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app20/SpringDocApp20Test.java new file mode 100644 index 000000000..42680d7ad --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app20/SpringDocApp20Test.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app20; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 20 test. + */ +class SpringDocApp20Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app21/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app21/HelloController.java new file mode 100644 index 000000000..bc7c700a8 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app21/HelloController.java @@ -0,0 +1,64 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app21; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.enums.SecuritySchemeType; +import io.swagger.v3.oas.annotations.security.OAuthFlow; +import io.swagger.v3.oas.annotations.security.OAuthFlows; +import io.swagger.v3.oas.annotations.security.OAuthScope; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.security.SecurityScheme; +import jakarta.validation.Valid; +import jakarta.validation.constraints.NotBlank; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +@SecurityScheme(name = "personstore_auth", type = SecuritySchemeType.OAUTH2, flows = @OAuthFlows(implicit = @OAuthFlow(authorizationUrl = "${springdoc.oAuthFlow.authorizationUrl}", scopes = { + @OAuthScope(name = "write:persons", description = "modify persons in your account"), + @OAuthScope(name = "read:persons", description = "read your persons") }))) +class HelloController { + + /** + * Persons. + * + * @param name the name + */ + @Operation(summary = "Add a new person to the store", description = "", security = { + @SecurityRequirement(name = "personstore_auth", scopes = { "write:persons", "read:persons" }) }, tags = { + "person" }) + @GetMapping(value = "/persons") + public void persons(@Valid @NotBlank String name) { + + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app21/SpringDocApp21Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app21/SpringDocApp21Test.java new file mode 100644 index 000000000..a1b4ed732 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app21/SpringDocApp21Test.java @@ -0,0 +1,45 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app21; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.test.context.TestPropertySource; + +/** + * The type Spring doc app 21 test. + */ +@TestPropertySource(properties = "springdoc.oAuthFlow.authorizationUrl=http://personstore.swagger.io/oauth/dialog") +class SpringDocApp21Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app22/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app22/HelloController.java new file mode 100644 index 000000000..436695a3a --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app22/HelloController.java @@ -0,0 +1,52 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app22; + +import java.util.List; + +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + + /** + * Do get response entity. + * + * @return the response entity + */ + @GetMapping(value = "/persons") + public ResponseEntity>> doGet() { + return null; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app22/PersonDTO.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app22/PersonDTO.java new file mode 100644 index 000000000..788ceaf13 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app22/PersonDTO.java @@ -0,0 +1,120 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app22; + +/** + * The type Person dto. + */ +class PersonDTO { + /** + * The Email. + */ + private String email; + + /** + * The First name. + */ + private String firstName; + + /** + * The Last name. + */ + private String lastName; + + /** + * Instantiates a new Person dto. + */ + public PersonDTO() { + } + + /** + * Instantiates a new Person dto. + * + * @param email the email + * @param firstName the first name + * @param lastName the last name + */ + public PersonDTO(final String email, final String firstName, final String lastName) { + this.email = email; + this.firstName = firstName; + this.lastName = lastName; + } + + /** + * Gets email. + * + * @return the email + */ + public String getEmail() { + return email; + } + + /** + * Sets email. + * + * @param email the email + */ + public void setEmail(final String email) { + this.email = email; + } + + /** + * Gets first name. + * + * @return the first name + */ + public String getFirstName() { + return firstName; + } + + /** + * Sets first name. + * + * @param firstName the first name + */ + public void setFirstName(final String firstName) { + this.firstName = firstName; + } + + /** + * Gets last name. + * + * @return the last name + */ + public String getLastName() { + return lastName; + } + + /** + * Sets last name. + * + * @param lastName the last name + */ + public void setLastName(final String lastName) { + this.lastName = lastName; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app22/SpringDocApp22Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app22/SpringDocApp22Test.java new file mode 100644 index 000000000..7f5028b5a --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app22/SpringDocApp22Test.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app22; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 22 test. + */ +class SpringDocApp22Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app23/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app23/HelloController.java new file mode 100644 index 000000000..dc3eb1225 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app23/HelloController.java @@ -0,0 +1,59 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app23; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.enums.SecuritySchemeIn; +import io.swagger.v3.oas.annotations.enums.SecuritySchemeType; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.security.SecurityScheme; +import jakarta.validation.Valid; +import jakarta.validation.constraints.NotBlank; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +@SecurityScheme(type = SecuritySchemeType.APIKEY, in = SecuritySchemeIn.HEADER, name = "Authorization", paramName = "JWT", description = "A core-auth Bearer token") +class HelloController { + + /** + * Persons. + * + * @param name the name + */ + @Operation(summary = "Add a new person to the store", description = "", security = { + @SecurityRequirement(name = "Authorization") }) + @GetMapping(value = "/persons") + public void persons(@Valid @NotBlank String name) { + + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app23/SpringDocApp23Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app23/SpringDocApp23Test.java new file mode 100644 index 000000000..7fb60a75e --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app23/SpringDocApp23Test.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app23; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 23 test. + */ +class SpringDocApp23Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app24/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app24/HelloController.java new file mode 100644 index 000000000..1adb6ecd7 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app24/HelloController.java @@ -0,0 +1,59 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app24; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.enums.SecuritySchemeIn; +import io.swagger.v3.oas.annotations.enums.SecuritySchemeType; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.security.SecurityScheme; +import jakarta.validation.Valid; +import jakarta.validation.constraints.NotBlank; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +@SecurityScheme(type = SecuritySchemeType.APIKEY, in = SecuritySchemeIn.HEADER, name = "Authorization", description = "A core-auth Bearer token") +class HelloController { + + /** + * Persons. + * + * @param name the name + */ + @Operation(summary = "Add a new person to the store", description = "", security = { + @SecurityRequirement(name = "Authorization") }) + @GetMapping(value = "/persons") + public void persons(@Valid @NotBlank String name) { + + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app24/SpringDocApp24Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app24/SpringDocApp24Test.java new file mode 100644 index 000000000..cf71627c4 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app24/SpringDocApp24Test.java @@ -0,0 +1,37 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app24; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +/** + * The type Spring doc app 24 test. + */ +class SpringDocApp24Test extends AbstractSpringDocTest { + + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app24/SpringDocTestApp.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app24/SpringDocTestApp.java new file mode 100644 index 000000000..ba0cb7c28 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app24/SpringDocTestApp.java @@ -0,0 +1,77 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app24; + +import io.swagger.v3.oas.models.Components; +import io.swagger.v3.oas.models.OpenAPI; +import io.swagger.v3.oas.models.headers.Header; +import io.swagger.v3.oas.models.info.Info; +import io.swagger.v3.oas.models.info.License; +import io.swagger.v3.oas.models.media.StringSchema; +import io.swagger.v3.oas.models.parameters.Parameter; +import io.swagger.v3.oas.models.security.SecurityScheme; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; + +/** + * The type Spring doc test app. + */ +@SpringBootApplication +class SpringDocTestApp { + + /** + * The entry point of application. + * + * @param args the input arguments + */ + public static void main(String[] args) { + SpringApplication.run(SpringDocTestApp.class, args); + } + + /** + * Custom open api open api. + * + * @return the open api + */ + @Bean + public OpenAPI customOpenAPI() { + return new OpenAPI() + .components(new Components() + .addSecuritySchemes("basicScheme", + new SecurityScheme().type(SecurityScheme.Type.HTTP).scheme("basic")) + .addParameters("myHeader1", + new Parameter().in("header").schema(new StringSchema()).name("myHeader1")) + .addHeaders("myHeader2", + new Header().description("myHeader2 header").schema(new StringSchema()))) + .info(new Info().title("Petstore API").version("v0").description( + "This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.") + .termsOfService("http://swagger.io/terms/") + .license(new License().name("Apache 2.0").url("http://springdoc.org"))); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app25/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app25/HelloController.java new file mode 100644 index 000000000..3de3fd55f --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app25/HelloController.java @@ -0,0 +1,109 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app25; + +import java.time.Instant; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.enums.ParameterIn; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; + +import org.springframework.http.HttpStatus; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.ResponseStatus; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * Check. + */ + @GetMapping(value = "/check") + @ResponseStatus(HttpStatus.OK) + void check() { + } + + /** + * List. + * + * @param trackerId the tracker id + * @param startDate the start date + * @param endDate the end date + */ + @GetMapping(value = "/list/{trackerId}") + void list( + + @Parameter(name = "trackerId", in = ParameterIn.PATH, required = true, schema = @Schema(type = "string", example = "the-tracker-id")) @PathVariable String trackerId, + @Parameter(name = "start", in = ParameterIn.QUERY, required = false, schema = @Schema(type = "string", format = "date-time", required = false, example = "1970-01-01T00:00:00.000Z")) @RequestParam(value = "start", required = false) Instant startDate, + @Parameter(name = "end", in = ParameterIn.QUERY, required = false, schema = @Schema(type = "string", format = "date-time", required = false, example = "1970-01-01T00:10:00.000Z")) @RequestParam(value = "end", required = false) Instant endDate) { + } + + /** + * Secondlist. + * + * @param trackerId the tracker id + * @param startDate the start date + * @param endDate the end date + */ + @GetMapping(value = "/secondlist/{trackerId}") + void secondlist( + @Parameter(name = "trackerId", in = ParameterIn.PATH, required = true, schema = @Schema(type = "string", example = "the-tracker-id")) @PathVariable String trackerId, + @Parameter(name = "start", in = ParameterIn.QUERY, required = false, schema = @Schema(type = "string", format = "date-time", required = false, example = "1970-01-01T00:00:00.000Z")) @RequestParam(value = "start", required = false) Instant startDate, + @Parameter(name = "end", in = ParameterIn.QUERY, required = false, schema = @Schema(type = "string", format = "date-time", required = false, example = "1970-01-01T00:10:00.000Z")) @RequestParam(value = "end", required = false) Instant endDate) { + + } + + /** + * Third list. + * + * @param trackerId the tracker id + * @param start the start + * @param end the end + * @param limit the limit + */ + @Operation(description = "Get last data from a tracker", parameters = { + @Parameter(name = "trackerId", in = ParameterIn.PATH, required = true, schema = @Schema(type = "string", example = "the-tracker-id")), + @Parameter(name = "start", in = ParameterIn.QUERY, required = false, schema = @Schema(type = "string", format = "date-time", required = false, example = "1970-01-01T00:00:00.000Z")), + @Parameter(name = "end", in = ParameterIn.QUERY, required = false, schema = @Schema(type = "string", format = "date-time", required = false, example = "1970-01-01T00:10:00.000Z")), + @Parameter(name = "limit", in = ParameterIn.QUERY, required = false, schema = @Schema(type = "number", required = false, example = "10")) }, responses = { + @ApiResponse(responseCode = "200") }) + + @GetMapping(value = "/values/{trackerId}/data") + void thirdList(@PathVariable String trackerId, @RequestParam(value = "start", required = false) Instant start, + @RequestParam(value = "end", required = false) Instant end, + @RequestParam(value = "limit", required = false) Integer limit) { + + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app25/SpringDocApp25Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app25/SpringDocApp25Test.java new file mode 100644 index 000000000..55ddeee1e --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app25/SpringDocApp25Test.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app25; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 25 test. + */ +class SpringDocApp25Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app26/Bar.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app26/Bar.java new file mode 100644 index 000000000..380124398 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app26/Bar.java @@ -0,0 +1,56 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app26; + +/** + * The type Bar. + */ +class Bar { + /** + * The Bar. + */ + private String bar; + + /** + * Gets bar. + * + * @return the bar + */ + public String getBar() { + return bar; + } + + /** + * Sets bar. + * + * @param bar the bar + */ + public void setBar(String bar) { + this.bar = bar; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app26/Foo.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app26/Foo.java new file mode 100644 index 000000000..67ea50630 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app26/Foo.java @@ -0,0 +1,57 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app26; + +/** + * The type Foo. + */ +class Foo { + + /** + * The Foo. + */ + private String foo; + + /** + * Gets foo. + * + * @return the foo + */ + public String getFoo() { + return foo; + } + + /** + * Sets foo. + * + * @param foo the foo + */ + public void setFoo(String foo) { + this.foo = foo; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app26/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app26/HelloController.java new file mode 100644 index 000000000..8fb5d7ec4 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app26/HelloController.java @@ -0,0 +1,49 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app26; + +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * Persons my model. + * + * @param myModel the my model + * @return the my model + */ + @PostMapping(value = "/persons") + public MyModel persons(MyModel myModel) { + return new MyModel(); + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app26/MyModel.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app26/MyModel.java new file mode 100644 index 000000000..3ce6f8bd5 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app26/MyModel.java @@ -0,0 +1,59 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app26; + +import io.swagger.v3.oas.annotations.media.Schema; + +/** + * The type My model. + */ +class MyModel { + + /** + * The Thing. + */ + @Schema(description = "Hello", type = "object", oneOf = { Foo.class, Bar.class }) + private Object thing; + + /** + * Gets thing. + * + * @return the thing + */ + public Object getThing() { + return thing; + } + + /** + * Sets thing. + * + * @param thing the thing + */ + public void setThing(Object thing) { + this.thing = thing; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app26/SpringDocApp26Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app26/SpringDocApp26Test.java new file mode 100644 index 000000000..1cc622d7b --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app26/SpringDocApp26Test.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app26; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 26 test. + */ +class SpringDocApp26Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app27/Advice.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app27/Advice.java new file mode 100644 index 000000000..e7a4309a2 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app27/Advice.java @@ -0,0 +1,82 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app27; + +import io.swagger.v3.oas.annotations.Hidden; + +import org.springframework.http.HttpStatus; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.ResponseStatus; +import org.springframework.web.bind.annotation.RestControllerAdvice; +import org.springframework.web.context.request.WebRequest; + +/** + * The type Advice. + */ +@RestControllerAdvice +class Advice { + + /** + * Handle exception foo. + * + * @param ex the ex + * @param request the request + * @return the foo + */ + @ExceptionHandler(Exception.class) + @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR) + public Foo handleException(Exception ex, WebRequest request) { + return new Foo(); + } + + /** + * Handle my exception bar. + * + * @param ex the ex + * @param request the request + * @return the bar + */ + @ExceptionHandler(MyException.class) + @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR) + public Bar handleMyException(MyException ex, WebRequest request) { + return new Bar(); + } + + /** + * Handle my exception 2 bar. + * + * @param ex the ex + * @param request the request + * @return the bar + */ + @Hidden + @ExceptionHandler(Throwable.class) + @ResponseStatus(HttpStatus.NOT_FOUND) + public Bar handleMyException2(MyException ex, WebRequest request) { + return new Bar(); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app27/Bar.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app27/Bar.java new file mode 100644 index 000000000..373ed987e --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app27/Bar.java @@ -0,0 +1,37 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app27; + +/** + * The type Bar. + */ +class Bar { + /** + * The Bar. + */ + public String bar = "bar"; +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app27/Foo.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app27/Foo.java new file mode 100644 index 000000000..e529033ed --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app27/Foo.java @@ -0,0 +1,37 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app27; + +/** + * The type Foo. + */ +class Foo { + /** + * The Foo. + */ + public String foo = "foo"; +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app27/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app27/HelloController.java new file mode 100644 index 000000000..14bcfc64f --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app27/HelloController.java @@ -0,0 +1,65 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app27; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * The Flag. + */ + private boolean flag = false; + + /** + * Index string. + * + * @return the string + */ + @RequestMapping("/") + public String index() { + return ""; + } + + /** + * Test string. + * + * @return the string + */ + @GetMapping("/test") + public String test() { + flag = !flag; + throw flag ? new MyException() : new RuntimeException(); + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app27/MyException.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app27/MyException.java new file mode 100644 index 000000000..565f89f70 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app27/MyException.java @@ -0,0 +1,39 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app27; + +/** + * The type My exception. + */ +class MyException extends RuntimeException { + + /** + * The constant serialVersionUID. + */ + private static final long serialVersionUID = 1L; + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app27/SpringDocApp27Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app27/SpringDocApp27Test.java new file mode 100644 index 000000000..270ef4af5 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app27/SpringDocApp27Test.java @@ -0,0 +1,63 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app27; + +import org.junit.jupiter.api.Test; +import org.springdoc.core.utils.Constants; +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +import static org.hamcrest.Matchers.containsInAnyOrder; +import static org.hamcrest.Matchers.is; +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; + +/** + * The type Spring doc app 27 test. + */ +class SpringDocApp27Test extends AbstractSpringDocTest { + + /** + * Test app. + * + * @throws Exception the exception + */ + @Test + protected void testApp() throws Exception { + mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL)).andExpect(status().isOk()) + .andExpect(jsonPath("$.openapi", is("3.1.0"))).andExpect(jsonPath("$.paths./test.get.responses.500.content.['*/*'].schema.oneOf").isArray()).andExpect(jsonPath("$.paths./test.get.responses.500.content.['*/*'].schema.oneOf[*].$ref", containsInAnyOrder("#/components/schemas/Bar", + "#/components/schemas/Foo"))); + } + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app28/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app28/HelloController.java new file mode 100644 index 000000000..b781ecce0 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app28/HelloController.java @@ -0,0 +1,52 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app28; + +import org.springframework.http.MediaType; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.multipart.MultipartFile; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * Upload 2 string. + * + * @param one the one + * @param two the two + * @return the string + */ + @PostMapping(value = "/upload2", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) + public String upload2(@RequestPart("one") MultipartFile one, @RequestPart("two") MultipartFile two) { + return "Ok"; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app28/SpringDocApp28Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app28/SpringDocApp28Test.java new file mode 100644 index 000000000..330f4dd78 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app28/SpringDocApp28Test.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app28; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 28 test. + */ +class SpringDocApp28Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app29/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app29/HelloController.java new file mode 100644 index 000000000..554764b72 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app29/HelloController.java @@ -0,0 +1,62 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app29; + +import java.util.List; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.media.ArraySchema; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.parameters.RequestBody; +import io.swagger.v3.oas.annotations.responses.ApiResponse; + +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * Post entity list. + * + * @param postEntity the post entity + * @return the list + */ + @PostMapping(value = "/post-entity") + @Operation(description = "Post entity", + requestBody = @RequestBody(content = @Content(mediaType = "application/json", schema = @Schema(implementation = TrackerData.class))), + responses = + { @ApiResponse(responseCode = "200", content = @Content(mediaType = "application/json", array = @ArraySchema(schema = @Schema(implementation = TrackerData.class)))) }) + List postEntity(@RequestBody TrackerData postEntity) { + return null; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app29/SpringDocApp29Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app29/SpringDocApp29Test.java new file mode 100644 index 000000000..c0b1381fe --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app29/SpringDocApp29Test.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app29; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 29 test. + */ +class SpringDocApp29Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app29/TrackerData.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app29/TrackerData.java new file mode 100644 index 000000000..e76eeb89c --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app29/TrackerData.java @@ -0,0 +1,61 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app29; + +import java.time.Instant; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.v3.oas.annotations.media.Schema; + +/** + * The type Tracker data. + */ +@Schema(name = "TrackerData") +class TrackerData { + + /** + * The Tracker id. + */ + @Schema(name = "trackerId", type = "string", required = true, example = "the-tracker-id") + @JsonProperty("trackerId") + String trackerId; + + /** + * The Timestamp. + */ + @Schema(name = "timestamp", type = "string", format = "date-time", required = true, example = "2018-01-01T00:00:00Z") + @JsonProperty("timestamp") + Instant timestamp; + + /** + * The Value. + */ + @Schema(name = "value", type = "number", format = "double", description = "The data value", required = true, example = "19.0") + @JsonProperty("value") + Double value; + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app3/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app3/HelloController.java new file mode 100644 index 000000000..b27de8ee1 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app3/HelloController.java @@ -0,0 +1,52 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app3; + +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * Echo playing card. + * + * @param card the card baby + * @param toto the toto baby + * @return the playing card baby + */ + @PostMapping + public PersonDTO echo(@RequestBody PlayingCard card, @RequestParam String toto) { + return null; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app3/PersonDTO.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app3/PersonDTO.java new file mode 100644 index 000000000..961d50fad --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app3/PersonDTO.java @@ -0,0 +1,121 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app3; + +/** + * The type Person dto. + */ +class PersonDTO { + + /** + * The email + */ + private String email; + + /** + * The firstName + */ + private String firstName; + + /** + * The lastName + */ + private String lastName; + + /** + * Instantiates a new Person dto. + */ + public PersonDTO() { + } + + /** + * Instantiates a new Person dto. + * + * @param email the email + * @param firstName the first name + * @param lastName the last name + */ + public PersonDTO(final String email, final String firstName, final String lastName) { + this.email = email; + this.firstName = firstName; + this.lastName = lastName; + } + + /** + * Gets email. + * + * @return the email + */ + public String getEmail() { + return email; + } + + /** + * Sets email. + * + * @param email the email + */ + public void setEmail(final String email) { + this.email = email; + } + + /** + * Gets first name. + * + * @return the first name + */ + public String getFirstName() { + return firstName; + } + + /** + * Sets first name. + * + * @param firstName the first name + */ + public void setFirstName(final String firstName) { + this.firstName = firstName; + } + + /** + * Gets last name. + * + * @return the last name + */ + public String getLastName() { + return lastName; + } + + /** + * Sets last name. + * + * @param lastName the last name + */ + public void setLastName(final String lastName) { + this.lastName = lastName; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app3/PlayingCard.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app3/PlayingCard.java new file mode 100644 index 000000000..ed40e6d9c --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app3/PlayingCard.java @@ -0,0 +1,151 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app3; + +import java.util.Date; + +import com.fasterxml.jackson.annotation.JsonValue; + +/** + * The type Playing card. + */ +class PlayingCard { + /** + * The Suit. + */ + private Suit suit; + + /** + * The Value. + */ + private Integer value; + + /** + * The Toto. + */ + private Date toto; + + /** + * Gets toto. + * + * @return the toto + */ + public Date getToto() { + return toto; + } + + /** + * Sets toto. + * + * @param toto the toto + */ + public void setToto(Date toto) { + this.toto = toto; + } + + /** + * Gets suit. + * + * @return the suit + */ + public Suit getSuit() { + return suit; + } + + /** + * Sets suit. + * + * @param suit the suit + */ + public void setSuit(Suit suit) { + this.suit = suit; + } + + /** + * Gets value. + * + * @return the value + */ + public Integer getValue() { + return value; + } + + /** + * Sets value. + * + * @param value the value + */ + public void setValue(Integer value) { + this.value = value; + } + + /** + * The enum Suit. + */ + public enum Suit { + /** + *Hearts suit. + */ + HEARTS("Hearts"), + /** + *Diamonds suit. + */ + DIAMONDS("Diamonds"), + /** + *Clubs suit. + */ + CLUBS("Clubs"), + /** + *Spades suit. + */ + SPADES("Spades"); + + /** + * The Json value. + */ + private final String jsonValue; + + /** + * Instantiates a new Suit. + * + * @param jsonValue the json value + */ + Suit(String jsonValue) { + this.jsonValue = jsonValue; + } + + /** + * Gets json value. + * + * @return the json value + */ + @JsonValue + public String getJsonValue() { + return jsonValue; + } + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app3/SpringDocApp3Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app3/SpringDocApp3Test.java new file mode 100644 index 000000000..9019092bc --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app3/SpringDocApp3Test.java @@ -0,0 +1,42 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app3; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 3 test. + */ +class SpringDocApp3Test extends AbstractSpringDocTest { + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app30/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app30/HelloController.java new file mode 100644 index 000000000..01b850cb6 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app30/HelloController.java @@ -0,0 +1,51 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app30; + +import org.springframework.http.MediaType; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * Echo string. + * + * @param text the text + * @return the string + */ + @GetMapping(produces = MediaType.TEXT_PLAIN_VALUE, path = "/test") + public String echo(@RequestParam(name = "text", defaultValue = "Hello, World!") String text) { + return text; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app30/SpringDocApp30Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app30/SpringDocApp30Test.java new file mode 100644 index 000000000..880ea67c9 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app30/SpringDocApp30Test.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app30; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 30 test. + */ +class SpringDocApp30Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app31/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app31/HelloController.java new file mode 100644 index 000000000..30586d903 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app31/HelloController.java @@ -0,0 +1,99 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app31; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.callbacks.Callback; +import io.swagger.v3.oas.annotations.enums.ParameterIn; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; + +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestHeader; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * Subscribe subscription response. + * + * @param token the token + * @param url the url + * @return the subscription response + */ + @PostMapping("/test") + @Callback(callbackUrlExpression = "http://$request.query.url", name = "subscription", operation = { + @Operation(method = "post", description = "payload data will be sent", parameters = { + @Parameter(in = ParameterIn.PATH, name = "subscriptionId", required = true, schema = @Schema(type = "string", format = "uuid", description = "the generated UUID", accessMode = Schema.AccessMode.READ_ONLY)) }, responses = { + @ApiResponse(responseCode = "200", description = "Return this code if the callback was received and processed successfully"), + @ApiResponse(responseCode = "205", description = "Return this code to unsubscribe from future data updates"), + @ApiResponse(responseCode = "default", description = "All other response codes will disable this callback subscription") }) }) + @Operation(description = "subscribes a client to updates relevant to the requestor's account, as " + + "identified by the input token. The supplied url will be used as the delivery address for response payloads") + public SubscriptionResponse subscribe(@Schema(required = true, description = "the authentication token " + + "provided after initially authenticating to the application") @RequestHeader("x-auth-token") String token, + @Schema(required = true, description = "the URL to call with response " + + "data") @RequestParam("url") String url) { + return null; + } + + /** + * The type Subscription response. + */ + static class SubscriptionResponse { + /** + * The Subscription uuid. + */ + private String subscriptionUuid; + + /** + * Gets subscription uuid. + * + * @return the subscription uuid + */ + public String getSubscriptionUuid() { + return subscriptionUuid; + } + + /** + * Sets subscription uuid. + * + * @param subscriptionUuid the subscription uuid + */ + public void setSubscriptionUuid(String subscriptionUuid) { + this.subscriptionUuid = subscriptionUuid; + } + + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app31/SpringDocApp31Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app31/SpringDocApp31Test.java new file mode 100644 index 000000000..8c7ad8400 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app31/SpringDocApp31Test.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app31; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 31 test. + */ +class SpringDocApp31Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app32/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app32/HelloController.java new file mode 100644 index 000000000..f8f970d68 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app32/HelloController.java @@ -0,0 +1,75 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app32; + +import io.swagger.v3.oas.annotations.parameters.RequestBody; + +import org.springframework.http.HttpStatus; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.ResponseStatus; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * Filter post string. + * + * @param filter the filter + * @return the string + */ + @RequestMapping(value = "/filter", method = RequestMethod.POST) + @ResponseStatus(value = HttpStatus.OK) + public String filterPost(@RequestBody final MyTestDto filter) { + return "OK"; + } + + /** + * The type My test dto. + */ + class MyTestDto { + /** + * The Object 1. + */ + public String object1; + + /** + * The Object 2. + */ + public String object2; + + /** + * The Object 3. + */ + public String object3; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app32/SpringDocApp32Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app32/SpringDocApp32Test.java new file mode 100644 index 000000000..7fe71b1bb --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app32/SpringDocApp32Test.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app32; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 32 test. + */ +class SpringDocApp32Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app33/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app33/HelloController.java new file mode 100644 index 000000000..20e91c3fc --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app33/HelloController.java @@ -0,0 +1,56 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app33; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.responses.ApiResponse; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + * + * @param the type parameter + */ +@RestController +class HelloController { + + /** + * Index t. + * + * @param numTel the num tel + * @param adresse the adresse + * @return the t + */ + @GetMapping(value = "/hello/{numTelco}") + @Operation(summary = "GET Persons", responses = @ApiResponse(responseCode = "418")) + public T index(@PathVariable("numTelco") String numTel, String adresse) { + return null; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app33/SpringDocApp33Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app33/SpringDocApp33Test.java new file mode 100644 index 000000000..de945d6a8 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app33/SpringDocApp33Test.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app33; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 33 test. + */ +class SpringDocApp33Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app34/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app34/HelloController.java new file mode 100644 index 000000000..0151eeb43 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app34/HelloController.java @@ -0,0 +1,56 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app34; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.responses.ApiResponse; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + * + * @param the type parameter + */ +@RestController +class HelloController { + + /** + * Index t. + * + * @param numTel the num tel + * @param adresse the adresse + * @return the t + */ + @GetMapping(value = "/hello/{numTelco}") + @Operation(summary = "GET Persons", responses = @ApiResponse(responseCode = "418")) + public T index(@PathVariable("numTelco") String numTel, String adresse) { + return null; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app34/MyExceptionHandler.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app34/MyExceptionHandler.java new file mode 100644 index 000000000..b732bb1be --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app34/MyExceptionHandler.java @@ -0,0 +1,66 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app34; + +import io.swagger.v3.oas.annotations.Hidden; + +import org.springframework.http.HttpStatus; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.ResponseStatus; +import org.springframework.web.bind.annotation.RestControllerAdvice; +import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler; + +/** + * The type My exception handler. + */ +@RestControllerAdvice +@Hidden +class MyExceptionHandler extends ResponseEntityExceptionHandler { + /** + * Bad object. + * + * @param e the e + * @return the object + */ + @ExceptionHandler(IllegalArgumentException.class) + @ResponseStatus(HttpStatus.BAD_REQUEST) + public Object bad(IllegalArgumentException e) { + return null; + } + + /** + * Gateway object. + * + * @param e the e + * @return the object + */ + @ExceptionHandler(RuntimeException.class) + @ResponseStatus(HttpStatus.BAD_GATEWAY) + public Object gateway(RuntimeException e) { + return null; + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app34/SpringDocApp34Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app34/SpringDocApp34Test.java new file mode 100644 index 000000000..7350ac83b --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app34/SpringDocApp34Test.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app34; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 34 test. + */ +class SpringDocApp34Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app35/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app35/HelloController.java new file mode 100644 index 000000000..ae49d2967 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app35/HelloController.java @@ -0,0 +1,73 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app35; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; + +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; + +/** + * The type Hello controller. + */ +@Controller +@RequestMapping("/api/v1/poc/") +class HelloController { + + /** + * Testme response entity. + * + * @return the response entity + */ + @Operation(summary = "Get thing", responses = { + @ApiResponse(description = "Successful Operation", responseCode = "200", content = @Content(mediaType = "application/json", schema = @Schema(implementation = String.class))), + @ApiResponse(responseCode = "404", description = "Not found", content = @Content), + @ApiResponse(responseCode = "401", description = "Authentication Failure", content = @Content(schema = @Schema(hidden = true))) }) + @RequestMapping(path = "/testme", method = RequestMethod.GET) + ResponseEntity testme() { + return ResponseEntity.ok("Hello"); + } + + /** + * Test response entity. + * + * @return the response entity + */ + @Operation(summary = "Get thing", responses = { + @ApiResponse(description = "Successful Operation", responseCode = "200", content = @Content(mediaType = "application/json", schema = @Schema(implementation = String.class))), + @ApiResponse(responseCode = "404", description = "Not found", content = @Content(schema = @Schema(hidden = true))), + @ApiResponse(responseCode = "401", description = "Authentication Failure", content = @Content(schema = @Schema(hidden = true))) }) + @RequestMapping(path = "/test", method = RequestMethod.GET) + ResponseEntity test() { + return ResponseEntity.ok("Hello"); + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app35/SpringDocApp35Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app35/SpringDocApp35Test.java new file mode 100644 index 000000000..fced6caca --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app35/SpringDocApp35Test.java @@ -0,0 +1,49 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app35; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +import static org.springdoc.core.utils.SpringDocUtils.getConfig; + +/** + * The type Spring doc app 35 test. + */ +class SpringDocApp35Test extends AbstractSpringDocTest { + + static { + getConfig().addRestControllers(HelloController.class); + } + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app37/Bar.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app37/Bar.java new file mode 100644 index 000000000..918128fec --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app37/Bar.java @@ -0,0 +1,37 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app37; + +/** + * The type Bar. + */ +class Bar { + /** + * The Bar. + */ + public String bar = "bar"; +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app37/Car.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app37/Car.java new file mode 100644 index 000000000..b6619cb90 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app37/Car.java @@ -0,0 +1,38 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app37; + +/** + * The type Car. + */ +class Car { + /** + * The Car. + */ + public String car = "car"; + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app37/Foo.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app37/Foo.java new file mode 100644 index 000000000..6c2032280 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app37/Foo.java @@ -0,0 +1,37 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app37; + +/** + * The type Foo. + */ +class Foo { + /** + * The Foo. + */ + public String foo = "foo"; +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app37/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app37/HelloController.java new file mode 100644 index 000000000..9ebaee7bd --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app37/HelloController.java @@ -0,0 +1,99 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app37; + +import io.swagger.v3.oas.annotations.parameters.RequestBody; +import jakarta.validation.Valid; + +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController("/api") +class HelloController { + + /** + * Process foo. + * + * @param a the a + * @return the foo + */ + @PostMapping(path = "/bar/baz", consumes = "application/x.a+json", produces = MediaType.TEXT_PLAIN_VALUE) + public Foo process(@RequestBody Foo a) { + return a; + } + + /** + * Process bar. + * + * @param b the b + * @return the bar + */ + @PostMapping(path = "/bar/baz", consumes = "application/x.b+json", produces = MediaType.TEXT_PLAIN_VALUE) + public Bar process(@RequestBody Bar b) { + return b; + } + + /** + * Process car. + * + * @param c the c + * @return the car + */ + @PostMapping(path = "/bar/baz", consumes = "application/x.c+json", produces = MediaType.APPLICATION_JSON_VALUE) + public Car process(@RequestBody Car c) { + return c; + } + + + /** + * Pets post response entity. + * + * @param pet the pet + * @return the response entity + */ + @PostMapping(value = "/pets1", consumes = "text/plain") + public ResponseEntity petsPost1(@Valid @RequestBody String pet) { + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); + } + + /** + * Pets post response entity. + * + * @param pet the pet + * @return the response entity + */ + @PostMapping(value = "/pets2", consumes = "application/json") + public ResponseEntity petsPost2(@Valid @RequestBody Pet pet) { + return new ResponseEntity(HttpStatus.NOT_IMPLEMENTED); + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app37/Pet.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app37/Pet.java new file mode 100644 index 000000000..a850b0449 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app37/Pet.java @@ -0,0 +1,38 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app37; + +/** + * The type Pet. + */ +class Pet { + /** + * The Pet. + */ + public String pet = "pet"; + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app37/SpringDocApp37Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app37/SpringDocApp37Test.java new file mode 100644 index 000000000..7becb66d9 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app37/SpringDocApp37Test.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app37; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 37 test. + */ +class SpringDocApp37Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app38/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app38/HelloController.java new file mode 100644 index 000000000..aeb946bb5 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app38/HelloController.java @@ -0,0 +1,51 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app38; + +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController("/api") +class HelloController { + + /** + * Gets model resource. + * + * @return the model resource + */ + @RequestMapping(value = "/npe_error", method = RequestMethod.GET) + public ResponseEntity getModelResource() { + return new ResponseEntity<>(new byte[0], HttpStatus.OK); + } + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app38/SpringDocApp38Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app38/SpringDocApp38Test.java new file mode 100644 index 000000000..868f68d93 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app38/SpringDocApp38Test.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app38; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 38 test. + */ +class SpringDocApp38Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app39/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app39/HelloController.java new file mode 100644 index 000000000..53331dcf8 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app39/HelloController.java @@ -0,0 +1,64 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app39; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.parameters.RequestBody; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * Search employee. + * + * @param test the test + */ + @Operation(summary = "test Request") + @RequestBody(description = "test value", required = true, content = @Content(schema = @Schema(implementation = String.class))) + @PostMapping("/test") + public void searchEmployee(String test) { + } + + /** + * Hello string. + * + * @return the string + */ + @GetMapping("/hello") + public String hello() { + return "hello"; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app39/SpringDocApp39Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app39/SpringDocApp39Test.java new file mode 100644 index 000000000..749a8459f --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app39/SpringDocApp39Test.java @@ -0,0 +1,37 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app39; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +/** + * The type Spring doc app 39 test. + */ +class SpringDocApp39Test extends AbstractSpringDocTest { + + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app39/SpringDocTestApp.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app39/SpringDocTestApp.java new file mode 100644 index 000000000..24d355c1e --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app39/SpringDocTestApp.java @@ -0,0 +1,76 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app39; + +import io.swagger.v3.oas.models.Components; +import io.swagger.v3.oas.models.OpenAPI; +import io.swagger.v3.oas.models.media.StringSchema; +import io.swagger.v3.oas.models.parameters.HeaderParameter; +import org.springdoc.core.customizers.OpenApiCustomizer; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; + +/** + * The type Spring doc test app. + */ +@SpringBootApplication +class SpringDocTestApp { + + /** + * The entry point of application. + * + * @param args the input arguments + */ + public static void main(String[] args) { + SpringApplication.run(SpringDocTestApp.class, args); + } + + /** + * Custom open api open api. + * + * @return the open api + */ + @Bean + public OpenAPI customOpenAPI() { + StringSchema schema = new StringSchema(); + return new OpenAPI() + .components(new Components().addParameters("myGlobalHeader", new HeaderParameter().required(true).name("My-Global-Header").description("My Global Header").schema(schema))); + } + + /** + * Customer global header open api customiser open api customiser. + * + * @return the open api customiser + */ + @Bean + public OpenApiCustomizer customerGlobalHeaderOpenApiCustomizer() { + return openApi -> openApi.getPaths().values().stream().flatMap(pathItem -> pathItem.readOperations().stream()) + .forEach(operation -> operation.addParametersItem(new HeaderParameter().$ref("#/components/parameters/myGlobalHeader"))); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app4/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app4/HelloController.java new file mode 100644 index 000000000..5d6c56414 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app4/HelloController.java @@ -0,0 +1,50 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app4; + +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * List tracker data. + * + * @param toto the toto + * @return the tracker data + */ + @PostMapping(value = "/values/data") + TrackerData list(TrackerData toto) { + return toto; + + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app4/SpringDocApp4Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app4/SpringDocApp4Test.java new file mode 100644 index 000000000..2d1fa8037 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app4/SpringDocApp4Test.java @@ -0,0 +1,55 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app4; + +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; + +/** + * The type Spring doc app 4 test. + */ +@TestPropertySource(properties = "springdoc.use-fqn=true") +class SpringDocApp4Test extends AbstractSpringDocTest { + + /** + * Restore. + */ + @AfterAll + static void restore() { + TypeNameResolver.std.setUseFqn(false); + } + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app4/TrackerData.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app4/TrackerData.java new file mode 100644 index 000000000..206bed595 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app4/TrackerData.java @@ -0,0 +1,60 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app4; + +import java.time.Instant; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.v3.oas.annotations.media.Schema; + +/** + * The type Tracker data. + */ +class TrackerData { + + /** + * The Tracker id. + */ + @Schema(name = "trackerId", type = "string", required = true, example = "the-tracker-id") + @JsonProperty("trackerId") + String trackerId; + + /** + * The Timestamp. + */ + @Schema(name = "timestamp", type = "string", format = "date-time", required = true, example = "2018-01-01T00:00:00Z") + @JsonProperty("timestamp") + Instant timestamp; + + /** + * The Value. + */ + @Schema(name = "value", type = "number", format = "double", description = "The data value", required = true, example = "19.0") + @JsonProperty("value") + Double value; + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app40/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app40/HelloController.java new file mode 100644 index 000000000..b41b528d3 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app40/HelloController.java @@ -0,0 +1,50 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app40; + +import com.fasterxml.jackson.databind.node.ObjectNode; + +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController("/api") +class HelloController { + + /** + * Gets start form properties. + * + * @return the start form properties + */ + @RequestMapping(value = "/iae_error", method = RequestMethod.GET) + public ObjectNode getStartFormProperties() { + return null; + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app40/SpringDocApp40Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app40/SpringDocApp40Test.java new file mode 100644 index 000000000..ceb14ac59 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app40/SpringDocApp40Test.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app40; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 40 test. + */ +class SpringDocApp40Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app41/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app41/HelloController.java new file mode 100644 index 000000000..e7ca6b814 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app41/HelloController.java @@ -0,0 +1,68 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app41; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; +import jakarta.validation.Valid; +import jakarta.validation.constraints.NotNull; + +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController("/api") +class HelloController { + + /** + * Gets file. + * + * @param path the path + * @return the file + */ + @Operation(description = "Download file") + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "File resource", content = @Content(schema = @Schema(implementation = java.io.File.class))), + @ApiResponse(responseCode = "400", description = "Wrong request", content = @Content(schema = @Schema(implementation = Error.class))), + @ApiResponse(responseCode = "500", description = "Unexpected error", content = @Content(schema = @Schema(implementation = Error.class))) }) + @GetMapping(value = "/file", produces = MediaType.APPLICATION_JSON_VALUE) + public ResponseEntity getFile( + @NotNull @Parameter(description = "File path", required = true) @Valid @RequestParam(value = "path") String path) { + return ResponseEntity.status(HttpStatus.NOT_IMPLEMENTED).build(); + } + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app41/SpringDocApp411Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app41/SpringDocApp411Test.java new file mode 100644 index 000000000..a6ad70be7 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app41/SpringDocApp411Test.java @@ -0,0 +1,78 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app41; + +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; + +import org.junit.jupiter.api.Test; +import org.springdoc.core.utils.Constants; +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +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; + +/** + * The type Spring doc app 411 test. + */ +class SpringDocApp411Test extends AbstractSpringDocTest { + + /** + * Test app. + * + * @throws Exception the exception + */ + @Test + protected void testApp() throws Exception { + String className = getClass().getSimpleName(); + String testNumber = className.replaceAll("[^0-9]", ""); + MvcResult mockMvcResult = mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL)).andExpect(status().isOk()) + .andExpect(jsonPath("$.openapi", is("3.1.0"))).andReturn(); + // Test result consistency + mockMvcResult = mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL)).andExpect(status().isOk()) + .andExpect(jsonPath("$.openapi", is("3.1.0"))).andReturn(); + String result = mockMvcResult.getResponse().getContentAsString(); + Path path = Paths.get(getClass().getClassLoader().getResource("results/3.1.0/app41.json").toURI()); + byte[] fileBytes = Files.readAllBytes(path); + String expected = new String(fileBytes); + assertEquals(expected, result, false); + } + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app41/SpringDocApp41Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app41/SpringDocApp41Test.java new file mode 100644 index 000000000..bc43882a1 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app41/SpringDocApp41Test.java @@ -0,0 +1,80 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app41; + +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; + +import org.junit.jupiter.api.Test; +import org.springdoc.core.utils.Constants; +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +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; + +/** + * The type Spring doc app 41 test. + */ +@TestPropertySource(properties = "springdoc.cache.disabled=true") +class SpringDocApp41Test extends AbstractSpringDocTest { + + /** + * Test app. + * + * @throws Exception the exception + */ + @Test + protected void testApp() throws Exception { + String className = getClass().getSimpleName(); + String testNumber = className.replaceAll("[^0-9]", ""); + MvcResult mockMvcResult = mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL)).andExpect(status().isOk()) + .andExpect(jsonPath("$.openapi", is("3.1.0"))).andReturn(); + // Test result consistency + mockMvcResult = mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL)).andExpect(status().isOk()) + .andExpect(jsonPath("$.openapi", is("3.1.0"))).andReturn(); + String result = mockMvcResult.getResponse().getContentAsString(); + Path path = Paths.get(getClass().getClassLoader().getResource("results/3.1.0/app" + testNumber + ".json").toURI()); + byte[] fileBytes = Files.readAllBytes(path); + String expected = new String(fileBytes); + assertEquals(expected, result, false); + } + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app42/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app42/HelloController.java new file mode 100644 index 000000000..70805316a --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app42/HelloController.java @@ -0,0 +1,50 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app42; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RestController; + + +/** + * The type Hello controller. + */ +@RestController("/api") +class HelloController { + + /** + * Tweets. + * + * @param id the id + */ + @GetMapping(value = "/tweets/{id}") + public void tweets(@PathVariable TweetId id) { + + } + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app42/SpringDocApp42Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app42/SpringDocApp42Test.java new file mode 100644 index 000000000..2a6ff46bc --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app42/SpringDocApp42Test.java @@ -0,0 +1,58 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app42; + +import io.swagger.v3.oas.models.Components; +import io.swagger.v3.oas.models.OpenAPI; +import io.swagger.v3.oas.models.media.StringSchema; +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; + +/** + * The type Spring doc app 42 test. + */ +class SpringDocApp42Test extends AbstractSpringDocTest { + + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp { + /** + * Custom open api open api. + * + * @return the open api + */ + @Bean + public OpenAPI customOpenAPI() { + return new OpenAPI().components(new Components().addSchemas("TweetId", new StringSchema())); + } + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app42/TweetId.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app42/TweetId.java new file mode 100644 index 000000000..c8afcde6a --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app42/TweetId.java @@ -0,0 +1,55 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app42; + +/** + * The type Tweet id. + */ +class TweetId { + /** + * The Value. + */ + private final String value; + + /** + * Instantiates a new Tweet id. + * + * @param value the value + */ + public TweetId(String value) { + this.value = value; + } + + /** + * Gets value. + * + * @return the value + */ + public String getValue() { + return value; + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app43/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app43/HelloController.java new file mode 100644 index 000000000..a3b6f2310 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app43/HelloController.java @@ -0,0 +1,54 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app43; + +import java.util.List; + +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.multipart.MultipartFile; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * Upload documents response entity. + * + * @param multipartFiles the multipart files + * @return the response entity + */ + @PostMapping(path = "/documents", consumes = "multipart/form-data") + public ResponseEntity uploadDocuments(@RequestPart("doc") List multipartFiles) { + return null; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app43/SpringDocApp43Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app43/SpringDocApp43Test.java new file mode 100644 index 000000000..4dafc1a19 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app43/SpringDocApp43Test.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app43; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 43 test. + */ +class SpringDocApp43Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app44/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app44/HelloController.java new file mode 100644 index 000000000..47c4dd70f --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app44/HelloController.java @@ -0,0 +1,234 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app44; + +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; + +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController("/api") +class HelloController { + + /** + * Hello response entity. + * + * @param request the request + * @return the response entity + */ + @PostMapping(value = "/helloworld", produces = "application/json", consumes = "application/vnd.v1+json") + @ApiResponses({ + @ApiResponse(responseCode = "200", description = "Successful operation", content = @Content(schema = @Schema(implementation = HelloDTO1.class))), + @ApiResponse(responseCode = "400", description = "Bad name", content = @Content(schema = @Schema(implementation = ErrorDTO.class))) }) + public ResponseEntity hello(@RequestBody RequestV1 request) { + final String name = request.getNameV1(); + if ("error".equalsIgnoreCase(name)) { + return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ErrorDTO("invalid name: " + name)); + } + return ResponseEntity.ok(new HelloDTO1("Greetings from Spring Boot v1! " + name)); + } + + /** + * Hello response entity. + * + * @param request the request + * @return the response entity + */ + @PostMapping(value = "/helloworld", produces = "application/json", consumes = "application/vnd.v2+json") + @ApiResponses({ + @ApiResponse(responseCode = "200", description = "Successful operation", content = @Content(schema = @Schema(implementation = HelloDTO2.class))), + @ApiResponse(responseCode = "400", description = "Bad name", content = @Content(schema = @Schema(implementation = ErrorDTO.class))) }) + public ResponseEntity hello(@RequestBody RequestV2 request) { + final String name = request.getNameV2(); + if ("error".equalsIgnoreCase(name)) { + return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ErrorDTO("invalid name: " + name)); + } + return ResponseEntity.ok(new HelloDTO2("Greetings from Spring Boot v2! " + name)); + } + + /** + * The type Request v 1. + */ + static class RequestV1 { + /** + * The Name v 1. + */ + private String nameV1; + + /** + * Instantiates a new Request v 1. + */ + public RequestV1() { + } + + /** + * Gets name v 1. + * + * @return the name v 1 + */ + public String getNameV1() { + return nameV1; + } + + /** + * Sets name v 1. + * + * @param nameV1 the name v 1 + */ + public void setNameV1(String nameV1) { + this.nameV1 = nameV1; + } + } + + /** + * The type Request v 2. + */ + static class RequestV2 { + /** + * The Name v 2. + */ + private String nameV2; + + /** + * Instantiates a new Request v 2. + */ + public RequestV2() { + } + + /** + * Gets name v 2. + * + * @return the name v 2 + */ + public String getNameV2() { + return nameV2; + } + + /** + * Sets name v 2. + * + * @param nameV2 the name v 2 + */ + public void setNameV2(String nameV2) { + this.nameV2 = nameV2; + } + } + + /** + * The type Hello dto 1. + */ + class HelloDTO1 { + /** + * The Message. + */ + private String message; + + /** + * Instantiates a new Hello dto 1. + * + * @param message the message + */ + public HelloDTO1(String message) { + this.message = message; + } + + /** + * Gets message. + * + * @return the message + */ + public String getMessage() { + return message; + } + } + + /** + * The type Hello dto 2. + */ + class HelloDTO2 { + /** + * The Message. + */ + private String message; + + /** + * Instantiates a new Hello dto 2. + * + * @param message the message + */ + public HelloDTO2(String message) { + this.message = message; + } + + /** + * Gets message. + * + * @return the message + */ + public String getMessage() { + return message; + } + } + + /** + * The type Error dto. + */ + class ErrorDTO { + /** + * The Error message. + */ + private String errorMessage; + + /** + * Instantiates a new Error dto. + * + * @param errorMessage the error message + */ + public ErrorDTO(String errorMessage) { + this.errorMessage = errorMessage; + } + + /** + * Gets error message. + * + * @return the error message + */ + public String getErrorMessage() { + return errorMessage; + } + } + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app44/SpringDocApp44Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app44/SpringDocApp44Test.java new file mode 100644 index 000000000..c3ea040a9 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app44/SpringDocApp44Test.java @@ -0,0 +1,68 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app44; + +import org.junit.jupiter.api.Test; +import org.springdoc.core.utils.Constants; +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +import static org.hamcrest.Matchers.containsInAnyOrder; +import static org.hamcrest.Matchers.is; +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; + +/** + * The type Spring doc app 44 test. + */ +class SpringDocApp44Test extends AbstractSpringDocTest { + + /** + * Test app. + * + * @throws Exception the exception + */ + @Test + protected void testApp() throws Exception { + mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL)).andExpect(status().isOk()) + .andExpect(jsonPath("$.openapi", is("3.1.0"))).andExpect(jsonPath("$.paths./helloworld.post.responses.200.content.['application/json'].schema.oneOf").isArray()).andExpect(jsonPath("$.paths./helloworld.post.responses.200.content.['application/json'].schema.oneOf[*].$ref", containsInAnyOrder("#/components/schemas/HelloDTO2", + "#/components/schemas/HelloDTO1"))) + .andExpect(jsonPath("$.paths./helloworld.post.requestBody.content.['application/vnd.v1+json'].schema.$ref", is("#/components/schemas/RequestV1"))) + .andExpect(jsonPath("$.paths./helloworld.post.requestBody.content.['application/vnd.v2+json'].schema.$ref", is("#/components/schemas/RequestV2"))) + .andExpect(jsonPath("$.paths./helloworld.post.responses.400.content.['application/json'].schema.$ref", is("#/components/schemas/ErrorDTO"))); + + } + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app45/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app45/HelloController.java new file mode 100644 index 000000000..af78a50c9 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app45/HelloController.java @@ -0,0 +1,84 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app45; + +import java.util.Collections; +import java.util.List; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.media.ArraySchema; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.tags.Tag; + +import org.springframework.http.MediaType; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + + +/** + * The type Hello controller. + */ +@Tag(name = "People", description = "Use this resource to serve all requests and initiate all operations related to people") +@RestController +@RequestMapping(value = "/v1/people") +class HelloController { + + + /** + * List list. + * + * @return the list + */ + @Operation(description = "List all persons") + @SecurityRequirement(name = "bearer") + @ApiResponse(responseCode = "200", description = "", content = @Content(array = @ArraySchema(schema = @Schema(implementation = PersonDTO.class)))) + @GetMapping(path = "/list", consumes = MediaType.ALL_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) + public List list() { + PersonDTO person = new PersonDTO(); + person.setFirstName("Nass"); + return Collections.singletonList(person); + } + + /** + * List two list. + * + * @return the list + */ + @Operation(description = "List all persons") + @ApiResponse(responseCode = "200", description = "", content = @Content(array = @ArraySchema(schema = @Schema(implementation = PersonDTO.class)))) + @GetMapping(path = "/listTwo", consumes = MediaType.ALL_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) + public List listTwo() { + PersonDTO person = new PersonDTO(); + person.setFirstName("Nass"); + return Collections.singletonList(person); + } + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app45/HelloController2.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app45/HelloController2.java new file mode 100644 index 000000000..f3fd8b513 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app45/HelloController2.java @@ -0,0 +1,84 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app45; + +import java.util.Collections; +import java.util.List; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.media.ArraySchema; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.tags.Tag; + +import org.springframework.http.MediaType; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + + +/** + * The type Hello controller 2. + */ +@Tag(name = "People", description = "Use this resource to serve all requests and initiate all operations related to people") +@SecurityRequirement(name = "bearer") +@RestController +@RequestMapping(value = "/v1/people2") +class HelloController2 { + + + /** + * List list. + * + * @return the list + */ + @Operation(description = "List all persons") + @ApiResponse(responseCode = "200", description = "", content = @Content(array = @ArraySchema(schema = @Schema(implementation = PersonDTO.class)))) + @GetMapping(path = "/list", consumes = MediaType.ALL_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) + public List list() { + PersonDTO person = new PersonDTO(); + person.setFirstName("Nass"); + return Collections.singletonList(person); + } + + /** + * List two list. + * + * @return the list + */ + @Operation(description = "List all persons") + @ApiResponse(responseCode = "200", description = "", content = @Content(array = @ArraySchema(schema = @Schema(implementation = PersonDTO.class)))) + @GetMapping(path = "/listTwo", consumes = MediaType.ALL_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) + public List listTwo() { + PersonDTO person = new PersonDTO(); + person.setFirstName("Nass"); + return Collections.singletonList(person); + } + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app45/OpenApiConfig.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app45/OpenApiConfig.java new file mode 100644 index 000000000..d1b5e4b94 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app45/OpenApiConfig.java @@ -0,0 +1,41 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app45; + +import io.swagger.v3.oas.annotations.OpenAPIDefinition; +import io.swagger.v3.oas.annotations.enums.SecuritySchemeType; +import io.swagger.v3.oas.annotations.info.Info; +import io.swagger.v3.oas.annotations.info.License; +import io.swagger.v3.oas.annotations.security.SecurityScheme; + +/** + * The type Open api config. + */ +@OpenAPIDefinition(info = @Info(title = "My App", description = "Some long and useful description", version = "v1", license = @License(name = "Apache 2.0", url = "https://www.apache.org/licenses/LICENSE-2.0"))) +@SecurityScheme(name = "bearer", type = SecuritySchemeType.HTTP, scheme = "bearer", bearerFormat = "JWT") +class OpenApiConfig { +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app45/PersonDTO.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app45/PersonDTO.java new file mode 100644 index 000000000..bd943d434 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app45/PersonDTO.java @@ -0,0 +1,120 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app45; + +/** + * The type Person dto. + */ +class PersonDTO { + /** + * The Email. + */ + private String email; + + /** + * The First name. + */ + private String firstName; + + /** + * The Last name. + */ + private String lastName; + + /** + * Instantiates a new Person dto. + */ + public PersonDTO() { + } + + /** + * Instantiates a new Person dto. + * + * @param email the email + * @param firstName the first name + * @param lastName the last name + */ + public PersonDTO(final String email, final String firstName, final String lastName) { + this.email = email; + this.firstName = firstName; + this.lastName = lastName; + } + + /** + * Gets email. + * + * @return the email + */ + public String getEmail() { + return email; + } + + /** + * Sets email. + * + * @param email the email + */ + public void setEmail(final String email) { + this.email = email; + } + + /** + * Gets first name. + * + * @return the first name + */ + public String getFirstName() { + return firstName; + } + + /** + * Sets first name. + * + * @param firstName the first name + */ + public void setFirstName(final String firstName) { + this.firstName = firstName; + } + + /** + * Gets last name. + * + * @return the last name + */ + public String getLastName() { + return lastName; + } + + /** + * Sets last name. + * + * @param lastName the last name + */ + public void setLastName(final String lastName) { + this.lastName = lastName; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app45/SpringDocApp45Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app45/SpringDocApp45Test.java new file mode 100644 index 000000000..98c7355a0 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app45/SpringDocApp45Test.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app45; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 45 test. + */ +class SpringDocApp45Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app46/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app46/HelloController.java new file mode 100644 index 000000000..9ad99155b --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app46/HelloController.java @@ -0,0 +1,61 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app46; + +import io.swagger.v3.oas.annotations.ExternalDocumentation; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.enums.ParameterIn; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * Persons string. + * + * @param subscriptionId the subscription id + * @return the string + */ + @GetMapping("/persons/{subscriptionId}") + @Operation(operationId = "operationId", summary = "Operation Summary", description = "Operation Description", tags = { + "Example Tag" }, externalDocs = @ExternalDocumentation(description = "External documentation description", url = "http://url.com"), parameters = { + @Parameter(in = ParameterIn.PATH, name = "subscriptionId", required = true, description = "parameter description", allowEmptyValue = true, allowReserved = true, schema = @Schema(type = "string", format = "uuid", description = "the generated UUID", accessMode = Schema.AccessMode.READ_ONLY)) }, responses = { + @ApiResponse(responseCode = "200", description = "voila!", content = @Content(mediaType = "application/json", schema = @Schema(implementation = String.class))) }) + public String persons(String subscriptionId) { + return "OK"; + } + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app46/SpringDocApp46Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app46/SpringDocApp46Test.java new file mode 100644 index 000000000..06490f5a1 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app46/SpringDocApp46Test.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app46; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 46 test. + */ +class SpringDocApp46Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app47/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app47/HelloController.java new file mode 100644 index 000000000..52f79e1bd --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app47/HelloController.java @@ -0,0 +1,55 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app47; + +import java.util.Locale; + +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.media.Schema; + +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + /** + * Gets documents with locale. + * + * @param locale the locale + * @return the documents with locale + */ + @GetMapping(path = "/documents/{locale}") + public ResponseEntity getDocumentsWithLocale( + @Parameter(schema = @Schema(type = "string")) @PathVariable("locale") Locale locale) { + return null; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app47/SpringDocApp47Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app47/SpringDocApp47Test.java new file mode 100644 index 000000000..7882cd709 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app47/SpringDocApp47Test.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app47; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 47 test. + */ +class SpringDocApp47Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app48/AbstractHelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app48/AbstractHelloController.java new file mode 100644 index 000000000..ed8119cb1 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app48/AbstractHelloController.java @@ -0,0 +1,58 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app48; + +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; + +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; + +/** + * The type Abstract hello controller. + */ +@ApiResponse(responseCode = "410") +@ApiResponses({ + @ApiResponse(responseCode = "411") +}) +class AbstractHelloController { + + /** + * Gets documents. + * + * @return the documents + */ + @GetMapping(path = "/documents/{locale}") + @ApiResponse(responseCode = "412") + @ApiResponses({ + @ApiResponse(responseCode = "413") + }) + public ResponseEntity getDocuments() { + return null; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app48/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app48/HelloController.java new file mode 100644 index 000000000..edb352534 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app48/HelloController.java @@ -0,0 +1,61 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app48; + +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; + +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController + +@ApiResponse(responseCode = "400") +@ApiResponses({ + @ApiResponse(responseCode = "401") +}) +class HelloController extends AbstractHelloController { + + /** + * Gets documents. + * + * @return the documents + */ + @Override + @GetMapping(path = "/documents/{locale}") + @ApiResponse(responseCode = "402") + @ApiResponses({ + @ApiResponse(responseCode = "403") + }) + public ResponseEntity getDocuments() { + return null; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app48/SpringDocApp48Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app48/SpringDocApp48Test.java new file mode 100644 index 000000000..0d5db3517 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app48/SpringDocApp48Test.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app48; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 48 test. + */ +class SpringDocApp48Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app49/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app49/HelloController.java new file mode 100644 index 000000000..72442d74d --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app49/HelloController.java @@ -0,0 +1,57 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app49; + +import java.util.List; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; + +import org.springframework.http.MediaType; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * List list. + * + * @return the list + */ + @Operation(description = "Obtain the list of services available in the system") + @ApiResponses({ @ApiResponse(responseCode = "401", ref = "Unauthorized") }) + @GetMapping(value = "/hello", produces = MediaType.APPLICATION_JSON_VALUE) + List list() { + return null; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app49/SpringDocApp49Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app49/SpringDocApp49Test.java new file mode 100644 index 000000000..bafdc085c --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app49/SpringDocApp49Test.java @@ -0,0 +1,37 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app49; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +/** + * The type Spring doc app 49 test. + */ +class SpringDocApp49Test extends AbstractSpringDocTest { + + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app49/SpringDocTestApp.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app49/SpringDocTestApp.java new file mode 100644 index 000000000..2bda19fb3 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app49/SpringDocTestApp.java @@ -0,0 +1,70 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app49; + +import io.swagger.v3.oas.models.Components; +import io.swagger.v3.oas.models.OpenAPI; +import io.swagger.v3.oas.models.media.Content; +import io.swagger.v3.oas.models.media.StringSchema; +import io.swagger.v3.oas.models.responses.ApiResponse; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; +import org.springframework.http.MediaType; + +/** + * The type Spring doc test app. + */ +@SpringBootApplication +class SpringDocTestApp { + + /** + * The entry point of application. + * + * @param args the input arguments + */ + public static void main(String[] args) { + SpringApplication.run(SpringDocTestApp.class, args); + } + + /** + * Define open api open api. + * + * @return the open api + */ + @Bean + public OpenAPI defineOpenApi() { + OpenAPI api = new OpenAPI(); + api.components(new Components().addResponses("Unauthorized", + new ApiResponse().description("Unauthorized") + .content(new Content().addMediaType(MediaType.APPLICATION_JSON_VALUE, + new io.swagger.v3.oas.models.media.MediaType().schema(new StringSchema()))))); + return api; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app5/CustomOpenAPIConfig.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app5/CustomOpenAPIConfig.java new file mode 100644 index 000000000..e1622cd5e --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app5/CustomOpenAPIConfig.java @@ -0,0 +1,51 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app5; + +import io.swagger.v3.oas.models.Components; +import io.swagger.v3.oas.models.OpenAPI; +import io.swagger.v3.oas.models.info.Info; +import io.swagger.v3.oas.models.tags.Tag; + +import org.springframework.context.annotation.Bean; + +/** + * The type Custom open api config. + */ +public class CustomOpenAPIConfig { + /** + * Custom open api open api. + * + * @return the open api + */ + @Bean + public OpenAPI customOpenAPI() { + return new OpenAPI() + .components(new Components()) + .info(new Info().title("Custom API").version("100")).addTagsItem(new Tag().name("mytag")); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app5/sample/OpenAPIResourceBeanConfigurationComponentsSecuritySchemesTest.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app5/sample/OpenAPIResourceBeanConfigurationComponentsSecuritySchemesTest.java new file mode 100644 index 000000000..d960a556c --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app5/sample/OpenAPIResourceBeanConfigurationComponentsSecuritySchemesTest.java @@ -0,0 +1,174 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app5.sample; + +import java.util.ArrayList; + +import io.swagger.v3.oas.models.Components; +import io.swagger.v3.oas.models.OpenAPI; +import io.swagger.v3.oas.models.security.OAuthFlow; +import io.swagger.v3.oas.models.security.OAuthFlows; +import io.swagger.v3.oas.models.security.Scopes; +import io.swagger.v3.oas.models.security.SecurityRequirement; +import io.swagger.v3.oas.models.security.SecurityScheme; +import org.junit.jupiter.api.Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.test.context.TestConfiguration; +import org.springframework.context.annotation.Bean; +import org.springframework.test.context.TestPropertySource; + +import static org.hamcrest.Matchers.is; +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; + +/** + * The type Open api resource bean configuration components security schemes test. + */ +@TestPropertySource(properties = "springdoc.api-docs.path=/api-docs") +class OpenAPIResourceBeanConfigurationComponentsSecuritySchemesTest extends AbstractSpringDocTest { + + /** + * Given: Bean configuration with security scheme http basic (shouldDefineComponentsSecuritySchemesForHttpBasic) + * When: Get api-docs + * Then: Return security definitions http basic + * @throws Exception the exception + */ + @Test + protected void testApp() throws Exception { + mockMvc + .perform(get("/api-docs")) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.security[0].basicScheme", is(new ArrayList()))) + .andExpect(jsonPath("$.components.securitySchemes.basicScheme.type", is("http"))) + .andExpect(jsonPath("$.components.securitySchemes.basicScheme.scheme", is("basic"))) + ; + } + + /** + * Given: Bean configuration with security scheme API key + * When: Get api-docs + * Then: Return security definitions with API key + * @throws Exception the exception + */ + @Test + void shouldDefineComponentsSecuritySchemesForApiKey() throws Exception { + mockMvc + .perform(get("/api-docs")) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.security[1].apiKeyScheme", is(new ArrayList()))) + .andExpect(jsonPath("$.components.securitySchemes.apiKeyScheme.type", is("apiKey"))) + .andExpect(jsonPath("$.components.securitySchemes.apiKeyScheme.in", is("header"))) + ; + } + + /** + * Given: Bean configuration with security scheme OAuth2 + * When: Get api-docs + * Then: Return security definitions with OAuth + * @throws Exception the exception + */ + @Test + void shouldDefineComponentsSecuritySchemesForOAuth2() throws Exception { + mockMvc + .perform(get("/api-docs")) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.security[2].oAuthScheme", is(new ArrayList()))) + .andExpect(jsonPath("$.components.securitySchemes.oAuthScheme.type", is("oauth2"))) + .andExpect(jsonPath("$.components.securitySchemes.oAuthScheme.description", is("This API uses OAuth 2 with the implicit grant flow. [More info](https://api.example.com/docs/auth)"))) + .andExpect(jsonPath("$.components.securitySchemes.oAuthScheme.flows.implicit.authorizationUrl", is("https://api.example.com/oauth2/authorize"))) + .andExpect(jsonPath("$.components.securitySchemes.oAuthScheme.flows.implicit.scopes.read_pets", is("read your pets"))) + .andExpect(jsonPath("$.components.securitySchemes.oAuthScheme.flows.implicit.scopes.write_pets", is("modify pets in your account"))) + ; + } + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} + + /** + * The type Config. + */ + @TestConfiguration + static class Config { + + /** + * Open api open api. + * + * @return the open api + */ + @Bean + public OpenAPI openApi() { + return new OpenAPI() + .components(new Components() + + //HTTP Basic, see: https://swagger.io/docs/specification/authentication/basic-authentication/ + .addSecuritySchemes("basicScheme", new SecurityScheme() + .type(SecurityScheme.Type.HTTP) + .scheme("basic") + ) + + //API Key, see: https://swagger.io/docs/specification/authentication/api-keys/ + .addSecuritySchemes("apiKeyScheme", new SecurityScheme() + .type(SecurityScheme.Type.APIKEY) + .in(SecurityScheme.In.HEADER) + .name("X-API-KEY") + ) + + //OAuth 2.0, see: https://swagger.io/docs/specification/authentication/oauth2/ + .addSecuritySchemes("oAuthScheme", new SecurityScheme() + .type(SecurityScheme.Type.OAUTH2) + .description("This API uses OAuth 2 with the implicit grant flow. [More info](https://api.example.com/docs/auth)") + .flows(new OAuthFlows() + .implicit(new OAuthFlow() + .authorizationUrl("https://api.example.com/oauth2/authorize") + .scopes(new Scopes() + .addString("read_pets", "read your pets") + .addString("write_pets", "modify pets in your account") + ) + ) + ) + ) + ) + .addSecurityItem(new SecurityRequirement() + .addList("basicScheme") + ) + .addSecurityItem(new SecurityRequirement() + .addList("apiKeyScheme") + ) + .addSecurityItem(new SecurityRequirement() + .addList("oAuthScheme") + ) + ; + } + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app5/sample/OpenApiResourceCustomConfigurationTest.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app5/sample/OpenApiResourceCustomConfigurationTest.java new file mode 100644 index 000000000..ad7c317fd --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app5/sample/OpenApiResourceCustomConfigurationTest.java @@ -0,0 +1,73 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app5.sample; + +import org.junit.jupiter.api.Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; +import test.org.springdoc.api.v31.app5.CustomOpenAPIConfig; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Import; +import org.springframework.test.context.TestPropertySource; + +import static org.hamcrest.Matchers.is; +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; + +/** + * The type Open api resource custom configuration test. + */ +@Import(CustomOpenAPIConfig.class) +@TestPropertySource(properties = "springdoc.api-docs.path=/api-docs") +class OpenApiResourceCustomConfigurationTest extends AbstractSpringDocTest { + + /** + * givenNoConfiguration_whenGetApiJson_returnsDefaultEmptyDocs - should return + * {"openapi":"3.1.0","info":{"title":"Custom API","version":"100"},"paths":{},"components":{}} + * @throws Exception the exception + */ + @Test + protected void testApp() throws Exception { + mockMvc + .perform(get("/api-docs")) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.openapi", is("3.1.0"))) + .andExpect(jsonPath("$.info.title", is("Custom API"))) + .andExpect(jsonPath("$.info.version", is("100"))) + .andExpect(jsonPath("$.paths").isEmpty()) + .andExpect(jsonPath("$.components").isEmpty()) + .andExpect(jsonPath("$.tags").isNotEmpty()) + .andExpect(jsonPath("$.tags[0].name", is("mytag"))); + } + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app5/sample/OpenApiResourceNoConfigurationTest.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app5/sample/OpenApiResourceNoConfigurationTest.java new file mode 100644 index 000000000..639f7aa00 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app5/sample/OpenApiResourceNoConfigurationTest.java @@ -0,0 +1,68 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app5.sample; + +import org.junit.jupiter.api.Test; +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.test.context.TestPropertySource; + +import static org.hamcrest.Matchers.is; +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; + +/** + * The type Open api resource no configuration test. + */ +@TestPropertySource(properties = "springdoc.api-docs.path=/api-docs") +class OpenApiResourceNoConfigurationTest extends AbstractSpringDocTest { + + /** + * givenNoConfiguration_whenGetApiJson_returnsDefaultEmptyDocs - should return + * {"openapi":"3.1.0","info":{"title":"OpenAPI definition","version":"v0"},"paths":{},"components":{}} + * @throws Exception the exception + */ + @Test + protected void testApp() throws Exception { + mockMvc + .perform(get("/api-docs")) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.openapi", is("3.1.0"))) + .andExpect(jsonPath("$.info.title", is("OpenAPI definition"))) + .andExpect(jsonPath("$.info.version", is("v0"))) + .andExpect(jsonPath("$.paths").isEmpty()) + .andExpect(jsonPath("$.components").isEmpty()); + } + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app50/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app50/HelloController.java new file mode 100644 index 000000000..1365038ad --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app50/HelloController.java @@ -0,0 +1,56 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app50; + +import java.util.List; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.responses.ApiResponse; + +import org.springframework.http.MediaType; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * List list. + * + * @return the list + */ + @Operation(description = "Some operation", responses = { @ApiResponse(responseCode = "401") }) + //@ApiResponse(responseCode = "401", content = @Content()) + @GetMapping(value = "/hello", produces = MediaType.APPLICATION_JSON_VALUE) + List list() { + return null; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app50/SpringDocApp50Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app50/SpringDocApp50Test.java new file mode 100644 index 000000000..1e77b933d --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app50/SpringDocApp50Test.java @@ -0,0 +1,37 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app50; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +/** + * The type Spring doc app 50 test. + */ +class SpringDocApp50Test extends AbstractSpringDocTest { + + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app50/SpringDocTestApp.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app50/SpringDocTestApp.java new file mode 100644 index 000000000..65c4c4631 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app50/SpringDocTestApp.java @@ -0,0 +1,70 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app50; + +import io.swagger.v3.oas.models.Components; +import io.swagger.v3.oas.models.OpenAPI; +import io.swagger.v3.oas.models.media.Content; +import io.swagger.v3.oas.models.media.StringSchema; +import io.swagger.v3.oas.models.responses.ApiResponse; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; +import org.springframework.http.MediaType; + +/** + * The type Spring doc test app. + */ +@SpringBootApplication +class SpringDocTestApp { + + /** + * The entry point of application. + * + * @param args the input arguments + */ + public static void main(String[] args) { + SpringApplication.run(SpringDocTestApp.class, args); + } + + /** + * Define open api open api. + * + * @return the open api + */ + @Bean + public OpenAPI defineOpenApi() { + OpenAPI api = new OpenAPI(); + api.components(new Components().addResponses("Unauthorized", + new ApiResponse().description("Unauthorized") + .content(new Content().addMediaType(MediaType.APPLICATION_JSON_VALUE, + new io.swagger.v3.oas.models.media.MediaType().schema(new StringSchema()))))); + return api; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app51/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app51/HelloController.java new file mode 100644 index 000000000..c166fe506 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app51/HelloController.java @@ -0,0 +1,115 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app51; + +import java.util.HashMap; +import java.util.Map; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.enums.ParameterIn; +import io.swagger.v3.oas.annotations.media.Schema; + +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * Test 1 string. + * + * @return the string + */ + @Operation(parameters = { + @Parameter(in = ParameterIn.HEADER, name = "test_header", required = true, schema = @Schema(type = "string", example = "rherherherherh")) }) + @GetMapping("/test1") + public String test1() { + return "test"; + } + + /** + * Test 2 string. + * + * @param param1 the param 1 + * @return the string + */ + @Operation(parameters = { + @Parameter(in = ParameterIn.HEADER, name = "test_header", required = true, schema = @Schema(type = "string", example = "rherherherherh")) }) + @GetMapping("/test2") + public String test2(@RequestParam(name = "param1") String param1) { + return "test"; + } + + /** + * Test 3 string. + * + * @param param1 the param 1 + * @return the string + */ + @Operation(parameters = { + @Parameter(in = ParameterIn.HEADER, name = "test_header", required = true, schema = @Schema(type = "string", example = "rherherherherh")), + @Parameter(description = "desc1", in = ParameterIn.QUERY, name = "param1", required = true, schema = @Schema(type = "string", example = "something")) }) + @GetMapping("/test3") + public String test3( + @RequestParam(name = "param1") @Parameter(description = "desc2", in = ParameterIn.QUERY) String param1) { + return "test"; + } + + /** + * Get string. + * + * @param path the path + * @param params the params + * @return the string + */ + @GetMapping("/test/{path}") + public String get( + @PathVariable String path, + @RequestParam(required = false) Map params) { + return null; + } + + /** + * Hello response entity. + * + * @param map the map + * @return the response entity + */ + @PostMapping + public ResponseEntity> hello(@RequestBody HashMap map) { + return ResponseEntity.ok(map); + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app51/SpringDocApp51Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app51/SpringDocApp51Test.java new file mode 100644 index 000000000..0be77d21c --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app51/SpringDocApp51Test.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app51; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 51 test. + */ +class SpringDocApp51Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app52/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app52/HelloController.java new file mode 100644 index 000000000..3034ad0f5 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app52/HelloController.java @@ -0,0 +1,104 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app52; + +import java.util.List; + +import org.springframework.http.MediaType; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.multipart.MultipartFile; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * Create test 1 string. + * + * @param username the username + * @param test the test + * @param imageFile the image file + * @return the string + */ + @PostMapping(value = "/test1/{username}", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) + public String createTest1(@PathVariable String username, @RequestPart("test") MyTestDto test, + @RequestPart("image") MultipartFile imageFile) { + return null; + } + + /** + * Create test 2 string. + * + * @param username the username + * @param imageFile the image file + * @param test the test + * @return the string + */ + @PostMapping(value = "/test2/{username}", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) + public String createTest2(@PathVariable String username, @RequestPart("image") MultipartFile imageFile, + @RequestPart("test") MyTestDto test) { + return null; + } + + /** + * Create test 3 string. + * + * @param test the test + * @param multipartFiles the multipart files + * @return the string + */ + @PostMapping(value = "/test3", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) + public String createTest3(@RequestPart("test") MyTestDto test, + @RequestPart("doc") List multipartFiles) { + return null; + } + + /** + * The type My test dto. + */ + class MyTestDto { + /** + * The Object 1. + */ + public String object1; + + /** + * The Object 2. + */ + public String object2; + + /** + * The Object 3. + */ + public String object3; + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app52/SpringDocApp52Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app52/SpringDocApp52Test.java new file mode 100644 index 000000000..0da503eb2 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app52/SpringDocApp52Test.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app52; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 52 test. + */ +class SpringDocApp52Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app53/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app53/HelloController.java new file mode 100644 index 000000000..2ad6f5a94 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app53/HelloController.java @@ -0,0 +1,155 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app53; + + +import java.util.List; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.responses.ApiResponse; + +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.ResponseStatus; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * List with no api response list. + * + * @return the list + */ + @Operation(description = "Some operation") + @GetMapping(value = "/hello1", produces = MediaType.APPLICATION_JSON_VALUE) + List listWithNoApiResponse() { + return null; + } + + /** + * List with empty api response list. + * + * @return the list + */ + @Operation(description = "Some operation") + @ApiResponse + @GetMapping(value = "/hello2", produces = MediaType.APPLICATION_JSON_VALUE) + List listWithEmptyApiResponse() { + return null; + } + + /** + * List with explicit response status list. + * + * @return the list + */ + @Operation(description = "Some operation") + @GetMapping(value = "/hello3", produces = MediaType.APPLICATION_JSON_VALUE) + @ResponseStatus(HttpStatus.NO_CONTENT) + List listWithExplicitResponseStatus() { + return null; + } + + /** + * Gets dto with explicit response status. + * + * @return the dto with explicit response status + */ + @Operation(description = "Some operation") + @GetMapping(value = "/hello4", produces = MediaType.APPLICATION_JSON_VALUE) + @ResponseStatus(HttpStatus.NO_CONTENT) + HelloDTO1 getDTOWithExplicitResponseStatus() { + return null; + } + + /** + * List with default response status list. + * + * @return the list + */ + @Operation(description = "Some operation") + @GetMapping(value = "/hello5", produces = MediaType.APPLICATION_JSON_VALUE) + List listWithDefaultResponseStatus() { + return null; + } + + /** + * Gets dto with default response status. + * + * @return the dto with default response status + */ + @Operation(description = "Some operation") + @GetMapping(value = "/hello6", produces = MediaType.APPLICATION_JSON_VALUE) + HelloDTO1 getDTOWithDefaultResponseStatus() { + return null; + } + + /** + * Gets nested dto with default response status. + * + * @return the nested dto with default response status + */ + @Operation(description = "Some operation") + @GetMapping(value = "/hello7", produces = MediaType.APPLICATION_JSON_VALUE) + ResponseEntity getNestedDTOWithDefaultResponseStatus() { + return null; + } + + /** + * The type Hello dto 1. + */ + static class HelloDTO1 { + /** + * The Message. + */ + private String message; + + /** + * Instantiates a new Hello dto 1. + * + * @param message the message + */ + public HelloDTO1(String message) { + this.message = message; + } + + /** + * Gets message. + * + * @return the message + */ + public String getMessage() { + return message; + } + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app53/HelloControllerWithGlobalApiResponse.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app53/HelloControllerWithGlobalApiResponse.java new file mode 100644 index 000000000..7b57433d9 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app53/HelloControllerWithGlobalApiResponse.java @@ -0,0 +1,72 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app53; + +import java.util.List; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.responses.ApiResponse; + +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseStatus; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller with global api response. + */ +@RestController +@RequestMapping(path = "/global") +class HelloControllerWithGlobalApiResponse { + + /** + * List with no api response list. + * + * @return the list + */ + @Operation(description = "Some operation", responses = { + @ApiResponse(responseCode = "204", description = "Explicit description for this response") }) + @ResponseStatus(HttpStatus.NO_CONTENT) + @GetMapping(value = "/hello1", produces = MediaType.APPLICATION_JSON_VALUE) + List listWithNoApiResponse() { + return null; + } + + /** + * List with default response status list. + * + * @return the list + */ + @Operation(description = "Some operation") + @ApiResponse(responseCode = "200", description = "Explicit description for this response") + @GetMapping(value = "/hello2", produces = MediaType.APPLICATION_JSON_VALUE) + List listWithDefaultResponseStatus() { + return null; + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app53/SpringDocApp53Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app53/SpringDocApp53Test.java new file mode 100644 index 000000000..91ffba758 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app53/SpringDocApp53Test.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app53; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 53 test. + */ +class SpringDocApp53Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app54/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app54/HelloController.java new file mode 100644 index 000000000..8822520e2 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app54/HelloController.java @@ -0,0 +1,84 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app54; + +import com.fasterxml.jackson.annotation.JsonView; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.parameters.RequestBody; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; + +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * Gets meal party. + * + * @param mealPartyId the meal party id + * @return the meal party + */ + @GetMapping(value = "/parties/{id}") + @JsonView(Views.Public.class) + @Operation(summary = "Gets meal party details [Meal party admin restricted]") + @ApiResponses(value = { @ApiResponse(responseCode = "200", description = "Successfully retrieved the meal party") }) + public MealParty getMealParty(@PathVariable("id") long mealPartyId) { + return null; + } + + /** + * Save meal party response entity. + * + * @param p the p + * @return the response entity + */ + @JsonView(Views.MealPartyAdmin.class) + @PostMapping(value = "/parties") + public ResponseEntity saveMealParty(@JsonView(Views.Public.class) @RequestBody MealParty p) { + return null; + } + + /** + * Save meal new party response entity. + * + * @param p the p + * @return the response entity + */ + @JsonView(Views.MealPartyAdmin.class) + @PostMapping(value = "/new-parties") + public ResponseEntity saveMealNewParty(@JsonView(Views.Public.class) @org.springframework.web.bind.annotation.RequestBody MealParty p) { + return null; + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app54/MealParty.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app54/MealParty.java new file mode 100644 index 000000000..19e4df19a --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app54/MealParty.java @@ -0,0 +1,49 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app54; + +import java.util.ArrayList; +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonView; + +/** + * The type Meal party. + */ +class MealParty { + /** + * The Name. + */ + @JsonView(Views.Public.class) + private String name; + + /** + * The Members. + */ + @JsonView(Views.MealPartyAdmin.class) + private List members = new ArrayList<>(); +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app54/SpringDocApp54Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app54/SpringDocApp54Test.java new file mode 100644 index 000000000..47a45d231 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app54/SpringDocApp54Test.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app54; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 54 test. + */ +class SpringDocApp54Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app54/Views.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app54/Views.java new file mode 100644 index 000000000..7e37781a1 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app54/Views.java @@ -0,0 +1,44 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app54; + +/** + * The interface Views. + */ +public interface Views { + /** + * The interface Public. + */ + public interface Public { + } + + /** + * The interface Meal party admin. + */ + public interface MealPartyAdmin extends Public { + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app55/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app55/HelloController.java new file mode 100644 index 000000000..86cc786b4 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app55/HelloController.java @@ -0,0 +1,60 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app55; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; +import io.swagger.v3.oas.annotations.tags.Tag; + +import org.springframework.http.HttpStatus; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.ResponseStatus; + +/** + * The type Hello controller. + */ +@Controller +@Tag(name = "health") +class HelloController { + + /** + * Ping endpoint used for health checks. + * @return the boolean + */ + @RequestMapping(value = "/ping", method = RequestMethod.GET) + @Operation(summary = "Simple health check") + @ApiResponses({ @ApiResponse(responseCode = "200", description = "OK") }) + @ResponseBody + @ResponseStatus(HttpStatus.OK) + public Boolean ping() { + return true; + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app55/SpringDocApp55Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app55/SpringDocApp55Test.java new file mode 100644 index 000000000..cc4a756f0 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app55/SpringDocApp55Test.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app55; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 55 test. + */ +class SpringDocApp55Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app56/GlobalExceptionHandler.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app56/GlobalExceptionHandler.java new file mode 100644 index 000000000..d651df665 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app56/GlobalExceptionHandler.java @@ -0,0 +1,90 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app56; + +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; + +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.ResponseStatus; +import org.springframework.web.bind.annotation.RestControllerAdvice; + +/** + * The type Global exception handler. + */ +@RestControllerAdvice +class GlobalExceptionHandler { + /** + * Handle unhandled error error dto. + * + * @return the error dto + */ + @ExceptionHandler(Exception.class) + @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR) + @ApiResponse( + responseCode = "500", + description = "Internal server error", + content = @Content( + mediaType = MediaType.APPLICATION_JSON_VALUE, + schema = @Schema(implementation = ErrorDTO.class) + ) + ) + ErrorDTO handleUnhandledError() { + return new ErrorDTO("internal error: "); + } + + /** + * The type Error dto. + */ + class ErrorDTO { + /** + * The Error message. + */ + private String errorMessage; + + /** + * Instantiates a new Error dto. + * + * @param errorMessage the error message + */ + ErrorDTO(String errorMessage) { + this.errorMessage = errorMessage; + } + + /** + * Gets error message. + * + * @return the error message + */ + public String getErrorMessage() { + return errorMessage; + } + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app56/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app56/HelloController.java new file mode 100644 index 000000000..5c8e8a991 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app56/HelloController.java @@ -0,0 +1,48 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app56; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * Persons string. + * + * @return the string + */ + @GetMapping("/persons") + public String persons() { + return "OK"; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app56/SpringDocApp56Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app56/SpringDocApp56Test.java new file mode 100644 index 000000000..7b34847a2 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app56/SpringDocApp56Test.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app56; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 56 test. + */ +class SpringDocApp56Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app57/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app57/HelloController.java new file mode 100644 index 000000000..bf6d9085b --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app57/HelloController.java @@ -0,0 +1,53 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app57; + +import io.swagger.v3.oas.annotations.Parameter; + +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * Gets text. + * + * @param name the name + * @return the text + */ + @GetMapping("/{name:.+}") + public ResponseEntity getText(@Parameter(description = "desc", required = true) @PathVariable String name) { + return null; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app57/SpringDocApp57Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app57/SpringDocApp57Test.java new file mode 100644 index 000000000..5cdc79e9d --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app57/SpringDocApp57Test.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app57; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 57 test. + */ +class SpringDocApp57Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app58/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app58/HelloController.java new file mode 100644 index 000000000..c181b92fe --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app58/HelloController.java @@ -0,0 +1,183 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app58; + +import com.fasterxml.jackson.databind.JsonNode; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * Example object. + * + * @param json the json + * @return the object + */ + @PostMapping("/examplePost") + @Operation(summary = "schema example") + public Object example(@Parameter(schema = @Schema(hidden = true)) JsonNode json) { + return null; + } + + /** + * Test. + * + * @param json the json + */ + @GetMapping("/example") + public void test(@Parameter(schema = @Schema(hidden = true)) JsonNode json) { + } + + /** + * Foobar. + * + * @param bar the bar + */ + @GetMapping(value = "/foo") + public void foobar(@Parameter(description = "User", name = "user", + schema = @Schema(implementation = PersonDTO.class)) @RequestParam("bar") String bar) { + + } + + /** + * Foobar 1. + * + * @param bar the bar + */ + @GetMapping(value = "/foo1") + public void foobar1(@Parameter(description = "User", name = "user", + content = @Content(mediaType = "application/json", + schema = @Schema(implementation = PersonDTO.class))) @RequestParam("bar") String bar) { + + } + + /** + * The type Person dto. + */ + class PersonDTO { + /** + * The Email. + */ + private String email; + + /** + * The First name. + */ + private String firstName; + + /** + * The Last name. + */ + private String lastName; + + /** + * Instantiates a new Person dto. + */ + public PersonDTO() { + } + + /** + * Instantiates a new Person dto. + * + * @param email the email + * @param firstName the first name + * @param lastName the last name + */ + public PersonDTO(final String email, final String firstName, final String lastName) { + this.email = email; + this.firstName = firstName; + this.lastName = lastName; + } + + /** + * Gets email. + * + * @return the email + */ + public String getEmail() { + return email; + } + + /** + * Sets email. + * + * @param email the email + */ + public void setEmail(final String email) { + this.email = email; + } + + /** + * Gets first name. + * + * @return the first name + */ + public String getFirstName() { + return firstName; + } + + /** + * Sets first name. + * + * @param firstName the first name + */ + public void setFirstName(final String firstName) { + this.firstName = firstName; + } + + /** + * Gets last name. + * + * @return the last name + */ + public String getLastName() { + return lastName; + } + + /** + * Sets last name. + * + * @param lastName the last name + */ + public void setLastName(final String lastName) { + this.lastName = lastName; + } + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app58/SpringDocApp58Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app58/SpringDocApp58Test.java new file mode 100644 index 000000000..07676f642 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app58/SpringDocApp58Test.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app58; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 58 test. + */ +class SpringDocApp58Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app59/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app59/HelloController.java new file mode 100644 index 000000000..e84dcf92f --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app59/HelloController.java @@ -0,0 +1,44 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app59; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + /** + * Test. + */ + @Deprecated + @GetMapping("/example") + public void test() { + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app59/SpringDocApp59Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app59/SpringDocApp59Test.java new file mode 100644 index 000000000..ff32d078d --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app59/SpringDocApp59Test.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app59; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 59 test. + */ +class SpringDocApp59Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app6/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app6/HelloController.java new file mode 100644 index 000000000..51d789bc3 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app6/HelloController.java @@ -0,0 +1,61 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app6; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.ExampleObject; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; + +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * Say hello response entity. + * + * @return the response entity + */ + @Operation(summary = "Get Something by key", responses = { + @ApiResponse(description = "Successful Operation", responseCode = "200", content = @Content(mediaType = "application/json", schema = @Schema(oneOf = { + String.class, Integer.class }), examples = { + @ExampleObject(name = "The String example", value = "urgheiurgheirghieurg"), + @ExampleObject(name = "The Integer example", value = "311414") })), + @ApiResponse(responseCode = "404", description = "Thing not found"), + @ApiResponse(responseCode = "401", description = "Authentication Failure") }) + @GetMapping(value = "/hello") + ResponseEntity sayHello() { + return null; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app6/SpringDocApp6Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app6/SpringDocApp6Test.java new file mode 100644 index 000000000..822927bd7 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app6/SpringDocApp6Test.java @@ -0,0 +1,44 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app6; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 6 test. + */ +class SpringDocApp6Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app60/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app60/HelloController.java new file mode 100644 index 000000000..e4623cb87 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app60/HelloController.java @@ -0,0 +1,76 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app60; + +import java.util.List; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Parameters; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * List 1 list. + * + * @param page the page + * @param size the size + * @return the list + */ + @GetMapping("/hello1") + @Operation(summary = "summary1") + @Parameters({ + @Parameter(name = "page", description = "The page"), + @Parameter(name = "size", description = "The size") + }) + public List list1(String page, String size) { + return null; + } + + /** + * List 2 list. + * + * @param page the page + * @param size the size + * @param sort the sort + * @return the list + */ + @GetMapping("/hello2") + @Operation(summary = "summary2") + @QuerySort + @QueryPaging + public List list2(String page, String size, String sort) { + return null; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app60/QueryPaging.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app60/QueryPaging.java new file mode 100644 index 000000000..f80fb53c8 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app60/QueryPaging.java @@ -0,0 +1,47 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app60; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Parameters; + +/** + * The interface Query paging. + */ +@Retention(RetentionPolicy.RUNTIME) +@Target({ ElementType.METHOD }) +@Parameters({ + @Parameter(name = "page", description = "desc page from Annotated interface"), + @Parameter(name = "size", description = "desc page from Annotated interface") +}) +public @interface QueryPaging { +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app60/QuerySort.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app60/QuerySort.java new file mode 100644 index 000000000..1e958b1b3 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app60/QuerySort.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app60; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import io.swagger.v3.oas.annotations.Parameter; + +/** + * The interface Query sort. + */ +@Retention(RetentionPolicy.RUNTIME) +@Target({ ElementType.METHOD }) +@Parameter(name = "sort", description = "desc sort from Annotated interface") +public @interface QuerySort { +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app60/SpringDocApp60Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app60/SpringDocApp60Test.java new file mode 100644 index 000000000..6a200d274 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app60/SpringDocApp60Test.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app60; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 60 test. + */ +class SpringDocApp60Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app61/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app61/HelloController.java new file mode 100644 index 000000000..1bf5498d9 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app61/HelloController.java @@ -0,0 +1,66 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app61; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.enums.ParameterIn; +import io.swagger.v3.oas.annotations.media.ArraySchema; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + + /** + * Persons string. + * + * @param name the name + * @param phone the phone + * @param createdFrom the created from + * @param createdRange the created range + * @return the string + */ + @Operation(description = "List", parameters = { + @Parameter(description = "Name", name = "name", in = ParameterIn.QUERY), + @Parameter(description = "Phone", name = "phone", in = ParameterIn.QUERY), + @Parameter(description = "createdFrom", name = "createdFrom", in = ParameterIn.QUERY, content = @Content(array = @ArraySchema(schema = @Schema(type = "string")))), + @Parameter(description = "createdRange", name = "createdRange", in = ParameterIn.QUERY, array = @ArraySchema(schema = @Schema(type = "string", format = "date"), minItems = 2, maxItems = 2)) + }) + @GetMapping(value = "/persons-with-user") + public String persons(String name, String phone, String createdFrom, String createdRange) { + return "OK"; + } + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app61/SpringDocApp61Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app61/SpringDocApp61Test.java new file mode 100644 index 000000000..cad6e2c20 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app61/SpringDocApp61Test.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app61; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 61 test. + */ +class SpringDocApp61Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app62/BaseController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app62/BaseController.java new file mode 100644 index 000000000..4bcbdafa5 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app62/BaseController.java @@ -0,0 +1,62 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app62; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import org.springframework.core.annotation.AliasFor; +import org.springframework.http.MediaType; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The interface Base controller. + */ +@Target({ ElementType.METHOD, ElementType.TYPE }) +@Retention(RetentionPolicy.RUNTIME) +@RestController +@RequestMapping +public @interface BaseController { + /** + * Value string [ ]. + * + * @return the string [ ] + */ + @AliasFor(annotation = RequestMapping.class) + String[] value() default {}; + + /** + * Produces string [ ]. + * + * @return the string [ ] + */ + @AliasFor(annotation = RequestMapping.class) + String[] produces() default { MediaType.APPLICATION_XML_VALUE, MediaType.APPLICATION_JSON_VALUE }; +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app62/SpringDocApp62Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app62/SpringDocApp62Test.java new file mode 100644 index 000000000..ecc033658 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app62/SpringDocApp62Test.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app62; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 62 test. + */ +class SpringDocApp62Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app62/TestController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app62/TestController.java new file mode 100644 index 000000000..e439ecde9 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app62/TestController.java @@ -0,0 +1,54 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app62; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; + +import org.springframework.web.bind.annotation.RequestHeader; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; + +/** + * The type Test controller. + */ +@BaseController +@Tag(name = "Test Controller") +class TestController { + + /** + * Test string. + * + * @param accept the accept + * @return the string + */ + @RequestMapping(value = "/test", method = RequestMethod.GET) + @Operation(summary = "This is the test endpoint") + public String test(@RequestHeader("Accept") String accept) { + return "This is a test"; + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app63/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app63/HelloController.java new file mode 100644 index 000000000..5e802b243 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app63/HelloController.java @@ -0,0 +1,58 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app63; + +import java.util.Locale; + +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; +import jakarta.servlet.http.HttpSession; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * Test. + * + * @param header the header + * @param request the request + * @param response the response + * @param locale the locale + * @param hello the hello + */ + @GetMapping("/test") + public void test(HttpSession header, HttpServletRequest request, HttpServletResponse response, Locale locale, + String hello) { + } + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app63/SpringDocApp63Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app63/SpringDocApp63Test.java new file mode 100644 index 000000000..d772a9e33 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app63/SpringDocApp63Test.java @@ -0,0 +1,48 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app63; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.test.context.TestPropertySource; + + +/** + * The type Spring doc app 63 test. + */ +@TestPropertySource(properties = { + "springdoc.packagesToScan=hell,hello1, hello.me", + "springdoc.packagesToExclude=test.org.springdoc.api.app63.65" }) +class SpringDocApp63Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app64/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app64/HelloController.java new file mode 100644 index 000000000..d9c64e48c --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app64/HelloController.java @@ -0,0 +1,61 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app64; + +import io.swagger.v3.oas.annotations.Operation; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * Test 1. + * + * @param hello the hello + */ + @GetMapping("/v1/test") + public void test1(String hello) { + } + + /** + * Test 2 string. + * + * @param from the from + * @return the string + */ + @GetMapping(value = "/api/balance/abcd") + @Operation(summary = "This is the test endpoint") + public String test2(String from) { + return "This is a fake test"; + } + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app64/SpringDocApp64Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app64/SpringDocApp64Test.java new file mode 100644 index 000000000..9bd6a6ade --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app64/SpringDocApp64Test.java @@ -0,0 +1,45 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app64; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.test.context.TestPropertySource; + +/** + * The type Spring doc app 64 test. + */ +@TestPropertySource(properties = "springdoc.paths-to-match=/v1, /api/**") +class SpringDocApp64Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app65/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app65/HelloController.java new file mode 100644 index 000000000..71f28af06 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app65/HelloController.java @@ -0,0 +1,55 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app65; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; + +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@Tag(name = "Health", description = "Health check / ping API") +@RestController +class HelloController { + + /** + * Ping response entity. + * + * @return the response entity + */ + @Operation(summary = "Check server status", description = "Check server status, will return 200 with simple string if alive. Do nothing else.") + @GetMapping(value = { "/ping", "/health", "/" }, produces = MediaType.TEXT_PLAIN_VALUE) + public ResponseEntity ping() { + return ResponseEntity.ok("Healthy"); + } + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app65/SpringDocApp65Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app65/SpringDocApp65Test.java new file mode 100644 index 000000000..a8f366b63 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app65/SpringDocApp65Test.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app65; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 65 test. + */ +class SpringDocApp65Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app66/DefaultHealthCheckApi.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app66/DefaultHealthCheckApi.java new file mode 100644 index 000000000..bff94f38d --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app66/DefaultHealthCheckApi.java @@ -0,0 +1,57 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app66; + +import java.time.LocalDate; + +import io.swagger.v3.oas.annotations.Hidden; + +import org.springframework.format.annotation.DateTimeFormat; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RestController; + + +/** + * The type Default health check api. + */ +@RestController +@Hidden +class DefaultHealthCheckApi { + + /** + * Test date echo string. + * + * @param date the date + * @return the string + */ + @GetMapping("/test/date/echo/{date}") + public String testDateEcho(@DateTimeFormat(pattern = "yyyyMMdd") @PathVariable LocalDate date) { + return date.toString(); + } + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app66/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app66/HelloController.java new file mode 100644 index 000000000..f5351936e --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app66/HelloController.java @@ -0,0 +1,56 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app66; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; + +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@Tag(name = "Health", description = "Health check / ping API") +@RestController +class HelloController { + + /** + * Ping response entity. + * + * @param possiblyInjectedByAspect the possibly injected by aspect + * @return the response entity + */ + @Operation(summary = "Check server status", description = "Check server status, will return 200 with simple string if alive. Do nothing else.") + @GetMapping(value = { "/ping", "/health", "/" }, produces = MediaType.TEXT_PLAIN_VALUE) + public ResponseEntity ping(UndocumentedClass possiblyInjectedByAspect) { + return ResponseEntity.ok("Healthy"); + } + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app66/SpringDocApp66Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app66/SpringDocApp66Test.java new file mode 100644 index 000000000..39b64bddd --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app66/SpringDocApp66Test.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app66; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 66 test. + */ +class SpringDocApp66Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app66/UndocumentedClass.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app66/UndocumentedClass.java new file mode 100644 index 000000000..85e133dea --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app66/UndocumentedClass.java @@ -0,0 +1,37 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app66; + +import io.swagger.v3.oas.annotations.Hidden; + +/** + * The type Undocumented class. + */ +@Hidden +class UndocumentedClass { + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app67/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app67/HelloController.java new file mode 100644 index 000000000..3dd8f832a --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app67/HelloController.java @@ -0,0 +1,141 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app67; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Parameters; +import io.swagger.v3.oas.annotations.enums.ParameterIn; +import io.swagger.v3.oas.annotations.media.Schema; + +import org.springframework.http.MediaType; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +@RequestMapping(path = "/demo", + produces = MediaType.TEXT_PLAIN_VALUE) +class HelloController { + + /** + * Operation 1 string. + * + * @return the string + */ + @GetMapping("operation1") + @Operation(summary = "Operation 1 (expected result - no parameters)") + public String operation1() { + return "operation1"; + } + + /** + * Operation 2 string. + * + * @return the string + */ + @GetMapping("operation2") + @Operation(summary = "Operation 2 (expected result - 3 parameters)", parameters = { + @Parameter(name = "pageNumber", description = "page number", + in = ParameterIn.QUERY, schema = @Schema(type = "integer")), + @Parameter(name = "pageSize", description = "page size", + in = ParameterIn.QUERY, schema = @Schema(type = "integer")), + @Parameter(name = "sort", description = "sort specification", + in = ParameterIn.QUERY, schema = @Schema(type = "string")) + }) + public String operation2() { + return "operation2"; + } + + /** + * Operation 3 string. + * + * @return the string + */ + @GetMapping("operation3") + @Operation(summary = "Operation 3 (expected result - 3 parameters)") + @Parameters({ + @Parameter(name = "pageNumber", description = "page number", + in = ParameterIn.QUERY, schema = @Schema(type = "integer")), + @Parameter(name = "pageSize", description = "page size", + in = ParameterIn.QUERY, schema = @Schema(type = "integer")), + @Parameter(name = "sort", description = "sort specification", + in = ParameterIn.QUERY, schema = @Schema(type = "string")) + }) + public String operation3() { + return "operation3"; + } + + /** + * Operation 4 string. + * + * @return the string + */ + @GetMapping("operation4") + @Operation(summary = "Operation 4 (expected result - 3 parameters)") + @QueryPaging + @QuerySort + public String operation4() { + return "operation4"; + } + + /** + * The interface Query paging. + */ + @Retention(RetentionPolicy.RUNTIME) + @Target({ ElementType.METHOD }) + @Parameters({ + @Parameter(name = "pageNumber", description = "page number", + in = ParameterIn.QUERY, schema = @Schema(type = "integer")), + @Parameter(name = "pageSize", description = "page size", + in = ParameterIn.QUERY, schema = @Schema(type = "integer")) + }) + public @interface QueryPaging { + + } + + /** + * The interface Query sort. + */ + @Retention(RetentionPolicy.RUNTIME) + @Target({ ElementType.METHOD }) + @Parameters({ + @Parameter(name = "sort", description = "sort specification", + in = ParameterIn.QUERY, schema = @Schema(type = "string")) + }) + public @interface QuerySort { + + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app67/SpringDocApp67Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app67/SpringDocApp67Test.java new file mode 100644 index 000000000..4bc3c0dbf --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app67/SpringDocApp67Test.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app67; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 67 test. + */ +class SpringDocApp67Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app69/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app69/HelloController.java new file mode 100644 index 000000000..a3e473485 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app69/HelloController.java @@ -0,0 +1,53 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app69; + +import java.util.concurrent.Callable; + +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * Gets tasks. + * + * @param str the str + * @return the tasks + */ + @RequestMapping(value = "/tasks", method = RequestMethod.GET) + private Callable> getTasks(String str) { + return null; + } + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app69/PersonDTO.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app69/PersonDTO.java new file mode 100644 index 000000000..f238d47cb --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app69/PersonDTO.java @@ -0,0 +1,120 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app69; + +/** + * The type Person dto. + */ +class PersonDTO { + /** + * The Email. + */ + private String email; + + /** + * The First name. + */ + private String firstName; + + /** + * The Last name. + */ + private String lastName; + + /** + * Instantiates a new Person dto. + */ + public PersonDTO() { + } + + /** + * Instantiates a new Person dto. + * + * @param email the email + * @param firstName the first name + * @param lastName the last name + */ + public PersonDTO(final String email, final String firstName, final String lastName) { + this.email = email; + this.firstName = firstName; + this.lastName = lastName; + } + + /** + * Gets email. + * + * @return the email + */ + public String getEmail() { + return email; + } + + /** + * Sets email. + * + * @param email the email + */ + public void setEmail(final String email) { + this.email = email; + } + + /** + * Gets first name. + * + * @return the first name + */ + public String getFirstName() { + return firstName; + } + + /** + * Sets first name. + * + * @param firstName the first name + */ + public void setFirstName(final String firstName) { + this.firstName = firstName; + } + + /** + * Gets last name. + * + * @return the last name + */ + public String getLastName() { + return lastName; + } + + /** + * Sets last name. + * + * @param lastName the last name + */ + public void setLastName(final String lastName) { + this.lastName = lastName; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app69/SpringDocApp69Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app69/SpringDocApp69Test.java new file mode 100644 index 000000000..fc36283cb --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app69/SpringDocApp69Test.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app69; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 69 test. + */ +class SpringDocApp69Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app7/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app7/HelloController.java new file mode 100644 index 000000000..906770a6b --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app7/HelloController.java @@ -0,0 +1,53 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app7; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.parameters.RequestBody; + +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * Search employee. + * + * @param test the test + */ + @Operation(summary = "test Request") + @RequestBody(description = "test value", required = true, content = @Content(schema = @Schema(implementation = String.class))) + @PostMapping("/test") + public void searchEmployee(String test) { + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app7/SpringDocApp7Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app7/SpringDocApp7Test.java new file mode 100644 index 000000000..6d134378a --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app7/SpringDocApp7Test.java @@ -0,0 +1,44 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app7; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 7 test. + */ +class SpringDocApp7Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app70/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app70/HelloController.java new file mode 100644 index 000000000..ef1f1428e --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app70/HelloController.java @@ -0,0 +1,57 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app70; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import test.org.springdoc.api.v31.app70.customizer.CustomizedOperation; +import test.org.springdoc.api.v31.app70.customizer.CustomizedParameter; +import test.org.springdoc.api.v31.app70.model.ApiType; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * Test api type. + * + * @param test the test + * @return the api type + */ + @CustomizedOperation + @Operation(description = "Some operation") + @GetMapping("/example/{test}") + public ApiType test(@PathVariable @CustomizedParameter @Parameter(description = "Parameter description") String test) { + return new ApiType(); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app70/SpringDocApp70Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app70/SpringDocApp70Test.java new file mode 100644 index 000000000..19940db3f --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app70/SpringDocApp70Test.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app70; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 70 test. + */ +class SpringDocApp70Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app70/customizer/CustomizedOperation.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app70/customizer/CustomizedOperation.java new file mode 100644 index 000000000..62dbfd165 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app70/customizer/CustomizedOperation.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app70.customizer; + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + +/** + * The interface Customized operation. + */ +@Retention(RetentionPolicy.RUNTIME) +public @interface CustomizedOperation { + /** + * Addition string. + * + * @return the string + */ + String addition() default "customized operation!"; +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app70/customizer/CustomizedParameter.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app70/customizer/CustomizedParameter.java new file mode 100644 index 000000000..811717b4a --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app70/customizer/CustomizedParameter.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app70.customizer; + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + +/** + * The interface Customized parameter. + */ +@Retention(RetentionPolicy.RUNTIME) +public @interface CustomizedParameter { + /** + * Addition string. + * + * @return the string + */ + String addition() default "customized parameter!"; +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app70/customizer/CustomizedProperty.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app70/customizer/CustomizedProperty.java new file mode 100644 index 000000000..0e43ed629 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app70/customizer/CustomizedProperty.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app70.customizer; + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + +/** + * The interface Customized property. + */ +@Retention(RetentionPolicy.RUNTIME) +public @interface CustomizedProperty { + /** + * Addition string. + * + * @return the string + */ + String addition() default "customized property!"; +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app70/customizer/OperationCustomizer.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app70/customizer/OperationCustomizer.java new file mode 100644 index 000000000..c79543eb6 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app70/customizer/OperationCustomizer.java @@ -0,0 +1,54 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app70.customizer; + +import io.swagger.v3.oas.models.Operation; + +import org.springframework.stereotype.Component; +import org.springframework.web.method.HandlerMethod; + +/** + * The type Operation customizer. + */ +@Component +class OperationCustomizer implements org.springdoc.core.customizers.OperationCustomizer { + /** + * Customize operation. + * + * @param operation the operation + * @param handlerMethod the handler method + * @return the operation + */ + @Override + public Operation customize(Operation operation, HandlerMethod handlerMethod) { + CustomizedOperation annotation = handlerMethod.getMethodAnnotation(CustomizedOperation.class); + if (annotation != null) { + operation.description(operation.getDescription() + ", " + annotation.addition()); + } + return operation; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app70/customizer/ParameterCustomizer.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app70/customizer/ParameterCustomizer.java new file mode 100644 index 000000000..97e2c69b8 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app70/customizer/ParameterCustomizer.java @@ -0,0 +1,54 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app70.customizer; + +import io.swagger.v3.oas.models.parameters.Parameter; + +import org.springframework.core.MethodParameter; +import org.springframework.stereotype.Component; + +/** + * The type Parameter customizer. + */ +@Component +class ParameterCustomizer implements org.springdoc.core.customizers.ParameterCustomizer { + /** + * Customize parameter. + * + * @param parameterModel the parameter model + * @param methodParameter the method parameter + * @return the parameter + */ + @Override + public Parameter customize(Parameter parameterModel, MethodParameter methodParameter) { + CustomizedParameter annotation = methodParameter.getParameterAnnotation(CustomizedParameter.class); + if (annotation != null) { + parameterModel.description(parameterModel.getDescription() + ", " + annotation.addition()); + } + return parameterModel; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app70/customizer/PropertyCustomizer.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app70/customizer/PropertyCustomizer.java new file mode 100644 index 000000000..bd4056588 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app70/customizer/PropertyCustomizer.java @@ -0,0 +1,78 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app70.customizer; + +import java.lang.annotation.Annotation; +import java.time.Duration; +import java.util.Collections; +import java.util.Optional; +import java.util.stream.Stream; + +import com.fasterxml.jackson.databind.JavaType; +import io.swagger.v3.core.converter.AnnotatedType; +import io.swagger.v3.oas.models.media.Schema; +import io.swagger.v3.oas.models.media.StringSchema; +import org.springdoc.core.providers.ObjectMapperProvider; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +/** + * The type Property customizer. + */ +@Component +class PropertyCustomizer implements org.springdoc.core.customizers.PropertyCustomizer { + + @Autowired + ObjectMapperProvider objectMapperProvider; + + /** + * Customize schema. + * + * @param property the property + * @param type the type + * @return the schema + */ + @Override + public Schema customize(Schema property, AnnotatedType type) { + Annotation[] ctxAnnotations = type.getCtxAnnotations(); + if (ctxAnnotations == null) { + return property; + } + + Optional propertyAnnotation = Stream.of(ctxAnnotations) + .filter(CustomizedProperty.class::isInstance) + .findFirst() + .map(CustomizedProperty.class::cast); + + JavaType javaType = objectMapperProvider.jsonMapper().constructType(type.getType()); + if (javaType.getRawClass().equals(Duration.class)) { + property = new StringSchema().format("duration").properties(Collections.emptyMap()); + } + return property; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app70/model/ApiType.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app70/model/ApiType.java new file mode 100644 index 000000000..8122e6b3e --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app70/model/ApiType.java @@ -0,0 +1,47 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app70.model; + +import java.time.Duration; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.v3.oas.annotations.media.Schema; +import test.org.springdoc.api.v31.app70.customizer.CustomizedProperty; + +/** + * The type Api type. + */ +public class ApiType { + /** + * The Some property. + */ + @CustomizedProperty + @Schema(description = "Test description") + @JsonProperty("someProperty") + private Duration someProperty; + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app71/Dog.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app71/Dog.java new file mode 100644 index 000000000..15edf4069 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app71/Dog.java @@ -0,0 +1,50 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app71; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.v3.oas.annotations.media.Schema; + + +/** + * The type Dog. + */ +@Schema(name = "Dog") +class Dog { + + /** + * The Display name. + */ + @JsonProperty("display_name") + @Schema( + name = "display_name", + description = "A name given to the Dog", + example = "Fido" + ) + String displayName; + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app71/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app71/HelloController.java new file mode 100644 index 000000000..62c58d4ce --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app71/HelloController.java @@ -0,0 +1,49 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app71; + +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * Persons string. + * + * @param dog the dog + * @return the string + */ + @PostMapping("/persons") + public String persons(Dog dog) { + return null; + } + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app71/SpringDocApp71Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app71/SpringDocApp71Test.java new file mode 100644 index 000000000..9be9c164f --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app71/SpringDocApp71Test.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app71; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 71 test. + */ +class SpringDocApp71Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app72/BlockingAutoConfigurationTest.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app72/BlockingAutoConfigurationTest.java new file mode 100644 index 000000000..3a97833ba --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app72/BlockingAutoConfigurationTest.java @@ -0,0 +1,130 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app72; + +import org.junit.jupiter.api.Test; +import org.springdoc.core.models.GroupedOpenApi; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.test.context.FilteredClassLoader; +import org.springframework.boot.test.context.runner.ApplicationContextRunner; +import org.springframework.boot.test.context.runner.WebApplicationContextRunner; +import org.springframework.context.annotation.Bean; + +import static org.assertj.core.api.Assertions.assertThat; + +/** + * The type Blocking auto configuration test. + */ +class BlockingAutoConfigurationTest { + + /** + * The Context runner. + */ + private final WebApplicationContextRunner contextRunner = new WebApplicationContextRunner() + .withUserConfiguration(TestApp.class); + + + /** + * Configurations not loaded when application is not web. + */ + @Test + void configurations_not_loaded_when_application_is_not_web() { + new ApplicationContextRunner() + .withUserConfiguration(TestApp.class) + .run(context -> assertThat(context) + .hasNotFailed() + .doesNotHaveBean("openApiResource") + .doesNotHaveBean("actuatorProvider") + .doesNotHaveBean("multipleOpenApiResource") + ); + } + + /** + * Actuator configuration not loaded when not enabled explicitly. + */ + @Test + void actuator_configuration_not_loaded_when_not_enabled_explicitly() { + contextRunner + .run(context -> assertThat(context) + .hasNotFailed() + .hasBean("openApiResource") + .doesNotHaveBean("actuatorPprrovider") + .hasBean("multipleOpenApiResource") + ); + } + + /** + * Configurations not loaded when disabled. + */ + @Test + void configurations_not_loaded_when_disabled() { + contextRunner + .withPropertyValues("springdoc.api-docs.enabled=false") + .run(context -> assertThat(context) + .hasNotFailed() + .doesNotHaveBean("openApiResource") + .doesNotHaveBean("actuatorProvider") + .doesNotHaveBean("multipleOpenApiResource") + ); + } + + /** + * Configurations not loaded when mvc is not on class path. + */ + @Test + void configurations_not_loaded_when_mvc_is_not_on_class_path() { + contextRunner + .withClassLoader(new FilteredClassLoader("org.springframework.web.context.support.GenericWebApplicationContext")) + .run(context -> assertThat(context) + .hasNotFailed() + .doesNotHaveBean("openApiResource") + .doesNotHaveBean("actuatorProvider") + .doesNotHaveBean("multipleOpenApiResource") + ); + + } + + /** + * The type Test app. + */ + @SpringBootApplication + static class TestApp { + /** + * Test grouped open api grouped open api. + * + * @return the grouped open api + */ + @Bean + GroupedOpenApi testGroupedOpenApi() { + return GroupedOpenApi.builder() + .group("test-group") + .packagesToScan("org.test") + .build(); + } + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app72/CacheAutoConfigurationTest1.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app72/CacheAutoConfigurationTest1.java new file mode 100644 index 000000000..2079aabdd --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app72/CacheAutoConfigurationTest1.java @@ -0,0 +1,114 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app72; + +import org.junit.jupiter.api.Test; + +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.boot.test.context.runner.WebApplicationContextRunner; + +import static org.assertj.core.api.Assertions.assertThat; + +/** + * The type Cache auto configuration test 1. + */ +class CacheAutoConfigurationTest1 { + + /** + * The Context runner. + */ + private final WebApplicationContextRunner contextRunner = new WebApplicationContextRunner() + .withUserConfiguration(TestApp.class); + + /** + * Cache configuration loaded when not disabled explicitly. + */ + @Test + void cache_configuration_loaded_when_not_disabled_explicitly() { + contextRunner + .run(context -> assertThat(context) + .hasNotFailed() + .hasBean("openApiResource") + .doesNotHaveBean("springdocBeanFactoryPostProcessor") + .doesNotHaveBean("multipleOpenApiResource") + ); + } + + /** + * Cache configuration loaded when disabled explicitly. + */ + @Test + void cache_configuration_loaded_when_disabled_explicitly() { + contextRunner + .withPropertyValues("springdoc.cache.disabled=false") + .run(context -> assertThat(context) + .hasNotFailed() + .hasBean("openApiResource") + .doesNotHaveBean("springdocBeanFactoryPostProcessor") + .doesNotHaveBean("multipleOpenApiResource") + ); + } + + /** + * Cache configurations successfully disabled. + */ + @Test + void cache_configurations_successfully_disabled() { + contextRunner + .withPropertyValues("springdoc.cache.disabled=true") + .run(context -> assertThat(context) + .hasNotFailed() + .hasBean("openApiResource") + .hasBean("springdocBeanFactoryPostProcessor") + .doesNotHaveBean("multipleOpenApiResource") + ); + } + + /** + * Group configuration loaded. + */ + @Test + void group_configuration_loaded() { + contextRunner + .withPropertyValues("springdoc.group-configs[0].group=stores", "springdoc.group-configs[0].paths-to-match=/store/**") + .run(context -> assertThat(context) + .hasNotFailed() + .hasBean("openApiResource") + .hasBean("multipleOpenApiResource") + .hasBean("springdocBeanFactoryPostProcessor") + ); + } + + + /** + * The type Test app. + */ + @EnableAutoConfiguration + static class TestApp { + + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app72/GroupAutoConfigurationTest.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app72/GroupAutoConfigurationTest.java new file mode 100644 index 000000000..11bfec015 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app72/GroupAutoConfigurationTest.java @@ -0,0 +1,81 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app72; + +import org.junit.jupiter.api.Test; +import org.springdoc.core.models.GroupedOpenApi; + +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.boot.test.context.runner.WebApplicationContextRunner; +import org.springframework.context.annotation.Bean; + +import static org.assertj.core.api.Assertions.assertThat; + +/** + * The type Group auto configuration test. + */ +class GroupAutoConfigurationTest { + + /** + * The Context runner. + */ + private final WebApplicationContextRunner contextRunner = new WebApplicationContextRunner() + .withUserConfiguration(TestApp.class); + + /** + * Group configuration loaded. + */ + @Test + void group_configuration_loaded() { + contextRunner + .run(context -> assertThat(context) + .hasNotFailed() + .hasBean("openApiResource") + .hasBean("springdocBeanFactoryPostProcessor") + .hasBean("multipleOpenApiResource") + ); + } + + /** + * The type Test app. + */ + @EnableAutoConfiguration + static class TestApp { + /** + * Test grouped open api grouped open api. + * + * @return the grouped open api + */ + @Bean + GroupedOpenApi testGroupedOpenApi() { + return GroupedOpenApi.builder() + .group("test-group") + .packagesToScan("org.test") + .build(); + } + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app73/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app73/HelloController.java new file mode 100644 index 000000000..c2d6ec353 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app73/HelloController.java @@ -0,0 +1,71 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app73; + +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.enums.ParameterIn; + +import org.springframework.http.HttpStatus; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseStatus; +import org.springframework.web.bind.annotation.RestController; + + +/** + * The type Hello controller. + */ +@RestController +@RequestMapping({ "/{country_code}/persons/", "/persons" }) +class HelloController { + + /** + * Delete. + * + * @param countryCode the country code + * @param id the id + */ + @DeleteMapping("/{id}") + @ResponseStatus(HttpStatus.NO_CONTENT) + public void delete(@Parameter(name = "country_code", in = ParameterIn.QUERY) String countryCode, @PathVariable("id") String id) { + + } + + /** + * Get string. + * + * @param countryCode the country code + * @param id the id + * @return the string + */ + @GetMapping("/{id}") + public String get(@Parameter(name = "country_code", in = ParameterIn.QUERY) String countryCode, @PathVariable("id") String id) { + return null; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app73/SpringDocApp73Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app73/SpringDocApp73Test.java new file mode 100644 index 000000000..7d51c391e --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app73/SpringDocApp73Test.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app73; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 73 test. + */ +class SpringDocApp73Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app74/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app74/HelloController.java new file mode 100644 index 000000000..1379be33a --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app74/HelloController.java @@ -0,0 +1,62 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app74; + +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.ExampleObject; +import io.swagger.v3.oas.annotations.parameters.RequestBody; + +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RestController; + + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * Post my request body string. + * + * @param myRequestBody the my request body + * @return the string + */ + @PostMapping("/test") + @RequestBody( + content = @Content( + examples = @ExampleObject( + value = "sample" + ) + ) + ) + public String postMyRequestBody( + String myRequestBody) { + return null; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app74/SpringDocApp74Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app74/SpringDocApp74Test.java new file mode 100644 index 000000000..238d0ec21 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app74/SpringDocApp74Test.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app74; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 74 test. + */ +class SpringDocApp74Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app75/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app75/HelloController.java new file mode 100644 index 000000000..da4f15d72 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app75/HelloController.java @@ -0,0 +1,127 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app75; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.enums.ParameterIn; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; + +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * Post my request body 1 string. + * + * @return the string + */ + @PostMapping("/test1/{uuid}") + @Operation(summary = "Example api that realize an ECHO operation", + description = "The result of the echo is the input value of the api", + parameters = { @Parameter(in = ParameterIn.PATH, + name = "uuid", + required = true, + description = "Is the identification of the document", + schema = @Schema(type = "string", + example = "uuid")) } + + + ) + @ApiResponses(value = { + @ApiResponse(description = "Successful Operation", + responseCode = "200", + content = @Content(mediaType = "application/json", + schema = @Schema(implementation = PersonDTO.class))), + @ApiResponse(responseCode = "201", + description = "other possible response") + }) + public String postMyRequestBody1() { + return null; + } + + /** + * Post my request body 2 string. + * + * @return the string + */ + @PostMapping("/test2/{uuid}") + @Operation(summary = "Example api that realize an ECHO operation", + description = "The result of the echo is the input value of the api", + responses = { + @ApiResponse(description = "Successful Operation", + responseCode = "200", + content = @Content(mediaType = "application/json", + schema = @Schema(implementation = PersonDTO.class))), + @ApiResponse(responseCode = "201", + description = "other possible response") + }, + parameters = { @Parameter(in = ParameterIn.PATH, + name = "uuid", + required = true, + description = "Is the identification of the document", + schema = @Schema(type = "string", + example = "uuid")) } + + + ) + public String postMyRequestBody2() { + return null; + } + + /** + * Post my request body 3 string. + * + * @return the string + */ + @PostMapping("/test3/{uuid}") + @Operation(summary = "Example api that realize an ECHO operation", + description = "The result of the echo is the input value of the api", + parameters = { @Parameter(in = ParameterIn.PATH, + name = "uuid", + required = true, + description = "Is the identification of the document", + schema = @Schema(type = "string", + example = "uuid")) } + + + ) + @ApiResponse(responseCode = "201", + description = "other possible response") + public String postMyRequestBody3() { + return null; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app75/PersonDTO.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app75/PersonDTO.java new file mode 100644 index 000000000..f50704efb --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app75/PersonDTO.java @@ -0,0 +1,120 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app75; + +/** + * The type Person dto. + */ +class PersonDTO { + /** + * The Email. + */ + private String email; + + /** + * The First name. + */ + private String firstName; + + /** + * The Last name. + */ + private String lastName; + + /** + * Instantiates a new Person dto. + */ + public PersonDTO() { + } + + /** + * Instantiates a new Person dto. + * + * @param email the email + * @param firstName the first name + * @param lastName the last name + */ + public PersonDTO(final String email, final String firstName, final String lastName) { + this.email = email; + this.firstName = firstName; + this.lastName = lastName; + } + + /** + * Gets email. + * + * @return the email + */ + public String getEmail() { + return email; + } + + /** + * Sets email. + * + * @param email the email + */ + public void setEmail(final String email) { + this.email = email; + } + + /** + * Gets first name. + * + * @return the first name + */ + public String getFirstName() { + return firstName; + } + + /** + * Sets first name. + * + * @param firstName the first name + */ + public void setFirstName(final String firstName) { + this.firstName = firstName; + } + + /** + * Gets last name. + * + * @return the last name + */ + public String getLastName() { + return lastName; + } + + /** + * Sets last name. + * + * @param lastName the last name + */ + public void setLastName(final String lastName) { + this.lastName = lastName; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app75/RestResponseEntityExceptionHandler.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app75/RestResponseEntityExceptionHandler.java new file mode 100644 index 000000000..f481b5fe8 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app75/RestResponseEntityExceptionHandler.java @@ -0,0 +1,58 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app75; + +import java.util.List; + +import jakarta.servlet.http.HttpServletRequest; + +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.ControllerAdvice; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.ResponseStatus; +import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler; + +/** + * The type Rest response entity exception handler. + */ +@ControllerAdvice +class RestResponseEntityExceptionHandler + extends ResponseEntityExceptionHandler { + /** + * Bad request response entity. + * + * @param req the req + * @param exception the exception + * @return the response entity + */ + @ResponseStatus(value = HttpStatus.OK) + @ExceptionHandler({ Exception.class }) + public ResponseEntity> badRequest(HttpServletRequest req, Exception exception) { + return null; + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app75/SpringDocApp75Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app75/SpringDocApp75Test.java new file mode 100644 index 000000000..663f68f88 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app75/SpringDocApp75Test.java @@ -0,0 +1,44 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app75; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 75 test. + */ +class SpringDocApp75Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp { + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app76/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app76/HelloController.java new file mode 100644 index 000000000..bd1a4a97f --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app76/HelloController.java @@ -0,0 +1,65 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app76; + +import io.swagger.v3.oas.annotations.security.SecurityRequirements; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.RestController; + + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * Secured string. + * + * @return the string + */ + @GetMapping("/secure") + @ResponseBody + public String secured() { + return "It works!"; + } + + /** + * Open string. + * + * @return the string + */ + @GetMapping("/open") + @ResponseBody + @SecurityRequirements + public String open() { + return "It works!"; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app76/SpringDocApp76Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app76/SpringDocApp76Test.java new file mode 100644 index 000000000..073191476 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app76/SpringDocApp76Test.java @@ -0,0 +1,68 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app76; + +import java.util.Arrays; + +import io.swagger.v3.oas.models.Components; +import io.swagger.v3.oas.models.OpenAPI; +import io.swagger.v3.oas.models.security.SecurityRequirement; +import io.swagger.v3.oas.models.security.SecurityScheme; +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; + +/** + * The type Spring doc app 76 test. + */ +class SpringDocApp76Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp { + /** + * Open api open api. + * + * @return the open api + */ + @Bean + public OpenAPI openAPI() { + return new OpenAPI() + .components(new Components().addSecuritySchemes("bearer-jwt", + new SecurityScheme() + .type(SecurityScheme.Type.HTTP) + .scheme("bearer") + .bearerFormat("JWT")) + ) + .addSecurityItem( + new SecurityRequirement().addList("bearer-jwt", Arrays.asList("read", "write"))); + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app77/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app77/HelloController.java new file mode 100644 index 000000000..9e072c0fa --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app77/HelloController.java @@ -0,0 +1,71 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app77; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.extensions.Extension; +import io.swagger.v3.oas.annotations.extensions.ExtensionProperty; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import jakarta.validation.Valid; +import org.hibernate.validator.constraints.NotBlank; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * Persons. + * + * @param name the name + */ + @ApiResponse(content = @Content(schema = @Schema(type = "string")), extensions = @Extension(properties = @ExtensionProperty(name = "x-is-file", value = "true"))) + @GetMapping(value = "/persons") + public void persons(@Valid @NotBlank String name) { + + } + + + /** + * Persons 2. + * + * @param name the name + */ + @Operation(responses = @ApiResponse(content = @Content(schema = @Schema(type = "string")), extensions = @Extension(properties = @ExtensionProperty(name = "x-is-file", value = "true")))) + @GetMapping(value = "/persons2") + public void persons2(@Valid @NotBlank String name) { + + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app77/SpringDocApp77Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app77/SpringDocApp77Test.java new file mode 100644 index 000000000..c8032fb24 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app77/SpringDocApp77Test.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app77; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 77 test. + */ +class SpringDocApp77Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app78/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app78/HelloController.java new file mode 100644 index 000000000..e977fdf89 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app78/HelloController.java @@ -0,0 +1,65 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app78; + +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.CompletionStage; + +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * Gets person 1. + * + * @param str the str + * @return the person 1 + */ + @RequestMapping(value = "/person1", method = RequestMethod.GET) + private CompletionStage> getPerson1(String str) { + return null; + } + + /** + * Gets person 2. + * + * @param str the str + * @return the person 2 + */ + @RequestMapping(value = "/person2", method = RequestMethod.GET) + private CompletableFuture getPerson2(String str) { + return null; + } + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app78/PersonDTO.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app78/PersonDTO.java new file mode 100644 index 000000000..280e22b31 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app78/PersonDTO.java @@ -0,0 +1,120 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app78; + +/** + * The type Person dto. + */ +class PersonDTO { + /** + * The Email. + */ + private String email; + + /** + * The First name. + */ + private String firstName; + + /** + * The Last name. + */ + private String lastName; + + /** + * Instantiates a new Person dto. + */ + public PersonDTO() { + } + + /** + * Instantiates a new Person dto. + * + * @param email the email + * @param firstName the first name + * @param lastName the last name + */ + public PersonDTO(final String email, final String firstName, final String lastName) { + this.email = email; + this.firstName = firstName; + this.lastName = lastName; + } + + /** + * Gets email. + * + * @return the email + */ + public String getEmail() { + return email; + } + + /** + * Sets email. + * + * @param email the email + */ + public void setEmail(final String email) { + this.email = email; + } + + /** + * Gets first name. + * + * @return the first name + */ + public String getFirstName() { + return firstName; + } + + /** + * Sets first name. + * + * @param firstName the first name + */ + public void setFirstName(final String firstName) { + this.firstName = firstName; + } + + /** + * Gets last name. + * + * @return the last name + */ + public String getLastName() { + return lastName; + } + + /** + * Sets last name. + * + * @param lastName the last name + */ + public void setLastName(final String lastName) { + this.lastName = lastName; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app78/SpringDocApp78Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app78/SpringDocApp78Test.java new file mode 100644 index 000000000..be8a419fa --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app78/SpringDocApp78Test.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app78; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 78 test. + */ +class SpringDocApp78Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app79/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app79/HelloController.java new file mode 100644 index 000000000..077c8536e --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app79/HelloController.java @@ -0,0 +1,53 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app79; + +import java.util.Optional; + +import org.springframework.http.MediaType; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * Echo string. + * + * @param text the text + * @return the string + */ + @GetMapping(produces = MediaType.TEXT_PLAIN_VALUE, path = "/test") + public String echo(@RequestParam Optional text) { + return text.orElse("not-specified"); + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app79/SpringDocApp79Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app79/SpringDocApp79Test.java new file mode 100644 index 000000000..1377e4759 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app79/SpringDocApp79Test.java @@ -0,0 +1,44 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app79; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + + +/** + * The type Spring doc app 79 test. + */ +class SpringDocApp79Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app8/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app8/HelloController.java new file mode 100644 index 000000000..cdbda9a24 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app8/HelloController.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.app8; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * Test. + * + * @param hello the hello + */ + @GetMapping("/test") + public void test(String hello) { + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app8/SpringDocApp8Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app8/SpringDocApp8Test.java new file mode 100644 index 000000000..e210ed251 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app8/SpringDocApp8Test.java @@ -0,0 +1,60 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app8; + +import org.junit.jupiter.api.Test; +import org.springdoc.core.utils.Constants; +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + + +/** + * The type Spring doc app 8 test. + */ +class SpringDocApp8Test extends AbstractSpringDocTest { + + /** + * Test app. + * + * @throws Exception the exception + */ + @Test + protected void testApp() throws Exception { + mockMvc.perform(get("/myapp" + Constants.DEFAULT_API_DOCS_URL).contextPath("/myapp")) + .andExpect(status().isOk()); + } + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app80/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app80/HelloController.java new file mode 100644 index 000000000..aa5d16e1c --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app80/HelloController.java @@ -0,0 +1,81 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app80; + +import java.net.URISyntaxException; + +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +@RequestMapping("/api") +class HelloController { + + + /** + * Testpost 1 response entity. + * + * @param dto the dto + * @return the response entity + * @throws URISyntaxException the uri syntax exception + */ + @RequestMapping(value = "/testpost1", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) + public ResponseEntity testpost1(@RequestBody TestObject dto) throws URISyntaxException { + return ResponseEntity.ok(dto); + } + + /** + * Testpost 2 response entity. + * + * @param dto the dto + * @return the response entity + * @throws URISyntaxException the uri syntax exception + */ + @RequestMapping(value = "/testpost2", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) + public ResponseEntity testpost2(@RequestBody TestObject dto) throws URISyntaxException { + return ResponseEntity.ok(dto); + } + + /** + * Hello response entity. + * + * @return the response entity + * @throws URISyntaxException the uri syntax exception + */ + @RequestMapping(value = "/hello", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) + public ResponseEntity hello() throws URISyntaxException { + return ResponseEntity.ok("Hello World"); + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app80/SpringDocApp80Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app80/SpringDocApp80Test.java new file mode 100644 index 000000000..954b4a88b --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app80/SpringDocApp80Test.java @@ -0,0 +1,45 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app80; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.test.context.ActiveProfiles; + +/** + * The type Spring doc app 80 test. + */ +@ActiveProfiles("80") +class SpringDocApp80Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app80/TestObject.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app80/TestObject.java new file mode 100644 index 000000000..0cd8ecc1f --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app80/TestObject.java @@ -0,0 +1,80 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app80; + +import java.time.LocalDateTime; + +/** + * The type Test object. + */ +class TestObject { + /** + * The String value. + */ + public String stringValue; + + /** + * The Local date time. + */ + public LocalDateTime localDateTime; + + /** + * Gets string value. + * + * @return the string value + */ + public String getStringValue() { + return stringValue; + } + + /** + * Sets string value. + * + * @param stringValue the string value + */ + public void setStringValue(String stringValue) { + this.stringValue = stringValue; + } + + /** + * Gets local date time. + * + * @return the local date time + */ + public LocalDateTime getLocalDateTime() { + return localDateTime; + } + + /** + * Sets local date time. + * + * @param localDateTime the local date time + */ + public void setLocalDateTime(LocalDateTime localDateTime) { + this.localDateTime = localDateTime; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app81/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app81/HelloController.java new file mode 100644 index 000000000..cbf695ba8 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app81/HelloController.java @@ -0,0 +1,49 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app81; + +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +@RequestMapping("/api") +class HelloController { + + /** + * Test string. + * + * @return the string + */ + @RequestMapping + public String test() { + return "ok"; + } + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app81/SpringDocApp81Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app81/SpringDocApp81Test.java new file mode 100644 index 000000000..d05f5977b --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app81/SpringDocApp81Test.java @@ -0,0 +1,84 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app81; + +import org.junit.jupiter.api.Test; +import org.springdoc.core.utils.Constants; +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +import static org.hamcrest.Matchers.containsString; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.startsWith; +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; + +/** + * The type Spring doc app 81 test. + */ +class SpringDocApp81Test extends AbstractSpringDocTest { + + /** + * Test app. + * + * @throws Exception the exception + */ + @Test + protected void testApp() throws Exception { + mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL)).andExpect(status().isOk()) + .andExpect(jsonPath("$.openapi", is("3.1.0"))) + .andExpect(jsonPath("$.paths./api.get.tags[0]", containsString("hello-controller"))) + .andExpect(jsonPath("$.paths./api.get.operationId", startsWith("test"))) + .andExpect(jsonPath("$.paths./api.get.responses.200.content.['*/*'].schema.type", is("string"))) + .andExpect(jsonPath("$.paths./api.post.tags[0]", containsString("hello-controller"))) + .andExpect(jsonPath("$.paths./api.post.operationId", startsWith("test"))) + .andExpect(jsonPath("$.paths./api.post.responses.200.content.['*/*'].schema.type", is("string"))) + .andExpect(jsonPath("$.paths./api.put.tags[0]", containsString("hello-controller"))) + .andExpect(jsonPath("$.paths./api.put.operationId", startsWith("test"))) + .andExpect(jsonPath("$.paths./api.put.responses.200.content.['*/*'].schema.type", is("string"))) + .andExpect(jsonPath("$.paths./api.patch.tags[0]", containsString("hello-controller"))) + .andExpect(jsonPath("$.paths./api.patch.operationId", startsWith("test"))) + .andExpect(jsonPath("$.paths./api.patch.responses.200.content.['*/*'].schema.type", is("string"))) + .andExpect(jsonPath("$.paths./api.delete.tags[0]", containsString("hello-controller"))) + .andExpect(jsonPath("$.paths./api.delete.operationId", startsWith("test"))) + .andExpect(jsonPath("$.paths./api.delete.responses.200.content.['*/*'].schema.type", is("string"))) + .andExpect(jsonPath("$.paths./api.options.tags[0]", containsString("hello-controller"))) + .andExpect(jsonPath("$.paths./api.options.operationId", startsWith("test"))) + .andExpect(jsonPath("$.paths./api.options.responses.200.content.['*/*'].schema.type", is("string"))) + .andExpect(jsonPath("$.paths./api.head.tags[0]", containsString("hello-controller"))) + .andExpect(jsonPath("$.paths./api.head.operationId", startsWith("test"))) + .andExpect(jsonPath("$.paths./api.head.responses.200.content.['*/*'].schema.type", is("string"))); + } + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app82/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app82/HelloController.java new file mode 100644 index 000000000..5172ba8e8 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app82/HelloController.java @@ -0,0 +1,55 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app82; + +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + + /** + * Put response entity. + * + * @param configuration the configuration + * @param second the second + * @param personDTO the person dto + * @return the response entity + */ + @PutMapping(value = "/test") + public ResponseEntity put( + String configuration, + String second, PersonDTO personDTO) { + return null; + } + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app82/PersonDTO.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app82/PersonDTO.java new file mode 100644 index 000000000..97f98c040 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app82/PersonDTO.java @@ -0,0 +1,120 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app82; + +/** + * The type Person dto. + */ +class PersonDTO { + /** + * The Email. + */ + private String email; + + /** + * The First name. + */ + private String firstName; + + /** + * The Last name. + */ + private String lastName; + + /** + * Instantiates a new Person dto. + */ + public PersonDTO() { + } + + /** + * Instantiates a new Person dto. + * + * @param email the email + * @param firstName the first name + * @param lastName the last name + */ + public PersonDTO(final String email, final String firstName, final String lastName) { + this.email = email; + this.firstName = firstName; + this.lastName = lastName; + } + + /** + * Gets email. + * + * @return the email + */ + public String getEmail() { + return email; + } + + /** + * Sets email. + * + * @param email the email + */ + public void setEmail(final String email) { + this.email = email; + } + + /** + * Gets first name. + * + * @return the first name + */ + public String getFirstName() { + return firstName; + } + + /** + * Sets first name. + * + * @param firstName the first name + */ + public void setFirstName(final String firstName) { + this.firstName = firstName; + } + + /** + * Gets last name. + * + * @return the last name + */ + public String getLastName() { + return lastName; + } + + /** + * Sets last name. + * + * @param lastName the last name + */ + public void setLastName(final String lastName) { + this.lastName = lastName; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app82/SpringDocApp82Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app82/SpringDocApp82Test.java new file mode 100644 index 000000000..e61d1eae8 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app82/SpringDocApp82Test.java @@ -0,0 +1,44 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app82; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 82 test. + */ +class SpringDocApp82Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app83/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app83/HelloController.java new file mode 100644 index 000000000..c4aa38cdc --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app83/HelloController.java @@ -0,0 +1,68 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app83; + +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.media.Schema; + +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.multipart.MultipartFile; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + + /** + * Put response entity. + * + * @param config the config + * @param configuration the configuration + * @param aFile the a file + * @return the response entity + */ + @RequestMapping(value = "/{config}", + method = RequestMethod.PUT, + consumes = { MediaType.MULTIPART_FORM_DATA_VALUE }, + produces = { MediaType.APPLICATION_JSON_VALUE } + ) + public ResponseEntity put( + @PathVariable("config") final String config, + @Parameter(name = "configuration", schema = @Schema(name = "configuration", type = "string", format = "binary")) @RequestPart(value = "configuration") final PersonDTO configuration, + @RequestPart(value = "file") final MultipartFile aFile) { + return null; + } + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app83/PersonDTO.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app83/PersonDTO.java new file mode 100644 index 000000000..a56295e75 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app83/PersonDTO.java @@ -0,0 +1,120 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app83; + +/** + * The type Person dto. + */ +class PersonDTO { + /** + * The Email. + */ + private String email; + + /** + * The First name. + */ + private String firstName; + + /** + * The Last name. + */ + private String lastName; + + /** + * Instantiates a new Person dto. + */ + public PersonDTO() { + } + + /** + * Instantiates a new Person dto. + * + * @param email the email + * @param firstName the first name + * @param lastName the last name + */ + public PersonDTO(final String email, final String firstName, final String lastName) { + this.email = email; + this.firstName = firstName; + this.lastName = lastName; + } + + /** + * Gets email. + * + * @return the email + */ + public String getEmail() { + return email; + } + + /** + * Sets email. + * + * @param email the email + */ + public void setEmail(final String email) { + this.email = email; + } + + /** + * Gets first name. + * + * @return the first name + */ + public String getFirstName() { + return firstName; + } + + /** + * Sets first name. + * + * @param firstName the first name + */ + public void setFirstName(final String firstName) { + this.firstName = firstName; + } + + /** + * Gets last name. + * + * @return the last name + */ + public String getLastName() { + return lastName; + } + + /** + * Sets last name. + * + * @param lastName the last name + */ + public void setLastName(final String lastName) { + this.lastName = lastName; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app83/SpringDocApp83Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app83/SpringDocApp83Test.java new file mode 100644 index 000000000..6325d986d --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app83/SpringDocApp83Test.java @@ -0,0 +1,44 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app83; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 83 test. + */ +class SpringDocApp83Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app84/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app84/HelloController.java new file mode 100644 index 000000000..c3918c93e --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app84/HelloController.java @@ -0,0 +1,61 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app84; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +@RequestMapping("/api") +class HelloController { + + /** + * Persons string. + * + * @return the string + */ + @GetMapping("/persons") + public String persons() { + return "OK"; + } + + /** + * Persons string. + * + * @param toto the toto + * @return the string + */ + @GetMapping("/persons1") + public String persons(String toto) { + return "OK"; + } + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app84/SpringDocApp84Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app84/SpringDocApp84Test.java new file mode 100644 index 000000000..22a65f3a8 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app84/SpringDocApp84Test.java @@ -0,0 +1,44 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app84; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 84 test. + */ +class SpringDocApp84Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app85/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app85/HelloController.java new file mode 100644 index 000000000..b42ba38b8 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app85/HelloController.java @@ -0,0 +1,58 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app85; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; + +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +@RequestMapping("/api") +class HelloController { + + /** + * Testme. + * + * @param id the id + */ + @PostMapping("/test/{id}") + @Operation( + parameters = { + @Parameter(ref = "#/components/parameters/paramA"), + @Parameter(ref = "#/components/parameters/paramB") + } + ) + public void testme(@PathVariable("id") String id) { + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app85/SpringDocApp85Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app85/SpringDocApp85Test.java new file mode 100644 index 000000000..f193f7508 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app85/SpringDocApp85Test.java @@ -0,0 +1,44 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app85; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 85 test. + */ +class SpringDocApp85Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app86/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app86/HelloController.java new file mode 100644 index 000000000..9578d20ff --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app86/HelloController.java @@ -0,0 +1,58 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app86; + +import java.util.Locale; + +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; +import jakarta.servlet.http.HttpSession; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * Test. + * + * @param header the header + * @param request the request + * @param response the response + * @param locale the locale + * @param hello the hello + */ + @GetMapping("/test") + public void test(HttpSession header, HttpServletRequest request, HttpServletResponse response, Locale locale, + String hello) { + } + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app86/SpringDocApp86Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app86/SpringDocApp86Test.java new file mode 100644 index 000000000..065a4a620 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app86/SpringDocApp86Test.java @@ -0,0 +1,47 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app86; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.test.context.TestPropertySource; + +/** + * The type Spring doc app 86 test. + */ +@TestPropertySource(properties = { + "springdoc.packagesToScan=test.org.springdoc.api.v31.app86", + "springdoc.packagesToExclude=test.org.springdoc.api.v31.app86.test" }) +class SpringDocApp86Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app86/test/HelloController2.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app86/test/HelloController2.java new file mode 100644 index 000000000..1e1a530a3 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app86/test/HelloController2.java @@ -0,0 +1,58 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app86.test; + +import java.util.Locale; + +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; +import jakarta.servlet.http.HttpSession; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller 2. + */ +@RestController +class HelloController2 { + + /** + * Test. + * + * @param header the header + * @param request the request + * @param response the response + * @param locale the locale + * @param hello the hello + */ + @GetMapping("/test2") + public void test(HttpSession header, HttpServletRequest request, HttpServletResponse response, Locale locale, + String hello) { + } + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app87/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app87/HelloController.java new file mode 100644 index 000000000..e22461209 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app87/HelloController.java @@ -0,0 +1,72 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app87; + +import java.util.UUID; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.parameters.RequestBody; + +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.CookieValue; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RestController; + + +/** + * The type Hello controller. + */ +@RestController("cookie") +class HelloController { + + /** + * Put item response entity. + * + * @param cookie the cookie + * @param itemId the item id + * @param item the item + * @return the response entity + */ + @PutMapping("/{itemId}") + @Operation + public ResponseEntity putItem( + @CookieValue( + name = "cookie" + ) String cookie, + @PathVariable UUID itemId, + @RequestBody Item item + ) { + return ResponseEntity.ok(item); + } + + /** + * The type Item. + */ + public static class Item { + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app87/SpringDocApp87Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app87/SpringDocApp87Test.java new file mode 100644 index 000000000..10f9e894a --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app87/SpringDocApp87Test.java @@ -0,0 +1,44 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app87; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 87 test. + */ +class SpringDocApp87Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app88/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app88/HelloController.java new file mode 100644 index 000000000..0b35d6d30 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app88/HelloController.java @@ -0,0 +1,48 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app88; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * Persons string. + * + * @return the string + */ + @GetMapping(value = "/persons") + public String persons() { + return null; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app88/SpringDocApp88Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app88/SpringDocApp88Test.java new file mode 100644 index 000000000..4a6a6a41e --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app88/SpringDocApp88Test.java @@ -0,0 +1,45 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app88; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.test.context.TestPropertySource; + +/** + * The type Spring doc app 88 test. + */ +@TestPropertySource(properties = "springdoc.auto-tag-classes=false") +class SpringDocApp88Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app89/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app89/HelloController.java new file mode 100644 index 000000000..8cfb08cd4 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app89/HelloController.java @@ -0,0 +1,54 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app89; + +import io.swagger.v3.oas.annotations.Operation; + +import org.springframework.http.MediaType; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.servlet.ModelAndView; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * Gets address. + * + * @param id the id + * @return the address + */ + @Operation(summary = "Get Status") + @GetMapping(value = "/status/{id}", produces = MediaType.TEXT_HTML_VALUE) + public ModelAndView getAddress(@PathVariable String id) { + return null; + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app89/SpringDocApp89Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app89/SpringDocApp89Test.java new file mode 100644 index 000000000..1a280cc1d --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app89/SpringDocApp89Test.java @@ -0,0 +1,54 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app89; + + +import io.swagger.v3.oas.models.media.ObjectSchema; +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.test.context.TestPropertySource; +import org.springframework.web.servlet.ModelAndView; + +import static org.springdoc.core.utils.SpringDocUtils.getConfig; + +/** + * The type Spring doc app 89 test. + */ +@TestPropertySource(properties = "springdoc.model-and-view-allowed=true") +class SpringDocApp89Test extends AbstractSpringDocTest { + + static { + getConfig().replaceWithSchema(ModelAndView.class, new ObjectSchema()); + } + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app9/MyApi.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app9/MyApi.java new file mode 100644 index 000000000..a68771497 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app9/MyApi.java @@ -0,0 +1,54 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app9; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.enums.ParameterIn; + +import org.springframework.http.HttpHeaders; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestHeader; +import org.springframework.web.bind.annotation.RequestMapping; + +/** + * The interface My api. + */ +@RequestMapping("/myapi") +public interface MyApi { + + /** + * Get string. + * + * @param language the language + * @return the string + */ + @Operation(description = "Annotations from interfaces test") + @GetMapping + String get( + @Parameter(hidden = true, in = ParameterIn.HEADER, name = HttpHeaders.ACCEPT_LANGUAGE) @RequestHeader(value = HttpHeaders.ACCEPT_LANGUAGE, required = false) String language); +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app9/MyApiController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app9/MyApiController.java new file mode 100644 index 000000000..0b0f20f5e --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app9/MyApiController.java @@ -0,0 +1,62 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app9; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type My api controller. + */ +@RestController +class MyApiController implements MyApi { + /** + * Get string. + * + * @param language the language + * @return the string + */ + public String get(String language) { + return language; + } + + + /** + * Gets code. + * + * @param code the code + * @return the code + */ + @Operation(description = "Annotations from class with hidden parameter code") + @GetMapping("/getCode") + public String getCode(@Parameter(hidden = true) String code) { + return code; + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app9/SpringDocApp9Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app9/SpringDocApp9Test.java new file mode 100644 index 000000000..0e58cc04e --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app9/SpringDocApp9Test.java @@ -0,0 +1,44 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app9; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 9 test. + */ +class SpringDocApp9Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app90/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app90/HelloController.java new file mode 100644 index 000000000..917a21704 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app90/HelloController.java @@ -0,0 +1,81 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app90; + +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.ExampleObject; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.parameters.RequestBody; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; + +import org.springframework.http.MediaType; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * Test 1. + * + * @param hello the hello + */ + @GetMapping("/test") + @ApiResponses(value = { @ApiResponse(description = "successful operation", content = { @Content(examples = @ExampleObject(name = "500", ref = "#/components/examples/http500Example"), mediaType = "application/json", schema = @Schema(implementation = User.class)), @Content(mediaType = "application/xml", schema = @Schema(implementation = User.class)) }) }) + public void test1(String hello) { + } + + /** + * Test 2. + * + * @param hello the hello + */ + @PostMapping("/test2") + @RequestBody( + description = "Details of the Item to be created", + required = true, + content = @Content( + schema = @Schema(implementation = User.class), + mediaType = MediaType.APPLICATION_JSON_VALUE, + examples = { + @ExampleObject( + name = "An example request with the minimum required fields to create.", + value = "min", + summary = "Minimal request"), + @ExampleObject( + name = "An example request with all fields provided with example values.", + value = "full", + summary = "Full request") })) + public void test2(String hello) { + } + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app90/SpringDocApp90Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app90/SpringDocApp90Test.java new file mode 100644 index 000000000..eea3cd9f3 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app90/SpringDocApp90Test.java @@ -0,0 +1,37 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app90; + + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +/** + * The type Spring doc app 90 test. + */ +class SpringDocApp90Test extends AbstractSpringDocTest { + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app90/SpringDocTestApp.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app90/SpringDocTestApp.java new file mode 100644 index 000000000..edfa88b49 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app90/SpringDocTestApp.java @@ -0,0 +1,103 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app90; + +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.Reader; +import java.io.UncheckedIOException; +import java.util.AbstractMap; +import java.util.Collection; +import java.util.Map.Entry; + +import io.swagger.v3.oas.models.examples.Example; +import org.springdoc.core.customizers.OpenApiCustomizer; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; +import org.springframework.core.io.Resource; +import org.springframework.util.FileCopyUtils; + +/** + * The type Spring doc test app. + */ +@SpringBootApplication +class SpringDocTestApp { + + /** + * The Http 500 example resource. + */ + @Value("classpath:/500-90.txt") + private Resource http500ExampleResource; + + /** + * As string string. + * + * @param resource the resource + * @return the string + */ + public static String asString(Resource resource) { + try (Reader reader = new InputStreamReader(resource.getInputStream())) { + return FileCopyUtils.copyToString(reader); + } + catch (IOException e) { + throw new UncheckedIOException(e); + } + } + + /** + * Open api customiser open api customiser. + * + * @param examples the examples + * @return the open api customiser + */ + @Bean + public OpenApiCustomizer openApiCustomizer(Collection> examples) { + return openAPI -> { + examples.forEach(example -> { + openAPI.getComponents().addExamples(example.getKey(), example.getValue()); + }); + }; + } + + /** + * Http 500 example entry. + * + * @return the entry + */ + @Bean + public Entry http500Example() { + Example http500Example = new Example(); + Entry entry = new AbstractMap.SimpleEntry("http500Example", http500Example); + http500Example.setSummary("HTTP 500 JSON Body response example"); + http500Example.setDescription( + "An example of HTTP response in case an error occurs on server side. instance attribute reference a traceId to ease server side analysis."); + http500Example.setValue(asString(http500ExampleResource)); + return entry; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app90/User.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app90/User.java new file mode 100644 index 000000000..5285d7377 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app90/User.java @@ -0,0 +1,448 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app90; + +import java.util.Objects; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.v3.oas.annotations.media.Schema; + +/** + * User + */ +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen", date = "2019-11-30T09:49:26.034469-01:00[Atlantic/Azores]") + + +class User { + + /** + * The Id. + */ + @JsonProperty("id") + + private Long id; + + + /** + * The Username. + */ + @JsonProperty("username") + + private String username; + + + /** + * The First name. + */ + @JsonProperty("firstName") + + private String firstName; + + + /** + * The Last name. + */ + @JsonProperty("lastName") + + private String lastName; + + + /** + * The Email. + */ + @JsonProperty("email") + + private String email; + + + /** + * The Password. + */ + @JsonProperty("password") + + private String password; + + + /** + * The Phone. + */ + @JsonProperty("phone") + + private String phone; + + + /** + * The User status. + */ + @JsonProperty("userStatus") + + private Integer userStatus; + + + /** + * Id user. + * + * @param id the id + * @return the user + */ + public User id(Long id) { + this.id = id; + return this; + } + + + /** + * Get id + * + * @return id id + */ + @Schema(example = "10", description = "") + + + public Long getId() { + return id; + } + + /** + * Sets id. + * + * @param id the id + */ + public void setId(Long id) { + this.id = id; + } + + + /** + * Username user. + * + * @param username the username + * @return the user + */ + public User username(String username) { + this.username = username; + return this; + } + + + /** + * Get username + * + * @return username username + */ + @Schema(example = "theUser", description = "") + + + public String getUsername() { + return username; + } + + /** + * Sets username. + * + * @param username the username + */ + public void setUsername(String username) { + this.username = username; + } + + + /** + * First name user. + * + * @param firstName the first name + * @return the user + */ + public User firstName(String firstName) { + this.firstName = firstName; + return this; + } + + + /** + * Get firstName + * + * @return firstName first name + */ + @Schema(example = "John", description = "") + + + public String getFirstName() { + return firstName; + } + + /** + * Sets first name. + * + * @param firstName the first name + */ + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + + /** + * Last name user. + * + * @param lastName the last name + * @return the user + */ + public User lastName(String lastName) { + this.lastName = lastName; + return this; + } + + + /** + * Get lastName + * + * @return lastName last name + */ + @Schema(example = "James", description = "") + + + public String getLastName() { + return lastName; + } + + /** + * Sets last name. + * + * @param lastName the last name + */ + public void setLastName(String lastName) { + this.lastName = lastName; + } + + + /** + * Email user. + * + * @param email the email + * @return the user + */ + public User email(String email) { + this.email = email; + return this; + } + + + /** + * Get email + * + * @return email email + */ + @Schema(example = "john@email.com", description = "") + + + public String getEmail() { + return email; + } + + /** + * Sets email. + * + * @param email the email + */ + public void setEmail(String email) { + this.email = email; + } + + + /** + * Password user. + * + * @param password the password + * @return the user + */ + public User password(String password) { + this.password = password; + return this; + } + + + /** + * Get password + * + * @return password password + */ + @Schema(example = "12345", description = "") + + + public String getPassword() { + return password; + } + + /** + * Sets password. + * + * @param password the password + */ + public void setPassword(String password) { + this.password = password; + } + + + /** + * Phone user. + * + * @param phone the phone + * @return the user + */ + public User phone(String phone) { + this.phone = phone; + return this; + } + + + /** + * Get phone + * + * @return phone phone + */ + @Schema(example = "12345", description = "") + + + public String getPhone() { + return phone; + } + + /** + * Sets phone. + * + * @param phone the phone + */ + public void setPhone(String phone) { + this.phone = phone; + } + + + /** + * User status user. + * + * @param userStatus the user status + * @return the user + */ + public User userStatus(Integer userStatus) { + this.userStatus = userStatus; + return this; + } + + + /** + * User Status + * + * @return userStatus user status + */ + @Schema(example = "1", description = "User Status") + + + public Integer getUserStatus() { + return userStatus; + } + + /** + * Sets user status. + * + * @param userStatus the user status + */ + public void setUserStatus(Integer userStatus) { + this.userStatus = userStatus; + } + + + /** + * Equals boolean. + * + * @param o the o + * @return the boolean + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + User user = (User) o; + return Objects.equals(this.id, user.id) && + Objects.equals(this.username, user.username) && + Objects.equals(this.firstName, user.firstName) && + Objects.equals(this.lastName, user.lastName) && + Objects.equals(this.email, user.email) && + Objects.equals(this.password, user.password) && + Objects.equals(this.phone, user.phone) && + Objects.equals(this.userStatus, user.userStatus); + } + + /** + * Hash code int. + * + * @return the int + */ + @Override + public int hashCode() { + return Objects.hash(id, username, firstName, lastName, email, password, phone, userStatus); + } + + /** + * To string string. + * + * @return the string + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class User {\n"); + + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" username: ").append(toIndentedString(username)).append("\n"); + sb.append(" firstName: ").append(toIndentedString(firstName)).append("\n"); + sb.append(" lastName: ").append(toIndentedString(lastName)).append("\n"); + sb.append(" email: ").append(toIndentedString(email)).append("\n"); + sb.append(" password: ").append(toIndentedString(password)).append("\n"); + sb.append(" phone: ").append(toIndentedString(phone)).append("\n"); + sb.append(" userStatus: ").append(toIndentedString(userStatus)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + * @param o the o + * @return the string + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} + diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app91/Advice.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app91/Advice.java new file mode 100644 index 000000000..e2b311cb6 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app91/Advice.java @@ -0,0 +1,110 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app91; + +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.ExampleObject; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import jakarta.servlet.http.HttpServletRequest; + +import org.springframework.beans.TypeMismatchException; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.ResponseStatus; +import org.springframework.web.bind.annotation.RestControllerAdvice; + +/** + * The type Advice. + */ +@RestControllerAdvice +class Advice { + + /** + * Bad request response entity. + * + * @param req the req + * @param exception the exception + * @return the response entity + */ + @ExceptionHandler(TypeMismatchException.class) + @ResponseStatus(HttpStatus.BAD_REQUEST) + @ApiResponse( + responseCode = "400", + description = "Bad Request", + content = + @Content( + mediaType = MediaType.APPLICATION_JSON_VALUE, + schema = @Schema(implementation = ApiError.class), + examples = { + @ExampleObject( + name = "Service-400", + summary = "400 from the service directly", + value = + "{\"status\": 400," + + "\"errorCode\": \"ERROR_001\"," + + "\"message\": \"An example message...\"" + + "}") + })) + public ResponseEntity badRequest(HttpServletRequest req, Exception exception) { + ApiError erroObj = new ApiError(400, "A code", "A message"); + return new ResponseEntity<>(erroObj, HttpStatus.BAD_REQUEST); + } + + /** + * Internal server error response entity. + * + * @param req the req + * @param exception the exception + * @return the response entity + */ + @ExceptionHandler(Exception.class) + @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR) + @ApiResponse( + responseCode = "500", + description = "Internal Server Error", + content = + @Content( + mediaType = MediaType.APPLICATION_JSON_VALUE, + schema = @Schema(implementation = ApiError.class), + examples = { + @ExampleObject( + name = "Service-500", + summary = "500 from the service directly", + value = + "{\"status\": 500," + + "\"errorCode\": \"ERROR_002\"," + + "\"message\": \"Another example message...\"" + + "}") + })) + public ResponseEntity internalServerError(HttpServletRequest req, Exception exception) { + ApiError erroObj = new ApiError(500, "A different code", "A different message"); + return new ResponseEntity<>(erroObj, HttpStatus.INTERNAL_SERVER_ERROR); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app91/ApiError.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app91/ApiError.java new file mode 100644 index 000000000..266139103 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app91/ApiError.java @@ -0,0 +1,79 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app91; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.v3.oas.annotations.media.Schema; + +/** + * The type Api error. + */ +@Schema( + type = "object", + name = "ApiError", + title = "ApiError", + description = "A consistent response object for sending errors over the wire.") +class ApiError { + + /** + * The Status. + */ + @Schema(name = "status", description = "The Http Status value", type = "int", nullable = true) + @JsonProperty("status") + private int status; + + /** + * The Error code. + */ + @Schema( + name = "errorCode", + description = "An Error Code which can help with identifying issues.", + type = "string", + nullable = true) + @JsonProperty("errorCode") + private String errorCode; + + /** + * The Message. + */ + @Schema(name = "message", description = "The Error Message.", type = "string", nullable = false) + @JsonProperty("message") + private String message; + + /** + * Instantiates a new Api error. + * + * @param status the status + * @param errorCode the error code + * @param message the message + */ + public ApiError(int status, String errorCode, String message) { + this.status = status; + this.errorCode = errorCode; + this.message = message; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app91/Greeting.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app91/Greeting.java new file mode 100644 index 000000000..448a59c42 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app91/Greeting.java @@ -0,0 +1,63 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app91; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.v3.oas.annotations.media.Schema; + +/** + * The type Greeting. + */ +@Schema( + type = "object", + name = "Greeting", + title = "Greeting", + description = "An object containing a greeting message") +class Greeting { + + + /** + * The Payload. + */ + @Schema( + name = "payload", + description = "The greeting value", + type = "string", + nullable = false, + example = "sdfsdfs") + @JsonProperty("payload") + private String payload; + + /** + * Instantiates a new Greeting. + * + * @param payload the payload + */ + public Greeting(String payload) { + this.payload = payload; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app91/GreetingController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app91/GreetingController.java new file mode 100644 index 000000000..eb5093235 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app91/GreetingController.java @@ -0,0 +1,72 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app91; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.apache.commons.lang3.RandomStringUtils; + +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE; + +/** + * The type Greeting controller. + */ +@RestController +@Tag(name = "Demo", description = "The Demo API") +class GreetingController { + + /** + * Say hello response entity. + * + * @return the response entity + */ + @GetMapping(produces = APPLICATION_JSON_VALUE) + @Operation(summary = "This API will return a random greeting.") + public ResponseEntity sayHello() { + return ResponseEntity.ok(new Greeting(RandomStringUtils.randomAlphanumeric(10))); + } + + /** + * Say hello 2 response entity. + * + * @return the response entity + */ + @GetMapping("/test") + @ApiResponses(value = { @ApiResponse(responseCode = "201", description = "item created"), + @ApiResponse(responseCode = "400", description = "invalid input, object invalid"), + @ApiResponse(responseCode = "409", description = "an existing item already exists") }) + public ResponseEntity sayHello2() { + return ResponseEntity.ok(new Greeting(RandomStringUtils.randomAlphanumeric(10))); + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app91/SpringDocApp91Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app91/SpringDocApp91Test.java new file mode 100644 index 000000000..be13c4450 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app91/SpringDocApp91Test.java @@ -0,0 +1,47 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app91; + + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.test.context.TestPropertySource; + +/** + * The type Spring doc app 91 test. + */ +@TestPropertySource(properties = "springdoc.override-with-generic-response=false") +class SpringDocApp91Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app92/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app92/HelloController.java new file mode 100644 index 000000000..d84ac0882 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app92/HelloController.java @@ -0,0 +1,53 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app92; + +import jakarta.validation.constraints.NotNull; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +@RequestMapping("/test") +class HelloController { + + /** + * Index string. + * + * @param test the test + * @return the string + */ + @GetMapping + String index(@NotNull String test) { + return null; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app92/ParameterCustomizer.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app92/ParameterCustomizer.java new file mode 100644 index 000000000..8385d851c --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app92/ParameterCustomizer.java @@ -0,0 +1,55 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app92; + +import io.swagger.v3.oas.models.parameters.Parameter; +import jakarta.validation.constraints.NotNull; + +import org.springframework.core.MethodParameter; +import org.springframework.stereotype.Component; + +/** + * The type Parameter customizer. + */ +@Component +class ParameterCustomizer implements org.springdoc.core.customizers.ParameterCustomizer { + /** + * Customize parameter. + * + * @param parameterModel the parameter model + * @param methodParameter the method parameter + * @return the parameter + */ + @Override + public Parameter customize(Parameter parameterModel, MethodParameter methodParameter) { + NotNull annotation = methodParameter.getParameterAnnotation(NotNull.class); + if (annotation != null) { + parameterModel.required(false); + } + return parameterModel; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app92/SpringDocApp92Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app92/SpringDocApp92Test.java new file mode 100644 index 000000000..af4afcb39 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app92/SpringDocApp92Test.java @@ -0,0 +1,45 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app92; + + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 92 test. + */ +class SpringDocApp92Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app93/BaseClientModel.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app93/BaseClientModel.java new file mode 100644 index 000000000..e19822f3c --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app93/BaseClientModel.java @@ -0,0 +1,40 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app93; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The type Base client model. + */ +public abstract class BaseClientModel { + /** + * The Id. + */ + @JsonProperty("id") + int id; +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app93/BaseController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app93/BaseController.java new file mode 100644 index 000000000..88bdc0393 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app93/BaseController.java @@ -0,0 +1,50 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app93; + +import io.swagger.v3.oas.annotations.Operation; + +import org.springframework.web.bind.annotation.GetMapping; + +/** + * The type Base controller. + * + * @param the type parameter + */ +public abstract class BaseController { + /** + * Get t client model. + * + * @param param the param + * @return the t client model + */ + @Operation + @GetMapping + TClientModel get(TClientModel param) { + return null; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app93/SpecificClientModel.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app93/SpecificClientModel.java new file mode 100644 index 000000000..132a4334f --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app93/SpecificClientModel.java @@ -0,0 +1,40 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app93; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The type Specific client model. + */ +class SpecificClientModel extends BaseClientModel { + /** + * The Name. + */ + @JsonProperty("name") + String name; +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app93/SpecificController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app93/SpecificController.java new file mode 100644 index 000000000..f5854fce0 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app93/SpecificController.java @@ -0,0 +1,35 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app93; + +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Specific controller. + */ +@RestController +class SpecificController extends BaseController {} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app93/SpringDocApp93Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app93/SpringDocApp93Test.java new file mode 100644 index 000000000..e3f138de5 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app93/SpringDocApp93Test.java @@ -0,0 +1,45 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app93; + + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 93 test. + */ +class SpringDocApp93Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app94/Greeting.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app94/Greeting.java new file mode 100644 index 000000000..d14d9896c --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app94/Greeting.java @@ -0,0 +1,63 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app94; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.v3.oas.annotations.media.Schema; + +/** + * The type Greeting. + */ +@Schema( + type = "object", + name = "Greeting", + title = "Greeting", + description = "An object containing a greeting message") +class Greeting { + + + /** + * The Payload. + */ + @Schema( + name = "payload", + description = "The greeting value", + type = "string", + nullable = false, + example = "sdfsdfs") + @JsonProperty("payload") + private String payload; + + /** + * Instantiates a new Greeting. + * + * @param payload the payload + */ + public Greeting(String payload) { + this.payload = payload; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app94/SpringDocApp94Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app94/SpringDocApp94Test.java new file mode 100644 index 000000000..90a78859c --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app94/SpringDocApp94Test.java @@ -0,0 +1,186 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app94; + +import java.util.Collections; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.apache.commons.lang3.RandomStringUtils; +import org.springdoc.core.customizers.OpenApiBuilderCustomizer; +import org.springdoc.core.customizers.SpringDocCustomizers; +import org.springdoc.core.properties.SpringDocConfigProperties; +import org.springdoc.core.providers.SpringDocProviders; +import org.springdoc.core.service.AbstractRequestService; +import org.springdoc.core.service.GenericResponseService; +import org.springdoc.core.service.OpenAPIService; +import org.springdoc.core.service.OperationService; +import org.springdoc.webmvc.api.OpenApiWebMvcResource; +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.beans.BeansException; +import org.springframework.beans.factory.ObjectFactory; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.ApplicationContext; +import org.springframework.context.ApplicationContextAware; +import org.springframework.context.annotation.Bean; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.test.context.TestPropertySource; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.servlet.mvc.method.RequestMappingInfo; +import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping; + +import static org.springdoc.core.utils.Constants.DEFAULT_GROUP_NAME; +import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE; + +/** + * The type Spring doc app 94 test. + */ +@TestPropertySource(properties = "springdoc.default-produces-media-type=application/json") +class SpringDocApp94Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp implements ApplicationContextAware { + + /** + * The Application context. + */ + private ApplicationContext applicationContext; + + /** + * Greeting controller greeting controller. + * + * @return the greeting controller + */ + @Bean + public GreetingController greetingController() { + return new GreetingController(); + } + + /** + * Custom open api open api builder customizer. + * + * @return the open api builder customizer + */ + @Bean + public OpenApiBuilderCustomizer customOpenAPI() { + return openApiBuilder -> openApiBuilder.addMappings(Collections.singletonMap("greetingController", new GreetingController())); + } + + /** + * Default test handler mapping request mapping handler mapping. + * + * @param greetingController the greeting controller + * @return the request mapping handler mapping + * @throws NoSuchMethodException the no such method exception + */ + @Bean + public RequestMappingHandlerMapping defaultTestHandlerMapping(GreetingController greetingController) throws NoSuchMethodException { + RequestMappingHandlerMapping result = new RequestMappingHandlerMapping(); + RequestMappingInfo requestMappingInfo = + RequestMappingInfo.paths("/test").methods(RequestMethod.GET).produces(MediaType.APPLICATION_JSON_VALUE).build(); + + result.setApplicationContext(this.applicationContext); + result.registerMapping(requestMappingInfo, "greetingController", GreetingController.class.getDeclaredMethod("sayHello2")); + //result.handlerme + return result; + } + + /** + * Open api resource open api web mvc resource. + * + * @param openAPIBuilderObjectFactory the open api builder object factory + * @param requestBuilder the request builder + * @param responseBuilder the response builder + * @param operationParser the operation parser + * @param springDocConfigProperties the spring doc config properties + * @param springDocProviders the spring doc providers + * @param springDocCustomizers the spring doc customizers + * @return the open api web mvc resource + */ + @Bean(name = "openApiResource") + public OpenApiWebMvcResource openApiResource(ObjectFactory openAPIBuilderObjectFactory, AbstractRequestService requestBuilder, GenericResponseService responseBuilder, + OperationService operationParser, + SpringDocConfigProperties springDocConfigProperties, + SpringDocProviders springDocProviders, SpringDocCustomizers springDocCustomizers) { + return new OpenApiWebMvcResource(DEFAULT_GROUP_NAME, openAPIBuilderObjectFactory, requestBuilder, responseBuilder, operationParser, + springDocConfigProperties, springDocProviders, springDocCustomizers); + } + + /** + * Sets application context. + * + * @param applicationContext the application context + * @throws BeansException the beans exception + */ + @Override + public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { + this.applicationContext = applicationContext; + } + } + + /** + * The type Greeting controller. + */ + @ResponseBody + @Tag(name = "Demo", description = "The Demo API") + public static class GreetingController { + + /** + * Say hello response entity. + * + * @return the response entity + */ + @GetMapping(produces = APPLICATION_JSON_VALUE) + @Operation(summary = "This API will return a random greeting.") + public ResponseEntity sayHello() { + return ResponseEntity.ok(new Greeting(RandomStringUtils.randomAlphanumeric(10))); + } + + /** + * Say hello 2 response entity. + * + * @return the response entity + */ + @GetMapping("/test") + @ApiResponses(value = { @ApiResponse(responseCode = "201", description = "item created"), + @ApiResponse(responseCode = "400", description = "invalid input, object invalid"), + @ApiResponse(responseCode = "409", description = "an existing item already exists") }) + public ResponseEntity sayHello2() { + return ResponseEntity.ok(new Greeting(RandomStringUtils.randomAlphanumeric(10))); + } + + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app95/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app95/HelloController.java new file mode 100644 index 000000000..686725a6f --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app95/HelloController.java @@ -0,0 +1,55 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app95; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +@RequestMapping("/persons") +class HelloController { + + /** + * Persons. + * + * @param name the name + */ + @GetMapping + @Operation(summary = "${test.app95.operation.persons.summary}", + description = "${test.app95.operation.persons.description}") + public void persons(@Parameter(description = "${test.app95.param.name.description}") String name) { + + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app95/SpringDocApp95Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app95/SpringDocApp95Test.java new file mode 100644 index 000000000..e2fd97ecf --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app95/SpringDocApp95Test.java @@ -0,0 +1,47 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app95; + + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.test.context.ActiveProfiles; + +/** + * The type Spring doc app 95 test. + */ +@ActiveProfiles("95") +class SpringDocApp95Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app96/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app96/HelloController.java new file mode 100644 index 000000000..c130d2c11 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app96/HelloController.java @@ -0,0 +1,76 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app96; + +import jakarta.validation.constraints.Min; +import jakarta.validation.constraints.NotNull; + +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + + /** + * Test 1 string. + * + * @param test the test + * @return the string + */ + @PostMapping("/api1") + String test1(@RequestBody @Min(2) int test) { + return null; + } + + /** + * Test 2 string. + * + * @param test the test + * @return the string + */ + @PostMapping("/api2") + String test2(@RequestBody String test) { + return null; + } + + /** + * Test 3 string. + * + * @param test the test + * @return the string + */ + @PostMapping("/api3") + String test3(@NotNull String test) { + return null; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app96/SpringDocApp96Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app96/SpringDocApp96Test.java new file mode 100644 index 000000000..c169ae6bd --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app96/SpringDocApp96Test.java @@ -0,0 +1,45 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app96; + + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 96 test. + */ +class SpringDocApp96Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app97/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app97/HelloController.java new file mode 100644 index 000000000..b17b89a8d --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app97/HelloController.java @@ -0,0 +1,69 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app97; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +@RequestMapping("/api") +class HelloController { + + /** + * Header v 1 student v 1. + * + * @return the student v 1 + */ + @GetMapping(value = "/student/header1", headers = "X-API-VERSION=1") + public StudentV1 headerV1() { + return new StudentV1("Bob Charlie"); + } + + /** + * Header v 2 student v 2. + * + * @return the student v 2 + */ + @GetMapping(value = "/student/header2", headers = "X-API-VERSION=2") + public StudentV2 headerV2() { + return new StudentV2("Charlie"); + } + + /** + * Header v 3 student v 3. + * + * @return the student v 3 + */ + @GetMapping(value = "/student/header3", headers = "X-API-VERSION") + public StudentV3 headerV3() { + return new StudentV3("Tom Charlie"); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app97/SpringDocApp97Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app97/SpringDocApp97Test.java new file mode 100644 index 000000000..d99c7cadd --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app97/SpringDocApp97Test.java @@ -0,0 +1,45 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app97; + + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 97 test. + */ +class SpringDocApp97Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app97/StudentV1.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app97/StudentV1.java new file mode 100644 index 000000000..44ef3060b --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app97/StudentV1.java @@ -0,0 +1,50 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app97; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The type Student v 1. + */ +class StudentV1 { + + /** + * The Name. + */ + @JsonProperty("name") + private String name; + + /** + * Instantiates a new Student v 1. + * + * @param name the name + */ + public StudentV1(String name) { + this.name = name; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app97/StudentV2.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app97/StudentV2.java new file mode 100644 index 000000000..5d9453388 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app97/StudentV2.java @@ -0,0 +1,50 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app97; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The type Student v 2. + */ +class StudentV2 { + + /** + * The Name. + */ + @JsonProperty("bb") + private String name; + + /** + * Instantiates a new Student v 2. + * + * @param name the name + */ + public StudentV2(String name) { + this.name = name; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app97/StudentV3.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app97/StudentV3.java new file mode 100644 index 000000000..f6955323e --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app97/StudentV3.java @@ -0,0 +1,50 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app97; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The type Student v 3. + */ +class StudentV3 { + + /** + * The Name. + */ + @JsonProperty("name") + private String name; + + /** + * Instantiates a new Student v 3. + * + * @param name the name + */ + public StudentV3(String name) { + this.name = name; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app98/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app98/HelloController.java new file mode 100644 index 000000000..5f7c8e19e --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app98/HelloController.java @@ -0,0 +1,48 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app98; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +class HelloController { + + /** + * Persons. + * + * @param name the name + */ + @GetMapping("/persons") + public void persons(@IgnoredAnnotationParameter String name) { + + } + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app98/IgnoredAnnotationParameter.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app98/IgnoredAnnotationParameter.java new file mode 100644 index 000000000..dafbf0a85 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app98/IgnoredAnnotationParameter.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app98; + +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + +/** + * The interface Ignored annotation parameter. + */ +@Retention(RetentionPolicy.RUNTIME) +public @interface IgnoredAnnotationParameter { + /** + * Addition string. + * + * @return the string + */ + String addition() default "customized parameter!"; +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app98/SpringDocApp98Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app98/SpringDocApp98Test.java new file mode 100644 index 000000000..a5cf82342 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app98/SpringDocApp98Test.java @@ -0,0 +1,49 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app98; + + +import org.springdoc.core.utils.SpringDocUtils; +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * The type Spring doc app 98 test. + */ +class SpringDocApp98Test extends AbstractSpringDocTest { + + static { + SpringDocUtils.getConfig().addAnnotationsToIgnore(IgnoredAnnotationParameter.class); + } + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app99/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app99/HelloController.java new file mode 100644 index 000000000..aea7efbe0 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app99/HelloController.java @@ -0,0 +1,54 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app99; + +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * The type Hello controller. + */ +@RestController +@RequestMapping("/persons") +class HelloController { + + /** + * Persons. + */ + @GetMapping + @ApiResponses({ + @ApiResponse(responseCode = "202", description = "${test.app99.operation.persons.response.202.description}") + }) + public void persons() { + + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app99/SpringDocApp99Test.java b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app99/SpringDocApp99Test.java new file mode 100644 index 000000000..98f3e942d --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/java/test/org/springdoc/api/v31/app99/SpringDocApp99Test.java @@ -0,0 +1,47 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app99; + + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.test.context.ActiveProfiles; + +/** + * The type Spring doc app 99 test. + */ +@ActiveProfiles("99") +class SpringDocApp99Test extends AbstractSpringDocTest { + + /** + * The type Spring doc test app. + */ + @SpringBootApplication + static class SpringDocTestApp {} + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app1.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app1.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app1.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app1.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app10.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app10.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app10.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app10.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app100.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app100.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app100.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app100.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app101.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app101.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app101.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app101.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app102.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app102.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app102.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app102.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app103.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app103.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app103.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app103.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app104.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app104.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app104.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app104.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app105-1.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app105-1.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app105-1.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app105-1.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app105-2.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app105-2.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app105-2.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app105-2.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app105-3.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app105-3.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app105-3.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app105-3.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app105-4.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app105-4.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app105-4.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app105-4.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app106.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app106.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app106.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app106.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app107.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app107.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app107.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app107.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app108.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app108.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app108.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app108.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app109.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app109.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app109.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app109.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app11.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app11.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app11.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app11.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app110.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app110.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app110.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app110.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app111.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app111.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app111.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app111.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app112.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app112.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app112.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app112.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app113.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app113.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app113.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app113.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app114.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app114.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app114.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app114.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app115.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app115.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app115.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app115.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app116.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app116.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app116.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app116.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app117.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app117.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app117.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app117.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app118.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app118.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app118.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app118.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app119.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app119.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app119.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app119.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app12.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app12.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app12.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app12.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app120.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app120.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app120.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app120.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app121.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app121.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app121.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app121.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app122.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app122.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app122.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app122.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app123.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app123.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app123.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app123.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app124.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app124.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app124.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app124.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app125.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app125.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app125.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app125.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app126.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app126.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app126.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app126.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app129.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app129.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app129.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app129.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app13.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app13.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app13.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app13.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app130.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app130.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app130.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app130.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app131.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app131.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app131.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app131.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app132.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app132.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app132.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app132.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app133.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app133.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app133.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app133.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app134-1.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app134-1.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app134-1.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app134-1.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app134-2.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app134-2.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app134-2.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app134-2.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app134-3.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app134-3.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app134-3.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app134-3.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app134-4.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app134-4.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app134-4.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app134-4.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app134-5.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app134-5.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app134-5.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app134-5.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app135.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app135.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app135.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app135.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app137.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app137.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app137.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app137.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app138.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app138.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app138.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app138.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app139.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app139.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app139.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app139.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app14.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app14.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app14.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app14.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app140.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app140.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app140.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app140.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app141.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app141.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app141.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app141.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app142.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app142.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app142.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app142.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app149.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app149.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app149.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app149.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app15.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app15.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app15.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app15.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app150.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app150.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app150.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app150.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app151.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app151.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app151.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app151.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app152.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app152.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app152.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app152.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app153.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app153.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app153.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app153.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app154.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app154.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app154.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app154.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app155.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app155.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app155.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app155.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app156.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app156.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app156.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app156.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app157.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app157.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app157.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app157.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app158.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app158.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app158.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app158.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app159.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app159.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app159.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app159.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app160.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app160.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app160.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app160.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app161.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app161.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app161.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app161.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app162.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app162.json new file mode 100644 index 000000000..1c58b6a4c --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app162.json @@ -0,0 +1,342 @@ +{ + "openapi": "3.0.1", + "info": { + "title": "SpringShop API", + "description": "The description of the api", + "version": "v1" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "javadoc-only-rest-controller", + "description": "This is the JavadocOnlyRestController class javadoc." + } + ], + "paths": { + "/javadoc-only/{guid}": { + "get": { + "tags": [ + "javadoc-only-rest-controller" + ], + "summary": "This is the find method's javadoc.", + "description": "This is the find method's javadoc.\n The method's signature: #find(String)", + "operationId": "find", + "parameters": [ + { + "name": "guid", + "in": "path", + "description": "the @param guid javadoc for the #find(String) method", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "404": { + "description": "the @throws NoResultException javadoc for the #find(String) method", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + }, + "x-exception-class": [ + "test.org.springdoc.api.v30.app162.exception.NoResultException" + ] + }, + "400": { + "description": "the return javadoc for the #handleNonUniqueResultException(NonUniqueResultException) method", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + }, + "x-exception-class": [ + "test.org.springdoc.api.v30.app162.exception.NonUniqueResultException" + ] + }, + "200": { + "description": "the @return javadoc for the #find(String) method", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/JavadocOnlyRestDto" + } + } + } + } + } + }, + "put": { + "tags": [ + "javadoc-only-rest-controller" + ], + "summary": "This is the update method's javadoc.", + "description": "This is the update method's javadoc.\n The method's signature: #update(String, JavadocOnlyRestDto)", + "operationId": "update", + "parameters": [ + { + "name": "guid", + "in": "path", + "description": "the @param input javadoc for the #update(String, JavadocOnlyRestDto) method", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/JavadocOnlyRestDto" + } + } + }, + "required": true + }, + "responses": { + "404": { + "description": "the return javadoc for the #handleNotFoundException(NoResultException) method", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + }, + "x-exception-class": [ + "test.org.springdoc.api.v30.app162.exception.NoResultException" + ] + }, + "400": { + "description": "the return javadoc for the #handleNonUniqueResultException(NonUniqueResultException) method", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + }, + "x-exception-class": [ + "test.org.springdoc.api.v30.app162.exception.NonUniqueResultException" + ] + }, + "200": { + "description": "the @return javadoc for the #update(String, JavadocOnlyRestDto) method", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/JavadocOnlyRestDto" + } + } + } + } + } + } + }, + "/javadoc-only": { + "get": { + "tags": [ + "javadoc-only-rest-controller" + ], + "summary": "This is the list method's javadoc.", + "description": "This is the list method's javadoc.\n The method's signature: #list()", + "operationId": "list", + "responses": { + "404": { + "description": "the return javadoc for the #handleNotFoundException(NoResultException) method", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + }, + "x-exception-class": [ + "test.org.springdoc.api.v30.app162.exception.NoResultException" + ] + }, + "400": { + "description": "the return javadoc for the #handleNonUniqueResultException(NonUniqueResultException) method", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + }, + "x-exception-class": [ + "test.org.springdoc.api.v30.app162.exception.NonUniqueResultException" + ] + }, + "200": { + "description": "the @return javadoc for the #list() method", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/JavadocOnlyRestDto" + } + } + } + } + } + } + }, + "post": { + "tags": [ + "javadoc-only-rest-controller" + ], + "summary": "This is the create method's javadoc.", + "description": "This is the create method's javadoc.\n The method's signature: #create(JavadocOnlyRestDto)", + "operationId": "create", + "requestBody": { + "description": "the @param input javadoc for the #create(JavadocOnlyRestDto) method", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/JavadocOnlyRestDto" + } + } + }, + "required": true + }, + "responses": { + "404": { + "description": "the return javadoc for the #handleNotFoundException(NoResultException) method", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + }, + "x-exception-class": [ + "test.org.springdoc.api.v30.app162.exception.NoResultException" + ] + }, + "400": { + "description": "the return javadoc for the #handleNonUniqueResultException(NonUniqueResultException) method", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + }, + "x-exception-class": [ + "test.org.springdoc.api.v30.app162.exception.NonUniqueResultException" + ] + }, + "201": { + "description": "the @return javadoc for the #create(JavadocOnlyRestDto) method", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/JavadocOnlyRestDto" + } + } + } + } + } + } + }, + "/javadoc-only/startsBy/{prefix}": { + "get": { + "tags": [ + "javadoc-only-rest-controller" + ], + "summary": "This is the findStartsBy method's javadoc.", + "description": "This is the findStartsBy method's javadoc.\n The method's signature: #findStartsBy(String)", + "operationId": "findStartsBy", + "parameters": [ + { + "name": "prefix", + "in": "path", + "description": "the @param prefix javadoc for the #findStartsBy(String) method", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "404": { + "description": "the @throws NoResultException javadoc for the #findStartsBy(String) method", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + }, + "x-exception-class": [ + "test.org.springdoc.api.v30.app162.exception.NoResultException" + ] + }, + "400": { + "description": "the @throws NonUniqueResultException javadoc for the #findStartsBy(String) method", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + }, + "x-exception-class": [ + "test.org.springdoc.api.v30.app162.exception.NonUniqueResultException" + ] + }, + "200": { + "description": "the @return javadoc for the #findStartsBy(String) method", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/JavadocOnlyRestDto" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "JavadocOnlyRestDto": { + "type": "object", + "properties": { + "guid": { + "type": "string", + "description": "This is the private #guid field's javadoc." + }, + "inner": { + "$ref": "#/components/schemas/JavadocOnlyStaticInnerRestDto" + } + }, + "description": "This is the JavadocOnlyRestDto class javadoc." + }, + "JavadocOnlyStaticInnerRestDto": { + "type": "object", + "properties": { + "content": { + "type": "string", + "description": "This is the private #content field's javadoc." + } + }, + "description": "This is the JavadocOnlyStaticInnerRestDto class javadoc." + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app163.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app163.json new file mode 100644 index 000000000..16f1598e1 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app163.json @@ -0,0 +1,227 @@ +{ + "openapi": "3.0.1", + "info": { + "title": "SpringShop API", + "description": "The description of the api", + "version": "v1" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "annotation-override", + "description": "Description for the tag." + } + ], + "paths": { + "/annotation-override/{guid}": { + "put": { + "tags": [ + "annotation-override" + ], + "summary": "Summary for #update(String, AnnotationOverrideForJavadocRestDto)", + "description": "This is the update method's javadoc.\n The method's signature: #update(String, AnnotationOverrideForJavadocRestDto)", + "operationId": "update", + "parameters": [ + { + "name": "guid", + "in": "path", + "description": "the @param input javadoc for the #update(String, AnnotationOverrideForJavadocRestDto) method", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/AnnotationOverrideForJavadocRestDto" + } + } + }, + "required": true + }, + "responses": { + "404": { + "description": "the return javadoc for the #handleNotFoundException(NoResultException) method", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + }, + "x-exception-class": [ + "test.org.springdoc.api.v30.app163.exception.NoResultException" + ] + }, + "400": { + "description": "the return javadoc for the #handleNonUniqueResultException(NonUniqueResultException) method", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + }, + "x-exception-class": [ + "test.org.springdoc.api.v30.app163.exception.NonUniqueResultException" + ] + }, + "200": { + "description": "the @return javadoc for the #update(String, AnnotationOverrideForJavadocRestDto) method", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/AnnotationOverrideForJavadocRestDto" + } + } + } + } + } + } + }, + "/annotation-override": { + "post": { + "tags": [ + "annotation-override" + ], + "summary": "Summary for #create(AnnotationOverrideForJavadocRestDto)", + "description": "Description for #create(AnnotationOverrideForJavadocRestDto)", + "operationId": "create", + "requestBody": { + "description": "Request body for #create(AnnotationOverrideForJavadocRestDto)", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/AnnotationOverrideForJavadocRestDto" + } + } + }, + "required": true + }, + "responses": { + "404": { + "description": "the return javadoc for the #handleNotFoundException(NoResultException) method", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + }, + "x-exception-class": [ + "test.org.springdoc.api.v30.app163.exception.NoResultException" + ] + }, + "400": { + "description": "the return javadoc for the #handleNonUniqueResultException(NonUniqueResultException) method", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + }, + "x-exception-class": [ + "test.org.springdoc.api.v30.app163.exception.NonUniqueResultException" + ] + }, + "default": { + "description": "API Response 201 for #create(AnnotationOverrideForJavadocRestDto)", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/AnnotationOverrideForJavadocRestDto" + } + } + } + } + } + } + }, + "/annotation-override/startsBy/{prefix}": { + "get": { + "tags": [ + "annotation-override" + ], + "summary": "This is the findStartsBy method's javadoc.", + "description": "This is the findStartsBy method's javadoc.\n The method's signature: #findStartsBy(String)", + "operationId": "findStartsBy", + "parameters": [ + { + "name": "prefix", + "in": "path", + "description": "Parameter prefix", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "404": { + "description": "the @throws NoResultException javadoc for the #findStartsBy(String) method", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + }, + "x-exception-class": [ + "test.org.springdoc.api.v30.app163.exception.NoResultException" + ] + }, + "400": { + "description": "API Response 400 for #findStartsBy(prefix)" + }, + "200": { + "description": "API Response 200 for #findStartsBy(prefix)", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/AnnotationOverrideForJavadocRestDto" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "AnnotationOverrideForJavadocRestDto": { + "title": "annotation-override-dto", + "type": "object", + "properties": { + "guid": { + "type": "string", + "description": "Description for the #guid field" + }, + "inner": { + "$ref": "#/components/schemas/AnnotationOverrideForJavadocStaticInnerRestDto" + } + }, + "description": "Description for the tag." + }, + "AnnotationOverrideForJavadocStaticInnerRestDto": { + "type": "object", + "properties": { + "content": { + "type": "string", + "description": "This is the private #content field's javadoc." + } + }, + "description": "This is the AnnotationOverrideForJavadocStaticInnerRestDto class javadoc." + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app164.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app164.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app164.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app164.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app166.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app166.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app166.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app166.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app167.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app167.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app167.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app167.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app168.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app168.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app168.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app168.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app169.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app169.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app169.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app169.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app17.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app17.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app17.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app17.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app170.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app170.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app170.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app170.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app171.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app171.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app171.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app171.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app173.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app173.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app173.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app173.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app174.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app174.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app174.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app174.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app18.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app18.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app18.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app18.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app19.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app19.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app19.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app19.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app2.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app2.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app2.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app2.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app20.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app20.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app20.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app20.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app21.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app21.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app21.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app21.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app22.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app22.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app22.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app22.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app23.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app23.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app23.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app23.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app24.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app24.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app24.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app24.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app25.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app25.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app25.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app25.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app26.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app26.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app26.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app26.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app27.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app27.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app27.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app27.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app28.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app28.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app28.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app28.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app29.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app29.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app29.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app29.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app3.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app3.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app3.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app3.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app30.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app30.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app30.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app30.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app31.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app31.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app31.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app31.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app32.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app32.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app32.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app32.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app33.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app33.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app33.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app33.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app34.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app34.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app34.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app34.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app35.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app35.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app35.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app35.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app37.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app37.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app37.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app37.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app38.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app38.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app38.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app38.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app39.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app39.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app39.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app39.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app4.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app4.json new file mode 100644 index 000000000..7f4405791 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app4.json @@ -0,0 +1,86 @@ +{ + "openapi": "3.0.1", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "hello-controller", + "description": "The type Hello controller." + } + ], + "paths": { + "/values/data": { + "post": { + "tags": [ + "hello-controller" + ], + "summary": "List tracker data.", + "description": "List tracker data.", + "operationId": "list", + "parameters": [ + { + "name": "toto", + "in": "query", + "description": "the toto", + "required": true, + "schema": { + "$ref": "#/components/schemas/test.org.springdoc.api.v30.app4.TrackerData" + } + } + ], + "responses": { + "200": { + "description": "the tracker data", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/test.org.springdoc.api.v30.app4.TrackerData" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "test.org.springdoc.api.v30.app4.TrackerData": { + "required": [ + "timestamp", + "trackerId", + "value" + ], + "type": "object", + "properties": { + "trackerId": { + "type": "string", + "description": "The Tracker id.", + "example": "the-tracker-id" + }, + "timestamp": { + "type": "string", + "description": "The Timestamp.", + "format": "date-time", + "example": "2018-01-01T00:00:00Z" + }, + "value": { + "type": "number", + "description": "The data value", + "format": "double", + "example": 19.0 + } + }, + "description": "The type Tracker data." + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app40.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app40.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app40.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app40.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app41.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app41.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app41.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app41.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app42.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app42.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app42.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app42.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app43.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app43.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app43.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app43.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app44.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app44.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app44.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app44.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app45.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app45.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app45.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app45.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app46.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app46.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app46.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app46.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app47.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app47.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app47.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app47.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app48.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app48.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app48.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app48.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app49.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app49.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app49.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app49.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app50.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app50.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app50.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app50.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app51.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app51.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app51.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app51.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app52.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app52.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app52.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app52.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app53.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app53.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app53.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app53.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app54.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app54.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app54.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app54.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app55.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app55.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app55.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app55.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app56.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app56.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app56.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app56.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app57.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app57.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app57.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app57.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app58.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app58.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app58.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app58.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app59.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app59.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app59.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app59.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app6.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app6.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app6.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app6.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app60.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app60.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app60.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app60.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app61.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app61.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app61.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app61.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app62.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app62.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app62.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app62.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app63.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app63.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app63.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app63.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app64.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app64.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app64.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app64.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app65.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app65.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app65.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app65.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app66.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app66.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app66.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app66.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app67.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app67.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app67.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app67.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app69.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app69.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app69.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app69.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app7.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app7.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app7.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app7.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app70.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app70.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app70.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app70.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app71.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app71.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app71.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app71.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app73.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app73.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app73.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app73.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app74.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app74.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app74.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app74.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app75.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app75.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app75.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app75.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app76.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app76.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app76.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app76.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app77.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app77.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app77.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app77.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app78.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app78.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app78.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app78.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app79.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app79.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app79.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app79.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app8.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app8.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app8.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app8.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app80.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app80.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app80.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app80.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app82.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app82.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app82.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app82.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app83.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app83.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app83.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app83.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app84.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app84.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app84.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app84.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app85.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app85.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app85.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app85.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app86.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app86.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app86.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app86.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app87.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app87.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app87.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app87.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app88.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app88.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app88.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app88.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app89.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app89.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app89.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app89.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app9.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app9.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app9.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app9.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app90.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app90.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app90.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app90.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app91.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app91.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app91.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app91.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app92.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app92.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app92.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app92.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app93.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app93.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app93.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app93.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app94.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app94.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app94.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app94.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app95.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app95.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app95.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app95.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app96.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app96.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app96.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app96.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app97.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app97.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app97.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app97.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app98.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app98.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app98.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app98.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app99.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app99.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app99.json rename to springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.0.1/app99.json diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app1.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app1.json new file mode 100644 index 000000000..b7f2e8bfa --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app1.json @@ -0,0 +1,682 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "SpringShop API", + "license": { + "name": "Apache 2.0", + "url": "http://springdoc.org" + }, + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/{email}": { + "get": { + "tags": [ + "people" + ], + "description": "Find person by e-mail", + "operationId": "findPerson", + "parameters": [ + { + "name": "email", + "in": "path", + "description": "E-Mail address to lookup for", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "500": { + "description": "the response entity", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, + "200": { + "description": "the person dto", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/PersonDTO" + } + } + } + }, + "404": { + "description": "Person with such e-mail doesn't exists", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/PersonDTO" + } + } + } + } + } + }, + "post": { + "tags": [ + "people" + ], + "description": "Create new person", + "operationId": "addPerson", + "parameters": [ + { + "name": "email", + "in": "path", + "description": "E-Mail", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/x-www-form-urlencoded": { + "schema": { + "type": "object", + "properties": { + "firstName": { + "type": "string", + "description": "First Name" + }, + "lastName": { + "type": "string", + "description": "Last Name" + } + }, + "required": [ + "firstName", + "lastName" + ] + } + } + } + }, + "responses": { + "500": { + "description": "the response entity", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, + "201": { + "description": "the response entity", + "headers": { + "Location": { + "style": "simple", + "schema": { + "type": "string" + } + } + }, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/PersonDTO" + } + } + } + }, + "409": { + "description": "Person with such e-mail already exists", + "content": { + "application/json": { + "schema": { + "type": "string" + } + } + } + } + } + }, + "delete": { + "tags": [ + "people" + ], + "description": "Delete existing person", + "operationId": "deletePerson", + "parameters": [ + { + "name": "email", + "in": "path", + "description": "E-Mail address to lookup for", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "500": { + "description": "the response entity", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, + "204": { + "description": "Person has been deleted", + "content": { + "application/json": { + "schema": { + "type": "string" + } + } + } + }, + "404": { + "description": "Person with such e-mail doesn't exists", + "content": { + "application/json": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/items": { + "get": { + "tags": [ + "items" + ], + "summary": "Show items list.", + "description": "Show items list.", + "operationId": "showItems", + "parameters": [ + { + "name": "cusID", + "in": "query", + "description": "the customer id", + "required": true, + "schema": { + "type": "string", + "maxLength": 6, + "minLength": 4 + } + }, + { + "name": "toto", + "in": "query", + "description": "the toto", + "required": true, + "schema": { + "type": "integer", + "format": "int32", + "maximum": 6, + "minimum": 4 + } + }, + { + "name": "start", + "in": "query", + "description": "the start date", + "required": false, + "schema": { + "type": "string", + "format": "date-time", + "example": "1970-01-01T00:00:00.000Z" + } + }, + { + "name": "filterIds", + "in": "query", + "description": "the filter ids", + "required": false, + "explode": false, + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + } + ], + "responses": { + "500": { + "description": "the response entity", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, + "200": { + "description": "the list", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/ItemDTO" + } + } + } + } + } + } + }, + "post": { + "tags": [ + "items" + ], + "summary": "Add item response entity.", + "description": "Add item response entity.", + "operationId": "addItem", + "requestBody": { + "description": "the item dto", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ItemLightDTO" + } + } + }, + "required": true + }, + "responses": { + "500": { + "description": "the response entity", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, + "200": { + "description": "the response entity", + "content": { + "application/json": { + "schema": { + "type": "string", + "format": "uri" + } + } + } + } + } + } + }, + "/inventory": { + "get": { + "tags": [ + "developers", + "inventory" + ], + "summary": "By passing in the appropriate options, you can search for available inventory in the system ", + "description": "searches inventory", + "operationId": "searchInventory", + "parameters": [ + { + "name": "searchString", + "in": "query", + "description": "pass an optional search string for looking up inventory", + "required": false, + "schema": { + "type": "string" + } + }, + { + "name": "skip", + "in": "query", + "description": "number of records to skip for pagination", + "required": true, + "schema": { + "type": "integer", + "format": "int32", + "minimum": 0 + } + }, + { + "name": "limit", + "in": "query", + "description": "maximum number of records to return", + "required": true, + "schema": { + "type": "integer", + "format": "int32", + "maximum": 50, + "minimum": 0 + } + } + ], + "responses": { + "500": { + "description": "the response entity", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, + "200": { + "description": "search results matching criteria", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/InventoryItem" + } + } + } + } + }, + "400": { + "description": "bad input parameter", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/InventoryItem" + } + } + } + } + } + } + }, + "post": { + "tags": [ + "inventory", + "admins" + ], + "summary": "Adds an item to the system", + "description": "adds an inventory item", + "operationId": "addInventory", + "requestBody": { + "description": "Inventory item to add", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/InventoryItem" + } + } + }, + "required": true + }, + "responses": { + "500": { + "description": "the response entity", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, + "201": { + "description": "item created" + }, + "400": { + "description": "invalid input, object invalid" + }, + "409": { + "description": "an existing item already exists" + } + } + } + }, + "/people": { + "get": { + "tags": [ + "people" + ], + "description": "List all people", + "operationId": "getPeople", + "responses": { + "500": { + "description": "the response entity", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, + "200": { + "description": "the people", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/PersonDTO" + } + } + } + } + } + } + } + }, + "/hello/{numTelco}": { + "get": { + "tags": [ + "tea" + ], + "summary": "Index string.", + "description": "Index string.", + "operationId": "index", + "parameters": [ + { + "name": "numTelco", + "in": "path", + "description": "the num tel", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "adresse", + "in": "query", + "description": "the adresse", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "500": { + "description": "the response entity", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, + "418": { + "description": "the string", + "content": { + "application/json": { + "schema": { + "type": "string" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "ErrorMessage": { + "type": "object", + "description": "The type Error message.", + "properties": { + "id": { + "type": "string", + "description": "The Id." + }, + "message": { + "type": "string", + "description": "The Message." + } + } + }, + "PersonDTO": { + "type": "object", + "description": "The type Person dto.", + "properties": { + "email": { + "type": "string", + "description": "The Email." + }, + "firstName": { + "type": "string", + "description": "The First name." + }, + "lastName": { + "type": "string", + "description": "The Last name." + } + } + }, + "ItemLightDTO": { + "type": "object", + "description": "The type Item light dto.", + "properties": { + "description": { + "type": "string", + "description": "description of type String" + }, + "price": { + "type": "integer", + "format": "int32", + "description": "price of type int" + }, + "deprecatedPrice": { + "type": "integer", + "format": "int32", + "deprecated": true, + "description": "The Deprecated price." + } + } + }, + "InventoryItem": { + "type": "object", + "description": "InventoryItem", + "properties": { + "id": { + "type": "string", + "format": "uuid", + "description": "The Id.", + "example": "d290f1ee-6c54-4b01-90e6-d701748f0851" + }, + "name": { + "type": "string", + "description": "The Name.", + "example": "Widget Adapter" + }, + "releaseDate": { + "type": "string", + "description": "The Release date.", + "example": "2016-08-29T09:12:33.001Z" + }, + "manufacturer": { + "$ref": "#/components/schemas/Manufacturer", + "description": "The Manufacturer." + } + }, + "required": [ + "id", + "manufacturer", + "name", + "releaseDate" + ] + }, + "Manufacturer": { + "type": "object", + "description": "Manufacturer", + "properties": { + "name": { + "type": "string", + "description": "The Name.", + "example": "ACME Corporation" + }, + "homePage": { + "type": "string", + "description": "The Home page.", + "example": "https://www.acme-corp.com" + }, + "phone": { + "type": "string", + "description": "The Phone.", + "example": "408-867-5309" + } + }, + "required": [ + "name" + ] + }, + "ItemDTO": { + "type": "object", + "description": "The type Item dto.", + "properties": { + "itemID": { + "type": "string", + "description": "itemID of type String" + }, + "description": { + "type": "string", + "description": "description of type String" + }, + "price": { + "type": "integer", + "format": "int32", + "description": "price of type int" + }, + "deprecatedPrice": { + "type": "integer", + "format": "int32", + "deprecated": true, + "description": "The Deprecated price." + } + } + } + }, + "securitySchemes": { + "basicScheme": { + "type": "http", + "scheme": "basic" + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app10.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app10.json new file mode 100644 index 000000000..3996702e3 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app10.json @@ -0,0 +1,74 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "hello-controller", + "description": "The type Hello controller." + } + ], + "paths": { + "/testreq": { + "get": { + "tags": [ + "hello-controller" + ], + "summary": "Test request attribute.", + "description": "Test request attribute.", + "operationId": "testRequestAttribute", + "parameters": [ + { + "name": "s", + "in": "query", + "description": "the s", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK" + } + } + } + }, + "/test": { + "get": { + "tags": [ + "hello-controller" + ], + "summary": "Test.", + "description": "Test.", + "operationId": "test", + "parameters": [ + { + "name": "hello", + "in": "query", + "description": "the hello", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK" + } + } + } + } + }, + "components": {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app100.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app100.json new file mode 100644 index 000000000..df63f44a6 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app100.json @@ -0,0 +1,76 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/search": { + "get": { + "tags": [ + "hello-ap1", + "hello-ap2" + ], + "summary": "Gets all pets.", + "description": "Gets all pets.", + "operationId": "getAllPets", + "parameters": [ + { + "name": "toto", + "in": "query", + "description": "the toto", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "the all pets", + "content": { + "application/xml": { + "schema": { + "$ref": "#/components/schemas/PersonDTO" + } + }, + "application/json": { + "schema": { + "$ref": "#/components/schemas/PersonDTO" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "PersonDTO": { + "type": "object", + "properties": { + "email": { + "type": "string", + "description": "The Email." + }, + "firstName": { + "type": "string", + "description": "The First name." + }, + "lastName": { + "type": "string", + "description": "The Last name." + } + }, + "description": "The type Person dto." + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app101.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app101.json new file mode 100644 index 000000000..0dd8e1248 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app101.json @@ -0,0 +1,58 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "hello-controller", + "description": "The type Hello controller." + } + ], + "paths": { + "/hello": { + "get": { + "tags": [ + "hello-controller" + ], + "summary": "Hello hello dto.", + "description": "Hello hello dto.", + "operationId": "hello", + "responses": { + "default": { + "description": "the hello dto", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/HelloDTO", + "description": "${test.app101.operation.hello.response.schema.description}" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "HelloDTO": { + "type": "object", + "description": "Description of schema of hello entity", + "properties": { + "id": { + "type": "string", + "description": "Description of schema of param id for api hello" + } + } + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app102.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app102.json new file mode 100644 index 000000000..c5b2139dd --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app102.json @@ -0,0 +1,160 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "test-controller", + "description": "The type Test controller." + } + ], + "paths": { + "/test": { + "get": { + "tags": [ + "test-controller" + ], + "summary": "Gets test.", + "description": "Gets test.", + "operationId": "getTest", + "parameters": [ + { + "name": "param", + "in": "query", + "description": "the param", + "required": false, + "schema": { + "type": "string" + } + }, + { + "name": "childParam", + "in": "query", + "description": "parameter from child of RequestParams", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "stringParam", + "in": "query", + "description": "string parameter", + "required": false, + "schema": { + "type": "string" + } + }, + { + "name": "stringParam1", + "in": "query", + "description": "The String param 1.", + "required": false, + "deprecated": true, + "schema": { + "type": "string" + } + }, + { + "name": "stringParam2", + "in": "query", + "description": "string parameter2", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "intParam", + "in": "query", + "description": "int parameter", + "required": false, + "schema": { + "type": "integer", + "format": "int32" + } + }, + { + "name": "intParam2", + "in": "query", + "description": "The Int param 2.", + "required": false, + "schema": { + "type": "string" + } + }, + { + "name": "intParam3", + "in": "query", + "description": "The Int param 3.", + "required": false, + "schema": { + "type": "string" + } + }, + { + "name": "nested.param1", + "in": "query", + "description": "nested string parameter", + "required": false, + "schema": { + "type": "string" + } + }, + { + "name": "nested.param2", + "in": "query", + "description": "nested BigInteger parameter", + "required": false, + "schema": { + "type": "integer" + } + }, + { + "name": "nestedList", + "in": "query", + "description": "The Nested list.", + "required": false, + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Nested" + } + } + } + ], + "responses": { + "200": { + "description": "OK" + } + } + } + } + }, + "components": { + "schemas": { + "Nested": { + "type": "object", + "properties": { + "param1": { + "type": "string", + "description": "The Param 1." + }, + "param2": { + "type": "integer", + "description": "The Param 2." + } + }, + "description": "The type Nested." + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app103.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app103.json new file mode 100644 index 000000000..6cd36e208 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app103.json @@ -0,0 +1,91 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "hello-controller", + "description": "The type Hello controller." + } + ], + "paths": { + "/test/103": { + "post": { + "tags": [ + "hello-controller" + ], + "summary": "Post my request body string.", + "description": "Post my request body string.", + "operationId": "postMyRequestBody", + "requestBody": { + "content": { + "multipart/form-data": { + "schema": { + "type": "object", + "properties": { + "body": { + "$ref": "#/components/schemas/ExampleBody", + "description": "the body" + }, + "file": { + "type": "string", + "format": "binary", + "description": "the file" + } + }, + "required": [ + "body", + "file" + ] + }, + "encoding": { + "body": { + "contentType": "application/json" + } + } + } + } + }, + "responses": { + "200": { + "description": "the string", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "ExampleBody": { + "type": "object", + "description": "The type Example body.", + "properties": { + "stringParam": { + "type": "string", + "description": "The String param." + }, + "intParam": { + "type": "integer", + "format": "int32", + "description": "The Int param." + } + } + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app104.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app104.json new file mode 100644 index 000000000..bed3c58af --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app104.json @@ -0,0 +1,80 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/design": { + "get": { + "tags": [ + "design" + ], + "description": "Receive a list of objects", + "operationId": "list", + "responses": { + "200": { + "description": "the list", + "content": { + "*/*": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Design" + } + } + } + } + } + } + } + }, + "/design/{id}": { + "get": { + "tags": [ + "design" + ], + "description": "Get single object", + "operationId": "get", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "The id to get.", + "required": true, + "schema": { + "type": "integer", + "format": "int32" + } + } + ], + "responses": { + "200": { + "description": "the t", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/Design" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "Design": { + "type": "object", + "description": "The type Design." + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app105-1.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app105-1.json new file mode 100644 index 000000000..d120cbc8f --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app105-1.json @@ -0,0 +1,283 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "Petstore API", + "description": "This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.", + "termsOfService": "http://swagger.io/terms/", + "license": { + "name": "Apache 2.0", + "url": "http://springdoc.org" + }, + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "store", + "description": "the store API" + } + ], + "paths": { + "/store/inventory": { + "get": { + "tags": [ + "store" + ], + "summary": "Returns pet inventories by status", + "description": "Returns a map of status codes to quantities", + "operationId": "getInventory", + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + } + } + }, + "400": { + "description": "the map", + "content": { + "*/*": { + "schema": { + "type": "object", + "additionalProperties": { + "type": "object" + } + } + } + } + } + }, + "security": [ + { + "api_key": [] + } + ] + } + }, + "/store/order": { + "post": { + "tags": [ + "store" + ], + "summary": "Place an order for a pet", + "description": "Place order response entity.", + "operationId": "placeOrder", + "requestBody": { + "description": "the order", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Order" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Order" + } + }, + "application/xml": { + "schema": { + "$ref": "#/components/schemas/Order" + } + } + } + }, + "400": { + "description": "Invalid Order", + "content": { + "*/*": { + "schema": { + "type": "object", + "additionalProperties": { + "type": "object" + } + } + } + } + } + } + } + }, + "/store/order/{orderId}": { + "get": { + "tags": [ + "store" + ], + "summary": "Find purchase order by ID", + "description": "Gets order by id.", + "operationId": "getOrderById", + "parameters": [ + { + "name": "orderId", + "in": "path", + "description": "ID of pet that needs to be fetched", + "required": true, + "schema": { + "maximum": 5, + "minimum": 1, + "type": "integer", + "format": "int64" + } + } + ], + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Order" + } + }, + "application/xml": { + "schema": { + "$ref": "#/components/schemas/Order" + } + } + } + }, + "400": { + "description": "Invalid ID supplied", + "content": { + "*/*": { + "schema": { + "type": "object", + "additionalProperties": { + "type": "object" + } + } + } + } + }, + "404": { + "description": "Order not found", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Order" + } + }, + "application/xml": { + "schema": { + "$ref": "#/components/schemas/Order" + } + } + } + } + } + }, + "delete": { + "tags": [ + "store" + ], + "summary": "Delete purchase order by ID", + "description": "Delete order response entity.", + "operationId": "deleteOrder", + "parameters": [ + { + "name": "orderId", + "in": "path", + "description": "ID of the order that needs to be deleted", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "400": { + "description": "Invalid ID supplied", + "content": { + "*/*": { + "schema": { + "type": "object", + "additionalProperties": { + "type": "object" + } + } + } + } + }, + "404": { + "description": "Order not found" + } + } + } + } + }, + "components": { + "schemas": { + "Order": { + "type": "object", + "properties": { + "complete": { + "type": "boolean", + "description": "The Complete." + }, + "id": { + "type": "integer", + "description": "The Id.", + "format": "int64" + }, + "petId": { + "type": "integer", + "description": "The Pet id.", + "format": "int64" + }, + "quantity": { + "type": "integer", + "description": "The Quantity.", + "format": "int32" + }, + "shipDate": { + "type": "string", + "description": "The Ship date.", + "format": "date-time" + }, + "status": { + "type": "string", + "description": "Order Status" + } + }, + "description": "The type Order." + } + }, + "securitySchemes": { + "basicScheme": { + "type": "http", + "scheme": "basic" + }, + "petstore_auth": { + "type": "oauth2", + "flows": { + "implicit": { + "authorizationUrl": "http://petstore.swagger.io/oauth/dialog", + "scopes": { + "read:pets": "read your pets", + "write:pets": "modify pets in your account" + } + } + } + } + } + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app105-2.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app105-2.json new file mode 100644 index 000000000..3cf9b92a9 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app105-2.json @@ -0,0 +1,451 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "Petstore API", + "description": "This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.", + "termsOfService": "http://swagger.io/terms/", + "license": { + "name": "Apache 2.0", + "url": "http://springdoc.org" + }, + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "user", + "description": "the user API" + } + ], + "paths": { + "/user": { + "post": { + "tags": [ + "user" + ], + "summary": "Create user", + "description": "Create user response entity.", + "operationId": "createUser", + "requestBody": { + "description": "Created user object", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/User" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "successful operation" + }, + "400": { + "description": "the map", + "content": { + "*/*": { + "schema": { + "type": "object", + "additionalProperties": { + "type": "object" + } + } + } + } + } + } + } + }, + "/user/createWithArray": { + "post": { + "tags": [ + "user" + ], + "summary": "Creates list of users with given input array", + "description": "Create users with array input response entity.", + "operationId": "createUsersWithArrayInput", + "requestBody": { + "description": "List of user object", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/User" + } + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "successful operation" + }, + "400": { + "description": "the map", + "content": { + "*/*": { + "schema": { + "type": "object", + "additionalProperties": { + "type": "object" + } + } + } + } + } + } + } + }, + "/user/createWithList": { + "post": { + "tags": [ + "user" + ], + "summary": "Creates list of users with given input array", + "description": "Create users with list input response entity.", + "operationId": "createUsersWithListInput", + "requestBody": { + "description": "List of user object", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/User" + } + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "successful operation" + }, + "400": { + "description": "the map", + "content": { + "*/*": { + "schema": { + "type": "object", + "additionalProperties": { + "type": "object" + } + } + } + } + } + } + } + }, + "/user/login": { + "get": { + "tags": [ + "user" + ], + "summary": "Logs user into the system", + "description": "Login user response entity.", + "operationId": "loginUser", + "parameters": [ + { + "name": "username", + "in": "query", + "description": "The user name for login", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "password", + "in": "query", + "description": "The password for login in clear text", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "type": "string" + } + }, + "application/xml": { + "schema": { + "type": "string" + } + } + } + }, + "400": { + "description": "Invalid username/password supplied", + "content": { + "*/*": { + "schema": { + "type": "object", + "additionalProperties": { + "type": "object" + } + } + } + } + } + } + } + }, + "/user/logout": { + "get": { + "tags": [ + "user" + ], + "summary": "Logs out current logged in user session", + "description": "Logout user response entity.", + "operationId": "logoutUser", + "responses": { + "200": { + "description": "successful operation" + }, + "400": { + "description": "the map", + "content": { + "*/*": { + "schema": { + "type": "object", + "additionalProperties": { + "type": "object" + } + } + } + } + } + } + } + }, + "/user/{username}": { + "get": { + "tags": [ + "user" + ], + "summary": "Get user by user name", + "description": "Gets user by name.", + "operationId": "getUserByName", + "parameters": [ + { + "name": "username", + "in": "path", + "description": "The name that needs to be fetched. Use user1 for testing.", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/User" + } + }, + "application/xml": { + "schema": { + "$ref": "#/components/schemas/User" + } + } + } + }, + "400": { + "description": "Invalid username supplied", + "content": { + "*/*": { + "schema": { + "type": "object", + "additionalProperties": { + "type": "object" + } + } + } + } + }, + "404": { + "description": "User not found", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/User" + } + }, + "application/xml": { + "schema": { + "$ref": "#/components/schemas/User" + } + } + } + } + } + }, + "put": { + "tags": [ + "user" + ], + "summary": "Updated user", + "description": "Update user response entity.", + "operationId": "updateUser", + "parameters": [ + { + "name": "username", + "in": "path", + "description": "name that need to be deleted", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "description": "Updated user object", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/User" + } + } + }, + "required": true + }, + "responses": { + "400": { + "description": "Invalid user supplied", + "content": { + "*/*": { + "schema": { + "type": "object", + "additionalProperties": { + "type": "object" + } + } + } + } + }, + "404": { + "description": "User not found" + } + } + }, + "delete": { + "tags": [ + "user" + ], + "summary": "Creates list of users with given input array", + "description": "Delete user response entity.", + "operationId": "deleteUser", + "parameters": [ + { + "name": "username", + "in": "path", + "description": "the username", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "successful operation" + }, + "400": { + "description": "the map", + "content": { + "*/*": { + "schema": { + "type": "object", + "additionalProperties": { + "type": "object" + } + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "User": { + "type": "object", + "properties": { + "email": { + "type": "string", + "description": "The Email." + }, + "firstName": { + "type": "string", + "description": "The First name." + }, + "id": { + "type": "integer", + "description": "The Id.", + "format": "int64" + }, + "lastName": { + "type": "string", + "description": "The Last name." + }, + "password": { + "type": "string", + "description": "The Password." + }, + "phone": { + "type": "string", + "description": "The Phone." + }, + "userStatus": { + "type": "integer", + "description": "User Status", + "format": "int32" + }, + "username": { + "type": "string", + "description": "The Username." + } + }, + "description": "The type User." + } + }, + "securitySchemes": { + "basicScheme": { + "type": "http", + "scheme": "basic" + }, + "petstore_auth": { + "type": "oauth2", + "flows": { + "implicit": { + "authorizationUrl": "http://petstore.swagger.io/oauth/dialog", + "scopes": { + "read:pets": "read your pets", + "write:pets": "modify pets in your account" + } + } + } + } + } + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app105-3.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app105-3.json new file mode 100644 index 000000000..9b86c0375 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app105-3.json @@ -0,0 +1,661 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "Petstore API", + "description": "This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.", + "termsOfService": "http://swagger.io/terms/", + "license": { + "name": "Apache 2.0", + "url": "http://springdoc.org" + }, + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "pet", + "description": "the pet API" + } + ], + "paths": { + "/pet": { + "put": { + "tags": [ + "pet" + ], + "summary": "Update an existing pet", + "description": "Update pet response entity.", + "operationId": "updatePet", + "requestBody": { + "description": "Pet object that needs to be added to the store", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Pet" + } + }, + "application/xml": { + "schema": { + "$ref": "#/components/schemas/Pet" + } + } + }, + "required": true + }, + "responses": { + "400": { + "description": "Invalid ID supplied", + "content": { + "*/*": { + "schema": { + "type": "object", + "additionalProperties": { + "type": "object" + } + } + } + } + }, + "404": { + "description": "Pet not found" + }, + "405": { + "description": "Validation exception" + } + }, + "security": [ + { + "petstore_auth": [ + "write:pets", + "read:pets" + ] + } + ] + }, + "post": { + "tags": [ + "pet" + ], + "summary": "Add a new pet to the store", + "description": "Add pet.", + "operationId": "addPet", + "requestBody": { + "description": "Pet object that needs to be added to the store", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Pet" + } + }, + "application/xml": { + "schema": { + "$ref": "#/components/schemas/Pet" + } + } + }, + "required": true + }, + "responses": { + "400": { + "description": "the map", + "content": { + "*/*": { + "schema": { + "type": "object", + "additionalProperties": { + "type": "object" + } + } + } + } + }, + "405": { + "description": "Invalid input" + } + }, + "security": [ + { + "petstore_auth": [ + "write:pets", + "read:pets" + ] + } + ] + } + }, + "/pet/{petId}": { + "get": { + "tags": [ + "pet" + ], + "summary": "Find pet by ID", + "description": "Returns a single pet", + "operationId": "getPetById", + "parameters": [ + { + "name": "petId", + "in": "path", + "description": "ID of pet to return", + "required": true, + "schema": { + "type": "integer", + "format": "int64" + } + } + ], + "responses": { + "400": { + "description": "Invalid ID supplied", + "content": { + "*/*": { + "schema": { + "type": "object", + "additionalProperties": { + "type": "object" + } + } + } + } + }, + "404": { + "description": "Pet not found", + "content": { + "application/xml": { + "schema": { + "$ref": "#/components/schemas/Pet" + } + }, + "application/json": { + "schema": { + "$ref": "#/components/schemas/Pet" + } + } + } + }, + "200": { + "description": "successful operation", + "content": { + "application/xml": { + "schema": { + "$ref": "#/components/schemas/Pet" + } + }, + "application/json": { + "schema": { + "$ref": "#/components/schemas/Pet" + } + } + } + } + }, + "security": [ + { + "api_key": [] + } + ] + }, + "post": { + "tags": [ + "pet" + ], + "summary": "Updates a pet in the store with form data", + "description": "Update pet with form response entity.", + "operationId": "updatePetWithForm", + "parameters": [ + { + "name": "petId", + "in": "path", + "description": "ID of pet that needs to be updated", + "required": true, + "schema": { + "type": "integer", + "format": "int64" + } + } + ], + "requestBody": { + "content": { + "application/x-www-form-urlencoded": { + "schema": { + "type": "object", + "properties": { + "name": { + "type": "string", + "description": "Updated name of the pet" + }, + "status": { + "type": "string", + "description": "Updated status of the pet" + } + } + } + } + } + }, + "responses": { + "400": { + "description": "the map", + "content": { + "*/*": { + "schema": { + "type": "object", + "additionalProperties": { + "type": "object" + } + } + } + } + }, + "405": { + "description": "Invalid input" + } + }, + "security": [ + { + "petstore_auth": [ + "write:pets", + "read:pets" + ] + } + ] + }, + "delete": { + "tags": [ + "pet" + ], + "summary": "Deletes a pet", + "description": "Delete pet response entity.", + "operationId": "deletePet", + "parameters": [ + { + "name": "petId", + "in": "path", + "description": "Pet id to delete", + "required": true, + "schema": { + "type": "integer", + "format": "int64" + } + }, + { + "name": "api_key", + "in": "header", + "description": "the api key", + "required": false, + "schema": { + "type": "string" + } + } + ], + "responses": { + "400": { + "description": "Invalid ID supplied", + "content": { + "*/*": { + "schema": { + "type": "object", + "additionalProperties": { + "type": "object" + } + } + } + } + }, + "404": { + "description": "Pet not found" + } + }, + "security": [ + { + "petstore_auth": [ + "write:pets", + "read:pets" + ] + } + ] + } + }, + "/pet/{petId}/uploadImage": { + "post": { + "tags": [ + "pet" + ], + "summary": "uploads an image", + "description": "Upload file response entity.", + "operationId": "uploadFile", + "parameters": [ + { + "name": "petId", + "in": "path", + "description": "ID of pet to update", + "required": true, + "schema": { + "type": "integer", + "format": "int64" + } + }, + { + "name": "additionalMetadata", + "in": "query", + "description": "Additional data to pass to server", + "required": false, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "multipart/form-data": { + "schema": { + "type": "object", + "properties": { + "file": { + "type": "string", + "format": "binary", + "description": "file detail" + } + }, + "required": [ + "file" + ] + } + } + } + }, + "responses": { + "400": { + "description": "the map", + "content": { + "*/*": { + "schema": { + "type": "object", + "additionalProperties": { + "type": "object" + } + } + } + } + }, + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ModelApiResponse" + } + } + } + } + }, + "security": [ + { + "petstore_auth": [ + "write:pets", + "read:pets" + ] + } + ] + } + }, + "/pet/findByTags": { + "get": { + "tags": [ + "pet" + ], + "summary": "Finds Pets by tags", + "description": "Muliple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.", + "operationId": "findPetsByTags", + "parameters": [ + { + "name": "tags", + "in": "query", + "description": "Tags to filter by", + "required": true, + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + } + ], + "responses": { + "400": { + "description": "Invalid tag value", + "content": { + "*/*": { + "schema": { + "type": "object", + "additionalProperties": { + "type": "object" + } + } + } + } + }, + "200": { + "description": "successful operation", + "content": { + "application/xml": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Pet" + } + } + }, + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Pet" + } + } + } + } + } + }, + "security": [ + { + "petstore_auth": [ + "write:pets", + "read:pets" + ] + } + ] + } + }, + "/pet/findByStatus": { + "get": { + "tags": [ + "pet" + ], + "summary": "Finds Pets by status", + "description": "Multiple status values can be provided with comma separated strings", + "operationId": "findPetsByStatus", + "parameters": [ + { + "name": "status", + "in": "query", + "description": "Status values that need to be considered for filter", + "required": true, + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + } + ], + "responses": { + "400": { + "description": "Invalid status value", + "content": { + "*/*": { + "schema": { + "type": "object", + "additionalProperties": { + "type": "object" + } + } + } + } + }, + "200": { + "description": "successful operation", + "content": { + "application/xml": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Pet" + } + } + }, + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Pet" + } + } + } + } + } + }, + "security": [ + { + "petstore_auth": [ + "write:pets", + "read:pets" + ] + } + ] + } + } + }, + "components": { + "schemas": { + "Category": { + "type": "object", + "description": "The type Category.", + "properties": { + "id": { + "type": "integer", + "format": "int64", + "description": "The Id." + }, + "name": { + "type": "string", + "description": "The Name." + } + } + }, + "Pet": { + "type": "object", + "description": "The type Pet.", + "properties": { + "id": { + "type": "integer", + "format": "int64", + "description": "The Id." + }, + "category": { + "$ref": "#/components/schemas/Category", + "description": "The Category." + }, + "name": { + "type": "string", + "description": "The Name.", + "example": "doggie" + }, + "photoUrls": { + "type": "array", + "description": "The Photo urls.", + "items": { + "type": "string" + } + }, + "tags": { + "type": "array", + "description": "The Tags.", + "items": { + "$ref": "#/components/schemas/Tag" + } + }, + "status": { + "type": "string", + "description": "pet status in the store", + "enum": [ + "available", + "pending", + "sold" + ] + } + }, + "required": [ + "name", + "photoUrls" + ] + }, + "Tag": { + "type": "object", + "description": "The type Tag.", + "properties": { + "id": { + "type": "integer", + "format": "int64", + "description": "The Id." + }, + "name": { + "type": "string", + "description": "The Name." + } + } + }, + "ModelApiResponse": { + "type": "object", + "description": "The type Model api response.", + "properties": { + "code": { + "type": "integer", + "format": "int32", + "description": "The Code." + }, + "type": { + "type": "string", + "description": "The Type." + }, + "message": { + "type": "string", + "description": "The Message." + } + } + } + }, + "securitySchemes": { + "basicScheme": { + "type": "http", + "scheme": "basic" + }, + "petstore_auth": { + "type": "oauth2", + "flows": { + "implicit": { + "authorizationUrl": "http://petstore.swagger.io/oauth/dialog", + "scopes": { + "write:pets": "modify pets in your account", + "read:pets": "read your pets" + } + } + } + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app105-4.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app105-4.json new file mode 100644 index 000000000..c5a35a361 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app105-4.json @@ -0,0 +1,86 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "Petstore API", + "description": "This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.", + "termsOfService": "http://swagger.io/terms/", + "license": { + "name": "Apache 2.0", + "url": "http://springdoc.org" + }, + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "store", + "description": "the store API" + } + ], + "paths": { + "/v1/stores": { + "get": { + "tags": [ + "store" + ], + "summary": "Stores.", + "description": "Stores.", + "operationId": "stores", + "parameters": [ + { + "name": "name", + "in": "query", + "description": "the name", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK" + }, + "400": { + "description": "the map", + "content": { + "*/*": { + "schema": { + "type": "object", + "additionalProperties": { + "type": "object" + } + } + } + } + } + } + } + } + }, + "components": { + "securitySchemes": { + "basicScheme": { + "type": "http", + "scheme": "basic" + }, + "petstore_auth": { + "type": "oauth2", + "flows": { + "implicit": { + "authorizationUrl": "http://petstore.swagger.io/oauth/dialog", + "scopes": { + "read:pets": "read your pets", + "write:pets": "modify pets in your account" + } + } + } + } + } + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app106.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app106.json new file mode 100644 index 000000000..7fa6d0fb2 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app106.json @@ -0,0 +1,57 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "hello-controller", + "description": "The type Hello controller." + } + ], + "paths": { + "/": { + "get": { + "tags": [ + "hello-controller" + ], + "summary": "find-articles", + "description": "Find articles response entity.", + "operationId": "findArticles", + "parameters": [ + { + "name": "If-Modified-Since", + "in": "header", + "description": "DateTime", + "required": false, + "schema": { + "type": "string", + "format": "date-time" + }, + "example": "2020-01-01T00:00:00.000Z" + } + ], + "responses": { + "200": { + "description": "the response entity", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + } + }, + "components": {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app107.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app107.json new file mode 100644 index 000000000..2f3ee9268 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app107.json @@ -0,0 +1,83 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "hello-controller", + "description": "The type Hello controller." + } + ], + "paths": { + "/entity-b": { + "get": { + "tags": [ + "hello-controller" + ], + "summary": "Gets entity b.", + "description": "Gets entity b.", + "operationId": "getEntityB", + "responses": { + "200": { + "description": "the entity b", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/EntityB" + } + }, + "application/xml": { + "schema": { + "$ref": "#/components/schemas/EntityB" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "EntityA": { + "type": "object", + "description": "The type Entity a.", + "properties": { + "fieldA": { + "type": "string", + "description": "The Field a." + } + }, + "required": [ + "fieldA" + ] + }, + "EntityB": { + "type": "object", + "description": "The type Entity b.", + "properties": { + "entityA": { + "$ref": "#/components/schemas/EntityA", + "description": "The Entity a." + }, + "fieldB": { + "type": "string", + "description": "The Field b." + } + }, + "required": [ + "entityA", + "fieldB" + ] + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app108.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app108.json new file mode 100644 index 000000000..7d44281a6 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app108.json @@ -0,0 +1,88 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "hello-controller", + "description": "The type Hello controller." + } + ], + "paths": { + "/": { + "post": { + "tags": [ + "hello-controller" + ], + "summary": "Update action result.", + "description": "Update action result.", + "operationId": "update", + "parameters": [ + { + "name": "toto", + "in": "query", + "description": "the toto", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "the action result", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/ActionResultVoid" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "ActionResultVoid": { + "type": "object", + "properties": { + "errorCode": { + "type": "string", + "description": "The Error code." + }, + "errorValue": { + "type": "object", + "description": "The Error value." + }, + "message": { + "type": "string", + "description": "The Message." + }, + "success": { + "type": "boolean", + "description": "The Success." + }, + "targetUrl": { + "type": "string", + "description": "The Target url." + }, + "value": { + "type": "object", + "description": "The Value." + } + }, + "description": "The type Action result." + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app109.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app109.json new file mode 100644 index 000000000..3a7f0f942 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app109.json @@ -0,0 +1,68 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "hello-controller", + "description": "The type Hello controller." + } + ], + "paths": { + "/api/v1/resource": { + "get": { + "tags": [ + "hello-controller" + ], + "summary": "Gets resource.", + "description": "Gets resource.", + "operationId": "getResource", + "responses": { + "200": { + "description": "the resource", + "content": { + "*/*": { + "schema": { + "type": "string", + "format": "binary" + } + } + } + } + } + } + }, + "/api/v1/bytearray": { + "get": { + "tags": [ + "hello-controller" + ], + "summary": "Get byte array byte [ ].", + "description": "Get byte array byte [ ].", + "operationId": "getByteArray", + "responses": { + "default": { + "description": "the byte [ ]", + "content": { + "*/*": { + "schema": { + "type": "string", + "format": "binary" + } + } + } + } + } + } + } + }, + "components": {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app11.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app11.json new file mode 100644 index 000000000..a41395c23 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app11.json @@ -0,0 +1,107 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "hello-controller", + "description": "The type Hello controller." + } + ], + "paths": { + "/documents": { + "post": { + "tags": [ + "hello-controller" + ], + "summary": "Upload documents response entity.", + "description": "Upload documents response entity.", + "operationId": "uploadDocuments", + "requestBody": { + "content": { + "multipart/form-data": { + "schema": { + "required": [ + "doc" + ], + "type": "object", + "properties": { + "doc": { + "type": "array", + "description": "the multipart files", + "items": { + "type": "string", + "format": "binary" + } + } + } + } + } + } + }, + "responses": { + "200": { + "description": "the response entity", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/tracks": { + "post": { + "tags": [ + "hello-controller" + ], + "summary": "Post track string.", + "description": "Post track string.", + "operationId": "postTrack", + "requestBody": { + "content": { + "multipart/form-data": { + "schema": { + "required": [ + "file" + ], + "type": "object", + "properties": { + "file": { + "type": "string", + "description": "the file", + "format": "binary" + } + } + } + } + } + }, + "responses": { + "200": { + "description": "the string", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + } + }, + "components": {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app110.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app110.json new file mode 100644 index 000000000..4c8e48984 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app110.json @@ -0,0 +1,310 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "sample application API", + "description": "description", + "termsOfService": "http://swagger.io/terms/", + "license": { + "name": "Apache 2.0", + "url": "http://springdoc.org" + }, + "version": "v1" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "person-controller", + "description": "The type Person controller." + }, + { + "name": "person-controller-2", + "description": "The type Person controller 2." + } + ], + "paths": { + "/person": { + "post": { + "tags": [ + "person-controller" + ], + "summary": "Person person.", + "description": "Person person.", + "operationId": "person", + "requestBody": { + "description": "the person", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Person" + } + } + }, + "required": true + }, + "responses": { + "500": { + "description": "the response entity", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/Problem" + } + } + } + }, + "400": { + "description": "the response entity", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, + "415": { + "description": "the response entity", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, + "200": { + "description": "the person", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/Person" + } + } + } + } + } + } + }, + "/person2": { + "post": { + "tags": [ + "person-controller-2" + ], + "summary": "Person person.", + "description": "Person person.", + "operationId": "person_1", + "requestBody": { + "description": "the person", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Person" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "the person", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/Person" + } + } + } + } + } + } + }, + "/personByLastName": { + "get": { + "tags": [ + "person-controller" + ], + "summary": "Find by last name list.", + "description": "Find by last name list.", + "operationId": "findByLastName", + "parameters": [ + { + "name": "lastName", + "in": "query", + "description": "the last name", + "required": true, + "schema": { + "maxLength": 10, + "minLength": 0, + "type": "string" + } + } + ], + "responses": { + "500": { + "description": "the response entity", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/Problem" + } + } + } + }, + "400": { + "description": "the response entity", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, + "415": { + "description": "the response entity", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, + "200": { + "description": "the list", + "content": { + "*/*": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Person" + } + } + } + } + } + } + } + }, + "/personByLastName2": { + "get": { + "tags": [ + "person-controller-2" + ], + "summary": "Find by last name list.", + "description": "Find by last name list.", + "operationId": "findByLastName_1", + "parameters": [ + { + "name": "lastName", + "in": "query", + "description": "the last name", + "required": true, + "schema": { + "maxLength": 10, + "minLength": 0, + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "the list", + "content": { + "*/*": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Person" + } + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "Problem": { + "type": "object", + "properties": { + "logRef": { + "type": "string", + "description": "The Log ref." + }, + "message": { + "type": "string", + "description": "The Message." + } + }, + "description": "The type Problem." + }, + "ErrorMessage": { + "type": "object", + "properties": { + "errors": { + "type": "array", + "description": "The Errors.", + "items": { + "type": "string" + } + } + }, + "description": "The type Error message." + }, + "Person": { + "required": [ + "lastName" + ], + "type": "object", + "properties": { + "id": { + "type": "integer", + "description": "The Id.", + "format": "int64" + }, + "firstName": { + "maxLength": 2147483647, + "minLength": 2, + "type": "string", + "description": "The First name." + }, + "lastName": { + "maxLength": 10, + "minLength": 0, + "type": "string", + "description": "The Last name." + }, + "email": { + "pattern": ".+@.+\\..+", + "type": "string", + "description": "The Email." + }, + "email1": { + "type": "string", + "description": "The Email 1." + }, + "age": { + "maximum": 30, + "minimum": 18, + "type": "integer", + "description": "The Age.", + "format": "int32" + }, + "creditCardNumber": { + "type": "string", + "description": "The Credit card number." + } + }, + "description": "The type Person." + } + } + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app111.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app111.json new file mode 100644 index 000000000..f55f690ec --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app111.json @@ -0,0 +1,223 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "sample application API", + "description": "description", + "termsOfService": "http://swagger.io/terms/", + "license": { + "name": "Apache 2.0", + "url": "http://springdoc.org" + }, + "version": "v1" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "person-controller", + "description": "The type Person controller." + }, + { + "name": "person-controller-2", + "description": "The type Person controller 2." + } + ], + "paths": { + "/person": { + "post": { + "tags": [ + "person-controller" + ], + "summary": "Person person.", + "description": "Person person.", + "operationId": "person", + "requestBody": { + "description": "the person", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Person" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "the person", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/Person" + } + } + } + } + } + } + }, + "/person2": { + "post": { + "tags": [ + "person-controller-2" + ], + "summary": "Person person.", + "description": "Person person.", + "operationId": "person_1", + "requestBody": { + "description": "the person", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Person" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "the person", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/Person" + } + } + } + } + } + } + }, + "/personByLastName": { + "get": { + "tags": [ + "person-controller" + ], + "summary": "Find by last name list.", + "description": "Find by last name list.", + "operationId": "findByLastName", + "parameters": [ + { + "name": "lastName", + "in": "query", + "description": "the last name", + "required": true, + "schema": { + "maxLength": 10, + "minLength": 0, + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "the list", + "content": { + "*/*": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Person" + } + } + } + } + } + } + } + }, + "/personByLastName2": { + "get": { + "tags": [ + "person-controller-2" + ], + "summary": "Find by last name list.", + "description": "Find by last name list.", + "operationId": "findByLastName_1", + "parameters": [ + { + "name": "lastName", + "in": "query", + "description": "the last name", + "required": true, + "schema": { + "maxLength": 10, + "minLength": 0, + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "the list", + "content": { + "*/*": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Person" + } + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "Person": { + "required": [ + "lastName" + ], + "type": "object", + "properties": { + "id": { + "type": "integer", + "description": "The Id.", + "format": "int64" + }, + "firstName": { + "maxLength": 2147483647, + "minLength": 2, + "type": "string", + "description": "The First name." + }, + "lastName": { + "maxLength": 10, + "minLength": 0, + "type": "string", + "description": "The Last name." + }, + "email": { + "pattern": ".+@.+\\..+", + "type": "string", + "description": "The Email." + }, + "email1": { + "type": "string", + "description": "The Email 1." + }, + "age": { + "maximum": 30, + "minimum": 18, + "type": "integer", + "description": "The Age.", + "format": "int32" + }, + "creditCardNumber": { + "type": "string", + "description": "The Credit card number." + } + }, + "description": "The type Person." + } + } + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app112.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app112.json new file mode 100644 index 000000000..a14264c5e --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app112.json @@ -0,0 +1,310 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "sample application API", + "description": "description", + "termsOfService": "http://swagger.io/terms/", + "license": { + "name": "Apache 2.0", + "url": "http://springdoc.org" + }, + "version": "v1" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "person-controller", + "description": "The type Person controller." + }, + { + "name": "person-controller-2", + "description": "The type Person controller 2." + } + ], + "paths": { + "/person": { + "post": { + "tags": [ + "person-controller" + ], + "summary": "Person person.", + "description": "Person person.", + "operationId": "person", + "requestBody": { + "description": "the person", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Person" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "the person", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/Person" + } + } + } + } + } + } + }, + "/person2": { + "post": { + "tags": [ + "person-controller-2" + ], + "summary": "Person person.", + "description": "Person person.", + "operationId": "person_1", + "requestBody": { + "description": "the person", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Person" + } + } + }, + "required": true + }, + "responses": { + "500": { + "description": "the response entity", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/Problem" + } + } + } + }, + "400": { + "description": "the response entity", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, + "415": { + "description": "the response entity", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, + "200": { + "description": "the person", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/Person" + } + } + } + } + } + } + }, + "/personByLastName": { + "get": { + "tags": [ + "person-controller" + ], + "summary": "Find by last name list.", + "description": "Find by last name list.", + "operationId": "findByLastName", + "parameters": [ + { + "name": "lastName", + "in": "query", + "description": "the last name", + "required": true, + "schema": { + "maxLength": 10, + "minLength": 0, + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "the list", + "content": { + "*/*": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Person" + } + } + } + } + } + } + } + }, + "/personByLastName2": { + "get": { + "tags": [ + "person-controller-2" + ], + "summary": "Find by last name list.", + "description": "Find by last name list.", + "operationId": "findByLastName_1", + "parameters": [ + { + "name": "lastName", + "in": "query", + "description": "the last name", + "required": true, + "schema": { + "maxLength": 10, + "minLength": 0, + "type": "string" + } + } + ], + "responses": { + "500": { + "description": "the response entity", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/Problem" + } + } + } + }, + "400": { + "description": "the response entity", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, + "415": { + "description": "the response entity", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/ErrorMessage" + } + } + } + }, + "200": { + "description": "the list", + "content": { + "*/*": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Person" + } + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "Problem": { + "type": "object", + "properties": { + "logRef": { + "type": "string", + "description": "The Log ref." + }, + "message": { + "type": "string", + "description": "The Message." + } + }, + "description": "The type Problem." + }, + "ErrorMessage": { + "type": "object", + "properties": { + "errors": { + "type": "array", + "description": "The Errors.", + "items": { + "type": "string" + } + } + }, + "description": "The type Error message." + }, + "Person": { + "required": [ + "lastName" + ], + "type": "object", + "properties": { + "id": { + "type": "integer", + "description": "The Id.", + "format": "int64" + }, + "firstName": { + "maxLength": 2147483647, + "minLength": 2, + "type": "string", + "description": "The First name." + }, + "lastName": { + "maxLength": 10, + "minLength": 0, + "type": "string", + "description": "The Last name." + }, + "email": { + "pattern": ".+@.+\\..+", + "type": "string", + "description": "The Email." + }, + "email1": { + "type": "string", + "description": "The Email 1." + }, + "age": { + "maximum": 30, + "minimum": 18, + "type": "integer", + "description": "The Age.", + "format": "int32" + }, + "creditCardNumber": { + "type": "string", + "description": "The Credit card number." + } + }, + "description": "The type Person." + } + } + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app113.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app113.json new file mode 100644 index 000000000..d0630c655 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app113.json @@ -0,0 +1,85 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "hello-controller", + "description": "The type Hello controller." + } + ], + "paths": { + "/lol": { + "post": { + "tags": [ + "hello-controller" + ], + "summary": "Test.", + "description": "Test.", + "operationId": "test", + "requestBody": { + "description": "the body", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Body" + } + } + } + }, + "responses": { + "200": { + "description": "OK" + } + } + } + }, + "/lol2": { + "post": { + "tags": [ + "hello-controller" + ], + "summary": "Test 2.", + "description": "Test 2.", + "operationId": "test2", + "requestBody": { + "description": "the body", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Body" + } + } + } + }, + "responses": { + "200": { + "description": "OK" + } + } + } + } + }, + "components": { + "schemas": { + "Body": { + "type": "object", + "properties": { + "field": { + "type": "string", + "description": "The Field." + } + }, + "description": "The type Body." + } + } + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app114.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app114.json new file mode 100644 index 000000000..6055c1cb2 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app114.json @@ -0,0 +1,81 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "hello-controller", + "description": "The type Hello controller." + } + ], + "paths": { + "/foos1": { + "post": { + "tags": [ + "hello-controller" + ], + "summary": "Gets currency.", + "description": "Gets currency.", + "operationId": "getCurrency", + "requestBody": { + "description": "the car dto", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CarDTO" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "the currency", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/MonetaryAmount" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "CarDTO": { + "type": "object", + "description": "The type Car dto.", + "properties": { + "price": { + "$ref": "#/components/schemas/MonetaryAmount", + "description": "The Price." + } + } + }, + "MonetaryAmount": { + "type": "object", + "properties": { + "amount": { + "type": "number", + "example": 99.96 + }, + "currency": { + "type": "string", + "example": "USD" + } + } + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app115.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app115.json new file mode 100644 index 000000000..052562581 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app115.json @@ -0,0 +1,45 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "hello-controller", + "description": "The type Hello controller." + } + ], + "paths": { + "/api/v2/timeout": { + "get": { + "tags": [ + "hello-controller" + ], + "summary": "Timeouts duration.", + "description": "Timeouts duration.", + "operationId": "timeouts", + "responses": { + "200": { + "description": "the duration", + "content": { + "application/json": { + "schema": { + "type": "string", + "properties": {} + } + } + } + } + } + } + } + }, + "components": {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app116.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app116.json new file mode 100644 index 000000000..31d873938 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app116.json @@ -0,0 +1,58 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "API Examples", + "version": "1.0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "Operations" + }, + { + "name": "hello-controller", + "description": "The type Hello controller." + } + ], + "paths": { + "/api/foo": { + "post": { + "tags": [ + "hello-controller" + ], + "summary": "Create string.", + "description": "Create string.", + "operationId": "create", + "requestBody": { + "description": "the foo", + "content": { + "application/json": { + "schema": { + "type": "string" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "the string", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + } + }, + "components": {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app117.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app117.json new file mode 100644 index 000000000..9b3eb4e37 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app117.json @@ -0,0 +1,168 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "greetings-rest-controller", + "description": "The type Greetings rest controller." + }, + { + "name": "person-service", + "description": "The type Person service." + } + ], + "paths": { + "/greet/{name}": { + "get": { + "tags": [ + "greetings-rest-controller" + ], + "summary": "Greet string.", + "description": "Greet string.", + "operationId": "greet", + "parameters": [ + { + "name": "name", + "in": "path", + "description": "the name", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "the string", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/people": { + "get": { + "tags": [ + "person-service" + ], + "summary": "All set.", + "description": "All set.", + "operationId": "all", + "responses": { + "200": { + "description": "the set", + "content": { + "*/*": { + "schema": { + "uniqueItems": true, + "type": "array", + "items": { + "$ref": "#/components/schemas/Person" + } + } + } + } + } + } + }, + "post": { + "tags": [ + "person-service" + ], + "summary": "Save person.", + "description": "Save person.", + "operationId": "save", + "parameters": [ + { + "name": "p", + "in": "query", + "description": "the p", + "required": true, + "schema": { + "$ref": "#/components/schemas/Person" + } + } + ], + "responses": { + "200": { + "description": "the person", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/Person" + } + } + } + } + } + } + }, + "/people/{id}": { + "get": { + "tags": [ + "person-service" + ], + "summary": "By id person.", + "description": "By id person.", + "operationId": "byId", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "the id", + "required": true, + "schema": { + "type": "integer", + "format": "int64" + } + } + ], + "responses": { + "200": { + "description": "the person", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/Person" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "Person": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "description": "The Id.", + "format": "int64" + }, + "name": { + "type": "string", + "description": "The Name." + } + }, + "description": "The type Person." + } + } + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app118.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app118.json new file mode 100644 index 000000000..fd1f31a21 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app118.json @@ -0,0 +1,270 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "controller", + "description": "The type Controller." + } + ], + "paths": { + "/class-hierarchy/concrete-parent": { + "post": { + "tags": [ + "controller" + ], + "summary": "Concrete parent response.", + "description": "Concrete parent response.", + "operationId": "concreteParent", + "requestBody": { + "description": "the payload", + "content": { + "application/json": { + "schema": { + "oneOf": [ + { + "$ref": "#/components/schemas/ConcreteParent" + }, + { + "$ref": "#/components/schemas/ChildOfConcrete1" + }, + { + "$ref": "#/components/schemas/ChildOfConcrete2" + } + ] + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "the response", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/Response" + } + } + } + } + } + } + }, + "/class-hierarchy/abstract-parent": { + "post": { + "tags": [ + "controller" + ], + "summary": "Abstract parent response.", + "description": "Abstract parent response.", + "operationId": "abstractParent", + "requestBody": { + "description": "the payload", + "content": { + "application/json": { + "schema": { + "oneOf": [ + { + "$ref": "#/components/schemas/ChildOfAbstract1" + }, + { + "$ref": "#/components/schemas/ChildOfAbstract2" + } + ] + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "the response", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/Response" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "ChildOfConcrete1": { + "allOf": [ + { + "$ref": "#/components/schemas/ConcreteParent" + }, + { + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int32", + "description": "The Id." + }, + "concreteChild1Param": { + "type": "string", + "description": "The Concrete child 1 param." + } + } + } + ], + "description": "The type Child of concrete 1." + }, + "ChildOfConcrete2": { + "allOf": [ + { + "$ref": "#/components/schemas/ConcreteParent" + }, + { + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int32", + "description": "The Id." + }, + "concreteChild2Param": { + "type": "string", + "description": "The Concrete child 2 param." + } + } + } + ], + "description": "The type Child of concrete 2." + }, + "ConcreteParent": { + "type": "object", + "description": "The type Concrete parent.", + "discriminator": { + "propertyName": "type" + }, + "properties": { + "id": { + "type": "integer", + "format": "int32", + "description": "The Id." + }, + "type": { + "type": "string" + } + }, + "required": [ + "type" + ] + }, + "AbstractParent": { + "type": "object", + "description": "The type Abstract parent.", + "discriminator": { + "propertyName": "type" + }, + "properties": { + "id": { + "type": "integer", + "format": "int32", + "description": "The Id." + }, + "type": { + "type": "string" + } + }, + "required": [ + "type" + ] + }, + "ChildOfAbstract1": { + "allOf": [ + { + "$ref": "#/components/schemas/AbstractParent" + }, + { + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int32", + "description": "The Id." + }, + "abstrachChild1Param": { + "type": "string", + "description": "The Abstrach child 1 param." + } + } + } + ], + "description": "The type Child of abstract 1." + }, + "ChildOfAbstract2": { + "allOf": [ + { + "$ref": "#/components/schemas/AbstractParent" + }, + { + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int32", + "description": "The Id." + }, + "abstractChild2Param": { + "type": "string", + "description": "The Abstract child 2 param." + } + } + } + ], + "description": "The type Child of abstract 2." + }, + "Response": { + "type": "object", + "description": "The type Response.", + "properties": { + "abstractParent": { + "description": "The Abstract parent.", + "oneOf": [ + { + "$ref": "#/components/schemas/ChildOfAbstract1" + }, + { + "$ref": "#/components/schemas/ChildOfAbstract2" + } + ] + }, + "concreteParents": { + "type": "array", + "description": "The Concrete parents.", + "items": { + "oneOf": [ + { + "$ref": "#/components/schemas/ConcreteParent" + }, + { + "$ref": "#/components/schemas/ChildOfConcrete1" + }, + { + "$ref": "#/components/schemas/ChildOfConcrete2" + } + ] + } + } + } + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app119.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app119.json new file mode 100644 index 000000000..063cfb38f --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app119.json @@ -0,0 +1,85 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "hello-controller", + "description": "The type Hello controller." + } + ], + "paths": { + "/multi": { + "post": { + "tags": [ + "hello-controller" + ], + "summary": "Multiple files and JSON payloads as multi part request", + "description": "Multi files in multi part string.", + "operationId": "multiFilesInMultiPart", + "requestBody": { + "content": { + "multipart/form-data": { + "schema": { + "type": "object", + "properties": { + "params": { + "$ref": "#/components/schemas/JsonRequest", + "description": "the json request" + }, + "file1": { + "type": "string", + "format": "binary", + "description": "This is file1" + }, + "file2": { + "type": "string", + "format": "binary", + "description": "This is file2" + } + }, + "required": [ + "params" + ] + } + } + } + }, + "responses": { + "200": { + "description": "the string", + "content": { + "text/plain": { + "schema": { + "type": "string" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "JsonRequest": { + "type": "object", + "description": "This is the configuration", + "properties": { + "name": { + "type": "string", + "description": "The Name." + } + } + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app12.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app12.json new file mode 100644 index 000000000..644c4d966 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app12.json @@ -0,0 +1,53 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "hello-controller", + "description": "The type Hello controller." + } + ], + "paths": { + "/persons": { + "get": { + "tags": [ + "hello-controller" + ], + "summary": "Persons string.", + "description": "Persons string.", + "operationId": "persons", + "parameters": [ + { + "name": "name", + "in": "query", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "the string", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + } + }, + "components": {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app120.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app120.json new file mode 100644 index 000000000..ba7fbdb7f --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app120.json @@ -0,0 +1,279 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "meta-annotation-controller", + "description": "The type Meta annotation controller." + } + ], + "paths": { + "/testTopLevelParamAnnotationOverrides/{id}": { + "get": { + "tags": [ + "meta-annotation-controller" + ], + "summary": "When there is a top level @Parameter annotation it has precedence over the meta-annotation\n So the id parameter should have all the defaults, with a name of \"id\"", + "description": "When there is a top level @Parameter annotation it has precedence over the meta-annotation\n So the id parameter should have all the defaults, with a name of \"id\"", + "operationId": "testTopLevelParamAnnotationOverrides", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "the account id", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "the string", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/testQueryParam": { + "get": { + "tags": [ + "meta-annotation-controller" + ], + "summary": "Test query param string.", + "description": "Test query param string.", + "operationId": "testQueryParam", + "parameters": [ + { + "name": "accountId", + "in": "query", + "description": "non alias description", + "required": true, + "schema": { + "type": "string" + }, + "example": 123456 + } + ], + "responses": { + "200": { + "description": "the string", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/testNoAliasFors/": { + "get": { + "tags": [ + "meta-annotation-controller" + ], + "summary": "Test no alias fors string.", + "description": "Test no alias fors string.", + "operationId": "testNoAliasFors", + "parameters": [ + { + "name": "name", + "in": "query", + "description": "desc", + "required": true, + "deprecated": true, + "allowEmptyValue": true, + "style": "deepObject", + "explode": true, + "allowReserved": true, + "schema": { + "type": "boolean" + }, + "example": 1234 + } + ], + "responses": { + "200": { + "description": "the string", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/testMetaMetaAnnotation/{accountId}": { + "get": { + "tags": [ + "meta-annotation-controller" + ], + "summary": "Test meta meta annotation string.", + "description": "Test meta meta annotation string.", + "operationId": "testMetaMetaAnnotation", + "parameters": [ + { + "name": "queryAccountId", + "in": "query", + "description": "non alias description", + "required": true, + "schema": { + "type": "string" + }, + "example": 123456 + }, + { + "name": "accountId", + "in": "path", + "description": "non alias description", + "required": true, + "schema": { + "type": "string" + }, + "example": 123456 + } + ], + "responses": { + "200": { + "description": "the string", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/testAllAttributesAsAlias/": { + "get": { + "tags": [ + "meta-annotation-controller" + ], + "summary": "Test all attributes as alias string.", + "description": "Test all attributes as alias string.", + "operationId": "testAllAttributesAsAlias", + "parameters": [ + { + "name": "name", + "in": "query", + "description": "desc", + "required": true, + "deprecated": true, + "allowEmptyValue": true, + "style": "deepObject", + "explode": true, + "allowReserved": true, + "schema": { + "type": "boolean" + }, + "example": 1234 + } + ], + "responses": { + "200": { + "description": "the string", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/testAliasFor": { + "get": { + "tags": [ + "meta-annotation-controller" + ], + "summary": "@AliasFor in the @AccountId annotation allows us to override the default it provides.", + "description": "@AliasFor in the @AccountId annotation allows us to override the default it provides.", + "operationId": "testAliasFor", + "parameters": [ + { + "name": "accountId", + "in": "query", + "description": "non alias description", + "required": true, + "schema": { + "type": "string" + }, + "example": "OVERRIDDEN EXAMPLE" + } + ], + "responses": { + "200": { + "description": "the string", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/simpleTest/{accountId}": { + "get": { + "tags": [ + "meta-annotation-controller" + ], + "summary": "Simple test string.", + "description": "Simple test string.", + "operationId": "simpleTest", + "parameters": [ + { + "name": "accountId", + "in": "path", + "description": "non alias description", + "required": true, + "schema": { + "type": "string" + }, + "example": 123456 + } + ], + "responses": { + "200": { + "description": "the string", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + } + }, + "components": {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app121.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app121.json new file mode 100644 index 000000000..ee3fc16e2 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app121.json @@ -0,0 +1,217 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "test-controller", + "description": "The type Test controller." + } + ], + "paths": { + "/test": { + "post": { + "tags": [ + "test-controller" + ], + "summary": "Gets test.", + "description": "Gets test.", + "operationId": "getTest", + "parameters": [ + { + "name": "param", + "in": "query", + "description": "the param", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "childParam", + "in": "query", + "description": "parameter from child of RequestParams", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "stringParam", + "in": "query", + "description": "string parameter", + "required": false, + "schema": { + "type": "string" + } + }, + { + "name": "stringParam1", + "in": "query", + "description": "The String param 1.", + "required": false, + "deprecated": true, + "schema": { + "type": "string" + } + }, + { + "name": "stringParam2", + "in": "query", + "description": "string parameter2", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "intParam", + "in": "query", + "description": "int parameter", + "required": false, + "schema": { + "type": "integer", + "format": "int32" + } + }, + { + "name": "intParam2", + "in": "query", + "description": "The Int param 2.", + "required": false, + "schema": { + "type": "string" + } + }, + { + "name": "intParam3", + "in": "query", + "description": "The Int param 3.", + "required": false, + "schema": { + "type": "string" + } + }, + { + "name": "nested.param1", + "in": "query", + "description": "nested string parameter", + "required": false, + "schema": { + "type": "string" + } + }, + { + "name": "nested.param2", + "in": "query", + "description": "nested BigInteger parameter", + "required": false, + "schema": { + "type": "integer" + } + }, + { + "name": "nestedList", + "in": "query", + "description": "The Nested list.", + "required": false, + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Nested" + } + } + } + ], + "responses": { + "200": { + "description": "the test", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/InheritedRequestParams" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "InheritedRequestParams": { + "type": "object", + "description": "The type Inherited request params.", + "properties": { + "childParam": { + "type": "string", + "description": "parameter from child of RequestParams" + }, + "intParam": { + "type": "integer", + "format": "int32", + "description": "The Int param." + }, + "intParam2": { + "type": "string", + "description": "The Int param 2." + }, + "intParam3": { + "type": "string", + "description": "The Int param 3." + }, + "nested": { + "$ref": "#/components/schemas/Nested", + "description": "The Nested." + }, + "nestedList": { + "type": "array", + "description": "The Nested list.", + "items": { + "$ref": "#/components/schemas/Nested" + } + }, + "stringParam": { + "type": "string", + "description": "The String param." + }, + "stringParam1": { + "type": "string", + "deprecated": true, + "description": "The String param 1." + }, + "stringParam2": { + "type": "string", + "description": "The String param 2." + } + }, + "required": [ + "childParam" + ] + }, + "Nested": { + "type": "object", + "description": "The type Nested.", + "properties": { + "param1": { + "type": "string", + "description": "The Param 1." + }, + "param2": { + "type": "integer", + "description": "The Param 2." + } + } + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app122.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app122.json new file mode 100644 index 000000000..c1649f202 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app122.json @@ -0,0 +1,76 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/": { + "post": { + "tags": [ + "example" + ], + "summary": "create", + "description": "Create response entity.", + "operationId": "create", + "requestBody": { + "description": "the payload", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/WrapperCustomerDto" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "the response entity", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/CustomerDto" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "CustomerDto": { + "type": "object", + "properties": { + "baseStr": { + "type": "string", + "description": "The Base str." + }, + "customerName": { + "type": "string", + "description": "The Customer name." + } + }, + "description": "The type Customer dto." + }, + "WrapperCustomerDto": { + "type": "object", + "properties": { + "wrapper": { + "type": "string", + "description": "The Wrapper." + } + }, + "description": "The type Wrapper." + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app123.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app123.json new file mode 100644 index 000000000..22949db49 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app123.json @@ -0,0 +1,77 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "hello-controller", + "description": "The type Hello controller." + } + ], + "paths": { + "/hello/{numTelco}": { + "get": { + "tags": [ + "hello-controller" + ], + "summary": "GET Persons", + "description": "Index t.", + "operationId": "index", + "parameters": [ + { + "name": "numTelco", + "in": "path", + "description": "the num tel", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "adresse", + "in": "query", + "description": "the adresse", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "404": { + "description": "Not here" + }, + "502": { + "description": "the object", + "content": { + "*/*": { + "schema": { + "type": "object" + } + } + } + }, + "418": { + "description": "the t", + "content": { + "*/*": { + "schema": { + "type": "object" + } + } + } + } + } + } + } + }, + "components": {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app124.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app124.json new file mode 100644 index 000000000..2fb7bf72d --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app124.json @@ -0,0 +1,77 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "hello-controller", + "description": "The type Hello controller." + } + ], + "paths": { + "/hello/{numTelco}": { + "get": { + "tags": [ + "hello-controller" + ], + "summary": "GET Persons", + "description": "Index t.", + "operationId": "index", + "parameters": [ + { + "name": "numTelco", + "in": "path", + "description": "the num tel", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "adresse", + "in": "query", + "description": "the adresse", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "502": { + "description": "the object", + "content": { + "*/*": { + "schema": { + "type": "object" + } + } + } + }, + "404": { + "description": "Not here" + }, + "418": { + "description": "the t", + "content": { + "*/*": { + "schema": { + "type": "object" + } + } + } + } + } + } + } + }, + "components": {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app125.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app125.json new file mode 100644 index 000000000..4e5912444 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app125.json @@ -0,0 +1,78 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "hello-controller", + "description": "The type Hello controller." + } + ], + "paths": { + "/search": { + "get": { + "tags": [ + "hello-controller" + ], + "summary": "Gets all pets.", + "description": "Gets all pets.", + "operationId": "getAllPets", + "parameters": [ + { + "name": "toto", + "in": "query", + "description": "the toto", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "the all pets", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/DeprecatedEntity" + } + }, + "application/xml": { + "schema": { + "$ref": "#/components/schemas/DeprecatedEntity" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "DeprecatedEntity": { + "type": "object", + "properties": { + "myNonDeprecatedField": { + "type": "string", + "description": "The My non deprecated field." + }, + "mydeprecatedField": { + "type": "string", + "description": "The Mydeprecated field.", + "deprecated": true + } + }, + "description": "The type Deprecated entity." + } + } + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app126.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app126.json new file mode 100644 index 000000000..074f383aa --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app126.json @@ -0,0 +1,124 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "hello-controller", + "description": "The type Hello controller." + } + ], + "paths": { + "/": { + "get": { + "tags": [ + "hello-controller" + ], + "summary": "getAllCurrencies", + "description": "Get all currencies", + "operationId": "getAllCurrencies", + "responses": { + "401": { + "$ref": "#/components/responses/http401NoToken" + }, + "403": { + "$ref": "#/components/responses/http403" + }, + "200": { + "description": "All currencies returned", + "content": { + "*/*": { + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "Problem": { + "type": "object", + "properties": { + "instance": { + "type": "string", + "description": "An absolute URI that identifies the specific occurrence of the problem.\n It may or may not yield further information if dereferenced.", + "format": "uri" + }, + "type": { + "type": "string", + "description": "An absolute URI that identifies the problem type. When dereferenced,\n it SHOULD provide human-readable documentation for the problem type\n (e.g., using HTML). When this member is not present, its value is\n assumed to be \"about:blank\".", + "format": "uri" + }, + "parameters": { + "type": "object", + "additionalProperties": { + "type": "object" + }, + "description": "Optional, additional attributes of the problem. Implementations can choose to ignore this in favor of concrete,\n typed fields." + }, + "title": { + "type": "string", + "description": "A short, human-readable summary of the problem type. It SHOULD NOT\n change from occurrence to occurrence of the problem, except for\n purposes of localisation." + }, + "detail": { + "type": "string", + "description": "A human readable explanation specific to this occurrence of the problem." + }, + "status": { + "type": "integer", + "description": "The HTTP status code generated by the origin server for this\n occurrence of the problem.", + "format": "int32" + } + }, + "description": "The interface Problem." + } + }, + "responses": { + "http401NoToken": { + "description": "Invalid authentication.", + "content": { + "application/problem+json": { + "schema": { + "$ref": "#/components/schemas/Problem" + } + } + } + }, + "http401BadToken": { + "description": "Invalid authentication.", + "content": { + "application/problem+json": { + "schema": { + "$ref": "#/components/schemas/Problem" + } + } + } + }, + "http403": { + "description": "Missing authorities.", + "content": { + "application/problem+json": { + "schema": { + "$ref": "#/components/schemas/Problem" + } + } + } + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app129.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app129.json new file mode 100644 index 000000000..5a15e9a9c --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app129.json @@ -0,0 +1,94 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "hello-controller", + "description": "The type Hello controller." + } + ], + "paths": { + "/api/test": { + "post": { + "tags": [ + "hello-controller" + ], + "summary": "Update deferred result.", + "description": "Update deferred result.", + "operationId": "update", + "parameters": [ + { + "name": "userId", + "in": "header", + "schema": { + "type": "string" + } + }, + { + "name": "registrationId", + "in": "header", + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "description": "the entity", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ActualReturnedEntity" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "the deferred result", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/OperationResponseActualReturnedEntity" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "ActualReturnedEntity": { + "type": "object", + "properties": { + "result": { + "type": "string", + "description": "The Result." + } + }, + "description": "The type Actual returned entity." + }, + "OperationResponseActualReturnedEntity": { + "type": "object", + "properties": { + "operationResult": { + "type": "string", + "description": "The Operation result." + } + }, + "description": "The type Operation response." + } + } + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app13.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app13.json new file mode 100644 index 000000000..f3326e31e --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app13.json @@ -0,0 +1,76 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "hello-controller", + "description": "The type Hello controller." + } + ], + "paths": { + "/persons": { + "get": { + "tags": [ + "hello-controller" + ], + "summary": "Persons string.", + "description": "Persons string.", + "operationId": "persons", + "parameters": [ + { + "name": "dto", + "in": "query", + "description": "the dto", + "required": true, + "schema": { + "$ref": "#/components/schemas/PersonDTO" + } + } + ], + "responses": { + "200": { + "description": "the string", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "PersonDTO": { + "type": "object", + "properties": { + "email": { + "type": "string", + "description": "The Email." + }, + "first_name": { + "type": "string", + "description": "The First name." + }, + "last_name": { + "type": "string", + "description": "The Last name." + } + }, + "description": "The type Person dto." + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app130.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app130.json new file mode 100644 index 000000000..bf95352ef --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app130.json @@ -0,0 +1,54 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "hello-controller", + "description": "The type Hello controller." + } + ], + "paths": { + "/values/data": { + "post": { + "tags": [ + "hello-controller" + ], + "summary": "List tracker data.", + "description": "List tracker data.", + "operationId": "list", + "responses": { + "200": { + "description": "the tracker data", + "content": {} + } + } + } + }, + "/values/datakk": { + "get": { + "tags": [ + "hello-controller" + ], + "summary": "Get tracker data.", + "description": "Get tracker data.", + "operationId": "get", + "responses": { + "200": { + "description": "the tracker data", + "content": {} + } + } + } + } + }, + "components": {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app131.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app131.json new file mode 100644 index 000000000..400b31edc --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app131.json @@ -0,0 +1,114 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "hello-controller", + "description": "The type Hello controller." + } + ], + "paths": { + "/organizations": { + "post": { + "tags": [ + "hello-controller" + ], + "summary": "Create the organization", + "description": "Create the organization", + "operationId": "createOrganization", + "requestBody": { + "description": "the organization", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Organization" + } + } + }, + "required": true + }, + "responses": { + "400": { + "description": "Invalid argument", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/RestControllerError" + } + } + } + }, + "500": { + "description": "An error has occurred and the request could not be processed at this time", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/RestControllerError" + } + } + } + }, + "409": { + "description": "An organization with the specified ID already exists", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/RestControllerError" + } + } + } + }, + "204": { + "description": "The organization was created successfully" + } + } + } + } + }, + "components": { + "schemas": { + "Organization": { + "required": [ + "id", + "name" + ], + "type": "object", + "properties": { + "id": { + "type": "string", + "description": "The Universally Unique Identifier (UUID) uniquely identifying the organization", + "format": "uuid" + }, + "name": { + "type": "string", + "description": "The name of the organization" + } + }, + "description": "This is the description being overwritten" + }, + "RestControllerError": { + "type": "object", + "properties": { + "id": { + "type": "string", + "description": "The Id." + }, + "message": { + "type": "string", + "description": "The Message." + } + }, + "description": "The type Rest controller error." + } + } + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app132.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app132.json new file mode 100644 index 000000000..89b68d8b3 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app132.json @@ -0,0 +1,114 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "hello-controller", + "description": "The type Hello controller." + } + ], + "paths": { + "/organizations": { + "post": { + "tags": [ + "hello-controller" + ], + "summary": "Create the organization", + "description": "Create the organization", + "operationId": "createOrganization", + "requestBody": { + "description": "the organization", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Organization" + } + } + }, + "required": true + }, + "responses": { + "400": { + "description": "Invalid argument", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/RestControllerError" + } + } + } + }, + "409": { + "description": "An organization with the specified ID already exists", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/RestControllerError" + } + } + } + }, + "204": { + "description": "The organization was created successfully" + }, + "500": { + "description": "An error has occurred and the request could not be processed at this time", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/RestControllerError" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "Organization": { + "required": [ + "id", + "name" + ], + "type": "object", + "properties": { + "id": { + "type": "string", + "description": "The Universally Unique Identifier (UUID) uniquely identifying the organization", + "format": "uuid" + }, + "name": { + "type": "string", + "description": "The name of the organization" + } + }, + "description": "i want to override the description of this object" + }, + "RestControllerError": { + "type": "object", + "properties": { + "id": { + "type": "string", + "description": "The Id." + }, + "message": { + "type": "string", + "description": "The Message." + } + }, + "description": "The type Rest controller error." + } + } + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app133.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app133.json new file mode 100644 index 000000000..40a919757 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app133.json @@ -0,0 +1,125 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "hello-controller", + "description": "The type Hello controller." + } + ], + "paths": { + "/test1": { + "get": { + "tags": [ + "hello-controller" + ], + "summary": "Gets message from header 1.", + "description": "Gets message from header 1.", + "operationId": "getMessageFromHeader1", + "parameters": [ + { + "name": "myHeader", + "in": "header", + "description": "A header", + "required": true, + "schema": { + "type": "string", + "enum": [ + "foo", + "bar" + ] + } + } + ], + "responses": { + "200": { + "description": "the message from header 1", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/test2": { + "get": { + "tags": [ + "hello-controller" + ], + "summary": "Gets message from header 2.", + "description": "Gets message from header 2.", + "operationId": "getMessageFromHeader2", + "parameters": [ + { + "name": "myHeader", + "in": "header", + "description": "A header", + "required": true, + "schema": { + "type": "integer" + } + } + ], + "responses": { + "200": { + "description": "the message from header 2", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/test3": { + "get": { + "tags": [ + "hello-controller" + ], + "summary": "Gets message from header 3.", + "description": "Gets message from header 3.", + "operationId": "getMessageFromHeader3", + "parameters": [ + { + "name": "myHeader", + "in": "header", + "description": "A header", + "required": true, + "schema": { + "type": "integer" + } + } + ], + "responses": { + "200": { + "description": "the message from header 3", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + } + }, + "components": {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app134-1.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app134-1.json new file mode 100644 index 000000000..bf940a24a --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app134-1.json @@ -0,0 +1,72 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/{id}": { + "get": { + "tags": [ + "The sample resource" + ], + "description": "Get the sample by its id.", + "operationId": "getSampleV1", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "The sample's id", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "X-API-VERSION", + "in": "header", + "schema": { + "type": "string", + "enum": [ + "1" + ] + } + } + ], + "responses": { + "200": { + "description": "the sample v 1", + "content": { + "application/vnd.samples.v1+json": { + "schema": { + "$ref": "#/components/schemas/SampleV1" + } + } + } + } + }, + "deprecated": true + } + } + }, + "components": { + "schemas": { + "SampleV1": { + "type": "object", + "properties": { + "id": { + "type": "string", + "description": "The Id." + } + }, + "description": "The type Sample v 1." + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app134-2.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app134-2.json new file mode 100644 index 000000000..0c4158920 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app134-2.json @@ -0,0 +1,139 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/search": { + "post": { + "tags": [ + "The sample resource" + ], + "description": "Searches for sample objects using the given search request.", + "operationId": "searchSamples", + "requestBody": { + "description": "the search request", + "content": { + "application/vnd.samples.v2+json": { + "schema": { + "$ref": "#/components/schemas/SampleSearchRequest" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "the list", + "content": { + "application/vnd.samples.v2+json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/SampleV2" + } + } + } + } + } + } + } + }, + "/{id}": { + "get": { + "tags": [ + "The sample resource" + ], + "description": "Get the sample by its id. This represents V2.", + "operationId": "getSampleV2", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "The sample's id", + "required": true, + "schema": { + "type": "integer", + "format": "int64" + } + }, + { + "name": "Accept-version", + "in": "header", + "schema": { + "type": "string", + "enum": [ + "v2" + ] + } + }, + { + "name": "X-API-VERSION", + "in": "header", + "schema": { + "type": "string", + "enum": [ + "1" + ] + } + } + ], + "responses": { + "200": { + "description": "the sample v 2", + "content": { + "application/vnd.samples.v2+json": { + "schema": { + "$ref": "#/components/schemas/SampleV1" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "SampleSearchRequest": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "description": "The Id.", + "format": "int64" + } + }, + "description": "The type Sample search request." + }, + "SampleV2": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "description": "The Id.", + "format": "int64" + } + }, + "description": "The type Sample v 2." + }, + "SampleV1": { + "type": "object", + "properties": { + "id": { + "type": "string", + "description": "The Id." + } + }, + "description": "The type Sample v 1." + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app134-3.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app134-3.json new file mode 100644 index 000000000..bf940a24a --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app134-3.json @@ -0,0 +1,72 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/{id}": { + "get": { + "tags": [ + "The sample resource" + ], + "description": "Get the sample by its id.", + "operationId": "getSampleV1", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "The sample's id", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "X-API-VERSION", + "in": "header", + "schema": { + "type": "string", + "enum": [ + "1" + ] + } + } + ], + "responses": { + "200": { + "description": "the sample v 1", + "content": { + "application/vnd.samples.v1+json": { + "schema": { + "$ref": "#/components/schemas/SampleV1" + } + } + } + } + }, + "deprecated": true + } + } + }, + "components": { + "schemas": { + "SampleV1": { + "type": "object", + "properties": { + "id": { + "type": "string", + "description": "The Id." + } + }, + "description": "The type Sample v 1." + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app134-4.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app134-4.json new file mode 100644 index 000000000..94eb50ce5 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app134-4.json @@ -0,0 +1,82 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/{id}": { + "get": { + "tags": [ + "The sample resource" + ], + "description": "Get the sample by its id. This represents V2.", + "operationId": "getSampleV2", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "The sample's id", + "required": true, + "schema": { + "type": "integer", + "format": "int64" + } + }, + { + "name": "Accept-version", + "in": "header", + "schema": { + "type": "string", + "enum": [ + "v2" + ] + } + }, + { + "name": "X-API-VERSION", + "in": "header", + "schema": { + "type": "string", + "enum": [ + "1" + ] + } + } + ], + "responses": { + "200": { + "description": "the sample v 2", + "content": { + "application/vnd.samples.v2+json": { + "schema": { + "$ref": "#/components/schemas/SampleV1" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "SampleV1": { + "type": "object", + "properties": { + "id": { + "type": "string", + "description": "The Id." + } + }, + "description": "The type Sample v 1." + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app134-5.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app134-5.json new file mode 100644 index 000000000..4fb26c92f --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app134-5.json @@ -0,0 +1,76 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/search": { + "post": { + "tags": [ + "The sample resource" + ], + "description": "Searches for sample objects using the given search request.", + "operationId": "searchSamples", + "requestBody": { + "description": "the search request", + "content": { + "application/vnd.samples.v2+json": { + "schema": { + "$ref": "#/components/schemas/SampleSearchRequest" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "the list", + "content": { + "application/vnd.samples.v2+json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/SampleV2" + } + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "SampleSearchRequest": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "description": "The Id.", + "format": "int64" + } + }, + "description": "The type Sample search request." + }, + "SampleV2": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "description": "The Id.", + "format": "int64" + } + }, + "description": "The type Sample v 2." + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app135.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app135.json new file mode 100644 index 000000000..5670536e4 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app135.json @@ -0,0 +1,428 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "book-repository", + "description": "The type Book repository." + } + ], + "paths": { + "/books": { + "get": { + "tags": [ + "book-repository" + ], + "summary": "Find all list.", + "description": "Find all list.", + "operationId": "findAll", + "responses": { + "200": { + "description": "the list", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Book" + } + } + }, + "application/xml": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Book" + } + } + } + } + } + } + } + }, + "/books/{author}": { + "get": { + "tags": [ + "book-repository" + ], + "summary": "Find by author list.", + "description": "Find by author list.", + "operationId": "findByAuthor", + "parameters": [ + { + "name": "author", + "in": "path", + "description": "the author", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "the list", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Book" + } + } + }, + "application/xml": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Book" + } + } + } + } + } + } + } + }, + "/greeter/books": { + "get": { + "tags": [ + "book-repository" + ], + "summary": "Find all list.", + "description": "Find all list.", + "operationId": "findAll_3", + "responses": { + "200": { + "description": "the list", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Book" + } + } + }, + "application/xml": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Book" + } + } + }, + "text/plain": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Book" + } + } + } + } + } + } + } + }, + "/greeter/books/{author}": { + "get": { + "tags": [ + "book-repository" + ], + "summary": "Find by author list.", + "description": "Find by author list.", + "operationId": "findByAuthor_3", + "parameters": [ + { + "name": "author", + "in": "path", + "description": "the author", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "the list", + "content": { + "*/*": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Book" + } + } + } + } + } + } + } + }, + "/greeter/greeter2/books": { + "get": { + "tags": [ + "book-repository" + ], + "summary": "Find all list.", + "description": "Find all list.", + "operationId": "findAll_1", + "responses": { + "200": { + "description": "the list", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Book" + } + } + }, + "application/xml": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Book" + } + } + }, + "text/plain": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Book" + } + } + } + } + } + } + } + }, + "/greeter/greeter2/books/{author}": { + "get": { + "tags": [ + "book-repository" + ], + "summary": "Find by author list.", + "description": "Find by author list.", + "operationId": "findByAuthor_1", + "parameters": [ + { + "name": "author", + "in": "path", + "description": "the author", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "the list", + "content": { + "*/*": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Book" + } + } + } + } + } + } + } + }, + "/greeter2/books": { + "get": { + "tags": [ + "book-repository" + ], + "summary": "Find all list.", + "description": "Find all list.", + "operationId": "findAll_4", + "responses": { + "200": { + "description": "the list", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Book" + } + } + }, + "application/xml": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Book" + } + } + }, + "text/plain": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Book" + } + } + } + } + } + } + } + }, + "/greeter2/books/{author}": { + "get": { + "tags": [ + "book-repository" + ], + "summary": "Find by author list.", + "description": "Find by author list.", + "operationId": "findByAuthor_4", + "parameters": [ + { + "name": "author", + "in": "path", + "description": "the author", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "the list", + "content": { + "*/*": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Book" + } + } + } + } + } + } + } + }, + "/test/greeter/greeter2/books": { + "get": { + "tags": [ + "book-repository" + ], + "summary": "Find all list.", + "description": "Find all list.", + "operationId": "findAll_2", + "responses": { + "200": { + "description": "the list", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Book" + } + } + }, + "application/xml": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Book" + } + } + }, + "text/plain": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Book" + } + } + } + } + } + } + } + }, + "/test/greeter/greeter2/books/{author}": { + "get": { + "tags": [ + "book-repository" + ], + "summary": "Find by author list.", + "description": "Find by author list.", + "operationId": "findByAuthor_2", + "parameters": [ + { + "name": "author", + "in": "path", + "description": "the author", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "the list", + "content": { + "*/*": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Book" + } + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "Book": { + "type": "object", + "properties": { + "author": { + "type": "string", + "description": "The Author." + }, + "id": { + "type": "string", + "description": "The Id." + }, + "title": { + "type": "string", + "description": "The Title." + } + }, + "description": "The type Book." + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app137.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app137.json new file mode 100644 index 000000000..26dcfbd38 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app137.json @@ -0,0 +1,67 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "My App", + "description": "Some long and useful description", + "version": "v1" + }, + "servers": [ + { + "url": "http://test.toto.com", + "description": "toto desc" + } + ], + "tags": [ + { + "name": "hello-controller", + "description": "The type Hello controller." + } + ], + "paths": { + "/test": { + "get": { + "tags": [ + "hello-controller" + ], + "summary": "Test.", + "description": "Test.", + "operationId": "test", + "parameters": [ + { + "name": "hello", + "in": "query", + "description": "the hello", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK" + } + }, + "security": [ + { + "security_auth": [] + } + ] + } + } + }, + "components": { + "securitySchemes": { + "security_auth": { + "type": "oauth2", + "flows": { + "authorizationCode": { + "authorizationUrl": "http://authorization.url", + "tokenUrl": "http://token.url", + "scopes": {} + } + } + } + } + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app138.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app138.json new file mode 100644 index 000000000..8ac947fc2 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app138.json @@ -0,0 +1,74 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "hello-controller", + "description": "The type Hello controller." + } + ], + "paths": { + "/testA": { + "get": { + "tags": [ + "hello-controller" + ], + "summary": "Test a.", + "description": "Test a.", + "operationId": "testA", + "parameters": [ + { + "name": "hello", + "in": "query", + "description": "the hello", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK" + } + } + } + }, + "/testB": { + "get": { + "tags": [ + "hello-controller" + ], + "summary": "Test b.", + "description": "Test b.", + "operationId": "testB", + "parameters": [ + { + "name": "hello", + "in": "query", + "description": "the hello", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK" + } + } + } + } + }, + "components": {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app139.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app139.json new file mode 100644 index 000000000..2c67c92d1 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app139.json @@ -0,0 +1,90 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "hello-controller", + "description": "The type Hello controller." + } + ], + "paths": { + "/test1": { + "get": { + "tags": [ + "hello-controller" + ], + "summary": "Echo 1 string.", + "description": "Echo 1 string.", + "operationId": "echo1", + "parameters": [ + { + "name": "text", + "in": "query", + "description": "the text", + "required": false, + "schema": { + "type": "string", + "default": "default-text" + } + } + ], + "responses": { + "200": { + "description": "the string", + "content": { + "text/plain": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/test2": { + "get": { + "tags": [ + "hello-controller" + ], + "summary": "Echo 2 string.", + "description": "Echo 2 string.", + "operationId": "echo2", + "parameters": [ + { + "name": "text", + "in": "query", + "description": "the text", + "required": false, + "schema": { + "type": "string", + "default": "default-text" + } + } + ], + "responses": { + "200": { + "description": "the string", + "content": { + "text/plain": { + "schema": { + "type": "string" + } + } + } + } + } + } + } + }, + "components": {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app14.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app14.json new file mode 100644 index 000000000..cae257649 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app14.json @@ -0,0 +1,70 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "hello-controller", + "description": "The type Hello controller." + } + ], + "paths": { + "/test": { + "get": { + "tags": [ + "hello-controller" + ], + "summary": "Demo 2 http entity.", + "description": "Demo 2 http entity.", + "operationId": "demo2", + "responses": { + "200": { + "description": "the http entity", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/persons": { + "get": { + "tags": [ + "hello-controller" + ], + "summary": "Persons.", + "description": "Persons.", + "operationId": "persons", + "parameters": [ + { + "name": "name", + "in": "query", + "description": "the name", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK" + } + } + } + } + }, + "components": {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app140.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app140.json new file mode 100644 index 000000000..9b3eb4e37 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app140.json @@ -0,0 +1,168 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "greetings-rest-controller", + "description": "The type Greetings rest controller." + }, + { + "name": "person-service", + "description": "The type Person service." + } + ], + "paths": { + "/greet/{name}": { + "get": { + "tags": [ + "greetings-rest-controller" + ], + "summary": "Greet string.", + "description": "Greet string.", + "operationId": "greet", + "parameters": [ + { + "name": "name", + "in": "path", + "description": "the name", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "the string", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/people": { + "get": { + "tags": [ + "person-service" + ], + "summary": "All set.", + "description": "All set.", + "operationId": "all", + "responses": { + "200": { + "description": "the set", + "content": { + "*/*": { + "schema": { + "uniqueItems": true, + "type": "array", + "items": { + "$ref": "#/components/schemas/Person" + } + } + } + } + } + } + }, + "post": { + "tags": [ + "person-service" + ], + "summary": "Save person.", + "description": "Save person.", + "operationId": "save", + "parameters": [ + { + "name": "p", + "in": "query", + "description": "the p", + "required": true, + "schema": { + "$ref": "#/components/schemas/Person" + } + } + ], + "responses": { + "200": { + "description": "the person", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/Person" + } + } + } + } + } + } + }, + "/people/{id}": { + "get": { + "tags": [ + "person-service" + ], + "summary": "By id person.", + "description": "By id person.", + "operationId": "byId", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "the id", + "required": true, + "schema": { + "type": "integer", + "format": "int64" + } + } + ], + "responses": { + "200": { + "description": "the person", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/Person" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "Person": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "description": "The Id.", + "format": "int64" + }, + "name": { + "type": "string", + "description": "The Name." + } + }, + "description": "The type Person." + } + } + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app141.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app141.json new file mode 100644 index 000000000..edf3839a8 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app141.json @@ -0,0 +1,428 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "book-repository", + "description": "The type Book repository." + } + ], + "paths": { + "/books": { + "get": { + "tags": [ + "book-repository" + ], + "summary": "Find all list.", + "description": "Find all list.", + "operationId": "findAll", + "responses": { + "200": { + "description": "the list", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Book" + } + } + }, + "application/xml": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Book" + } + } + } + } + } + } + } + }, + "/books/{author}": { + "get": { + "tags": [ + "book-repository" + ], + "summary": "Find by author list.", + "description": "Find by author list.", + "operationId": "findByAuthor", + "parameters": [ + { + "name": "author", + "in": "path", + "description": "the author", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "the list", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Book" + } + } + }, + "application/xml": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Book" + } + } + } + } + } + } + } + }, + "/greeter/greeter2/books": { + "get": { + "tags": [ + "book-repository" + ], + "summary": "Find all list.", + "description": "Find all list.", + "operationId": "findAll_1", + "responses": { + "200": { + "description": "the list", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Book" + } + } + }, + "application/xml": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Book" + } + } + }, + "text/plain": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Book" + } + } + } + } + } + } + } + }, + "/greeter/greeter2/books/{author}": { + "get": { + "tags": [ + "book-repository" + ], + "summary": "Find by author list.", + "description": "Find by author list.", + "operationId": "findByAuthor_1", + "parameters": [ + { + "name": "author", + "in": "path", + "description": "the author", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "the list", + "content": { + "*/*": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Book" + } + } + } + } + } + } + } + }, + "/test/greeter/greeter2/books": { + "get": { + "tags": [ + "book-repository" + ], + "summary": "Find all list.", + "description": "Find all list.", + "operationId": "findAll_2", + "responses": { + "200": { + "description": "the list", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Book" + } + } + }, + "application/xml": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Book" + } + } + }, + "text/plain": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Book" + } + } + } + } + } + } + } + }, + "/test/greeter/greeter2/books/{author}": { + "get": { + "tags": [ + "book-repository" + ], + "summary": "Find by author list.", + "description": "Find by author list.", + "operationId": "findByAuthor_2", + "parameters": [ + { + "name": "author", + "in": "path", + "description": "the author", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "the list", + "content": { + "*/*": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Book" + } + } + } + } + } + } + } + }, + "/greeter/books": { + "get": { + "tags": [ + "book-repository" + ], + "summary": "Find all list.", + "description": "Find all list.", + "operationId": "findAll_3", + "responses": { + "200": { + "description": "the list", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Book" + } + } + }, + "application/xml": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Book" + } + } + }, + "text/plain": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Book" + } + } + } + } + } + } + } + }, + "/greeter/books/{author}": { + "get": { + "tags": [ + "book-repository" + ], + "summary": "Find by author list.", + "description": "Find by author list.", + "operationId": "findByAuthor_3", + "parameters": [ + { + "name": "author", + "in": "path", + "description": "the author", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "the list", + "content": { + "*/*": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Book" + } + } + } + } + } + } + } + }, + "/greeter2/books": { + "get": { + "tags": [ + "book-repository" + ], + "summary": "Find all list.", + "description": "Find all list.", + "operationId": "findAll_4", + "responses": { + "200": { + "description": "the list", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Book" + } + } + }, + "application/xml": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Book" + } + } + }, + "text/plain": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Book" + } + } + } + } + } + } + } + }, + "/greeter2/books/{author}": { + "get": { + "tags": [ + "book-repository" + ], + "summary": "Find by author list.", + "description": "Find by author list.", + "operationId": "findByAuthor_4", + "parameters": [ + { + "name": "author", + "in": "path", + "description": "the author", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "the list", + "content": { + "*/*": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Book" + } + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "Book": { + "type": "object", + "properties": { + "id": { + "type": "string", + "description": "The Id." + }, + "title": { + "type": "string", + "description": "The Title." + }, + "author": { + "type": "string", + "description": "The Author." + } + }, + "description": "The type Book." + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app142.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app142.json new file mode 100644 index 000000000..9b3eb4e37 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app142.json @@ -0,0 +1,168 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "greetings-rest-controller", + "description": "The type Greetings rest controller." + }, + { + "name": "person-service", + "description": "The type Person service." + } + ], + "paths": { + "/greet/{name}": { + "get": { + "tags": [ + "greetings-rest-controller" + ], + "summary": "Greet string.", + "description": "Greet string.", + "operationId": "greet", + "parameters": [ + { + "name": "name", + "in": "path", + "description": "the name", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "the string", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/people": { + "get": { + "tags": [ + "person-service" + ], + "summary": "All set.", + "description": "All set.", + "operationId": "all", + "responses": { + "200": { + "description": "the set", + "content": { + "*/*": { + "schema": { + "uniqueItems": true, + "type": "array", + "items": { + "$ref": "#/components/schemas/Person" + } + } + } + } + } + } + }, + "post": { + "tags": [ + "person-service" + ], + "summary": "Save person.", + "description": "Save person.", + "operationId": "save", + "parameters": [ + { + "name": "p", + "in": "query", + "description": "the p", + "required": true, + "schema": { + "$ref": "#/components/schemas/Person" + } + } + ], + "responses": { + "200": { + "description": "the person", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/Person" + } + } + } + } + } + } + }, + "/people/{id}": { + "get": { + "tags": [ + "person-service" + ], + "summary": "By id person.", + "description": "By id person.", + "operationId": "byId", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "the id", + "required": true, + "schema": { + "type": "integer", + "format": "int64" + } + } + ], + "responses": { + "200": { + "description": "the person", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/Person" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "Person": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "description": "The Id.", + "format": "int64" + }, + "name": { + "type": "string", + "description": "The Name." + } + }, + "description": "The type Person." + } + } + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app149.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app149.json new file mode 100644 index 000000000..d66a10160 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app149.json @@ -0,0 +1,106 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "hello-controller", + "description": "To test the case a user does not use @RestController but puts @Operation on handler methods\n and wants these methods to be exposed." + } + ], + "paths": { + "/message": { + "get": { + "tags": [ + "hello-controller" + ], + "summary": "Message hello message.", + "description": "Message hello message.", + "operationId": "message", + "responses": { + "200": { + "description": "the hello message", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/HelloMessage" + } + } + } + } + } + } + }, + "/hello": { + "get": { + "tags": [ + "hello-controller" + ], + "summary": "Hello string.", + "description": "Hello string.", + "operationId": "hello", + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/HelloMessage" + } + } + } + } + } + } + }, + "/helloModelAndView": { + "get": { + "tags": [ + "hello-controller" + ], + "summary": "Hello model and view model and view.", + "description": "Hello model and view model and view.", + "operationId": "helloModelAndView", + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/HelloMessage" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "HelloMessage": { + "type": "object", + "properties": { + "text": { + "type": "string", + "description": "The Text." + }, + "number": { + "type": "integer", + "description": "The Number.", + "format": "int32" + } + }, + "description": "The type Hello message." + } + } + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app15.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app15.json new file mode 100644 index 000000000..79ce6ed95 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app15.json @@ -0,0 +1,47 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "My title", + "description": "My description", + "termsOfService": "My terms", + "contact": { + "email": "My contact email", + "name": "My contact name", + "url": "My contact url" + }, + "license": { + "name": "My license name", + "url": "My license url" + }, + "version": "My version" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "hello-controller", + "description": "The type Hello controller." + } + ], + "paths": { + "/persons": { + "get": { + "tags": [ + "hello-controller" + ], + "description": "My Desc", + "operationId": "persons", + "responses": { + "200": { + "description": "the json object" + } + } + } + } + }, + "components": {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app150.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app150.json new file mode 100644 index 000000000..af4081757 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app150.json @@ -0,0 +1,137 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "hello-controller", + "description": "The type Hello controller." + } + ], + "paths": { + "/test/": { + "get": { + "tags": [ + "hello-controller" + ], + "summary": "Test.", + "description": "Test.", + "operationId": "test", + "parameters": [ + { + "name": "toto", + "in": "query", + "description": "the toto", + "required": false, + "schema": { + "type": "integer", + "format": "int32", + "default": 1 + } + } + ], + "responses": { + "204": { + "description": "No content" + } + } + } + }, + "/test1": { + "get": { + "tags": [ + "hello-controller" + ], + "summary": "Test 1.", + "description": "Test 1.", + "operationId": "test1", + "parameters": [ + { + "name": "toto", + "in": "query", + "description": "the toto", + "required": true, + "schema": { + "type": "boolean", + "default": false + } + } + ], + "responses": { + "204": { + "description": "No content" + } + } + } + }, + "/test3": { + "get": { + "tags": [ + "hello-controller" + ], + "summary": "Test 3.", + "description": "Test 3.", + "operationId": "test3", + "parameters": [ + { + "name": "toto", + "in": "query", + "description": "the toto", + "required": false, + "schema": { + "type": "array", + "items": { + "type": "string" + }, + "default": [ + "users", + "123" + ] + } + } + ], + "responses": { + "204": { + "description": "No content" + } + } + } + }, + "/test4": { + "get": { + "tags": [ + "hello-controller" + ], + "summary": "Test 4.", + "description": "Test 4.", + "operationId": "test4", + "parameters": [ + { + "name": "localDate", + "in": "query", + "description": "the local date", + "required": false, + "schema": { + "type": "string", + "format": "date" + } + } + ], + "responses": { + "204": { + "description": "No content" + } + } + } + } + }, + "components": {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app151.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app151.json new file mode 100644 index 000000000..9bdb7292d --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app151.json @@ -0,0 +1,45 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "hello-controller", + "description": "The type Hello controller." + } + ], + "paths": { + "/test": { + "get": { + "tags": [ + "hello-controller" + ], + "summary": "Test int.", + "description": "Test int.", + "operationId": "test", + "responses": { + "200": { + "description": "the int", + "content": { + "*/*": { + "schema": { + "type": "integer", + "format": "int32" + } + } + } + } + } + } + } + }, + "components": {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app152.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app152.json new file mode 100644 index 000000000..f752800dc --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app152.json @@ -0,0 +1,44 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "hello-controller", + "description": "The type Hello controller." + } + ], + "paths": { + "/api": { + "get": { + "tags": [ + "hello-controller" + ], + "summary": "Hello world string.", + "description": "Hello world string.", + "operationId": "helloWorld", + "responses": { + "200": { + "description": "the string", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + } + }, + "components": {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app153.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app153.json new file mode 100644 index 000000000..55649f6fe --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app153.json @@ -0,0 +1,60 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "test-controller", + "description": "The type Test controller." + } + ], + "paths": { + "/orders": { + "get": { + "tags": [ + "test-controller" + ], + "summary": "Method object.", + "description": "Method object.", + "operationId": "method", + "parameters": [ + { + "name": "state", + "in": "query", + "description": "the order state", + "required": false, + "schema": { + "type": "string", + "default": "finished", + "enum": [ + "finished", + "new" + ] + } + } + ], + "responses": { + "200": { + "description": "the object", + "content": { + "*/*": { + "schema": { + "type": "object" + } + } + } + } + } + } + } + }, + "components": {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app154.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app154.json new file mode 100644 index 000000000..caeb96bf3 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app154.json @@ -0,0 +1,194 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "toto", + "version": "1.0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "security": [ + { + "basicAuth": [] + }, + { + "bearerToken": [] + } + ], + "tags": [ + { + "name": "hello-controller", + "description": "The type Hello controller." + } + ], + "paths": { + "/personsone": { + "post": { + "tags": [ + "hello-controller" + ], + "summary": "Createone.", + "description": "Createone.", + "operationId": "createone", + "parameters": [ + { + "name": "id", + "in": "query", + "description": "the id", + "required": true, + "schema": { + "type": "integer", + "format": "int64" + } + } + ], + "requestBody": { + "description": "the o", + "content": { + "application/json": { + "schema": { + "type": "object" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "OK" + } + } + } + }, + "/persons": { + "post": { + "tags": [ + "hello-controller" + ], + "summary": "Create.", + "description": "Create.", + "operationId": "create", + "parameters": [ + { + "name": "id", + "in": "query", + "description": "the id", + "required": true, + "schema": { + "type": "integer", + "format": "int64" + } + } + ], + "requestBody": { + "description": "the o", + "content": { + "application/json": { + "schema": { + "type": "object" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "OK" + } + } + } + }, + "/createtwo": { + "post": { + "tags": [ + "hello-controller" + ], + "summary": "Createtwo.", + "description": "Createtwo.", + "operationId": "createtwo", + "parameters": [ + { + "name": "id", + "in": "query", + "description": "the id", + "required": true, + "schema": { + "type": "integer", + "format": "int32" + } + } + ], + "responses": { + "200": { + "description": "OK" + } + } + } + }, + "/createthree": { + "post": { + "tags": [ + "hello-controller" + ], + "summary": "Createthree.", + "description": "Createthree.", + "operationId": "createthree", + "parameters": [ + { + "name": "id", + "in": "query", + "description": "the id", + "required": true, + "schema": { + "type": "integer", + "format": "int32" + } + } + ], + "responses": { + "200": { + "description": "OK" + } + } + } + }, + "/": { + "get": { + "tags": [ + "hello-controller" + ], + "summary": "Hello string.", + "description": "Hello string.", + "operationId": "hello", + "responses": { + "200": { + "description": "the string", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + } + }, + "components": { + "securitySchemes": { + "bearerToken": { + "type": "http", + "scheme": "bearer", + "bearerFormat": "JWT" + }, + "basicAuth": { + "type": "http", + "scheme": "basic" + } + } + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app155.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app155.json new file mode 100644 index 000000000..bb98b0a84 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app155.json @@ -0,0 +1,133 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "hello-controller", + "description": "The type Hello controller." + } + ], + "paths": { + "/test1": { + "get": { + "tags": [ + "hello-controller" + ], + "summary": "Say hello response entity.", + "description": "Say hello response entity.", + "operationId": "sayHello_1", + "parameters": [ + { + "name": "primitiveConcreteField", + "in": "query", + "description": "The Primitive concrete field.", + "required": false, + "schema": { + "type": "integer", + "format": "int32" + } + }, + { + "name": "primitiveBaseField", + "in": "query", + "description": "The Primitive base field.", + "required": false, + "schema": { + "type": "integer", + "format": "int32" + } + }, + { + "name": "genericField", + "in": "query", + "description": "The Generic field.", + "required": false, + "schema": { + "type": "string", + "enum": [ + "ONE", + "TWO" + ] + } + } + ], + "responses": { + "200": { + "description": "the response entity", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/test2": { + "get": { + "tags": [ + "hello-controller" + ], + "summary": "Say hello response entity.", + "description": "Say hello response entity.", + "operationId": "sayHello", + "parameters": [ + { + "name": "primitiveConcreteField", + "in": "query", + "description": "The Primitive concrete field.", + "required": false, + "schema": { + "type": "integer", + "format": "int32" + } + }, + { + "name": "primitiveBaseField", + "in": "query", + "description": "The Primitive base field.", + "required": false, + "schema": { + "type": "integer", + "format": "int32" + } + }, + { + "name": "genericField", + "in": "query", + "description": "The Generic field.", + "required": false, + "schema": { + "type": "integer", + "format": "int32" + } + } + ], + "responses": { + "200": { + "description": "the response entity", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + } + }, + "components": {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app156.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app156.json new file mode 100644 index 000000000..f36d91205 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app156.json @@ -0,0 +1,80 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "hello-controller", + "description": "The type Hello controller." + } + ], + "paths": { + "/hello": { + "get": { + "tags": [ + "hello-controller" + ], + "summary": "Hello string.", + "description": "Hello string.", + "operationId": "hello", + "parameters": [ + { + "name": "someEnums", + "in": "query", + "description": "SomeEum decs", + "schema": { + "type": "array", + "items": { + "type": "string", + "enum": [ + "FIRST", + "SECOND" + ] + } + } + }, + { + "name": "textSet", + "in": "query", + "description": "First decs", + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + }, + { + "name": "someText", + "in": "query", + "description": "Second decs", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "the string", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + } + }, + "components": {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app157.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app157.json new file mode 100644 index 000000000..cf4bea57e --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app157.json @@ -0,0 +1,70 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "API Examples", + "version": "1.0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "Operations" + } + ], + "paths": { + "/api/foo": { + "get": { + "tags": [ + "hello-controller" + ], + "operationId": "hello", + "responses": { + "409": { + "description": "Conflict", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/ErrorDTO" + } + } + } + }, + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/SimpleDTO" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "ErrorDTO": { + "type": "object", + "properties": { + "message": { + "type": "string" + } + } + }, + "SimpleDTO": { + "type": "object", + "properties": { + "payload": { + "type": "string" + } + } + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app158.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app158.json new file mode 100644 index 000000000..add523316 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app158.json @@ -0,0 +1,80 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "API Examples", + "version": "1.0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "Operations" + }, + { + "name": "hello-controller", + "description": "The type Hello controller." + } + ], + "paths": { + "/api/foo": { + "get": { + "tags": [ + "hello-controller" + ], + "summary": "Hello simple dto.", + "description": "Hello simple dto.", + "operationId": "hello", + "responses": { + "200": { + "description": "the simple dto", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/SimpleDTO" + } + } + } + }, + "409": { + "description": "the error dto", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/ErrorDTO" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "ErrorDTO": { + "type": "object", + "properties": { + "message": { + "type": "string", + "description": "The Message." + } + }, + "description": "The type Error dto." + }, + "SimpleDTO": { + "type": "object", + "properties": { + "payload": { + "type": "string", + "description": "The Payload." + } + }, + "description": "The type Simple dto." + } + } + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app159.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app159.json new file mode 100644 index 000000000..f8505d1d4 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app159.json @@ -0,0 +1,107 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "API Examples", + "version": "1.0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "Operations" + }, + { + "name": "hello-controller", + "description": "The type Hello controller." + } + ], + "paths": { + "/api/foo": { + "post": { + "tags": [ + "hello-controller" + ], + "summary": "Create string.", + "description": "Create string.", + "operationId": "create", + "requestBody": { + "description": "the foo", + "content": { + "application/json": { + "schema": { + "type": "string" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "the string", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + }, + "400": { + "description": "the response entity", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/FooBean_View2" + } + } + } + }, + "500": { + "description": "the response entity", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/FooBean_View1" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "FooBean_View1": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "description": "The Code.", + "format": "int32" + } + }, + "description": "The type Foo bean." + }, + "FooBean_View2": { + "type": "object", + "properties": { + "code": { + "type": "integer", + "description": "The Code.", + "format": "int32" + }, + "message": { + "type": "string", + "description": "The Message." + } + }, + "description": "The type Foo bean." + } + } + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app160.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app160.json new file mode 100644 index 000000000..e15cd7999 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app160.json @@ -0,0 +1,65 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "hello-controller", + "description": "The type Hello controller." + } + ], + "paths": { + "/test": { + "post": { + "tags": [ + "hello-controller" + ], + "summary": "Do something interesting error response.", + "description": "Do something interesting error response.", + "operationId": "doSomethingInteresting", + "responses": { + "200": { + "description": "the error response", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "ErrorResponse": { + "required": [ + "errorCode" + ], + "type": "object", + "properties": { + "errorCode": { + "type": "integer", + "description": "titi", + "format": "int32" + }, + "errorMessage": { + "type": "string", + "description": "tata" + } + }, + "description": "toto" + } + } + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app161.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app161.json new file mode 100644 index 000000000..169dd28af --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app161.json @@ -0,0 +1,132 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "hello-controller", + "description": "The type Hello controller." + } + ], + "paths": { + "/add": { + "post": { + "tags": [ + "hello-controller" + ], + "summary": "add", + "description": "Add response entity.", + "operationId": "add", + "requestBody": { + "content": { + "multipart/form-data": { + "schema": { + "required": [ + "content" + ], + "type": "object", + "properties": { + "content": { + "type": "string", + "description": "content" + } + } + } + } + } + }, + "responses": { + "200": { + "description": "the response entity" + } + } + } + }, + "/add2": { + "post": { + "tags": [ + "hello-controller" + ], + "summary": "add2", + "description": "Add 2 response entity.", + "operationId": "add2", + "requestBody": { + "content": { + "multipart/form-data": { + "schema": { + "required": [ + "content", + "type" + ], + "type": "object", + "properties": { + "content": { + "type": "string", + "description": "content" + }, + "type": { + "type": "string", + "description": "the type" + } + } + } + } + } + }, + "responses": { + "200": { + "description": "the response entity" + } + } + } + }, + "/": { + "post": { + "tags": [ + "hello-controller" + ], + "summary": "test", + "description": "Test.", + "operationId": "test", + "requestBody": { + "content": { + "multipart/form-data": { + "schema": { + "required": [ + "intValue", + "strValue" + ], + "type": "object", + "properties": { + "strValue": { + "type": "string", + "description": "the str value" + }, + "intValue": { + "type": "integer", + "description": "the int value", + "format": "int32" + } + } + } + } + } + }, + "responses": { + "200": { + "description": "OK" + } + } + } + } + }, + "components": {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app162.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app162.json new file mode 100644 index 000000000..9df83bcf3 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app162.json @@ -0,0 +1,343 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "SpringShop API", + "description": "The description of the api", + "version": "v1" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "javadoc-only-rest-controller", + "description": "This is the JavadocOnlyRestController class javadoc." + } + ], + "paths": { + "/javadoc-only/{guid}": { + "get": { + "tags": [ + "javadoc-only-rest-controller" + ], + "summary": "This is the find method's javadoc.", + "description": "This is the find method's javadoc.\n The method's signature: #find(String)", + "operationId": "find", + "parameters": [ + { + "name": "guid", + "in": "path", + "description": "the @param guid javadoc for the #find(String) method", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "404": { + "description": "the @throws NoResultException javadoc for the #find(String) method", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + }, + "x-exception-class": [ + "test.org.springdoc.api.v31.app162.exception.NoResultException" + ] + }, + "400": { + "description": "the return javadoc for the #handleNonUniqueResultException(NonUniqueResultException) method", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + }, + "x-exception-class": [ + "test.org.springdoc.api.v31.app162.exception.NonUniqueResultException" + ] + }, + "200": { + "description": "the @return javadoc for the #find(String) method", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/JavadocOnlyRestDto" + } + } + } + } + } + }, + "put": { + "tags": [ + "javadoc-only-rest-controller" + ], + "summary": "This is the update method's javadoc.", + "description": "This is the update method's javadoc.\n The method's signature: #update(String, JavadocOnlyRestDto)", + "operationId": "update", + "parameters": [ + { + "name": "guid", + "in": "path", + "description": "the @param input javadoc for the #update(String, JavadocOnlyRestDto) method", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/JavadocOnlyRestDto" + } + } + }, + "required": true + }, + "responses": { + "404": { + "description": "the return javadoc for the #handleNotFoundException(NoResultException) method", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + }, + "x-exception-class": [ + "test.org.springdoc.api.v31.app162.exception.NoResultException" + ] + }, + "400": { + "description": "the return javadoc for the #handleNonUniqueResultException(NonUniqueResultException) method", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + }, + "x-exception-class": [ + "test.org.springdoc.api.v31.app162.exception.NonUniqueResultException" + ] + }, + "200": { + "description": "the @return javadoc for the #update(String, JavadocOnlyRestDto) method", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/JavadocOnlyRestDto" + } + } + } + } + } + } + }, + "/javadoc-only": { + "get": { + "tags": [ + "javadoc-only-rest-controller" + ], + "summary": "This is the list method's javadoc.", + "description": "This is the list method's javadoc.\n The method's signature: #list()", + "operationId": "list", + "responses": { + "404": { + "description": "the return javadoc for the #handleNotFoundException(NoResultException) method", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + }, + "x-exception-class": [ + "test.org.springdoc.api.v31.app162.exception.NoResultException" + ] + }, + "400": { + "description": "the return javadoc for the #handleNonUniqueResultException(NonUniqueResultException) method", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + }, + "x-exception-class": [ + "test.org.springdoc.api.v31.app162.exception.NonUniqueResultException" + ] + }, + "200": { + "description": "the @return javadoc for the #list() method", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/JavadocOnlyRestDto" + } + } + } + } + } + } + }, + "post": { + "tags": [ + "javadoc-only-rest-controller" + ], + "summary": "This is the create method's javadoc.", + "description": "This is the create method's javadoc.\n The method's signature: #create(JavadocOnlyRestDto)", + "operationId": "create", + "requestBody": { + "description": "the @param input javadoc for the #create(JavadocOnlyRestDto) method", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/JavadocOnlyRestDto" + } + } + }, + "required": true + }, + "responses": { + "404": { + "description": "the return javadoc for the #handleNotFoundException(NoResultException) method", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + }, + "x-exception-class": [ + "test.org.springdoc.api.v31.app162.exception.NoResultException" + ] + }, + "400": { + "description": "the return javadoc for the #handleNonUniqueResultException(NonUniqueResultException) method", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + }, + "x-exception-class": [ + "test.org.springdoc.api.v31.app162.exception.NonUniqueResultException" + ] + }, + "201": { + "description": "the @return javadoc for the #create(JavadocOnlyRestDto) method", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/JavadocOnlyRestDto" + } + } + } + } + } + } + }, + "/javadoc-only/startsBy/{prefix}": { + "get": { + "tags": [ + "javadoc-only-rest-controller" + ], + "summary": "This is the findStartsBy method's javadoc.", + "description": "This is the findStartsBy method's javadoc.\n The method's signature: #findStartsBy(String)", + "operationId": "findStartsBy", + "parameters": [ + { + "name": "prefix", + "in": "path", + "description": "the @param prefix javadoc for the #findStartsBy(String) method", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "404": { + "description": "the @throws NoResultException javadoc for the #findStartsBy(String) method", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + }, + "x-exception-class": [ + "test.org.springdoc.api.v31.app162.exception.NoResultException" + ] + }, + "400": { + "description": "the @throws NonUniqueResultException javadoc for the #findStartsBy(String) method", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + }, + "x-exception-class": [ + "test.org.springdoc.api.v31.app162.exception.NonUniqueResultException" + ] + }, + "200": { + "description": "the @return javadoc for the #findStartsBy(String) method", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/JavadocOnlyRestDto" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "JavadocOnlyRestDto": { + "type": "object", + "description": "This is the JavadocOnlyRestDto class javadoc.", + "properties": { + "guid": { + "type": "string", + "description": "This is the private #guid field's javadoc." + }, + "inner": { + "$ref": "#/components/schemas/JavadocOnlyStaticInnerRestDto", + "description": "This is the private #inner field's javadoc.\n\n This javadoc description is ignored by the REST documentation:\n the $ref can't have a description as any sibling elements of a $ref are ignored." + } + } + }, + "JavadocOnlyStaticInnerRestDto": { + "type": "object", + "description": "This is the JavadocOnlyStaticInnerRestDto class javadoc.", + "properties": { + "content": { + "type": "string", + "description": "This is the private #content field's javadoc." + } + } + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app163.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app163.json new file mode 100644 index 000000000..dd3c086cc --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app163.json @@ -0,0 +1,228 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "SpringShop API", + "description": "The description of the api", + "version": "v1" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "annotation-override", + "description": "Description for the tag." + } + ], + "paths": { + "/annotation-override/{guid}": { + "put": { + "tags": [ + "annotation-override" + ], + "summary": "Summary for #update(String, AnnotationOverrideForJavadocRestDto)", + "description": "This is the update method's javadoc.\n The method's signature: #update(String, AnnotationOverrideForJavadocRestDto)", + "operationId": "update", + "parameters": [ + { + "name": "guid", + "in": "path", + "description": "the @param input javadoc for the #update(String, AnnotationOverrideForJavadocRestDto) method", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/AnnotationOverrideForJavadocRestDto" + } + } + }, + "required": true + }, + "responses": { + "404": { + "description": "the return javadoc for the #handleNotFoundException(NoResultException) method", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + }, + "x-exception-class": [ + "test.org.springdoc.api.v31.app163.exception.NoResultException" + ] + }, + "400": { + "description": "the return javadoc for the #handleNonUniqueResultException(NonUniqueResultException) method", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + }, + "x-exception-class": [ + "test.org.springdoc.api.v31.app163.exception.NonUniqueResultException" + ] + }, + "200": { + "description": "the @return javadoc for the #update(String, AnnotationOverrideForJavadocRestDto) method", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/AnnotationOverrideForJavadocRestDto" + } + } + } + } + } + } + }, + "/annotation-override": { + "post": { + "tags": [ + "annotation-override" + ], + "summary": "Summary for #create(AnnotationOverrideForJavadocRestDto)", + "description": "Description for #create(AnnotationOverrideForJavadocRestDto)", + "operationId": "create", + "requestBody": { + "description": "Request body for #create(AnnotationOverrideForJavadocRestDto)", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/AnnotationOverrideForJavadocRestDto" + } + } + }, + "required": true + }, + "responses": { + "404": { + "description": "the return javadoc for the #handleNotFoundException(NoResultException) method", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + }, + "x-exception-class": [ + "test.org.springdoc.api.v31.app163.exception.NoResultException" + ] + }, + "400": { + "description": "the return javadoc for the #handleNonUniqueResultException(NonUniqueResultException) method", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + }, + "x-exception-class": [ + "test.org.springdoc.api.v31.app163.exception.NonUniqueResultException" + ] + }, + "default": { + "description": "API Response 201 for #create(AnnotationOverrideForJavadocRestDto)", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/AnnotationOverrideForJavadocRestDto" + } + } + } + } + } + } + }, + "/annotation-override/startsBy/{prefix}": { + "get": { + "tags": [ + "annotation-override" + ], + "summary": "This is the findStartsBy method's javadoc.", + "description": "This is the findStartsBy method's javadoc.\n The method's signature: #findStartsBy(String)", + "operationId": "findStartsBy", + "parameters": [ + { + "name": "prefix", + "in": "path", + "description": "Parameter prefix", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "404": { + "description": "the @throws NoResultException javadoc for the #findStartsBy(String) method", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + }, + "x-exception-class": [ + "test.org.springdoc.api.v31.app163.exception.NoResultException" + ] + }, + "400": { + "description": "API Response 400 for #findStartsBy(prefix)" + }, + "200": { + "description": "API Response 200 for #findStartsBy(prefix)", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/AnnotationOverrideForJavadocRestDto" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "AnnotationOverrideForJavadocRestDto": { + "type": "object", + "description": "Description for the tag.", + "properties": { + "guid": { + "type": "string", + "description": "Description for the #guid field" + }, + "inner": { + "$ref": "#/components/schemas/AnnotationOverrideForJavadocStaticInnerRestDto", + "description": "This is the private #inner field's javadoc.\n

\n This javadoc description is ignored by the REST documentation:\n the $ref can't have a description as any sibling elements of a $ref are ignored." + } + }, + "title": "annotation-override-dto" + }, + "AnnotationOverrideForJavadocStaticInnerRestDto": { + "type": "object", + "description": "This is the AnnotationOverrideForJavadocStaticInnerRestDto class javadoc.", + "properties": { + "content": { + "type": "string", + "description": "This is the private #content field's javadoc." + } + } + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app164.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app164.json new file mode 100644 index 000000000..f4030bb2a --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app164.json @@ -0,0 +1,129 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "SpringShop API", + "description": "The description of the api", + "version": "v1" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "no-generic-override-rest-controller", + "description": "This is the JavadocOnlyRestController class javadoc." + } + ], + "paths": { + "/no-generic-override": { + "post": { + "tags": [ + "no-generic-override-rest-controller" + ], + "summary": "This is the create method's javadoc.", + "description": "This is the create method's javadoc.\n The method's signature: #create(JavadocOnlyRestDto)", + "operationId": "create", + "requestBody": { + "description": "the @param input javadoc for the #create(JavadocOnlyRestDto) method", + "content": { + "application/json": { + "schema": { + "type": "string" + } + } + }, + "required": true + }, + "responses": { + "404": { + "description": "the return javadoc for the #handleNotFoundException(NoResultException) method", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + }, + "400": { + "description": "the return javadoc for the #handleNonUniqueResultException(NonUniqueResultException) method", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + }, + "201": { + "description": "the @return javadoc for the #create(JavadocOnlyRestDto) method", + "content": { + "application/json": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/no-generic-override/startsBy/{prefix}": { + "get": { + "tags": [ + "no-generic-override-rest-controller" + ], + "summary": "This is the findStartsBy method's javadoc.", + "description": "This is the findStartsBy method's javadoc.\n The method's signature: #findStartsBy(String)", + "operationId": "findStartsBy", + "parameters": [ + { + "name": "prefix", + "in": "path", + "description": "the @param prefix javadoc for the #findStartsBy(String) method", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "404": { + "description": "the return javadoc for the #handleNotFoundException(NoResultException) method", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + }, + "400": { + "description": "the return javadoc for the #handleNonUniqueResultException(NonUniqueResultException) method", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + }, + "200": { + "description": "the @return javadoc for the #findStartsBy(String) method", + "content": { + "application/json": { + "schema": { + "type": "string" + } + } + } + } + } + } + } + }, + "components": {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app166.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app166.json new file mode 100644 index 000000000..d0b75a178 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app166.json @@ -0,0 +1,175 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/nested": { + "get": { + "tags": [ + "hello-controller" + ], + "operationId": "nested", + "parameters": [ + { + "name": "name", + "in": "query", + "description": "Returns the name of the outer class", + "required": false, + "schema": { + "type": "string" + } + }, + { + "name": "innerClass.innerInnerClass.name", + "in": "query", + "description": "Returns the name of the inner inner class", + "required": false, + "schema": { + "type": "boolean" + } + }, + { + "name": "innerClass.innerInnerClass.maxNumber", + "in": "query", + "description": "Returns the maxNumber of the inner inner class", + "required": false, + "schema": { + "type": "integer", + "format": "int32" + } + }, + { + "name": "innerClass.name", + "in": "query", + "description": "Returns the boolean name", + "required": false, + "schema": { + "type": "boolean" + } + }, + { + "name": "innerClass.maxNumber", + "in": "query", + "description": "Returns the max number", + "required": false, + "schema": { + "type": "integer", + "format": "int32" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/nestedTypeErasureGeneric": { + "get": { + "tags": [ + "hello-controller" + ], + "operationId": "nestedTypeErasureGeneric", + "parameters": [ + { + "name": "name", + "in": "query", + "description": "Returns name", + "required": false, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/nestedReifiableGeneric": { + "get": { + "tags": [ + "hello-controller" + ], + "operationId": "nestedReifiableGeneric", + "parameters": [ + { + "name": "topName", + "in": "query", + "description": "Return the top name", + "required": false, + "schema": { + "type": "string" + } + }, + { + "name": "name", + "in": "query", + "description": "Returns name", + "required": false, + "schema": { + "type": "string" + } + }, + { + "name": "child.firstName", + "in": "query", + "description": "Returns the first name", + "required": false, + "schema": { + "type": "string" + } + }, + { + "name": "child.maxNumber", + "in": "query", + "description": "Returns the max number", + "required": false, + "schema": { + "type": "integer", + "format": "int32" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + } + }, + "components": {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app167.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app167.json new file mode 100644 index 000000000..434414a9c --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app167.json @@ -0,0 +1,101 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "hello-controller", + "description": "The type Hello controller." + } + ], + "paths": { + "/process": { + "get": { + "tags": [ + "hello-controller" + ], + "operationId": "process", + "responses": { + "200": { + "description": "OK" + } + } + }, + "put": { + "tags": [ + "hello-controller" + ], + "operationId": "process_2", + "responses": { + "200": { + "description": "OK" + } + } + }, + "post": { + "tags": [ + "hello-controller" + ], + "operationId": "process_1", + "responses": { + "200": { + "description": "OK" + } + } + }, + "delete": { + "tags": [ + "hello-controller" + ], + "operationId": "process_3", + "responses": { + "200": { + "description": "OK" + } + } + }, + "options": { + "tags": [ + "hello-controller" + ], + "operationId": "process_6", + "responses": { + "200": { + "description": "OK" + } + } + }, + "head": { + "tags": [ + "hello-controller" + ], + "operationId": "process_5", + "responses": { + "200": { + "description": "OK" + } + } + }, + "patch": { + "tags": [ + "hello-controller" + ], + "operationId": "process_4", + "responses": { + "200": { + "description": "OK" + } + } + } + } + }, + "components": {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app168.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app168.json new file mode 100644 index 000000000..34d5caa2a --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app168.json @@ -0,0 +1,63 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "description-field-in-request-body-is-null-controller", + "description": "If the RequestBody description field is null, get the description from the javadoc." + } + ], + "paths": { + "/description-in-requestbody-is-null": { + "post": { + "tags": [ + "description-field-in-request-body-is-null-controller" + ], + "operationId": "person", + "summary": "Person person.", + "description": "Person person.", + "operationId": "person", + "requestBody": { + "description": "the person", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Person" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "OK" + } + } + } + } + }, + "components": { + "schemas": { + "Person": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "description": "The Id.", + "format": "int64" + } + }, + "description": "The type Person." + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app169.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app169.json new file mode 100644 index 000000000..2e8475681 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app169.json @@ -0,0 +1,98 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/record": { + "get": { + "tags": [ + "record-controller" + ], + "operationId": "index", + "parameters": [ + { + "name": "name", + "in": "query", + "description": "the name of the outer class", + "required": false, + "schema": { + "type": "string" + } + }, + { + "name": "simpleInnerClass.name", + "in": "query", + "description": "the boolean name", + "required": false, + "schema": { + "type": "boolean" + } + }, + { + "name": "simpleInnerClass.maxNumber", + "in": "query", + "description": "the max number", + "required": false, + "schema": { + "type": "integer", + "format": "int32" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/SimpleOuterClass" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "SimpleInnerClass": { + "type": "object", + "description": "simple inner class", + "properties": { + "maxNumber": { + "type": "integer", + "format": "int32", + "description": "the max number" + }, + "name": { + "type": "boolean", + "description": "the boolean name" + } + } + }, + "SimpleOuterClass": { + "type": "object", + "description": "simple outer class", + "properties": { + "name": { + "type": "string", + "description": "the name of the outer class" + }, + "simpleInnerClass": { + "$ref": "#/components/schemas/SimpleInnerClass", + "description": "the inner class" + } + } + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app17.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app17.json new file mode 100644 index 000000000..90b470867 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app17.json @@ -0,0 +1,50 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "hello-controller", + "description": "The type Hello controller." + } + ], + "paths": { + "/persons": { + "get": { + "tags": [ + "hello-controller" + ], + "summary": "Persons.", + "description": "Persons.", + "operationId": "persons", + "parameters": [ + { + "name": "name", + "in": "query", + "description": "the name", + "required": true, + "schema": { + "maxLength": 6, + "minLength": 4, + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK" + } + } + } + } + }, + "components": {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app170.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app170.json new file mode 100644 index 000000000..f95d8ba43 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app170.json @@ -0,0 +1,88 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/test1": { + "get": { + "tags": [ + "basic-controller" + ], + "summary": "get1", + "description": "Provides an animal.", + "operationId": "get1", + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "oneOf": [ + { + "$ref": "#/components/schemas/Cat" + }, + { + "$ref": "#/components/schemas/Dog" + } + ] + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "Animal": { + "type": "object", + "description": "Represents an Animal class." + }, + "Cat": { + "allOf": [ + { + "$ref": "#/components/schemas/Animal" + }, + { + "type": "object", + "properties": { + "speed": { + "type": "integer", + "format": "int32" + } + } + } + ] + }, + "Dog": { + "allOf": [ + { + "$ref": "#/components/schemas/Animal" + }, + { + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "age": { + "type": "integer", + "format": "int32" + } + } + } + ], + "description": "Represents a Dog class." + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app171.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app171.json new file mode 100644 index 000000000..f862b1ea4 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app171.json @@ -0,0 +1,65 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "hello-controller", + "description": "The type Hello controller." + } + ], + "paths": { + "/persons": { + "get": { + "tags": [ + "hello-controller" + ], + "summary": "PersonProjection interface.", + "description": "PersonProjection interface.", + "operationId": "persons", + "responses": { + "200": { + "description": "the PersonProjection", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/PersonProjection" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "PersonProjection" : { + "type" : "object", + "properties" : { + "email" : { + "type" : "string", + "description" : "The Email." + }, + "firstName" : { + "type" : "string", + "description" : "The First name." + }, + "lastName" : { + "type" : "string", + "description" : "The Last name." + } + }, + "description" : "The type PersonProjection dto interface." + } + } + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app173.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app173.json new file mode 100644 index 000000000..c6c1539cc --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app173.json @@ -0,0 +1,132 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "example-controller", + "description": "The Example Controller" + } + ], + "paths": { + "/example": { + "put": { + "tags": [ + "example-controller" + ], + "summary": "update example", + "description": "Allows to update an example", + "operationId": "putExample", + "requestBody": { + "description": "Default description for example", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Example" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "string", + "format": "uuid" + } + } + } + } + } + }, + "post": { + "tags": [ + "example-controller" + ], + "summary": "insert example", + "description": "Allows to insert an example", + "operationId": "postExample", + "requestBody": { + "description": "The example object", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Example" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "string", + "format": "uuid" + } + } + } + } + } + }, + "patch": { + "tags": [ + "example-controller" + ], + "summary": "patch example", + "description": "Allows to patch an example", + "operationId": "patchExample", + "requestBody": { + "description": "Description without the use of variables", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Example" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "string", + "format": "uuid" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "Example": { + "type": "object", + "properties": { + "name": { + "type": "string" + } + }, + "description": "The Example object" + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app174.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app174.json new file mode 100644 index 000000000..b15e95920 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app174.json @@ -0,0 +1,120 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "example-controller", + "description": "The Example Controller" + } + ], + "paths": { + "/": { + "post": { + "tags": [ + "example-controller" + ], + "operationId": "post", + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/Test" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "Question": { + "type": "object", + "description": "The type Question.", + "discriminator": { + "propertyName": "type" + }, + "properties": { + "question": { + "type": "string" + }, + "type": { + "type": "string" + } + } + }, + "Test": { + "type": "object", + "description": "The type Test.", + "properties": { + "questions": { + "type": "array", + "items": { + "oneOf": [ + { + "$ref": "#/components/schemas/TestQuestion" + }, + { + "$ref": "#/components/schemas/TextQuestion" + } + ] + } + } + } + }, + "TestQuestion": { + "allOf": [ + { + "$ref": "#/components/schemas/Question" + }, + { + "type": "object", + "properties": { + "variants": { + "type": "array", + "description": "list of variants", + "items": { + "type": "string" + } + }, + "answer": { + "type": "integer", + "format": "int32", + "description": "correct answer" + } + } + } + ], + "description": "The type Test question." + }, + "TextQuestion": { + "allOf": [ + { + "$ref": "#/components/schemas/Question" + }, + { + "type": "object", + "properties": { + "answer": { + "type": "string" + } + } + } + ], + "description": "The type Text question." + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app18.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app18.json new file mode 100644 index 000000000..af987cb87 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app18.json @@ -0,0 +1,224 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "hello-controller", + "description": "The type Hello controller." + } + ], + "paths": { + "/persons": { + "get": { + "tags": [ + "hello-controller" + ], + "summary": "Persons string.", + "description": "Persons string.", + "operationId": "persons", + "parameters": [ + { + "name": "name", + "in": "query", + "description": "the name", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "the string", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/persons6": { + "get": { + "tags": [ + "hello-controller" + ], + "summary": "Persons 6 string.", + "description": "Persons 6 string.", + "operationId": "persons6", + "parameters": [ + { + "name": "name", + "in": "query", + "description": "persons name", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "the string", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/persons5": { + "get": { + "tags": [ + "hello-controller" + ], + "summary": "Persons 5 string.", + "description": "Persons 5 string.", + "operationId": "persons5", + "parameters": [ + { + "name": "age", + "in": "query", + "description": "the age", + "required": true, + "schema": { + "maximum": 0, + "type": "integer", + "format": "int32" + } + } + ], + "responses": { + "200": { + "description": "the string", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/persons4": { + "get": { + "tags": [ + "hello-controller" + ], + "summary": "Persons 4 string.", + "description": "Persons 4 string.", + "operationId": "persons4", + "parameters": [ + { + "name": "age", + "in": "query", + "description": "the age", + "required": true, + "schema": { + "minimum": 0, + "type": "integer", + "format": "int32" + } + } + ], + "responses": { + "200": { + "description": "the string", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/persons3": { + "get": { + "tags": [ + "hello-controller" + ], + "summary": "Persons 3 string.", + "description": "Persons 3 string.", + "operationId": "persons3", + "parameters": [ + { + "name": "name", + "in": "query", + "description": "persons name", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "the string", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/persons2": { + "get": { + "tags": [ + "hello-controller" + ], + "summary": "Persons 2 string.", + "description": "Persons 2 string.", + "operationId": "persons2", + "parameters": [ + { + "name": "name", + "in": "query", + "description": "persons name", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "the string", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + } + }, + "components": {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app19.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app19.json new file mode 100644 index 000000000..615738628 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app19.json @@ -0,0 +1,119 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "hello-controller", + "description": "The type Hello controller." + } + ], + "paths": { + "/persons": { + "post": { + "tags": [ + "hello-controller" + ], + "summary": "Persons string.", + "description": "Persons string.", + "operationId": "persons", + "requestBody": { + "description": "requestBody description as parameter", + "content": { + "application/json": { + "schema": { + "type": "string" + } + } + } + }, + "responses": { + "200": { + "description": "the string", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/persons3": { + "post": { + "tags": [ + "hello-controller" + ], + "summary": "Persons 3 string.", + "description": "Persons 3 string.", + "operationId": "persons3", + "requestBody": { + "description": "requestBody inside operation annotation", + "content": { + "application/json": { + "schema": { + "type": "string" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "the string", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/persons2": { + "post": { + "tags": [ + "hello-controller" + ], + "summary": "Persons 2 string.", + "description": "Persons 2 string.", + "operationId": "persons2", + "requestBody": { + "description": "requestBody description outside", + "content": { + "application/json": { + "schema": { + "type": "string" + } + } + } + }, + "responses": { + "200": { + "description": "the string", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + } + }, + "components": {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app2.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app2.json new file mode 100644 index 000000000..efe180514 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app2.json @@ -0,0 +1,1305 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "Petstore API", + "description": "This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.", + "termsOfService": "http://swagger.io/terms/", + "license": { + "name": "Apache 2.0", + "url": "http://springdoc.org" + }, + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "user", + "description": "the user API" + }, + { + "name": "pet", + "description": "the pet API" + }, + { + "name": "store", + "description": "the store API" + } + ], + "paths": { + "/user/{username}": { + "get": { + "tags": [ + "user" + ], + "summary": "Get user by user name", + "description": "Gets user by name.", + "operationId": "getUserByName", + "parameters": [ + { + "name": "username", + "in": "path", + "description": "The name that needs to be fetched. Use user1 for testing.", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "400": { + "description": "Invalid username supplied", + "content": { + "*/*": { + "schema": { + "type": "object", + "additionalProperties": { + "type": "object" + } + } + } + } + }, + "200": { + "description": "successful operation", + "content": { + "application/xml": { + "schema": { + "$ref": "#/components/schemas/User" + } + }, + "application/json": { + "schema": { + "$ref": "#/components/schemas/User" + } + } + } + }, + "404": { + "description": "User not found", + "content": { + "application/xml": { + "schema": { + "$ref": "#/components/schemas/User" + } + }, + "application/json": { + "schema": { + "$ref": "#/components/schemas/User" + } + } + } + } + } + }, + "put": { + "tags": [ + "user" + ], + "summary": "Updated user", + "description": "Update user response entity.", + "operationId": "updateUser", + "parameters": [ + { + "name": "username", + "in": "path", + "description": "name that need to be deleted", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "description": "Updated user object", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/User" + } + } + }, + "required": true + }, + "responses": { + "400": { + "description": "Invalid user supplied", + "content": { + "*/*": { + "schema": { + "type": "object", + "additionalProperties": { + "type": "object" + } + } + } + } + }, + "404": { + "description": "User not found" + } + } + }, + "delete": { + "tags": [ + "user" + ], + "summary": "Creates list of users with given input array", + "description": "Delete user response entity.", + "operationId": "deleteUser", + "parameters": [ + { + "name": "username", + "in": "path", + "description": "the username", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "400": { + "description": "the map", + "content": { + "*/*": { + "schema": { + "type": "object", + "additionalProperties": { + "type": "object" + } + } + } + } + }, + "200": { + "description": "successful operation" + } + } + } + }, + "/pet": { + "put": { + "tags": [ + "pet" + ], + "summary": "Update an existing pet", + "description": "Update pet response entity.", + "operationId": "updatePet", + "requestBody": { + "description": "Pet object that needs to be added to the store", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Pet" + } + }, + "application/xml": { + "schema": { + "$ref": "#/components/schemas/Pet" + } + } + }, + "required": true + }, + "responses": { + "400": { + "description": "Invalid ID supplied", + "content": { + "*/*": { + "schema": { + "type": "object", + "additionalProperties": { + "type": "object" + } + } + } + } + }, + "404": { + "description": "Pet not found" + }, + "405": { + "description": "Validation exception" + } + }, + "security": [ + { + "petstore_auth": [ + "write:pets", + "read:pets" + ] + } + ] + }, + "post": { + "tags": [ + "pet" + ], + "summary": "Add a new pet to the store", + "description": "Add pet.", + "operationId": "addPet", + "requestBody": { + "description": "Pet object that needs to be added to the store", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Pet" + } + }, + "application/xml": { + "schema": { + "$ref": "#/components/schemas/Pet" + } + } + }, + "required": true + }, + "responses": { + "400": { + "description": "the map", + "content": { + "*/*": { + "schema": { + "type": "object", + "additionalProperties": { + "type": "object" + } + } + } + } + }, + "405": { + "description": "Invalid input" + } + }, + "security": [ + { + "petstore_auth": [ + "write:pets", + "read:pets" + ] + } + ] + } + }, + "/user": { + "post": { + "tags": [ + "user" + ], + "summary": "Create user", + "description": "Create user response entity.", + "operationId": "createUser", + "requestBody": { + "description": "Created user object", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/User" + } + } + }, + "required": true + }, + "responses": { + "400": { + "description": "the map", + "content": { + "*/*": { + "schema": { + "type": "object", + "additionalProperties": { + "type": "object" + } + } + } + } + }, + "200": { + "description": "successful operation" + } + } + } + }, + "/user/createWithList": { + "post": { + "tags": [ + "user" + ], + "summary": "Creates list of users with given input array", + "description": "Create users with list input response entity.", + "operationId": "createUsersWithListInput", + "requestBody": { + "description": "List of user object", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/User" + } + } + } + }, + "required": true + }, + "responses": { + "400": { + "description": "the map", + "content": { + "*/*": { + "schema": { + "type": "object", + "additionalProperties": { + "type": "object" + } + } + } + } + }, + "200": { + "description": "successful operation" + } + } + } + }, + "/user/createWithArray": { + "post": { + "tags": [ + "user" + ], + "summary": "Creates list of users with given input array", + "description": "Create users with array input response entity.", + "operationId": "createUsersWithArrayInput", + "requestBody": { + "description": "List of user object", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/User" + } + } + } + }, + "required": true + }, + "responses": { + "400": { + "description": "the map", + "content": { + "*/*": { + "schema": { + "type": "object", + "additionalProperties": { + "type": "object" + } + } + } + } + }, + "200": { + "description": "successful operation" + } + } + } + }, + "/store/order": { + "post": { + "tags": [ + "store" + ], + "summary": "Place an order for a pet", + "description": "Place order response entity.", + "operationId": "placeOrder", + "requestBody": { + "description": "the order", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Order" + } + } + }, + "required": true + }, + "responses": { + "400": { + "description": "Invalid Order", + "content": { + "*/*": { + "schema": { + "type": "object", + "additionalProperties": { + "type": "object" + } + } + } + } + }, + "200": { + "description": "successful operation", + "content": { + "application/xml": { + "schema": { + "$ref": "#/components/schemas/Order" + } + }, + "application/json": { + "schema": { + "$ref": "#/components/schemas/Order" + } + } + } + } + } + } + }, + "/pet/{petId}": { + "get": { + "tags": [ + "pet" + ], + "summary": "Find pet by ID", + "description": "Returns a single pet", + "operationId": "getPetById", + "parameters": [ + { + "name": "petId", + "in": "path", + "description": "ID of pet to return", + "required": true, + "schema": { + "type": "integer", + "format": "int64" + } + } + ], + "responses": { + "400": { + "description": "Invalid ID supplied", + "content": { + "*/*": { + "schema": { + "type": "object", + "additionalProperties": { + "type": "object" + } + } + } + } + }, + "404": { + "description": "Pet not found", + "content": { + "application/xml": { + "schema": { + "$ref": "#/components/schemas/Pet" + } + }, + "application/json": { + "schema": { + "$ref": "#/components/schemas/Pet" + } + } + } + }, + "200": { + "description": "successful operation", + "content": { + "application/xml": { + "schema": { + "$ref": "#/components/schemas/Pet" + } + }, + "application/json": { + "schema": { + "$ref": "#/components/schemas/Pet" + } + } + } + } + }, + "security": [ + { + "api_key": [] + } + ] + }, + "post": { + "tags": [ + "pet" + ], + "summary": "Updates a pet in the store with form data", + "description": "Update pet with form response entity.", + "operationId": "updatePetWithForm", + "parameters": [ + { + "name": "petId", + "in": "path", + "description": "ID of pet that needs to be updated", + "required": true, + "schema": { + "type": "integer", + "format": "int64" + } + } + ], + "requestBody": { + "content": { + "application/x-www-form-urlencoded": { + "schema": { + "type": "object", + "properties": { + "name": { + "type": "string", + "description": "Updated name of the pet" + }, + "status": { + "type": "string", + "description": "Updated status of the pet" + } + } + } + } + } + }, + "responses": { + "400": { + "description": "the map", + "content": { + "*/*": { + "schema": { + "type": "object", + "additionalProperties": { + "type": "object" + } + } + } + } + }, + "405": { + "description": "Invalid input" + } + }, + "security": [ + { + "petstore_auth": [ + "write:pets", + "read:pets" + ] + } + ] + }, + "delete": { + "tags": [ + "pet" + ], + "summary": "Deletes a pet", + "description": "Delete pet response entity.", + "operationId": "deletePet", + "parameters": [ + { + "name": "petId", + "in": "path", + "description": "Pet id to delete", + "required": true, + "schema": { + "type": "integer", + "format": "int64" + } + }, + { + "name": "api_key", + "in": "header", + "description": "the api key", + "required": false, + "schema": { + "type": "string" + } + } + ], + "responses": { + "400": { + "description": "Invalid ID supplied", + "content": { + "*/*": { + "schema": { + "type": "object", + "additionalProperties": { + "type": "object" + } + } + } + } + }, + "404": { + "description": "Pet not found" + } + }, + "security": [ + { + "petstore_auth": [ + "write:pets", + "read:pets" + ] + } + ] + } + }, + "/pet/{petId}/uploadImage": { + "post": { + "tags": [ + "pet" + ], + "summary": "uploads an image", + "description": "Upload file response entity.", + "operationId": "uploadFile", + "parameters": [ + { + "name": "petId", + "in": "path", + "description": "ID of pet to update", + "required": true, + "schema": { + "type": "integer", + "format": "int64" + } + }, + { + "name": "additionalMetadata", + "in": "query", + "description": "Additional data to pass to server", + "required": false, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "multipart/form-data": { + "schema": { + "type": "object", + "properties": { + "file": { + "type": "string", + "format": "binary", + "description": "file detail" + } + }, + "required": [ + "file" + ] + } + } + } + }, + "responses": { + "400": { + "description": "the map", + "content": { + "*/*": { + "schema": { + "type": "object", + "additionalProperties": { + "type": "object" + } + } + } + } + }, + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ModelApiResponse" + } + } + } + } + }, + "security": [ + { + "petstore_auth": [ + "write:pets", + "read:pets" + ] + } + ] + } + }, + "/user/logout": { + "get": { + "tags": [ + "user" + ], + "summary": "Logs out current logged in user session", + "description": "Logout user response entity.", + "operationId": "logoutUser", + "responses": { + "400": { + "description": "the map", + "content": { + "*/*": { + "schema": { + "type": "object", + "additionalProperties": { + "type": "object" + } + } + } + } + }, + "200": { + "description": "successful operation" + } + } + } + }, + "/user/login": { + "get": { + "tags": [ + "user" + ], + "summary": "Logs user into the system", + "description": "Login user response entity.", + "operationId": "loginUser", + "parameters": [ + { + "name": "username", + "in": "query", + "description": "The user name for login", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "password", + "in": "query", + "description": "The password for login in clear text", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "400": { + "description": "Invalid username/password supplied", + "content": { + "*/*": { + "schema": { + "type": "object", + "additionalProperties": { + "type": "object" + } + } + } + } + }, + "200": { + "description": "successful operation", + "content": { + "application/xml": { + "schema": { + "type": "string" + } + }, + "application/json": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/store/order/{orderId}": { + "get": { + "tags": [ + "store" + ], + "summary": "Find purchase order by ID", + "description": "Gets order by id.", + "operationId": "getOrderById", + "parameters": [ + { + "name": "orderId", + "in": "path", + "description": "ID of pet that needs to be fetched", + "required": true, + "schema": { + "type": "integer", + "format": "int64", + "maximum": 5, + "minimum": 1 + } + } + ], + "responses": { + "400": { + "description": "Invalid ID supplied", + "content": { + "*/*": { + "schema": { + "type": "object", + "additionalProperties": { + "type": "object" + } + } + } + } + }, + "404": { + "description": "Order not found", + "content": { + "application/xml": { + "schema": { + "$ref": "#/components/schemas/Order" + } + }, + "application/json": { + "schema": { + "$ref": "#/components/schemas/Order" + } + } + } + }, + "200": { + "description": "successful operation", + "content": { + "application/xml": { + "schema": { + "$ref": "#/components/schemas/Order" + } + }, + "application/json": { + "schema": { + "$ref": "#/components/schemas/Order" + } + } + } + } + } + }, + "delete": { + "tags": [ + "store" + ], + "summary": "Delete purchase order by ID", + "description": "Delete order response entity.", + "operationId": "deleteOrder", + "parameters": [ + { + "name": "orderId", + "in": "path", + "description": "ID of the order that needs to be deleted", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "400": { + "description": "Invalid ID supplied", + "content": { + "*/*": { + "schema": { + "type": "object", + "additionalProperties": { + "type": "object" + } + } + } + } + }, + "404": { + "description": "Order not found" + } + } + } + }, + "/store/inventory": { + "get": { + "tags": [ + "store" + ], + "summary": "Returns pet inventories by status", + "description": "Returns a map of status codes to quantities", + "operationId": "getInventory", + "responses": { + "400": { + "description": "the map", + "content": { + "*/*": { + "schema": { + "type": "object", + "additionalProperties": { + "type": "object" + } + } + } + } + }, + "200": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + } + } + } + }, + "security": [ + { + "api_key": [] + } + ] + } + }, + "/pet/findByTags": { + "get": { + "tags": [ + "pet" + ], + "summary": "Finds Pets by tags", + "description": "Muliple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.", + "operationId": "findPetsByTags", + "parameters": [ + { + "name": "tags", + "in": "query", + "description": "Tags to filter by", + "required": true, + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + } + ], + "responses": { + "400": { + "description": "Invalid tag value", + "content": { + "*/*": { + "schema": { + "type": "object", + "additionalProperties": { + "type": "object" + } + } + } + } + }, + "200": { + "description": "successful operation", + "content": { + "application/xml": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Pet" + } + } + }, + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Pet" + } + } + } + } + } + }, + "security": [ + { + "petstore_auth": [ + "write:pets", + "read:pets" + ] + } + ] + } + }, + "/pet/findByStatus": { + "get": { + "tags": [ + "pet" + ], + "summary": "Finds Pets by status", + "description": "Multiple status values can be provided with comma separated strings", + "operationId": "findPetsByStatus", + "parameters": [ + { + "name": "status", + "in": "query", + "description": "Status values that need to be considered for filter", + "required": true, + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + } + ], + "responses": { + "400": { + "description": "Invalid status value", + "content": { + "*/*": { + "schema": { + "type": "object", + "additionalProperties": { + "type": "object" + } + } + } + } + }, + "200": { + "description": "successful operation", + "content": { + "application/xml": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Pet" + } + } + }, + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Pet" + } + } + } + } + } + }, + "security": [ + { + "petstore_auth": [ + "write:pets", + "read:pets" + ] + } + ] + } + } + }, + "components": { + "schemas": { + "User": { + "type": "object", + "description": "The type User.", + "properties": { + "id": { + "type": "integer", + "format": "int64", + "description": "The Id." + }, + "username": { + "type": "string", + "description": "The Username." + }, + "firstName": { + "type": "string", + "description": "The First name." + }, + "lastName": { + "type": "string", + "description": "The Last name." + }, + "email": { + "type": "string", + "description": "The Email." + }, + "password": { + "type": "string", + "description": "The Password." + }, + "phone": { + "type": "string", + "description": "The Phone." + }, + "userStatus": { + "type": "integer", + "format": "int32", + "description": "User Status" + } + } + }, + "Category": { + "type": "object", + "description": "The type Category.", + "properties": { + "id": { + "type": "integer", + "format": "int64", + "description": "The Id." + }, + "name": { + "type": "string", + "description": "The Name." + } + } + }, + "Pet": { + "type": "object", + "description": "The type Pet.", + "properties": { + "id": { + "type": "integer", + "format": "int64", + "description": "The Id." + }, + "category": { + "$ref": "#/components/schemas/Category", + "description": "The Category." + }, + "name": { + "type": "string", + "description": "The Name.", + "example": "doggie" + }, + "photoUrls": { + "type": "array", + "description": "The Photo urls.", + "items": { + "type": "string" + } + }, + "tags": { + "type": "array", + "description": "The Tags.", + "items": { + "$ref": "#/components/schemas/Tag" + } + }, + "status": { + "type": "string", + "description": "pet status in the store", + "enum": [ + "available", + "pending", + "sold" + ] + } + }, + "required": [ + "name", + "photoUrls" + ] + }, + "Tag": { + "type": "object", + "description": "The type Tag.", + "properties": { + "id": { + "type": "integer", + "format": "int64", + "description": "The Id." + }, + "name": { + "type": "string", + "description": "The Name." + } + } + }, + "Order": { + "type": "object", + "description": "The type Order.", + "properties": { + "complete": { + "type": "boolean", + "description": "The Complete." + }, + "id": { + "type": "integer", + "format": "int64", + "description": "The Id." + }, + "petId": { + "type": "integer", + "format": "int64", + "description": "The Pet id." + }, + "quantity": { + "type": "integer", + "format": "int32", + "description": "The Quantity." + }, + "shipDate": { + "type": "string", + "format": "date-time", + "description": "The Ship date." + }, + "status": { + "type": "string", + "description": "Order Status" + } + } + }, + "ModelApiResponse": { + "type": "object", + "description": "The type Model api response.", + "properties": { + "code": { + "type": "integer", + "format": "int32", + "description": "The Code." + }, + "type": { + "type": "string", + "description": "The Type." + }, + "message": { + "type": "string", + "description": "The Message." + } + } + } + }, + "securitySchemes": { + "basicScheme": { + "type": "http", + "scheme": "basic" + }, + "petstore_auth": { + "type": "oauth2", + "flows": { + "implicit": { + "authorizationUrl": "http://petstore.swagger.io/oauth/dialog", + "scopes": { + "write:pets": "modify pets in your account", + "read:pets": "read your pets" + } + } + } + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app20.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app20.json new file mode 100644 index 000000000..16823bacd --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app20.json @@ -0,0 +1,15 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": {}, + "components": {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app21.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app21.json new file mode 100644 index 000000000..75ef58948 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app21.json @@ -0,0 +1,65 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/persons": { + "get": { + "tags": [ + "person" + ], + "summary": "Add a new person to the store", + "description": "Persons.", + "operationId": "persons", + "parameters": [ + { + "name": "name", + "in": "query", + "description": "the name", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK" + } + }, + "security": [ + { + "personstore_auth": [ + "write:persons", + "read:persons" + ] + } + ] + } + } + }, + "components": { + "securitySchemes": { + "personstore_auth": { + "type": "oauth2", + "flows": { + "implicit": { + "authorizationUrl": "http://personstore.swagger.io/oauth/dialog", + "scopes": { + "write:persons": "modify persons in your account", + "read:persons": "read your persons" + } + } + } + } + } + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app22.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app22.json new file mode 100644 index 000000000..a17a53e22 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app22.json @@ -0,0 +1,71 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "hello-controller", + "description": "The type Hello controller." + } + ], + "paths": { + "/persons": { + "get": { + "tags": [ + "hello-controller" + ], + "summary": "Do get response entity.", + "description": "Do get response entity.", + "operationId": "doGet", + "responses": { + "200": { + "description": "the response entity", + "content": { + "*/*": { + "schema": { + "type": "array", + "items": { + "type": "array", + "items": { + "$ref": "#/components/schemas/PersonDTO" + } + } + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "PersonDTO": { + "type": "object", + "properties": { + "email": { + "type": "string", + "description": "The Email." + }, + "firstName": { + "type": "string", + "description": "The First name." + }, + "lastName": { + "type": "string", + "description": "The Last name." + } + }, + "description": "The type Person dto." + } + } + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app23.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app23.json new file mode 100644 index 000000000..88155203a --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app23.json @@ -0,0 +1,62 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "hello-controller", + "description": "The type Hello controller." + } + ], + "paths": { + "/persons": { + "get": { + "tags": [ + "hello-controller" + ], + "summary": "Add a new person to the store", + "description": "Persons.", + "operationId": "persons", + "parameters": [ + { + "name": "name", + "in": "query", + "description": "the name", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK" + } + }, + "security": [ + { + "Authorization": [] + } + ] + } + } + }, + "components": { + "securitySchemes": { + "Authorization": { + "type": "apiKey", + "description": "A core-auth Bearer token", + "name": "JWT", + "in": "header" + } + } + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app24.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app24.json new file mode 100644 index 000000000..7575323f0 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app24.json @@ -0,0 +1,89 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "Petstore API", + "description": "This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.", + "termsOfService": "http://swagger.io/terms/", + "license": { + "name": "Apache 2.0", + "url": "http://springdoc.org" + }, + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "hello-controller", + "description": "The type Hello controller." + } + ], + "paths": { + "/persons": { + "get": { + "tags": [ + "hello-controller" + ], + "summary": "Add a new person to the store", + "description": "Persons.", + "operationId": "persons", + "parameters": [ + { + "name": "name", + "in": "query", + "description": "the name", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK" + } + }, + "security": [ + { + "Authorization": [] + } + ] + } + } + }, + "components": { + "parameters": { + "myHeader1": { + "name": "myHeader1", + "in": "header", + "schema": { + "type": "string" + } + } + }, + "headers": { + "myHeader2": { + "description": "myHeader2 header", + "schema": { + "type": "string" + } + } + }, + "securitySchemes": { + "basicScheme": { + "type": "http", + "scheme": "basic" + }, + "Authorization": { + "type": "apiKey", + "description": "A core-auth Bearer token", + "name": "Authorization", + "in": "header" + } + } + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app25.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app25.json new file mode 100644 index 000000000..389afd31d --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app25.json @@ -0,0 +1,193 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "hello-controller", + "description": "The type Hello controller." + } + ], + "paths": { + "/values/{trackerId}/data": { + "get": { + "tags": [ + "hello-controller" + ], + "description": "Get last data from a tracker", + "operationId": "thirdList", + "parameters": [ + { + "name": "trackerId", + "in": "path", + "description": "the tracker id", + "required": true, + "schema": { + "type": "string", + "example": "the-tracker-id" + } + }, + { + "name": "start", + "in": "query", + "description": "the start", + "required": false, + "schema": { + "type": "string", + "format": "date-time", + "example": "1970-01-01T00:00:00.000Z" + } + }, + { + "name": "end", + "in": "query", + "description": "the end", + "required": false, + "schema": { + "type": "string", + "format": "date-time", + "example": "1970-01-01T00:10:00.000Z" + } + }, + { + "name": "limit", + "in": "query", + "description": "the limit", + "required": false, + "schema": { + "type": "number", + "example": 10 + } + } + ], + "responses": { + "200": { + "description": "OK" + } + } + } + }, + "/secondlist/{trackerId}": { + "get": { + "tags": [ + "hello-controller" + ], + "summary": "Secondlist.", + "description": "Secondlist.", + "operationId": "secondlist", + "parameters": [ + { + "name": "trackerId", + "in": "path", + "description": "the tracker id", + "required": true, + "schema": { + "type": "string", + "example": "the-tracker-id" + } + }, + { + "name": "start", + "in": "query", + "description": "the start date", + "required": false, + "schema": { + "type": "string", + "format": "date-time", + "example": "1970-01-01T00:00:00.000Z" + } + }, + { + "name": "end", + "in": "query", + "description": "the end date", + "required": false, + "schema": { + "type": "string", + "format": "date-time", + "example": "1970-01-01T00:10:00.000Z" + } + } + ], + "responses": { + "200": { + "description": "OK" + } + } + } + }, + "/list/{trackerId}": { + "get": { + "tags": [ + "hello-controller" + ], + "summary": "List.", + "description": "List.", + "operationId": "list", + "parameters": [ + { + "name": "trackerId", + "in": "path", + "description": "the tracker id", + "required": true, + "schema": { + "type": "string", + "example": "the-tracker-id" + } + }, + { + "name": "start", + "in": "query", + "description": "the start date", + "required": false, + "schema": { + "type": "string", + "format": "date-time", + "example": "1970-01-01T00:00:00.000Z" + } + }, + { + "name": "end", + "in": "query", + "description": "the end date", + "required": false, + "schema": { + "type": "string", + "format": "date-time", + "example": "1970-01-01T00:10:00.000Z" + } + } + ], + "responses": { + "200": { + "description": "OK" + } + } + } + }, + "/check": { + "get": { + "tags": [ + "hello-controller" + ], + "summary": "Check.", + "description": "Check.", + "operationId": "check", + "responses": { + "200": { + "description": "OK" + } + } + } + } + }, + "components": {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app26.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app26.json new file mode 100644 index 000000000..c8b7aeb38 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app26.json @@ -0,0 +1,102 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "hello-controller", + "description": "The type Hello controller." + } + ], + "paths": { + "/persons": { + "post": { + "tags": [ + "hello-controller" + ], + "summary": "Persons my model.", + "description": "Persons my model.", + "operationId": "persons", + "parameters": [ + { + "name": "myModel", + "in": "query", + "description": "the my model", + "required": true, + "schema": { + "$ref": "#/components/schemas/MyModel" + } + } + ], + "responses": { + "200": { + "description": "the my model", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/MyModel" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "Bar": { + "type": "object", + "description": "The type Bar.", + "properties": { + "bar": { + "type": "string", + "description": "The Bar." + } + } + }, + "Foo": { + "type": "object", + "description": "The type Foo.", + "properties": { + "foo": { + "type": "string", + "description": "The Foo." + } + } + }, + "MyModel": { + "type": "object", + "description": "The type My model.", + "properties": { + "thing": { + "type": "object", + "description": "Hello", + "oneOf": [ + { + "$ref": "#/components/schemas/Foo" + }, + { + "$ref": "#/components/schemas/Bar" + }, + { + "$ref": "#/components/schemas/Foo" + }, + { + "$ref": "#/components/schemas/Bar" + } + ] + } + } + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app27.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app27.json new file mode 100644 index 000000000..2ebe908a1 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app27.json @@ -0,0 +1,69 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/test": { + "get": { + "operationId": "test", + "responses": { + "500": { + "description": "default response", + "content": { + "*/*": { + "schema": { + "oneOf": [ + { + "$ref": "#/components/schemas/Bar" + }, + { + "$ref": "#/components/schemas/Foo" + } + ] + } + } + } + }, + "200": { + "description": "default response", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "Foo": { + "type": "object", + "properties": { + "foo": { + "type": "string" + } + } + }, + "Bar": { + "type": "object", + "properties": { + "bar": { + "type": "string" + } + } + } + } + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app28.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app28.json new file mode 100644 index 000000000..a19278516 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app28.json @@ -0,0 +1,69 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "hello-controller", + "description": "The type Hello controller." + } + ], + "paths": { + "/upload2": { + "post": { + "tags": [ + "hello-controller" + ], + "summary": "Upload 2 string.", + "description": "Upload 2 string.", + "operationId": "upload2", + "requestBody": { + "content": { + "multipart/form-data": { + "schema": { + "required": [ + "one", + "two" + ], + "type": "object", + "properties": { + "one": { + "type": "string", + "description": "the one", + "format": "binary" + }, + "two": { + "type": "string", + "description": "the two", + "format": "binary" + } + } + } + } + } + }, + "responses": { + "200": { + "description": "the string", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + } + }, + "components": {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app29.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app29.json new file mode 100644 index 000000000..b6f802bad --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app29.json @@ -0,0 +1,87 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "hello-controller", + "description": "The type Hello controller." + } + ], + "paths": { + "/post-entity": { + "post": { + "tags": [ + "hello-controller" + ], + "description": "Post entity", + "operationId": "postEntity", + "requestBody": { + "description": "the post entity", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/TrackerData" + } + } + } + }, + "responses": { + "200": { + "description": "the list", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/TrackerData" + } + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "TrackerData": { + "required": [ + "timestamp", + "trackerId", + "value" + ], + "type": "object", + "properties": { + "trackerId": { + "type": "string", + "description": "The Tracker id.", + "example": "the-tracker-id" + }, + "timestamp": { + "type": "string", + "description": "The Timestamp.", + "format": "date-time", + "example": "2018-01-01T00:00:00Z" + }, + "value": { + "type": "number", + "description": "The data value", + "format": "double", + "example": 19.0 + } + }, + "description": "The type Tracker data." + } + } + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app3.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app3.json new file mode 100644 index 000000000..d798a430c --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app3.json @@ -0,0 +1,113 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "hello-controller", + "description": "The type Hello controller." + } + ], + "paths": { + "/": { + "post": { + "tags": [ + "hello-controller" + ], + "summary": "Echo playing card.", + "description": "Echo playing card.", + "operationId": "echo", + "parameters": [ + { + "name": "toto", + "in": "query", + "description": "the toto baby", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "description": "the card baby", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/PlayingCard" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "the playing card baby", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/PersonDTO" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "PlayingCard": { + "type": "object", + "properties": { + "suit": { + "type": "string", + "description": "The Suit.", + "enum": [ + "Hearts", + "Diamonds", + "Clubs", + "Spades" + ] + }, + "value": { + "type": "integer", + "description": "The Value.", + "format": "int32" + }, + "toto": { + "type": "string", + "description": "The Toto.", + "format": "date-time" + } + }, + "description": "The type Playing card." + }, + "PersonDTO": { + "type": "object", + "properties": { + "email": { + "type": "string", + "description": "The email" + }, + "firstName": { + "type": "string", + "description": "The firstName" + }, + "lastName": { + "type": "string", + "description": "The lastName" + } + }, + "description": "The type Person dto." + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app30.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app30.json new file mode 100644 index 000000000..95e4e7ade --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app30.json @@ -0,0 +1,56 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "hello-controller", + "description": "The type Hello controller." + } + ], + "paths": { + "/test": { + "get": { + "tags": [ + "hello-controller" + ], + "summary": "Echo string.", + "description": "Echo string.", + "operationId": "echo", + "parameters": [ + { + "name": "text", + "in": "query", + "description": "the text", + "required": false, + "schema": { + "type": "string", + "default": "Hello, World!" + } + } + ], + "responses": { + "200": { + "description": "the string", + "content": { + "text/plain": { + "schema": { + "type": "string" + } + } + } + } + } + } + } + }, + "components": {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app31.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app31.json new file mode 100644 index 000000000..47e4ca02c --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app31.json @@ -0,0 +1,111 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "hello-controller", + "description": "The type Hello controller." + } + ], + "paths": { + "/test": { + "post": { + "tags": [ + "hello-controller" + ], + "description": "subscribes a client to updates relevant to the requestor's account, as identified by the input token. The supplied url will be used as the delivery address for response payloads", + "operationId": "subscribe", + "parameters": [ + { + "name": "x-auth-token", + "in": "header", + "description": "the authentication token provided after initially authenticating to the application", + "required": true, + "schema": { + "type": "string", + "description": "the authentication token provided after initially authenticating to the application" + } + }, + { + "name": "url", + "in": "query", + "description": "the URL to call with response data", + "required": true, + "schema": { + "type": "string", + "description": "the URL to call with response data" + } + } + ], + "responses": { + "200": { + "description": "the subscription response", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/SubscriptionResponse" + } + } + } + } + }, + "callbacks": { + "subscription": { + "http://$request.query.url": { + "post": { + "description": "payload data will be sent", + "parameters": [ + { + "name": "subscriptionId", + "in": "path", + "required": true, + "schema": { + "type": "string", + "description": "the generated UUID", + "format": "uuid", + "readOnly": true + } + } + ], + "responses": { + "200": { + "description": "Return this code if the callback was received and processed successfully" + }, + "205": { + "description": "Return this code to unsubscribe from future data updates" + }, + "default": { + "description": "All other response codes will disable this callback subscription" + } + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "SubscriptionResponse": { + "type": "object", + "properties": { + "subscriptionUuid": { + "type": "string", + "description": "The Subscription uuid." + } + }, + "description": "The type Subscription response." + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app32.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app32.json new file mode 100644 index 000000000..46d07e6e9 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app32.json @@ -0,0 +1,75 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "hello-controller", + "description": "The type Hello controller." + } + ], + "paths": { + "/filter": { + "post": { + "tags": [ + "hello-controller" + ], + "summary": "Filter post string.", + "description": "Filter post string.", + "operationId": "filterPost", + "requestBody": { + "description": "the filter", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/MyTestDto" + } + } + } + }, + "responses": { + "200": { + "description": "the string", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "MyTestDto": { + "type": "object", + "properties": { + "object1": { + "type": "string", + "description": "The Object 1." + }, + "object2": { + "type": "string", + "description": "The Object 2." + }, + "object3": { + "type": "string", + "description": "The Object 3." + } + }, + "description": "The type My test dto." + } + } + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app33.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app33.json new file mode 100644 index 000000000..bf711def1 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app33.json @@ -0,0 +1,64 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "hello-controller", + "description": "The type Hello controller." + } + ], + "paths": { + "/hello/{numTelco}": { + "get": { + "tags": [ + "hello-controller" + ], + "summary": "GET Persons", + "description": "Index t.", + "operationId": "index", + "parameters": [ + { + "name": "numTelco", + "in": "path", + "description": "the num tel", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "adresse", + "in": "query", + "description": "the adresse", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "418": { + "description": "the t", + "content": { + "*/*": { + "schema": { + "type": "object" + } + } + } + } + } + } + } + }, + "components": {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app34.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app34.json new file mode 100644 index 000000000..bf711def1 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app34.json @@ -0,0 +1,64 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "hello-controller", + "description": "The type Hello controller." + } + ], + "paths": { + "/hello/{numTelco}": { + "get": { + "tags": [ + "hello-controller" + ], + "summary": "GET Persons", + "description": "Index t.", + "operationId": "index", + "parameters": [ + { + "name": "numTelco", + "in": "path", + "description": "the num tel", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "adresse", + "in": "query", + "description": "the adresse", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "418": { + "description": "the t", + "content": { + "*/*": { + "schema": { + "type": "object" + } + } + } + } + } + } + } + }, + "components": {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app35.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app35.json new file mode 100644 index 000000000..cee19de65 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app35.json @@ -0,0 +1,78 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "hello-controller", + "description": "The type Hello controller." + } + ], + "paths": { + "/api/v1/poc/testme": { + "get": { + "tags": [ + "hello-controller" + ], + "summary": "Get thing", + "description": "Testme response entity.", + "operationId": "testme", + "responses": { + "200": { + "description": "Successful Operation", + "content": { + "application/json": { + "schema": { + "type": "string" + } + } + } + }, + "404": { + "description": "Not found" + }, + "401": { + "description": "Authentication Failure" + } + } + } + }, + "/api/v1/poc/test": { + "get": { + "tags": [ + "hello-controller" + ], + "summary": "Get thing", + "description": "Test response entity.", + "operationId": "test", + "responses": { + "200": { + "description": "Successful Operation", + "content": { + "application/json": { + "schema": { + "type": "string" + } + } + } + }, + "404": { + "description": "Not found" + }, + "401": { + "description": "Authentication Failure" + } + } + } + } + }, + "components": {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app37.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app37.json new file mode 100644 index 000000000..be3651b4c --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app37.json @@ -0,0 +1,169 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "hello-controller", + "description": "The type Hello controller." + } + ], + "paths": { + "/bar/baz": { + "post": { + "tags": [ + "hello-controller" + ], + "summary": "Process car.", + "description": "Process car.", + "operationId": "process", + "requestBody": { + "description": "the c", + "content": { + "application/x.a+json": { + "schema": { + "$ref": "#/components/schemas/Foo" + } + }, + "application/x.b+json": { + "schema": { + "$ref": "#/components/schemas/Bar" + } + }, + "application/x.c+json": { + "schema": { + "$ref": "#/components/schemas/Car" + } + } + } + }, + "responses": { + "200": { + "description": "the car", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Car" + } + }, + "text/plain": { + "schema": { + "oneOf": [ + { + "$ref": "#/components/schemas/Foo" + }, + { + "$ref": "#/components/schemas/Bar" + } + ] + } + } + } + } + } + } + }, + "/pets1": { + "post": { + "tags": [ + "hello-controller" + ], + "summary": "Pets post response entity.", + "description": "Pets post response entity.", + "operationId": "petsPost1", + "requestBody": { + "description": "the pet", + "content": { + "text/plain": { + "schema": { + "type": "string" + } + } + } + }, + "responses": { + "200": { + "description": "the response entity" + } + } + } + }, + "/pets2": { + "post": { + "tags": [ + "hello-controller" + ], + "summary": "Pets post response entity.", + "description": "Pets post response entity.", + "operationId": "petsPost2", + "requestBody": { + "description": "the pet", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Pet" + } + } + } + }, + "responses": { + "200": { + "description": "the response entity" + } + } + } + } + }, + "components": { + "schemas": { + "Bar": { + "type": "object", + "properties": { + "bar": { + "type": "string", + "description": "The Bar." + } + }, + "description": "The type Bar." + }, + "Car": { + "type": "object", + "properties": { + "car": { + "type": "string", + "description": "The Car." + } + }, + "description": "The type Car." + }, + "Foo": { + "type": "object", + "properties": { + "foo": { + "type": "string", + "description": "The Foo." + } + }, + "description": "The type Foo." + }, + "Pet": { + "type": "object", + "properties": { + "pet": { + "type": "string", + "description": "The Pet." + } + }, + "description": "The type Pet." + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app38.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app38.json new file mode 100644 index 000000000..736ed56c4 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app38.json @@ -0,0 +1,45 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "hello-controller", + "description": "The type Hello controller." + } + ], + "paths": { + "/npe_error": { + "get": { + "tags": [ + "hello-controller" + ], + "summary": "Gets model resource.", + "description": "Gets model resource.", + "operationId": "getModelResource", + "responses": { + "200": { + "description": "the model resource", + "content": { + "*/*": { + "schema": { + "type": "string", + "format": "byte" + } + } + } + } + } + } + } + }, + "components": {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app39.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app39.json new file mode 100644 index 000000000..8fb8ed523 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app39.json @@ -0,0 +1,94 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "hello-controller", + "description": "The type Hello controller." + } + ], + "paths": { + "/hello": { + "get": { + "tags": [ + "hello-controller" + ], + "summary": "Hello string.", + "description": "Hello string.", + "operationId": "hello", + "parameters": [ + { + "$ref": "#/components/parameters/myGlobalHeader", + "in": "header" + } + ], + "responses": { + "200": { + "description": "the string", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/test": { + "post": { + "tags": [ + "hello-controller" + ], + "summary": "test Request", + "description": "Search employee.", + "operationId": "searchEmployee", + "parameters": [ + { + "$ref": "#/components/parameters/myGlobalHeader", + "in": "header" + } + ], + "requestBody": { + "description": "test value", + "content": { + "application/json": { + "schema": { + "type": "string" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "OK" + } + } + } + } + }, + "components": { + "parameters": { + "myGlobalHeader": { + "name": "My-Global-Header", + "in": "header", + "description": "My Global Header", + "required": true, + "schema": { + "type": "string" + } + } + } + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app4.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app4.json new file mode 100644 index 000000000..081ab063f --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app4.json @@ -0,0 +1,86 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "hello-controller", + "description": "The type Hello controller." + } + ], + "paths": { + "/values/data": { + "post": { + "tags": [ + "hello-controller" + ], + "summary": "List tracker data.", + "description": "List tracker data.", + "operationId": "list", + "parameters": [ + { + "name": "toto", + "in": "query", + "description": "the toto", + "required": true, + "schema": { + "$ref": "#/components/schemas/test.org.springdoc.api.v31.app4.TrackerData" + } + } + ], + "responses": { + "200": { + "description": "the tracker data", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/test.org.springdoc.api.v31.app4.TrackerData" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "test.org.springdoc.api.v31.app4.TrackerData": { + "required": [ + "timestamp", + "trackerId", + "value" + ], + "type": "object", + "properties": { + "trackerId": { + "type": "string", + "description": "The Tracker id.", + "example": "the-tracker-id" + }, + "timestamp": { + "type": "string", + "description": "The Timestamp.", + "format": "date-time", + "example": "2018-01-01T00:00:00Z" + }, + "value": { + "type": "number", + "description": "The data value", + "format": "double", + "example": 19.0 + } + }, + "description": "The type Tracker data." + } + } + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app40.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app40.json new file mode 100644 index 000000000..0413b3e6b --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app40.json @@ -0,0 +1,44 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "hello-controller", + "description": "The type Hello controller." + } + ], + "paths": { + "/iae_error": { + "get": { + "tags": [ + "hello-controller" + ], + "summary": "Gets start form properties.", + "description": "Gets start form properties.", + "operationId": "getStartFormProperties", + "responses": { + "200": { + "description": "the start form properties", + "content": { + "*/*": { + "schema": { + "type": "object" + } + } + } + } + } + } + } + }, + "components": {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app41.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app41.json new file mode 100644 index 000000000..6fb3d61a0 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app41.json @@ -0,0 +1,69 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/file": { + "get": { + "tags": [ + "hello-controller" + ], + "description": "Download file", + "operationId": "getFile", + "parameters": [ + { + "name": "path", + "in": "query", + "description": "File path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "500": { + "description": "Unexpected error", + "content": { + "application/json": { + "schema": { + "type": "string" + } + } + } + }, + "200": { + "description": "File resource", + "content": { + "application/json": { + "schema": { + "type": "string", + "format": "binary" + } + } + } + }, + "400": { + "description": "Wrong request", + "content": { + "application/json": { + "schema": { + "type": "string" + } + } + } + } + } + } + } + }, + "components": {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app42.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app42.json new file mode 100644 index 000000000..c8e6b5153 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app42.json @@ -0,0 +1,54 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "hello-controller", + "description": "The type Hello controller." + } + ], + "paths": { + "/tweets/{id}": { + "get": { + "tags": [ + "hello-controller" + ], + "summary": "Tweets.", + "description": "Tweets.", + "operationId": "tweets", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "the id", + "required": true, + "schema": { + "$ref": "#/components/schemas/TweetId" + } + } + ], + "responses": { + "200": { + "description": "OK" + } + } + } + } + }, + "components": { + "schemas": { + "TweetId": { + "type": "string" + } + } + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app43.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app43.json new file mode 100644 index 000000000..b7e5f3188 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app43.json @@ -0,0 +1,66 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "hello-controller", + "description": "The type Hello controller." + } + ], + "paths": { + "/documents": { + "post": { + "tags": [ + "hello-controller" + ], + "summary": "Upload documents response entity.", + "description": "Upload documents response entity.", + "operationId": "uploadDocuments", + "requestBody": { + "content": { + "multipart/form-data": { + "schema": { + "required": [ + "doc" + ], + "type": "object", + "properties": { + "doc": { + "type": "array", + "description": "the multipart files", + "items": { + "type": "string", + "format": "binary" + } + } + } + } + } + } + }, + "responses": { + "200": { + "description": "the response entity", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + } + }, + "components": {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app44.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app44.json new file mode 100644 index 000000000..f9b750dc4 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app44.json @@ -0,0 +1,107 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/helloworld": { + "post": { + "operationId": "hello_1", + "requestBody": { + "content": { + "application/vnd.v1+json": { + "schema": { + "$ref": "#/components/schemas/RequestV1" + } + }, + "application/vnd.v2+json": { + "schema": { + "$ref": "#/components/schemas/RequestV2" + } + } + } + }, + "responses": { + "400": { + "description": "Bad name", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorDTO" + } + } + } + }, + "200": { + "description": "Successful operation", + "content": { + "application/json": { + "schema": { + "oneOf": [ + { + "$ref": "#/components/schemas/HelloDTO2" + }, + { + "$ref": "#/components/schemas/HelloDTO1" + } + ] + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "RequestV1": { + "type": "object", + "properties": { + "nameV1": { + "type": "string" + } + } + }, + "ErrorDTO": { + "type": "object", + "properties": { + "errorMessage": { + "type": "string" + } + } + }, + "HelloDTO1": { + "type": "object", + "properties": { + "message": { + "type": "string" + } + } + }, + "RequestV2": { + "type": "object", + "properties": { + "nameV2": { + "type": "string" + } + } + }, + "HelloDTO2": { + "type": "object", + "properties": { + "message": { + "type": "string" + } + } + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app45.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app45.json new file mode 100644 index 000000000..fa1622a4d --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app45.json @@ -0,0 +1,166 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "My App", + "description": "Some long and useful description", + "license": { + "name": "Apache 2.0", + "url": "https://www.apache.org/licenses/LICENSE-2.0" + }, + "version": "v1" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "People", + "description": "Use this resource to serve all requests and initiate all operations related to people" + } + ], + "paths": { + "/v1/people2/list": { + "get": { + "tags": [ + "People" + ], + "description": "List all persons", + "operationId": "list", + "responses": { + "200": { + "description": "the list", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/PersonDTO" + } + } + } + } + } + }, + "security": [ + { + "bearer": [] + } + ] + } + }, + "/v1/people2/listTwo": { + "get": { + "tags": [ + "People" + ], + "description": "List all persons", + "operationId": "listTwo", + "responses": { + "200": { + "description": "the list", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/PersonDTO" + } + } + } + } + } + }, + "security": [ + { + "bearer": [] + } + ] + } + }, + "/v1/people/list": { + "get": { + "tags": [ + "People" + ], + "description": "List all persons", + "operationId": "list_1", + "responses": { + "200": { + "description": "the list", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/PersonDTO" + } + } + } + } + } + }, + "security": [ + { + "bearer": [] + } + ] + } + }, + "/v1/people/listTwo": { + "get": { + "tags": [ + "People" + ], + "description": "List all persons", + "operationId": "listTwo_1", + "responses": { + "200": { + "description": "the list", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/PersonDTO" + } + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "PersonDTO": { + "type": "object", + "properties": { + "email": { + "type": "string", + "description": "The Email." + }, + "firstName": { + "type": "string", + "description": "The First name." + }, + "lastName": { + "type": "string", + "description": "The Last name." + } + }, + "description": "The type Person dto." + } + }, + "securitySchemes": { + "bearer": { + "type": "http", + "scheme": "bearer", + "bearerFormat": "JWT" + } + } + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app46.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app46.json new file mode 100644 index 000000000..65ddb363f --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app46.json @@ -0,0 +1,58 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/persons/{subscriptionId}": { + "get": { + "tags": [ + "Example Tag" + ], + "summary": "Operation Summary", + "description": "Operation Description", + "externalDocs": { + "description": "External documentation description", + "url": "http://url.com" + }, + "operationId": "operationId", + "parameters": [ + { + "name": "subscriptionId", + "in": "path", + "description": "parameter description", + "required": true, + "allowEmptyValue": true, + "allowReserved": true, + "schema": { + "type": "string", + "description": "the generated UUID", + "format": "uuid", + "readOnly": true + } + } + ], + "responses": { + "200": { + "description": "voila!", + "content": { + "application/json": { + "schema": { + "type": "string" + } + } + } + } + } + } + } + }, + "components": {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app47.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app47.json new file mode 100644 index 000000000..f8c62edc7 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app47.json @@ -0,0 +1,55 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "hello-controller", + "description": "The type Hello controller." + } + ], + "paths": { + "/documents/{locale}": { + "get": { + "tags": [ + "hello-controller" + ], + "summary": "Gets documents with locale.", + "description": "Gets documents with locale.", + "operationId": "getDocumentsWithLocale", + "parameters": [ + { + "name": "locale", + "in": "path", + "description": "the locale", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "the documents with locale", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + } + }, + "components": {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app48.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app48.json new file mode 100644 index 000000000..6b8033997 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app48.json @@ -0,0 +1,114 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "hello-controller", + "description": "The type Hello controller." + } + ], + "paths": { + "/documents/{locale}": { + "get": { + "tags": [ + "hello-controller" + ], + "summary": "Gets documents.", + "description": "Gets documents.", + "operationId": "getDocuments", + "responses": { + "400": { + "description": "the documents", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + }, + "401": { + "description": "the documents", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + }, + "402": { + "description": "the documents", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + }, + "403": { + "description": "the documents", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + }, + "410": { + "description": "the documents", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + }, + "411": { + "description": "the documents", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + }, + "412": { + "description": "the documents", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + }, + "413": { + "description": "the documents", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + } + }, + "components": {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app49.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app49.json new file mode 100644 index 000000000..878b849e5 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app49.json @@ -0,0 +1,49 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "hello-controller", + "description": "The type Hello controller." + } + ], + "paths": { + "/hello": { + "get": { + "tags": [ + "hello-controller" + ], + "description": "Obtain the list of services available in the system", + "operationId": "list", + "responses": { + "401": { + "$ref": "#/components/responses/Unauthorized" + } + } + } + } + }, + "components": { + "responses": { + "Unauthorized": { + "description": "Unauthorized", + "content": { + "application/json": { + "schema": { + "type": "string" + } + } + } + } + } + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app50.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app50.json new file mode 100644 index 000000000..bcf417178 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app50.json @@ -0,0 +1,59 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "hello-controller", + "description": "The type Hello controller." + } + ], + "paths": { + "/hello": { + "get": { + "tags": [ + "hello-controller" + ], + "description": "Some operation", + "operationId": "list", + "responses": { + "401": { + "description": "the list", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + } + } + } + } + } + } + }, + "components": { + "responses": { + "Unauthorized": { + "description": "Unauthorized", + "content": { + "application/json": { + "schema": { + "type": "string" + } + } + } + } + } + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app51.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app51.json new file mode 100644 index 000000000..420aff299 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app51.json @@ -0,0 +1,212 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "hello-controller", + "description": "The type Hello controller." + } + ], + "paths": { + "/": { + "post": { + "tags": [ + "hello-controller" + ], + "summary": "Hello response entity.", + "description": "Hello response entity.", + "operationId": "hello", + "requestBody": { + "description": "the map", + "content": { + "application/json": { + "schema": { + "type": "object", + "additionalProperties": { + "type": "object" + } + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "the response entity", + "content": { + "*/*": { + "schema": { + "type": "object", + "additionalProperties": { + "type": "object" + } + } + } + } + } + } + } + }, + "/test3": { + "get": { + "tags": [ + "hello-controller" + ], + "summary": "Test 3 string.", + "description": "Test 3 string.", + "operationId": "test3", + "parameters": [ + { + "name": "test_header", + "in": "header", + "required": true, + "schema": { + "type": "string", + "example": "rherherherherh" + } + }, + { + "name": "param1", + "in": "query", + "description": "desc1", + "required": true, + "schema": { + "type": "string", + "example": "something" + } + } + ], + "responses": { + "200": { + "description": "the string", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/test2": { + "get": { + "tags": [ + "hello-controller" + ], + "summary": "Test 2 string.", + "description": "Test 2 string.", + "operationId": "test2", + "parameters": [ + { + "name": "test_header", + "in": "header", + "required": true, + "schema": { + "type": "string", + "example": "rherherherherh" + } + }, + { + "name": "param1", + "in": "query", + "description": "the param 1", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "the string", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/test1": { + "get": { + "tags": [ + "hello-controller" + ], + "summary": "Test 1 string.", + "description": "Test 1 string.", + "operationId": "test1", + "parameters": [ + { + "name": "test_header", + "in": "header", + "required": true, + "schema": { + "type": "string", + "example": "rherherherherh" + } + } + ], + "responses": { + "200": { + "description": "the string", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/test/{path}": { + "get": { + "tags": [ + "hello-controller" + ], + "summary": "Get string.", + "description": "Get string.", + "operationId": "get", + "parameters": [ + { + "name": "path", + "in": "path", + "description": "the path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "the string", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + } + }, + "components": {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app52.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app52.json new file mode 100644 index 000000000..1904233b9 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app52.json @@ -0,0 +1,206 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "hello-controller", + "description": "The type Hello controller." + } + ], + "paths": { + "/test3": { + "post": { + "tags": [ + "hello-controller" + ], + "summary": "Create test 3 string.", + "description": "Create test 3 string.", + "operationId": "createTest3", + "requestBody": { + "content": { + "multipart/form-data": { + "schema": { + "type": "object", + "properties": { + "test": { + "$ref": "#/components/schemas/MyTestDto", + "description": "the test" + }, + "doc": { + "type": "array", + "description": "the multipart files", + "items": { + "type": "string", + "format": "binary" + } + } + }, + "required": [ + "doc", + "test" + ] + } + } + } + }, + "responses": { + "200": { + "description": "the string", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/test2/{username}": { + "post": { + "tags": [ + "hello-controller" + ], + "summary": "Create test 2 string.", + "description": "Create test 2 string.", + "operationId": "createTest2", + "parameters": [ + { + "name": "username", + "in": "path", + "description": "the username", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "multipart/form-data": { + "schema": { + "type": "object", + "properties": { + "image": { + "type": "string", + "format": "binary", + "description": "the image file" + }, + "test": { + "$ref": "#/components/schemas/MyTestDto", + "description": "the test" + } + }, + "required": [ + "image", + "test" + ] + } + } + } + }, + "responses": { + "200": { + "description": "the string", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/test1/{username}": { + "post": { + "tags": [ + "hello-controller" + ], + "summary": "Create test 1 string.", + "description": "Create test 1 string.", + "operationId": "createTest1", + "parameters": [ + { + "name": "username", + "in": "path", + "description": "the username", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "multipart/form-data": { + "schema": { + "type": "object", + "properties": { + "test": { + "$ref": "#/components/schemas/MyTestDto", + "description": "the test" + }, + "image": { + "type": "string", + "format": "binary", + "description": "the image file" + } + }, + "required": [ + "image", + "test" + ] + } + } + } + }, + "responses": { + "200": { + "description": "the string", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "MyTestDto": { + "type": "object", + "description": "The type My test dto.", + "properties": { + "object1": { + "type": "string", + "description": "The Object 1." + }, + "object2": { + "type": "string", + "description": "The Object 2." + }, + "object3": { + "type": "string", + "description": "The Object 3." + } + } + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app53.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app53.json new file mode 100644 index 000000000..734394892 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app53.json @@ -0,0 +1,246 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "hello-controller", + "description": "The type Hello controller." + }, + { + "name": "hello-controller-with-global-api-response", + "description": "The type Hello controller with global api response." + } + ], + "paths": { + "/hello7": { + "get": { + "tags": [ + "hello-controller" + ], + "description": "Some operation", + "operationId": "getNestedDTOWithDefaultResponseStatus", + "responses": { + "200": { + "description": "the nested dto with default response status", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/HelloDTO1" + } + } + } + } + } + } + }, + "/hello6": { + "get": { + "tags": [ + "hello-controller" + ], + "description": "Some operation", + "operationId": "getDTOWithDefaultResponseStatus", + "responses": { + "200": { + "description": "the dto with default response status", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/HelloDTO1" + } + } + } + } + } + } + }, + "/hello5": { + "get": { + "tags": [ + "hello-controller" + ], + "description": "Some operation", + "operationId": "listWithDefaultResponseStatus", + "responses": { + "200": { + "description": "the list", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + } + } + } + } + } + }, + "/hello4": { + "get": { + "tags": [ + "hello-controller" + ], + "description": "Some operation", + "operationId": "getDTOWithExplicitResponseStatus", + "responses": { + "204": { + "description": "the dto with explicit response status", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/HelloDTO1" + } + } + } + } + } + } + }, + "/hello3": { + "get": { + "tags": [ + "hello-controller" + ], + "description": "Some operation", + "operationId": "listWithExplicitResponseStatus", + "responses": { + "204": { + "description": "the list", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + } + } + } + } + } + }, + "/hello2": { + "get": { + "tags": [ + "hello-controller" + ], + "description": "Some operation", + "operationId": "listWithEmptyApiResponse", + "responses": { + "default": { + "description": "the list", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + } + } + } + } + } + }, + "/hello1": { + "get": { + "tags": [ + "hello-controller" + ], + "description": "Some operation", + "operationId": "listWithNoApiResponse", + "responses": { + "200": { + "description": "the list", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + } + } + } + } + } + }, + "/global/hello2": { + "get": { + "tags": [ + "hello-controller-with-global-api-response" + ], + "description": "Some operation", + "operationId": "listWithDefaultResponseStatus_1", + "responses": { + "200": { + "description": "Explicit description for this response", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + } + } + } + } + } + }, + "/global/hello1": { + "get": { + "tags": [ + "hello-controller-with-global-api-response" + ], + "description": "Some operation", + "operationId": "listWithNoApiResponse_1", + "responses": { + "204": { + "description": "Explicit description for this response", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "HelloDTO1": { + "type": "object", + "properties": { + "message": { + "type": "string", + "description": "The Message." + } + }, + "description": "The type Hello dto 1." + } + } + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app54.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app54.json new file mode 100644 index 000000000..9960fa129 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app54.json @@ -0,0 +1,151 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "hello-controller", + "description": "The type Hello controller." + } + ], + "paths": { + "/parties": { + "post": { + "tags": [ + "hello-controller" + ], + "summary": "Save meal party response entity.", + "description": "Save meal party response entity.", + "operationId": "saveMealParty", + "requestBody": { + "description": "the p", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/MealParty_Public" + } + } + } + }, + "responses": { + "200": { + "description": "the response entity", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/MealParty_MealPartyAdmin" + } + } + } + } + } + } + }, + "/new-parties": { + "post": { + "tags": [ + "hello-controller" + ], + "summary": "Save meal new party response entity.", + "description": "Save meal new party response entity.", + "operationId": "saveMealNewParty", + "requestBody": { + "description": "the p", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/MealParty_Public" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "the response entity", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/MealParty_MealPartyAdmin" + } + } + } + } + } + } + }, + "/parties/{id}": { + "get": { + "tags": [ + "hello-controller" + ], + "summary": "Gets meal party details [Meal party admin restricted]", + "description": "Gets meal party.", + "operationId": "getMealParty", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "the meal party id", + "required": true, + "schema": { + "type": "integer", + "format": "int64" + } + } + ], + "responses": { + "200": { + "description": "Successfully retrieved the meal party", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/MealParty_Public" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "MealParty_Public": { + "type": "object", + "properties": { + "name": { + "type": "string", + "description": "The Name." + } + }, + "description": "The type Meal party." + }, + "MealParty_MealPartyAdmin": { + "type": "object", + "properties": { + "name": { + "type": "string", + "description": "The Name." + }, + "members": { + "type": "array", + "description": "The Members.", + "items": { + "type": "string" + } + } + }, + "description": "The type Meal party." + } + } + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app55.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app55.json new file mode 100644 index 000000000..f43e74b75 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app55.json @@ -0,0 +1,38 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/ping": { + "get": { + "tags": [ + "health" + ], + "summary": "Simple health check", + "description": "Ping endpoint used for health checks.", + "operationId": "ping", + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "boolean" + } + } + } + } + } + } + } + }, + "components": {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app56.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app56.json new file mode 100644 index 000000000..68d1daf5a --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app56.json @@ -0,0 +1,67 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "hello-controller", + "description": "The type Hello controller." + } + ], + "paths": { + "/persons": { + "get": { + "tags": [ + "hello-controller" + ], + "summary": "Persons string.", + "description": "Persons string.", + "operationId": "persons", + "responses": { + "500": { + "description": "Internal server error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorDTO" + } + } + } + }, + "200": { + "description": "the string", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "ErrorDTO": { + "type": "object", + "properties": { + "errorMessage": { + "type": "string", + "description": "The Error message." + } + }, + "description": "The type Error dto." + } + } + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app57.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app57.json new file mode 100644 index 000000000..668fc728c --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app57.json @@ -0,0 +1,55 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "hello-controller", + "description": "The type Hello controller." + } + ], + "paths": { + "/{name}": { + "get": { + "tags": [ + "hello-controller" + ], + "summary": "Gets text.", + "description": "Gets text.", + "operationId": "getText", + "parameters": [ + { + "name": "name", + "in": "path", + "description": "desc", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "the text", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + } + }, + "components": {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app58.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app58.json new file mode 100644 index 000000000..22d347dd7 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app58.json @@ -0,0 +1,136 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "hello-controller", + "description": "The type Hello controller." + } + ], + "paths": { + "/examplePost": { + "post": { + "tags": [ + "hello-controller" + ], + "summary": "schema example", + "description": "Example object.", + "operationId": "example", + "responses": { + "200": { + "description": "the object", + "content": { + "*/*": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/foo": { + "get": { + "tags": [ + "hello-controller" + ], + "summary": "Foobar.", + "description": "Foobar.", + "operationId": "foobar", + "parameters": [ + { + "name": "user", + "in": "query", + "description": "User", + "required": true, + "schema": { + "$ref": "#/components/schemas/PersonDTO" + } + } + ], + "responses": { + "200": { + "description": "OK" + } + } + } + }, + "/foo1": { + "get": { + "tags": [ + "hello-controller" + ], + "summary": "Foobar 1.", + "description": "Foobar 1.", + "operationId": "foobar1", + "parameters": [ + { + "name": "user", + "in": "query", + "description": "User", + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/PersonDTO" + } + } + } + } + ], + "responses": { + "200": { + "description": "OK" + } + } + } + }, + "/example": { + "get": { + "tags": [ + "hello-controller" + ], + "summary": "Test.", + "description": "Test.", + "operationId": "test", + "responses": { + "200": { + "description": "OK" + } + } + } + } + }, + "components": { + "schemas": { + "PersonDTO": { + "type": "object", + "properties": { + "email": { + "type": "string", + "description": "The Email." + }, + "firstName": { + "type": "string", + "description": "The First name." + }, + "lastName": { + "type": "string", + "description": "The Last name." + } + }, + "description": "The type Person dto." + } + } + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app59.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app59.json new file mode 100644 index 000000000..d7ea16f1b --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app59.json @@ -0,0 +1,38 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "hello-controller", + "description": "The type Hello controller." + } + ], + "paths": { + "/example": { + "get": { + "tags": [ + "hello-controller" + ], + "summary": "Test.", + "description": "Test.", + "operationId": "test", + "responses": { + "200": { + "description": "OK" + } + }, + "deprecated": true + } + } + }, + "components": {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app6.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app6.json new file mode 100644 index 000000000..8ef6012de --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app6.json @@ -0,0 +1,69 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "hello-controller", + "description": "The type Hello controller." + } + ], + "paths": { + "/hello": { + "get": { + "tags": [ + "hello-controller" + ], + "summary": "Get Something by key", + "description": "Say hello response entity.", + "operationId": "sayHello", + "responses": { + "200": { + "description": "Successful Operation", + "content": { + "application/json": { + "schema": { + "type": "string", + "oneOf": [ + { + "type": "string" + }, + { + "type": "integer", + "format": "int32" + } + ] + }, + "examples": { + "The String example": { + "description": "The String example", + "value": "urgheiurgheirghieurg" + }, + "The Integer example": { + "description": "The Integer example", + "value": 311414 + } + } + } + } + }, + "404": { + "description": "Thing not found" + }, + "401": { + "description": "Authentication Failure" + } + } + } + } + }, + "components": {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app60.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app60.json new file mode 100644 index 000000000..7415af483 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app60.json @@ -0,0 +1,121 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "hello-controller", + "description": "The type Hello controller." + } + ], + "paths": { + "/hello2": { + "get": { + "tags": [ + "hello-controller" + ], + "summary": "summary2", + "description": "List 2 list.", + "operationId": "list2", + "parameters": [ + { + "name": "page", + "in": "query", + "description": "desc page from Annotated interface", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "size", + "in": "query", + "description": "desc page from Annotated interface", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "sort", + "in": "query", + "description": "desc sort from Annotated interface", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "the list", + "content": { + "*/*": { + "schema": { + "type": "array", + "items": { + "type": "object" + } + } + } + } + } + } + } + }, + "/hello1": { + "get": { + "tags": [ + "hello-controller" + ], + "summary": "summary1", + "description": "List 1 list.", + "operationId": "list1", + "parameters": [ + { + "name": "page", + "in": "query", + "description": "The page", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "size", + "in": "query", + "description": "The size", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "the list", + "content": { + "*/*": { + "schema": { + "type": "array", + "items": { + "type": "object" + } + } + } + } + } + } + } + } + }, + "components": {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app61.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app61.json new file mode 100644 index 000000000..a5fd6fc9e --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app61.json @@ -0,0 +1,94 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "hello-controller", + "description": "The type Hello controller." + } + ], + "paths": { + "/persons-with-user": { + "get": { + "tags": [ + "hello-controller" + ], + "description": "List", + "operationId": "persons", + "parameters": [ + { + "name": "name", + "in": "query", + "description": "Name", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "phone", + "in": "query", + "description": "Phone", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "createdFrom", + "in": "query", + "description": "createdFrom", + "required": true, + "content": { + "*/*": { + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + } + } + }, + { + "name": "createdRange", + "in": "query", + "description": "createdRange", + "required": true, + "schema": { + "maxItems": 2, + "minItems": 2, + "type": "array", + "items": { + "type": "string", + "format": "date" + } + } + } + ], + "responses": { + "200": { + "description": "the string", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + } + }, + "components": {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app62.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app62.json new file mode 100644 index 000000000..56e0db3bf --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app62.json @@ -0,0 +1,54 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/test": { + "get": { + "tags": [ + "Test Controller" + ], + "summary": "This is the test endpoint", + "description": "Test string.", + "operationId": "test", + "parameters": [ + { + "name": "Accept", + "in": "header", + "description": "the accept", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "the string", + "content": { + "application/xml": { + "schema": { + "type": "string" + } + }, + "application/json": { + "schema": { + "type": "string" + } + } + } + } + } + } + } + }, + "components": {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app63.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app63.json new file mode 100644 index 000000000..16823bacd --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app63.json @@ -0,0 +1,15 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": {}, + "components": {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app64.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app64.json new file mode 100644 index 000000000..1f5a97c2f --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app64.json @@ -0,0 +1,55 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "hello-controller", + "description": "The type Hello controller." + } + ], + "paths": { + "/api/balance/abcd": { + "get": { + "tags": [ + "hello-controller" + ], + "summary": "This is the test endpoint", + "description": "Test 2 string.", + "operationId": "test2", + "parameters": [ + { + "name": "from", + "in": "query", + "description": "the from", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "the string", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + } + }, + "components": {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app65.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app65.json new file mode 100644 index 000000000..30e140d3a --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app65.json @@ -0,0 +1,88 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "Health", + "description": "Health check / ping API" + } + ], + "paths": { + "/health": { + "get": { + "tags": [ + "Health" + ], + "summary": "Check server status", + "description": "Check server status, will return 200 with simple string if alive. Do nothing else.", + "operationId": "ping", + "responses": { + "200": { + "description": "the response entity", + "content": { + "text/plain": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/ping": { + "get": { + "tags": [ + "Health" + ], + "summary": "Check server status", + "description": "Check server status, will return 200 with simple string if alive. Do nothing else.", + "operationId": "ping_1", + "responses": { + "200": { + "description": "the response entity", + "content": { + "text/plain": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/": { + "get": { + "tags": [ + "Health" + ], + "summary": "Check server status", + "description": "Check server status, will return 200 with simple string if alive. Do nothing else.", + "operationId": "ping_2", + "responses": { + "200": { + "description": "the response entity", + "content": { + "text/plain": { + "schema": { + "type": "string" + } + } + } + } + } + } + } + }, + "components": {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app66.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app66.json new file mode 100644 index 000000000..997a89dbd --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app66.json @@ -0,0 +1,88 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "Health", + "description": "Health check / ping API" + } + ], + "paths": { + "/": { + "get": { + "tags": [ + "Health" + ], + "summary": "Check server status", + "description": "Check server status, will return 200 with simple string if alive. Do nothing else.", + "operationId": "ping_2", + "responses": { + "200": { + "description": "the response entity", + "content": { + "text/plain": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/health": { + "get": { + "tags": [ + "Health" + ], + "summary": "Check server status", + "description": "Check server status, will return 200 with simple string if alive. Do nothing else.", + "operationId": "ping", + "responses": { + "200": { + "description": "the response entity", + "content": { + "text/plain": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/ping": { + "get": { + "tags": [ + "Health" + ], + "summary": "Check server status", + "description": "Check server status, will return 200 with simple string if alive. Do nothing else.", + "operationId": "ping_1", + "responses": { + "200": { + "description": "the response entity", + "content": { + "text/plain": { + "schema": { + "type": "string" + } + } + } + } + } + } + } + }, + "components": {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app67.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app67.json new file mode 100644 index 000000000..5385070a9 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app67.json @@ -0,0 +1,188 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "hello-controller", + "description": "The type Hello controller." + } + ], + "paths": { + "/demo/operation4": { + "get": { + "tags": [ + "hello-controller" + ], + "summary": "Operation 4 (expected result - 3 parameters)", + "description": "Operation 4 string.", + "operationId": "operation4", + "parameters": [ + { + "name": "pageNumber", + "in": "query", + "description": "page number", + "schema": { + "type": "integer" + } + }, + { + "name": "pageSize", + "in": "query", + "description": "page size", + "schema": { + "type": "integer" + } + }, + { + "name": "sort", + "in": "query", + "description": "sort specification", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "the string", + "content": { + "text/plain": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/demo/operation3": { + "get": { + "tags": [ + "hello-controller" + ], + "summary": "Operation 3 (expected result - 3 parameters)", + "description": "Operation 3 string.", + "operationId": "operation3", + "parameters": [ + { + "name": "pageNumber", + "in": "query", + "description": "page number", + "schema": { + "type": "integer" + } + }, + { + "name": "pageSize", + "in": "query", + "description": "page size", + "schema": { + "type": "integer" + } + }, + { + "name": "sort", + "in": "query", + "description": "sort specification", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "the string", + "content": { + "text/plain": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/demo/operation2": { + "get": { + "tags": [ + "hello-controller" + ], + "summary": "Operation 2 (expected result - 3 parameters)", + "description": "Operation 2 string.", + "operationId": "operation2", + "parameters": [ + { + "name": "pageNumber", + "in": "query", + "description": "page number", + "schema": { + "type": "integer" + } + }, + { + "name": "pageSize", + "in": "query", + "description": "page size", + "schema": { + "type": "integer" + } + }, + { + "name": "sort", + "in": "query", + "description": "sort specification", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "the string", + "content": { + "text/plain": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/demo/operation1": { + "get": { + "tags": [ + "hello-controller" + ], + "summary": "Operation 1 (expected result - no parameters)", + "description": "Operation 1 string.", + "operationId": "operation1", + "responses": { + "200": { + "description": "the string", + "content": { + "text/plain": { + "schema": { + "type": "string" + } + } + } + } + } + } + } + }, + "components": {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app69.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app69.json new file mode 100644 index 000000000..e76fa359b --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app69.json @@ -0,0 +1,76 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "hello-controller", + "description": "The type Hello controller." + } + ], + "paths": { + "/tasks": { + "get": { + "tags": [ + "hello-controller" + ], + "summary": "Gets tasks.", + "description": "Gets tasks.", + "operationId": "getTasks", + "parameters": [ + { + "name": "str", + "in": "query", + "description": "the str", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "the tasks", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/PersonDTO" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "PersonDTO": { + "type": "object", + "properties": { + "email": { + "type": "string", + "description": "The Email." + }, + "firstName": { + "type": "string", + "description": "The First name." + }, + "lastName": { + "type": "string", + "description": "The Last name." + } + }, + "description": "The type Person dto." + } + } + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app7.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app7.json new file mode 100644 index 000000000..f91a3e405 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app7.json @@ -0,0 +1,48 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "hello-controller", + "description": "The type Hello controller." + } + ], + "paths": { + "/test": { + "post": { + "tags": [ + "hello-controller" + ], + "summary": "test Request", + "description": "Search employee.", + "operationId": "searchEmployee", + "requestBody": { + "description": "test value", + "content": { + "application/json": { + "schema": { + "type": "string" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "OK" + } + } + } + } + }, + "components": {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app70.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app70.json new file mode 100644 index 000000000..b64b8dbca --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app70.json @@ -0,0 +1,69 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "hello-controller", + "description": "The type Hello controller." + } + ], + "paths": { + "/example/{test}": { + "get": { + "tags": [ + "hello-controller" + ], + "description": "Some operation, customized operation!", + "operationId": "test", + "parameters": [ + { + "name": "test", + "in": "path", + "description": "Parameter description, customized parameter!", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "the api type", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/ApiType" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "ApiType": { + "type": "object", + "description": "The type Api type.", + "properties": { + "someProperty": { + "type": "string", + "format": "duration", + "description": "Test description", + "properties": {} + } + } + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app71.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app71.json new file mode 100644 index 000000000..c77a6c2b4 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app71.json @@ -0,0 +1,69 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "hello-controller", + "description": "The type Hello controller." + } + ], + "paths": { + "/persons": { + "post": { + "tags": [ + "hello-controller" + ], + "summary": "Persons string.", + "description": "Persons string.", + "operationId": "persons", + "parameters": [ + { + "name": "dog", + "in": "query", + "description": "the dog", + "required": true, + "schema": { + "$ref": "#/components/schemas/Dog" + } + } + ], + "responses": { + "200": { + "description": "the string", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "Dog": { + "type": "object", + "properties": { + "display_name": { + "type": "string", + "description": "A name given to the Dog", + "example": "Fido" + } + }, + "description": "The type Dog." + } + } + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app73.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app73.json new file mode 100644 index 000000000..77d68b7fe --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app73.json @@ -0,0 +1,172 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "hello-controller", + "description": "The type Hello controller." + } + ], + "paths": { + "/{country_code}/persons/{id}": { + "get": { + "tags": [ + "hello-controller" + ], + "summary": "Get string.", + "description": "Get string.", + "operationId": "get", + "parameters": [ + { + "name": "country_code", + "in": "query", + "description": "the country code", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "id", + "in": "path", + "description": "the id", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "the string", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + }, + "delete": { + "tags": [ + "hello-controller" + ], + "summary": "Delete.", + "description": "Delete.", + "operationId": "delete", + "parameters": [ + { + "name": "country_code", + "in": "query", + "description": "the country code", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "id", + "in": "path", + "description": "the id", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "204": { + "description": "No Content" + } + } + } + }, + "/persons/{id}": { + "get": { + "tags": [ + "hello-controller" + ], + "summary": "Get string.", + "description": "Get string.", + "operationId": "get_1", + "parameters": [ + { + "name": "country_code", + "in": "query", + "description": "the country code", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "id", + "in": "path", + "description": "the id", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "the string", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + }, + "delete": { + "tags": [ + "hello-controller" + ], + "summary": "Delete.", + "description": "Delete.", + "operationId": "delete_1", + "parameters": [ + { + "name": "country_code", + "in": "query", + "description": "the country code", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "id", + "in": "path", + "description": "the id", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "204": { + "description": "No Content" + } + } + } + } + }, + "components": {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app74.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app74.json new file mode 100644 index 000000000..4c4ecb9f0 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app74.json @@ -0,0 +1,55 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "hello-controller", + "description": "The type Hello controller." + } + ], + "paths": { + "/test": { + "post": { + "tags": [ + "hello-controller" + ], + "summary": "Post my request body string.", + "description": "Post my request body string.", + "operationId": "postMyRequestBody", + "requestBody": { + "description": "the my request body", + "content": { + "application/json": { + "schema": { + "type": "string" + }, + "example": "sample" + } + } + }, + "responses": { + "200": { + "description": "the string", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + } + }, + "components": {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app75.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app75.json new file mode 100644 index 000000000..8e5e05b43 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app75.json @@ -0,0 +1,178 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "hello-controller", + "description": "The type Hello controller." + } + ], + "paths": { + "/test3/{uuid}": { + "post": { + "tags": [ + "hello-controller" + ], + "summary": "Example api that realize an ECHO operation", + "description": "The result of the echo is the input value of the api", + "operationId": "postMyRequestBody3", + "parameters": [ + { + "name": "uuid", + "in": "path", + "description": "Is the identification of the document", + "required": true, + "schema": { + "type": "string", + "example": "uuid" + } + } + ], + "responses": { + "200": { + "description": "the response entity", + "content": { + "*/*": { + "schema": { + "type": "array", + "items": { + "type": "object" + } + } + } + } + }, + "201": { + "description": "other possible response", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/test2/{uuid}": { + "post": { + "tags": [ + "hello-controller" + ], + "summary": "Example api that realize an ECHO operation", + "description": "The result of the echo is the input value of the api", + "operationId": "postMyRequestBody2", + "parameters": [ + { + "name": "uuid", + "in": "path", + "description": "Is the identification of the document", + "required": true, + "schema": { + "type": "string", + "example": "uuid" + } + } + ], + "responses": { + "200": { + "description": "Successful Operation", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/PersonDTO" + } + } + } + }, + "201": { + "description": "other possible response", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/test1/{uuid}": { + "post": { + "tags": [ + "hello-controller" + ], + "summary": "Example api that realize an ECHO operation", + "description": "The result of the echo is the input value of the api", + "operationId": "postMyRequestBody1", + "parameters": [ + { + "name": "uuid", + "in": "path", + "description": "Is the identification of the document", + "required": true, + "schema": { + "type": "string", + "example": "uuid" + } + } + ], + "responses": { + "200": { + "description": "Successful Operation", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/PersonDTO" + } + } + } + }, + "201": { + "description": "other possible response", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "PersonDTO": { + "type": "object", + "properties": { + "email": { + "type": "string", + "description": "The Email." + }, + "firstName": { + "type": "string", + "description": "The First name." + }, + "lastName": { + "type": "string", + "description": "The Last name." + } + }, + "description": "The type Person dto." + } + } + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app76.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app76.json new file mode 100644 index 000000000..dff90ed52 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app76.json @@ -0,0 +1,83 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "security": [ + { + "bearer-jwt": [ + "read", + "write" + ] + } + ], + "tags": [ + { + "name": "hello-controller", + "description": "The type Hello controller." + } + ], + "paths": { + "/secure": { + "get": { + "tags": [ + "hello-controller" + ], + "summary": "Secured string.", + "description": "Secured string.", + "operationId": "secured", + "responses": { + "200": { + "description": "the string", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/open": { + "get": { + "tags": [ + "hello-controller" + ], + "summary": "Open string.", + "description": "Open string.", + "operationId": "open", + "responses": { + "200": { + "description": "the string", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + }, + "security": [] + } + } + }, + "components": { + "securitySchemes": { + "bearer-jwt": { + "type": "http", + "scheme": "bearer", + "bearerFormat": "JWT" + } + } + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app77.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app77.json new file mode 100644 index 000000000..0d5e8e402 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app77.json @@ -0,0 +1,90 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "hello-controller", + "description": "The type Hello controller." + } + ], + "paths": { + "/persons": { + "get": { + "tags": [ + "hello-controller" + ], + "summary": "Persons.", + "description": "Persons.", + "operationId": "persons", + "parameters": [ + { + "name": "name", + "in": "query", + "description": "the name", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "default": { + "description": "default response", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + }, + "x-is-file": "true" + } + } + } + }, + "/persons2": { + "get": { + "tags": [ + "hello-controller" + ], + "summary": "Persons 2.", + "description": "Persons 2.", + "operationId": "persons2", + "parameters": [ + { + "name": "name", + "in": "query", + "description": "the name", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "default": { + "description": "default response", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + }, + "x-is-file": "true" + } + } + } + } + }, + "components": {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app78.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app78.json new file mode 100644 index 000000000..540fffb87 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app78.json @@ -0,0 +1,109 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "hello-controller", + "description": "The type Hello controller." + } + ], + "paths": { + "/person2": { + "get": { + "tags": [ + "hello-controller" + ], + "summary": "Gets person 2.", + "description": "Gets person 2.", + "operationId": "getPerson2", + "parameters": [ + { + "name": "str", + "in": "query", + "description": "the str", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "the person 2", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/PersonDTO" + } + } + } + } + } + } + }, + "/person1": { + "get": { + "tags": [ + "hello-controller" + ], + "summary": "Gets person 1.", + "description": "Gets person 1.", + "operationId": "getPerson1", + "parameters": [ + { + "name": "str", + "in": "query", + "description": "the str", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "the person 1", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/PersonDTO" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "PersonDTO": { + "type": "object", + "properties": { + "email": { + "type": "string", + "description": "The Email." + }, + "firstName": { + "type": "string", + "description": "The First name." + }, + "lastName": { + "type": "string", + "description": "The Last name." + } + }, + "description": "The type Person dto." + } + } + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app79.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app79.json new file mode 100644 index 000000000..1dfccd26c --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app79.json @@ -0,0 +1,55 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "hello-controller", + "description": "The type Hello controller." + } + ], + "paths": { + "/test": { + "get": { + "tags": [ + "hello-controller" + ], + "summary": "Echo string.", + "description": "Echo string.", + "operationId": "echo", + "parameters": [ + { + "name": "text", + "in": "query", + "description": "the text", + "required": false, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "the string", + "content": { + "text/plain": { + "schema": { + "type": "string" + } + } + } + } + } + } + } + }, + "components": {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app8.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app8.json new file mode 100644 index 000000000..e87dfaabc --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app8.json @@ -0,0 +1,73 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/test": { + "put": { + "tags": [ + "hello-controller" + ], + "operationId": "put", + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "configuration": { + "type": "string" + }, + "second": { + "type": "string" + }, + "personDTO": { + "$ref": "#/components/schemas/PersonDTO" + } + } + } + } + } + }, + "responses": { + "200": { + "description": "default response", + "content": { + "*/*": { + "schema": { + "type": "object" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "PersonDTO": { + "type": "object", + "properties": { + "email": { + "type": "string" + }, + "firstName": { + "type": "string" + }, + "lastName": { + "type": "string" + } + } + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app80.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app80.json new file mode 100644 index 000000000..3dfc18569 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app80.json @@ -0,0 +1,95 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "hello-controller", + "description": "The type Hello controller." + } + ], + "paths": { + "/api/hello": { + "get": { + "tags": [ + "hello-controller" + ], + "summary": "Hello response entity.", + "description": "Hello response entity.", + "operationId": "hello", + "responses": { + "200": { + "description": "the response entity", + "content": { + "application/json": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/api/testpost1": { + "post": { + "tags": [ + "hello-controller" + ], + "summary": "Testpost 1 response entity.", + "description": "Testpost 1 response entity.", + "operationId": "testpost1", + "requestBody": { + "description": "the dto", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/TestObject" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "the response entity", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/TestObject" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "TestObject": { + "type": "object", + "properties": { + "localDateTime": { + "type": "string", + "description": "The Local date time.", + "format": "date-time" + }, + "stringValue": { + "type": "string", + "description": "The String value." + } + }, + "description": "The type Test object." + } + } + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app82.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app82.json new file mode 100644 index 000000000..e46be40ac --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app82.json @@ -0,0 +1,94 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "hello-controller", + "description": "The type Hello controller." + } + ], + "paths": { + "/test": { + "put": { + "tags": [ + "hello-controller" + ], + "summary": "Put response entity.", + "description": "Put response entity.", + "operationId": "put", + "parameters": [ + { + "name": "configuration", + "in": "query", + "description": "the configuration", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "second", + "in": "query", + "description": "the second", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "personDTO", + "in": "query", + "description": "the person dto", + "required": true, + "schema": { + "$ref": "#/components/schemas/PersonDTO" + } + } + ], + "responses": { + "200": { + "description": "the response entity", + "content": { + "*/*": { + "schema": { + "type": "object" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "PersonDTO": { + "type": "object", + "properties": { + "email": { + "type": "string", + "description": "The Email." + }, + "firstName": { + "type": "string", + "description": "The First name." + }, + "lastName": { + "type": "string", + "description": "The Last name." + } + }, + "description": "The type Person dto." + } + } + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app83.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app83.json new file mode 100644 index 000000000..9eaa8558e --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app83.json @@ -0,0 +1,80 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "hello-controller", + "description": "The type Hello controller." + } + ], + "paths": { + "/{config}": { + "put": { + "tags": [ + "hello-controller" + ], + "summary": "Put response entity.", + "description": "Put response entity.", + "operationId": "put", + "parameters": [ + { + "name": "config", + "in": "path", + "description": "the config", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "multipart/form-data": { + "schema": { + "required": [ + "configuration", + "file" + ], + "type": "object", + "properties": { + "configuration": { + "type": "string", + "description": "the configuration", + "format": "binary" + }, + "file": { + "type": "string", + "description": "the a file", + "format": "binary" + } + } + } + } + } + }, + "responses": { + "200": { + "description": "the response entity", + "content": { + "application/json": { + "schema": { + "type": "object" + } + } + } + } + } + } + } + }, + "components": {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app84.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app84.json new file mode 100644 index 000000000..90de7138c --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app84.json @@ -0,0 +1,77 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "hello-controller", + "description": "The type Hello controller." + } + ], + "paths": { + "/api/persons": { + "get": { + "tags": [ + "hello-controller" + ], + "summary": "Persons string.", + "description": "Persons string.", + "operationId": "persons", + "responses": { + "200": { + "description": "the string", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/api/persons1": { + "get": { + "tags": [ + "hello-controller" + ], + "summary": "Persons string.", + "description": "Persons string.", + "operationId": "persons_1", + "parameters": [ + { + "name": "toto", + "in": "query", + "description": "the toto", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "the string", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + } + }, + "components": {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app85.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app85.json new file mode 100644 index 000000000..6ca1b1c32 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app85.json @@ -0,0 +1,54 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "hello-controller", + "description": "The type Hello controller." + } + ], + "paths": { + "/api/test/{id}": { + "post": { + "tags": [ + "hello-controller" + ], + "summary": "Testme.", + "description": "Testme.", + "operationId": "testme", + "parameters": [ + { + "$ref": "#/components/parameters/paramA" + }, + { + "$ref": "#/components/parameters/paramB" + }, + { + "name": "id", + "in": "path", + "description": "the id", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK" + } + } + } + } + }, + "components": {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app86.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app86.json new file mode 100644 index 000000000..c63fb2931 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app86.json @@ -0,0 +1,48 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "hello-controller", + "description": "The type Hello controller." + } + ], + "paths": { + "/test": { + "get": { + "tags": [ + "hello-controller" + ], + "summary": "Test.", + "description": "Test.", + "operationId": "test", + "parameters": [ + { + "name": "hello", + "in": "query", + "description": "the hello", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK" + } + } + } + } + }, + "components": {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app87.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app87.json new file mode 100644 index 000000000..d97ae618f --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app87.json @@ -0,0 +1,82 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "hello-controller", + "description": "The type Hello controller." + } + ], + "paths": { + "/{itemId}": { + "put": { + "tags": [ + "hello-controller" + ], + "summary": "Put item response entity.", + "description": "Put item response entity.", + "operationId": "putItem", + "parameters": [ + { + "name": "cookie", + "in": "cookie", + "description": "the cookie", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "itemId", + "in": "path", + "description": "the item id", + "required": true, + "schema": { + "type": "string", + "format": "uuid" + } + } + ], + "requestBody": { + "description": "the item", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Item" + } + } + } + }, + "responses": { + "200": { + "description": "the response entity", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/Item" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "Item": { + "type": "object", + "description": "The type Item." + } + } + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app88.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app88.json new file mode 100644 index 000000000..e49840b77 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app88.json @@ -0,0 +1,35 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/persons": { + "get": { + "summary": "Persons string.", + "description": "Persons string.", + "operationId": "persons", + "responses": { + "200": { + "description": "the string", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + } + }, + "components": {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app89.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app89.json new file mode 100644 index 000000000..5de4a5547 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app89.json @@ -0,0 +1,55 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "hello-controller", + "description": "The type Hello controller." + } + ], + "paths": { + "/status/{id}": { + "get": { + "tags": [ + "hello-controller" + ], + "summary": "Get Status", + "description": "Gets address.", + "operationId": "getAddress", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "the id", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "the address", + "content": { + "text/html": { + "schema": { + "type": "object" + } + } + } + } + } + } + } + }, + "components": {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app9.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app9.json new file mode 100644 index 000000000..b3a4002a0 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app9.json @@ -0,0 +1,64 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "my-api-controller", + "description": "The type My api controller." + } + ], + "paths": { + "/myapi": { + "get": { + "tags": [ + "my-api-controller" + ], + "description": "Annotations from interfaces test", + "operationId": "get", + "responses": { + "200": { + "description": "the string", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/myapi/getCode": { + "get": { + "tags": [ + "my-api-controller" + ], + "description": "Annotations from class with hidden parameter code", + "operationId": "getCode", + "responses": { + "200": { + "description": "the code", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + } + }, + "components": {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app90.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app90.json new file mode 100644 index 000000000..8c9354cd0 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app90.json @@ -0,0 +1,161 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "hello-controller", + "description": "The type Hello controller." + } + ], + "paths": { + "/test2": { + "post": { + "tags": [ + "hello-controller" + ], + "summary": "Test 2.", + "description": "Test 2.", + "operationId": "test2", + "requestBody": { + "description": "Details of the Item to be created", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/User" + }, + "examples": { + "An example request with the minimum required fields to create.": { + "summary": "Minimal request", + "description": "An example request with the minimum required fields to create.", + "value": "min" + }, + "An example request with all fields provided with example values.": { + "summary": "Full request", + "description": "An example request with all fields provided with example values.", + "value": "full" + } + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "OK" + } + } + } + }, + "/test": { + "get": { + "tags": [ + "hello-controller" + ], + "summary": "Test 1.", + "description": "Test 1.", + "operationId": "test1", + "parameters": [ + { + "name": "hello", + "in": "query", + "description": "the hello", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "default": { + "description": "successful operation", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/User" + }, + "examples": { + "500": { + "$ref": "#/components/examples/http500Example" + } + } + }, + "application/xml": { + "schema": { + "$ref": "#/components/schemas/User" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "User": { + "type": "object", + "description": "User", + "properties": { + "id": { + "type": "integer", + "format": "int64", + "description": "The Id.", + "example": 10 + }, + "username": { + "type": "string", + "description": "The Username.", + "example": "theUser" + }, + "firstName": { + "type": "string", + "description": "The First name.", + "example": "John" + }, + "lastName": { + "type": "string", + "description": "The Last name.", + "example": "James" + }, + "email": { + "type": "string", + "description": "The Email.", + "example": "john@email.com" + }, + "password": { + "type": "string", + "description": "The Password.", + "example": 12345 + }, + "phone": { + "type": "string", + "description": "The Phone.", + "example": 12345 + }, + "userStatus": { + "type": "integer", + "format": "int32", + "description": "User Status", + "example": 1 + } + } + } + }, + "examples": { + "http500Example": { + "summary": "HTTP 500 JSON Body response example", + "description": "An example of HTTP response in case an error occurs on server side. instance attribute reference a traceId to ease server side analysis.", + "value": "{\"500\":{\"$ref\":\"#/components/examples/http500Example\"}}" + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app91.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app91.json new file mode 100644 index 000000000..a06b5e714 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app91.json @@ -0,0 +1,101 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "Demo", + "description": "The Demo API" + } + ], + "paths": { + "/": { + "get": { + "tags": [ + "Demo" + ], + "summary": "This API will return a random greeting.", + "description": "Say hello response entity.", + "operationId": "sayHello", + "responses": { + "200": { + "description": "the response entity", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Greeting" + } + } + } + } + } + } + }, + "/test": { + "get": { + "tags": [ + "Demo" + ], + "summary": "Say hello 2 response entity.", + "description": "Say hello 2 response entity.", + "operationId": "sayHello2", + "responses": { + "201": { + "description": "item created", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/Greeting" + } + } + } + }, + "400": { + "description": "invalid input, object invalid", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/Greeting" + } + } + } + }, + "409": { + "description": "an existing item already exists", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/Greeting" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "Greeting": { + "title": "Greeting", + "type": "object", + "properties": { + "payload": { + "type": "string", + "description": "The greeting value", + "example": "sdfsdfs" + } + }, + "description": "An object containing a greeting message" + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app92.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app92.json new file mode 100644 index 000000000..db80d69ad --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app92.json @@ -0,0 +1,55 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "hello-controller", + "description": "The type Hello controller." + } + ], + "paths": { + "/test": { + "get": { + "tags": [ + "hello-controller" + ], + "summary": "Index string.", + "description": "Index string.", + "operationId": "index", + "parameters": [ + { + "name": "test", + "in": "query", + "description": "the test", + "required": false, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "the string", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + } + }, + "components": {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app93.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app93.json new file mode 100644 index 000000000..27f24b85e --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app93.json @@ -0,0 +1,73 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "specific-controller", + "description": "The type Specific controller." + } + ], + "paths": { + "/": { + "get": { + "tags": [ + "specific-controller" + ], + "summary": "Get t client model.", + "description": "Get t client model.", + "operationId": "get", + "parameters": [ + { + "name": "param", + "in": "query", + "description": "the param", + "required": true, + "schema": { + "$ref": "#/components/schemas/SpecificClientModel" + } + } + ], + "responses": { + "200": { + "description": "the t client model", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/SpecificClientModel" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "SpecificClientModel": { + "type": "object", + "properties": { + "id": { + "type": "integer", + "description": "The Id.", + "format": "int32" + }, + "name": { + "type": "string", + "description": "The Name." + } + }, + "description": "The type Specific client model." + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app94.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app94.json new file mode 100644 index 000000000..7ecc8ba42 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app94.json @@ -0,0 +1,79 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "Demo", + "description": "The Demo API" + } + ], + "paths": { + "/test": { + "get": { + "tags": [ + "Demo" + ], + "summary": "Say hello 2 response entity.", + "description": "Say hello 2 response entity.", + "operationId": "sayHello2", + "responses": { + "201": { + "description": "item created", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Greeting" + } + } + } + }, + "400": { + "description": "invalid input, object invalid", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Greeting" + } + } + } + }, + "409": { + "description": "an existing item already exists", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Greeting" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "Greeting": { + "title": "Greeting", + "type": "object", + "properties": { + "payload": { + "type": "string", + "description": "The greeting value", + "example": "sdfsdfs" + } + }, + "description": "An object containing a greeting message" + } + } + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app95.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app95.json new file mode 100644 index 000000000..c8a738efd --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app95.json @@ -0,0 +1,48 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "hello-controller", + "description": "The type Hello controller." + } + ], + "paths": { + "/persons": { + "get": { + "tags": [ + "hello-controller" + ], + "summary": "Summary of operation persons", + "description": "Description of operation persons", + "operationId": "persons", + "parameters": [ + { + "name": "name", + "in": "query", + "description": "Description of parameter name", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK" + } + } + } + } + }, + "components": {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app96.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app96.json new file mode 100644 index 000000000..f13560b17 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app96.json @@ -0,0 +1,123 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "hello-controller", + "description": "The type Hello controller." + } + ], + "paths": { + "/api1": { + "post": { + "tags": [ + "hello-controller" + ], + "summary": "Test 1 string.", + "description": "Test 1 string.", + "operationId": "test1", + "requestBody": { + "description": "the test", + "content": { + "application/json": { + "schema": { + "minimum": 2, + "type": "integer", + "format": "int32" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "the string", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/api2": { + "post": { + "tags": [ + "hello-controller" + ], + "summary": "Test 2 string.", + "description": "Test 2 string.", + "operationId": "test2", + "requestBody": { + "description": "the test", + "content": { + "application/json": { + "schema": { + "type": "string" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "the string", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/api3": { + "post": { + "tags": [ + "hello-controller" + ], + "summary": "Test 3 string.", + "description": "Test 3 string.", + "operationId": "test3", + "parameters": [ + { + "name": "test", + "in": "query", + "description": "the test", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "the string", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + } + }, + "components": {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app97.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app97.json new file mode 100644 index 000000000..be77ef3b3 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app97.json @@ -0,0 +1,154 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "hello-controller", + "description": "The type Hello controller." + } + ], + "paths": { + "/api/student/header3": { + "get": { + "tags": [ + "hello-controller" + ], + "summary": "Header v 3 student v 3.", + "description": "Header v 3 student v 3.", + "operationId": "headerV3", + "parameters": [ + { + "name": "X-API-VERSION", + "in": "header", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "the student v 3", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/StudentV3" + } + } + } + } + } + } + }, + "/api/student/header2": { + "get": { + "tags": [ + "hello-controller" + ], + "summary": "Header v 2 student v 2.", + "description": "Header v 2 student v 2.", + "operationId": "headerV2", + "parameters": [ + { + "name": "X-API-VERSION", + "in": "header", + "schema": { + "type": "string", + "enum": [ + "2" + ] + } + } + ], + "responses": { + "200": { + "description": "the student v 2", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/StudentV2" + } + } + } + } + } + } + }, + "/api/student/header1": { + "get": { + "tags": [ + "hello-controller" + ], + "summary": "Header v 1 student v 1.", + "description": "Header v 1 student v 1.", + "operationId": "headerV1", + "parameters": [ + { + "name": "X-API-VERSION", + "in": "header", + "schema": { + "type": "string", + "enum": [ + "1" + ] + } + } + ], + "responses": { + "200": { + "description": "the student v 1", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/StudentV1" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "StudentV3": { + "type": "object", + "properties": { + "name": { + "type": "string", + "description": "The Name." + } + }, + "description": "The type Student v 3." + }, + "StudentV2": { + "type": "object", + "properties": { + "bb": { + "type": "string", + "description": "The Name." + } + }, + "description": "The type Student v 2." + }, + "StudentV1": { + "type": "object", + "properties": { + "name": { + "type": "string", + "description": "The Name." + } + }, + "description": "The type Student v 1." + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app98.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app98.json new file mode 100644 index 000000000..b3e434687 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app98.json @@ -0,0 +1,37 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "hello-controller", + "description": "The type Hello controller." + } + ], + "paths": { + "/persons": { + "get": { + "tags": [ + "hello-controller" + ], + "summary": "Persons.", + "description": "Persons.", + "operationId": "persons", + "responses": { + "200": { + "description": "OK" + } + } + } + } + }, + "components": {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app99.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app99.json new file mode 100644 index 000000000..9024dd52d --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/3.1.0/app99.json @@ -0,0 +1,37 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "tags": [ + { + "name": "hello-controller", + "description": "The type Hello controller." + } + ], + "paths": { + "/persons": { + "get": { + "tags": [ + "hello-controller" + ], + "summary": "Persons.", + "description": "Persons.", + "operationId": "persons", + "responses": { + "202": { + "description": "Description of api response 202" + } + } + } + } + }, + "components": {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app162.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app162.json deleted file mode 100644 index 10fea0271..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app162.json +++ /dev/null @@ -1,342 +0,0 @@ -{ - "openapi": "3.0.1", - "info": { - "title": "SpringShop API", - "description": "The description of the api", - "version": "v1" - }, - "servers": [ - { - "url": "http://localhost", - "description": "Generated server url" - } - ], - "tags": [ - { - "name": "javadoc-only-rest-controller", - "description": "This is the JavadocOnlyRestController class javadoc." - } - ], - "paths": { - "/javadoc-only": { - "get": { - "tags": [ - "javadoc-only-rest-controller" - ], - "summary": "This is the list method's javadoc.", - "description": "This is the list method's javadoc.\n The method's signature: #list()", - "operationId": "list", - "responses": { - "200": { - "description": "the @return javadoc for the #list() method", - "content": { - "application/json": { - "schema": { - "type": "array", - "items": { - "$ref": "#/components/schemas/JavadocOnlyRestDto" - } - } - } - } - }, - "400": { - "description": "the return javadoc for the #handleNonUniqueResultException(NonUniqueResultException) method", - "content": { - "*/*": { - "schema": { - "type": "string" - } - } - }, - "x-exception-class": [ - "test.org.springdoc.api.app162.exception.NonUniqueResultException" - ] - }, - "404": { - "description": "the return javadoc for the #handleNotFoundException(NoResultException) method", - "content": { - "*/*": { - "schema": { - "type": "string" - } - } - }, - "x-exception-class": [ - "test.org.springdoc.api.app162.exception.NoResultException" - ] - } - } - }, - "post": { - "tags": [ - "javadoc-only-rest-controller" - ], - "summary": "This is the create method's javadoc.", - "description": "This is the create method's javadoc.\n The method's signature: #create(JavadocOnlyRestDto)", - "operationId": "create", - "requestBody": { - "description": "the @param input javadoc for the #create(JavadocOnlyRestDto) method", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/JavadocOnlyRestDto" - } - } - }, - "required": true - }, - "responses": { - "201": { - "description": "the @return javadoc for the #create(JavadocOnlyRestDto) method", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/JavadocOnlyRestDto" - } - } - } - }, - "400": { - "description": "the return javadoc for the #handleNonUniqueResultException(NonUniqueResultException) method", - "content": { - "*/*": { - "schema": { - "type": "string" - } - } - }, - "x-exception-class": [ - "test.org.springdoc.api.app162.exception.NonUniqueResultException" - ] - }, - "404": { - "description": "the return javadoc for the #handleNotFoundException(NoResultException) method", - "content": { - "*/*": { - "schema": { - "type": "string" - } - } - }, - "x-exception-class": [ - "test.org.springdoc.api.app162.exception.NoResultException" - ] - } - } - } - }, - "/javadoc-only/startsBy/{prefix}": { - "get": { - "tags": [ - "javadoc-only-rest-controller" - ], - "summary": "This is the findStartsBy method's javadoc.", - "description": "This is the findStartsBy method's javadoc.\n The method's signature: #findStartsBy(String)", - "operationId": "findStartsBy", - "parameters": [ - { - "name": "prefix", - "in": "path", - "description": "the @param prefix javadoc for the #findStartsBy(String) method", - "required": true, - "schema": { - "type": "string" - } - } - ], - "responses": { - "200": { - "description": "the @return javadoc for the #findStartsBy(String) method", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/JavadocOnlyRestDto" - } - } - } - }, - "400": { - "description": "the @throws NonUniqueResultException javadoc for the #findStartsBy(String) method", - "content": { - "*/*": { - "schema": { - "type": "string" - } - } - }, - "x-exception-class": [ - "test.org.springdoc.api.app162.exception.NonUniqueResultException" - ] - }, - "404": { - "description": "the @throws NoResultException javadoc for the #findStartsBy(String) method", - "content": { - "*/*": { - "schema": { - "type": "string" - } - } - }, - "x-exception-class": [ - "test.org.springdoc.api.app162.exception.NoResultException" - ] - } - } - } - }, - "/javadoc-only/{guid}": { - "get": { - "tags": [ - "javadoc-only-rest-controller" - ], - "summary": "This is the find method's javadoc.", - "description": "This is the find method's javadoc.\n The method's signature: #find(String)", - "operationId": "find", - "parameters": [ - { - "name": "guid", - "in": "path", - "description": "the @param guid javadoc for the #find(String) method", - "required": true, - "schema": { - "type": "string" - } - } - ], - "responses": { - "200": { - "description": "the @return javadoc for the #find(String) method", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/JavadocOnlyRestDto" - } - } - } - }, - "400": { - "description": "the return javadoc for the #handleNonUniqueResultException(NonUniqueResultException) method", - "content": { - "*/*": { - "schema": { - "type": "string" - } - } - }, - "x-exception-class": [ - "test.org.springdoc.api.app162.exception.NonUniqueResultException" - ] - }, - "404": { - "description": "the @throws NoResultException javadoc for the #find(String) method", - "content": { - "*/*": { - "schema": { - "type": "string" - } - } - }, - "x-exception-class": [ - "test.org.springdoc.api.app162.exception.NoResultException" - ] - } - } - }, - "put": { - "tags": [ - "javadoc-only-rest-controller" - ], - "summary": "This is the update method's javadoc.", - "description": "This is the update method's javadoc.\n The method's signature: #update(String, JavadocOnlyRestDto)", - "operationId": "update", - "parameters": [ - { - "name": "guid", - "in": "path", - "description": "the @param input javadoc for the #update(String, JavadocOnlyRestDto) method", - "required": true, - "schema": { - "type": "string" - } - } - ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/JavadocOnlyRestDto" - } - } - }, - "required": true - }, - "responses": { - "200": { - "description": "the @return javadoc for the #update(String, JavadocOnlyRestDto) method", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/JavadocOnlyRestDto" - } - } - } - }, - "400": { - "description": "the return javadoc for the #handleNonUniqueResultException(NonUniqueResultException) method", - "content": { - "*/*": { - "schema": { - "type": "string" - } - } - }, - "x-exception-class": [ - "test.org.springdoc.api.app162.exception.NonUniqueResultException" - ] - }, - "404": { - "description": "the return javadoc for the #handleNotFoundException(NoResultException) method", - "content": { - "*/*": { - "schema": { - "type": "string" - } - } - }, - "x-exception-class": [ - "test.org.springdoc.api.app162.exception.NoResultException" - ] - } - } - } - } - }, - "components": { - "schemas": { - "JavadocOnlyRestDto": { - "type": "object", - "properties": { - "guid": { - "type": "string", - "description": "This is the private #guid field's javadoc." - }, - "inner": { - "$ref": "#/components/schemas/JavadocOnlyStaticInnerRestDto" - } - }, - "description": "This is the JavadocOnlyRestDto class javadoc." - }, - "JavadocOnlyStaticInnerRestDto": { - "type": "object", - "properties": { - "content": { - "type": "string", - "description": "This is the private #content field's javadoc." - } - }, - "description": "This is the JavadocOnlyStaticInnerRestDto class javadoc." - } - } - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app163.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app163.json deleted file mode 100644 index 00af8c11d..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app163.json +++ /dev/null @@ -1,227 +0,0 @@ -{ - "openapi": "3.0.1", - "info": { - "title": "SpringShop API", - "description": "The description of the api", - "version": "v1" - }, - "servers": [ - { - "url": "http://localhost", - "description": "Generated server url" - } - ], - "tags": [ - { - "name": "annotation-override", - "description": "Description for the tag." - } - ], - "paths": { - "/annotation-override/{guid}": { - "put": { - "tags": [ - "annotation-override" - ], - "summary": "Summary for #update(String, AnnotationOverrideForJavadocRestDto)", - "description": "This is the update method's javadoc.\n The method's signature: #update(String, AnnotationOverrideForJavadocRestDto)", - "operationId": "update", - "parameters": [ - { - "name": "guid", - "in": "path", - "description": "the @param input javadoc for the #update(String, AnnotationOverrideForJavadocRestDto) method", - "required": true, - "schema": { - "type": "string" - } - } - ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/AnnotationOverrideForJavadocRestDto" - } - } - }, - "required": true - }, - "responses": { - "400": { - "description": "the return javadoc for the #handleNonUniqueResultException(NonUniqueResultException) method", - "content": { - "*/*": { - "schema": { - "type": "string" - } - } - }, - "x-exception-class": [ - "test.org.springdoc.api.app163.exception.NonUniqueResultException" - ] - }, - "404": { - "description": "the return javadoc for the #handleNotFoundException(NoResultException) method", - "content": { - "*/*": { - "schema": { - "type": "string" - } - } - }, - "x-exception-class": [ - "test.org.springdoc.api.app163.exception.NoResultException" - ] - }, - "200": { - "description": "the @return javadoc for the #update(String, AnnotationOverrideForJavadocRestDto) method", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/AnnotationOverrideForJavadocRestDto" - } - } - } - } - } - } - }, - "/annotation-override": { - "post": { - "tags": [ - "annotation-override" - ], - "summary": "Summary for #create(AnnotationOverrideForJavadocRestDto)", - "description": "Description for #create(AnnotationOverrideForJavadocRestDto)", - "operationId": "create", - "requestBody": { - "description": "Request body for #create(AnnotationOverrideForJavadocRestDto)", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/AnnotationOverrideForJavadocRestDto" - } - } - }, - "required": true - }, - "responses": { - "400": { - "description": "the return javadoc for the #handleNonUniqueResultException(NonUniqueResultException) method", - "content": { - "*/*": { - "schema": { - "type": "string" - } - } - }, - "x-exception-class": [ - "test.org.springdoc.api.app163.exception.NonUniqueResultException" - ] - }, - "404": { - "description": "the return javadoc for the #handleNotFoundException(NoResultException) method", - "content": { - "*/*": { - "schema": { - "type": "string" - } - } - }, - "x-exception-class": [ - "test.org.springdoc.api.app163.exception.NoResultException" - ] - }, - "default": { - "description": "API Response 201 for #create(AnnotationOverrideForJavadocRestDto)", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/AnnotationOverrideForJavadocRestDto" - } - } - } - } - } - } - }, - "/annotation-override/startsBy/{prefix}": { - "get": { - "tags": [ - "annotation-override" - ], - "summary": "This is the findStartsBy method's javadoc.", - "description": "This is the findStartsBy method's javadoc.\n The method's signature: #findStartsBy(String)", - "operationId": "findStartsBy", - "parameters": [ - { - "name": "prefix", - "in": "path", - "description": "Parameter prefix", - "required": true, - "schema": { - "type": "string" - } - } - ], - "responses": { - "400": { - "description": "API Response 400 for #findStartsBy(prefix)" - }, - "404": { - "description": "the @throws NoResultException javadoc for the #findStartsBy(String) method", - "content": { - "*/*": { - "schema": { - "type": "string" - } - } - }, - "x-exception-class": [ - "test.org.springdoc.api.app163.exception.NoResultException" - ] - }, - "200": { - "description": "API Response 200 for #findStartsBy(prefix)", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/AnnotationOverrideForJavadocRestDto" - } - } - } - } - } - } - } - }, - "components": { - "schemas": { - "AnnotationOverrideForJavadocRestDto": { - "title": "annotation-override-dto", - "type": "object", - "properties": { - "guid": { - "type": "string", - "description": "Description for the #guid field" - }, - "inner": { - "$ref": "#/components/schemas/AnnotationOverrideForJavadocStaticInnerRestDto" - } - }, - "description": "Description for the tag." - }, - "AnnotationOverrideForJavadocStaticInnerRestDto": { - "type": "object", - "properties": { - "content": { - "type": "string", - "description": "This is the private #content field's javadoc." - } - }, - "description": "This is the AnnotationOverrideForJavadocStaticInnerRestDto class javadoc." - } - } - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app4.json b/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app4.json deleted file mode 100644 index 5b08ca8ce..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-javadoc-tests/src/test/resources/results/app4.json +++ /dev/null @@ -1,86 +0,0 @@ -{ - "openapi": "3.0.1", - "info": { - "title": "OpenAPI definition", - "version": "v0" - }, - "servers": [ - { - "url": "http://localhost", - "description": "Generated server url" - } - ], - "tags": [ - { - "name": "hello-controller", - "description": "The type Hello controller." - } - ], - "paths": { - "/values/data": { - "post": { - "tags": [ - "hello-controller" - ], - "summary": "List tracker data.", - "description": "List tracker data.", - "operationId": "list", - "parameters": [ - { - "name": "toto", - "in": "query", - "description": "the toto", - "required": true, - "schema": { - "$ref": "#/components/schemas/test.org.springdoc.api.app4.TrackerData" - } - } - ], - "responses": { - "200": { - "description": "the tracker data", - "content": { - "*/*": { - "schema": { - "$ref": "#/components/schemas/test.org.springdoc.api.app4.TrackerData" - } - } - } - } - } - } - } - }, - "components": { - "schemas": { - "test.org.springdoc.api.app4.TrackerData": { - "required": [ - "timestamp", - "trackerId", - "value" - ], - "type": "object", - "properties": { - "trackerId": { - "type": "string", - "description": "The Tracker id.", - "example": "the-tracker-id" - }, - "timestamp": { - "type": "string", - "description": "The Timestamp.", - "format": "date-time", - "example": "2018-01-01T00:00:00Z" - }, - "value": { - "type": "number", - "description": "The data value", - "format": "double", - "example": 19.0 - } - }, - "description": "The type Tracker data." - } - } - } -} \ No newline at end of file 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 82f8098ed..60f82a007 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.1 + 2.8.2 4.0.0 springdoc-openapi-kotlin-webflux-tests diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/java/test/org/springdoc/api/AbstractSpringDocTest.java b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/java/test/org/springdoc/api/AbstractSpringDocTest.java deleted file mode 100644 index 549773fb9..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/java/test/org/springdoc/api/AbstractSpringDocTest.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * - * * Copyright 2019-2020 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; - -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; - -import org.junit.jupiter.api.Test; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springdoc.core.utils.Constants; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.autoconfigure.web.reactive.WebFluxTest; -import org.springframework.test.context.ActiveProfiles; -import org.springframework.test.context.TestPropertySource; -import org.springframework.test.web.reactive.server.EntityExchangeResult; -import org.springframework.test.web.reactive.server.WebTestClient; - -import static org.skyscreamer.jsonassert.JSONAssert.assertEquals; - -@WebFluxTest -@ActiveProfiles("test") -@TestPropertySource(properties = "springdoc.api-docs.version=openapi_3_0" ) -public abstract class AbstractSpringDocTest { - - protected static final Logger LOGGER = LoggerFactory.getLogger(AbstractSpringDocTest.class); - - @Autowired - private WebTestClient webTestClient; - - public static String getContent(String fileName) { - try { - Path path = Paths.get(AbstractSpringDocTest.class.getClassLoader().getResource(fileName).toURI()); - byte[] fileBytes = Files.readAllBytes(path); - return new String(fileBytes, StandardCharsets.UTF_8); - } - catch (Exception e) { - throw new RuntimeException("Failed to read file: " + fileName, e); - } - } - - @Test - void testApp() throws Exception { - String result = null; - try { - EntityExchangeResult getResult = webTestClient.get().uri(Constants.DEFAULT_API_DOCS_URL).exchange() - .expectStatus().isOk().expectBody().returnResult(); - - result = new String(getResult.getResponseBody()); - String className = getClass().getSimpleName(); - String testNumber = className.replaceAll("[^0-9]", ""); - String expected = getContent("results/app" + testNumber + ".json"); - assertEquals(expected, result, true); - } - catch (java.lang.AssertionError e) { - LOGGER.error(result); - throw e; - } - } -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/java/test/org/springdoc/api/app1/ControllerWithContinuationParameter.java b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/java/test/org/springdoc/api/app1/ControllerWithContinuationParameter.java deleted file mode 100644 index 413beb27a..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/java/test/org/springdoc/api/app1/ControllerWithContinuationParameter.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app1; - -import io.swagger.v3.oas.annotations.Operation; -import kotlin.coroutines.Continuation; -import reactor.core.publisher.Mono; - -import org.springframework.http.MediaType; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RestController; - -@RestController -public class ControllerWithContinuationParameter { - - @Operation(summary = "Ignore Continuation parameter") - @GetMapping(value = "/test/{id}", produces = { MediaType.APPLICATION_JSON_VALUE }) - public Mono get(@PathVariable(value = "id") String key, Continuation continuation) { - return null; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/java/test/org/springdoc/api/app1/SpringDocApp1Test.java b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/java/test/org/springdoc/api/app1/SpringDocApp1Test.java deleted file mode 100644 index d3c5a5f17..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/java/test/org/springdoc/api/app1/SpringDocApp1Test.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app1; - -import test.org.springdoc.api.AbstractSpringDocTest; - -public class SpringDocApp1Test extends AbstractSpringDocTest { - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/java/test/org/springdoc/api/app1/SpringDocTestApp.java b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/java/test/org/springdoc/api/app1/SpringDocTestApp.java deleted file mode 100644 index f16e3284d..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/java/test/org/springdoc/api/app1/SpringDocTestApp.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app1; - -import io.swagger.v3.oas.models.OpenAPI; -import io.swagger.v3.oas.models.info.Info; -import io.swagger.v3.oas.models.info.License; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; - -@SpringBootApplication -@ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.app1" }) -public class SpringDocTestApp { - public static void main(String[] args) { - SpringApplication.run(SpringDocTestApp.class, args); - } - - @Bean - public OpenAPI customOpenAPI() { - return new OpenAPI() - .info(new Info().title("Kotlin API").version("v1") - .license(new License().name("Apache 2.0").url("http://springdoc.org"))); - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/java/test/org/springdoc/api/app21/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/java/test/org/springdoc/api/app21/HelloController.java deleted file mode 100644 index 10e0b6359..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/java/test/org/springdoc/api/app21/HelloController.java +++ /dev/null @@ -1,25 +0,0 @@ -package test.org.springdoc.api.app21; - -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; - -import org.springframework.http.MediaType; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -@Tag(name = "Test") -@RestController -@RequestMapping(value = "/api/v2/test", produces = MediaType.APPLICATION_JSON_VALUE) -public class HelloController { - - @GetMapping("/") - public void greet(@RequestParam(required = false) @Parameter(required = false) final String name) { - } - - @GetMapping("/test2") - public void greet1(@RequestHeader(required = false) @Parameter(required = false) final String name) { - } -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/java/test/org/springdoc/api/app21/SpringDocApp21Test.java b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/java/test/org/springdoc/api/app21/SpringDocApp21Test.java deleted file mode 100644 index b5e473e96..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/java/test/org/springdoc/api/app21/SpringDocApp21Test.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * - * * - * * * - * * * * - * * * * * 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.app21; -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.ComponentScan; - - -public class SpringDocApp21Test extends AbstractSpringDocTest { - - @SpringBootApplication - @ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.app21" }) - static class SpringDocTestApp {} -} diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/java/test/org/springdoc/api/v30/AbstractSpringDocTest.java b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/java/test/org/springdoc/api/v30/AbstractSpringDocTest.java new file mode 100644 index 000000000..9fe19c31c --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/java/test/org/springdoc/api/v30/AbstractSpringDocTest.java @@ -0,0 +1,87 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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; + +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; + +import org.junit.jupiter.api.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springdoc.core.utils.Constants; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.reactive.WebFluxTest; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.context.TestPropertySource; +import org.springframework.test.web.reactive.server.EntityExchangeResult; +import org.springframework.test.web.reactive.server.WebTestClient; + +import static org.skyscreamer.jsonassert.JSONAssert.assertEquals; + +@WebFluxTest +@ActiveProfiles("test") +@TestPropertySource(properties = "springdoc.api-docs.version=openapi_3_0" ) +public abstract class AbstractSpringDocTest { + + protected static final Logger LOGGER = LoggerFactory.getLogger(AbstractSpringDocTest.class); + + @Autowired + private WebTestClient webTestClient; + + public static String getContent(String fileName) { + try { + Path path = Paths.get(AbstractSpringDocTest.class.getClassLoader().getResource(fileName).toURI()); + byte[] fileBytes = Files.readAllBytes(path); + return new String(fileBytes, StandardCharsets.UTF_8); + } + catch (Exception e) { + throw new RuntimeException("Failed to read file: " + fileName, e); + } + } + + @Test + void testApp() throws Exception { + String result = null; + try { + EntityExchangeResult getResult = webTestClient.get().uri(Constants.DEFAULT_API_DOCS_URL).exchange() + .expectStatus().isOk().expectBody().returnResult(); + + result = new String(getResult.getResponseBody()); + String className = getClass().getSimpleName(); + String testNumber = className.replaceAll("[^0-9]", ""); + String expected = getContent("results/3.0.1/app" + testNumber + ".json"); + assertEquals(expected, result, true); + } + catch (java.lang.AssertionError e) { + LOGGER.error(result); + throw e; + } + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/java/test/org/springdoc/api/v30/app1/ControllerWithContinuationParameter.java b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/java/test/org/springdoc/api/v30/app1/ControllerWithContinuationParameter.java new file mode 100644 index 000000000..9afa3470e --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/java/test/org/springdoc/api/v30/app1/ControllerWithContinuationParameter.java @@ -0,0 +1,38 @@ +/* + * + * * Copyright 2019-2020 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.app1; + +import io.swagger.v3.oas.annotations.Operation; +import kotlin.coroutines.Continuation; +import reactor.core.publisher.Mono; + +import org.springframework.http.MediaType; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class ControllerWithContinuationParameter { + + @Operation(summary = "Ignore Continuation parameter") + @GetMapping(value = "/test/{id}", produces = { MediaType.APPLICATION_JSON_VALUE }) + public Mono get(@PathVariable(value = "id") String key, Continuation continuation) { + return null; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/java/test/org/springdoc/api/v30/app1/SpringDocApp1Test.java b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/java/test/org/springdoc/api/v30/app1/SpringDocApp1Test.java new file mode 100644 index 000000000..009084aad --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/java/test/org/springdoc/api/v30/app1/SpringDocApp1Test.java @@ -0,0 +1,25 @@ +/* + * + * * Copyright 2019-2020 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.app1; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +public class SpringDocApp1Test extends AbstractSpringDocTest { + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/java/test/org/springdoc/api/v30/app1/SpringDocTestApp.java b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/java/test/org/springdoc/api/v30/app1/SpringDocTestApp.java new file mode 100644 index 000000000..7b6401858 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/java/test/org/springdoc/api/v30/app1/SpringDocTestApp.java @@ -0,0 +1,43 @@ +/* + * + * * Copyright 2019-2020 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.app1; + +import io.swagger.v3.oas.models.OpenAPI; +import io.swagger.v3.oas.models.info.Info; +import io.swagger.v3.oas.models.info.License; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; + +@SpringBootApplication +@ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.v30.app1" }) +public class SpringDocTestApp { + public static void main(String[] args) { + SpringApplication.run(SpringDocTestApp.class, args); + } + + @Bean + public OpenAPI customOpenAPI() { + return new OpenAPI() + .info(new Info().title("Kotlin API").version("v1") + .license(new License().name("Apache 2.0").url("http://springdoc.org"))); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/java/test/org/springdoc/api/v30/app21/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/java/test/org/springdoc/api/v30/app21/HelloController.java new file mode 100644 index 000000000..e202dfea9 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/java/test/org/springdoc/api/v30/app21/HelloController.java @@ -0,0 +1,25 @@ +package test.org.springdoc.api.v30.app21; + +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.tags.Tag; + +import org.springframework.http.MediaType; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestHeader; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +@Tag(name = "Test") +@RestController +@RequestMapping(value = "/api/v2/test", produces = MediaType.APPLICATION_JSON_VALUE) +public class HelloController { + + @GetMapping("/") + public void greet(@RequestParam(required = false) @Parameter(required = false) final String name) { + } + + @GetMapping("/test2") + public void greet1(@RequestHeader(required = false) @Parameter(required = false) final String name) { + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/java/test/org/springdoc/api/v30/app21/SpringDocApp21Test.java b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/java/test/org/springdoc/api/v30/app21/SpringDocApp21Test.java new file mode 100644 index 000000000..80235f9a7 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/java/test/org/springdoc/api/v30/app21/SpringDocApp21Test.java @@ -0,0 +1,37 @@ +/* + * + * * + * * * + * * * * + * * * * * 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.app21; +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.ComponentScan; + + +public class SpringDocApp21Test extends AbstractSpringDocTest { + + @SpringBootApplication + @ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.v30.app21" }) + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/java/test/org/springdoc/api/v31/AbstractSpringDocTest.java b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/java/test/org/springdoc/api/v31/AbstractSpringDocTest.java new file mode 100644 index 000000000..672cf2501 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/java/test/org/springdoc/api/v31/AbstractSpringDocTest.java @@ -0,0 +1,85 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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; + +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; + +import org.junit.jupiter.api.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springdoc.core.utils.Constants; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.reactive.WebFluxTest; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.web.reactive.server.EntityExchangeResult; +import org.springframework.test.web.reactive.server.WebTestClient; + +import static org.skyscreamer.jsonassert.JSONAssert.assertEquals; + +@WebFluxTest +@ActiveProfiles("test") +public abstract class AbstractSpringDocTest { + + protected static final Logger LOGGER = LoggerFactory.getLogger(AbstractSpringDocTest.class); + + @Autowired + private WebTestClient webTestClient; + + public static String getContent(String fileName) { + try { + Path path = Paths.get(AbstractSpringDocTest.class.getClassLoader().getResource(fileName).toURI()); + byte[] fileBytes = Files.readAllBytes(path); + return new String(fileBytes, StandardCharsets.UTF_8); + } + catch (Exception e) { + throw new RuntimeException("Failed to read file: " + fileName, e); + } + } + + @Test + void testApp() throws Exception { + String result = null; + try { + EntityExchangeResult getResult = webTestClient.get().uri(Constants.DEFAULT_API_DOCS_URL).exchange() + .expectStatus().isOk().expectBody().returnResult(); + + result = new String(getResult.getResponseBody()); + String className = getClass().getSimpleName(); + String testNumber = className.replaceAll("[^0-9]", ""); + String expected = getContent("results/3.1.0/app" + testNumber + ".json"); + assertEquals(expected, result, true); + } + catch (AssertionError e) { + LOGGER.error(result); + throw e; + } + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/java/test/org/springdoc/api/v31/app1/ControllerWithContinuationParameter.java b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/java/test/org/springdoc/api/v31/app1/ControllerWithContinuationParameter.java new file mode 100644 index 000000000..25aedbce1 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/java/test/org/springdoc/api/v31/app1/ControllerWithContinuationParameter.java @@ -0,0 +1,38 @@ +/* + * + * * Copyright 2019-2020 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.app1; + +import io.swagger.v3.oas.annotations.Operation; +import kotlin.coroutines.Continuation; +import reactor.core.publisher.Mono; + +import org.springframework.http.MediaType; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class ControllerWithContinuationParameter { + + @Operation(summary = "Ignore Continuation parameter") + @GetMapping(value = "/test/{id}", produces = { MediaType.APPLICATION_JSON_VALUE }) + public Mono get(@PathVariable(value = "id") String key, Continuation continuation) { + return null; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/java/test/org/springdoc/api/v31/app1/SpringDocApp1Test.java b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/java/test/org/springdoc/api/v31/app1/SpringDocApp1Test.java new file mode 100644 index 000000000..64400f19a --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/java/test/org/springdoc/api/v31/app1/SpringDocApp1Test.java @@ -0,0 +1,25 @@ +/* + * + * * Copyright 2019-2020 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.app1; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +public class SpringDocApp1Test extends AbstractSpringDocTest { + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/java/test/org/springdoc/api/v31/app1/SpringDocTestApp.java b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/java/test/org/springdoc/api/v31/app1/SpringDocTestApp.java new file mode 100644 index 000000000..ab84c8b11 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/java/test/org/springdoc/api/v31/app1/SpringDocTestApp.java @@ -0,0 +1,43 @@ +/* + * + * * Copyright 2019-2020 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.app1; + +import io.swagger.v3.oas.models.OpenAPI; +import io.swagger.v3.oas.models.info.Info; +import io.swagger.v3.oas.models.info.License; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; + +@SpringBootApplication +@ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.v31.app1" }) +public class SpringDocTestApp { + public static void main(String[] args) { + SpringApplication.run(SpringDocTestApp.class, args); + } + + @Bean + public OpenAPI customOpenAPI() { + return new OpenAPI() + .info(new Info().title("Kotlin API").version("v1") + .license(new License().name("Apache 2.0").url("http://springdoc.org"))); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/java/test/org/springdoc/api/v31/app21/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/java/test/org/springdoc/api/v31/app21/HelloController.java new file mode 100644 index 000000000..0526c4cb9 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/java/test/org/springdoc/api/v31/app21/HelloController.java @@ -0,0 +1,25 @@ +package test.org.springdoc.api.v31.app21; + +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.tags.Tag; + +import org.springframework.http.MediaType; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestHeader; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +@Tag(name = "Test") +@RestController +@RequestMapping(value = "/api/v2/test", produces = MediaType.APPLICATION_JSON_VALUE) +public class HelloController { + + @GetMapping("/") + public void greet(@RequestParam(required = false) @Parameter(required = false) final String name) { + } + + @GetMapping("/test2") + public void greet1(@RequestHeader(required = false) @Parameter(required = false) final String name) { + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/java/test/org/springdoc/api/v31/app21/SpringDocApp21Test.java b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/java/test/org/springdoc/api/v31/app21/SpringDocApp21Test.java new file mode 100644 index 000000000..64f3e842a --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/java/test/org/springdoc/api/v31/app21/SpringDocApp21Test.java @@ -0,0 +1,38 @@ +/* + * + * * + * * * + * * * * + * * * * * 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.app21; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.ComponentScan; + + +public class SpringDocApp21Test extends AbstractSpringDocTest { + + @SpringBootApplication + @ComponentScan(basePackages = { "org.springdoc", "test.org.springdoc.api.v31.app21" }) + static class SpringDocTestApp {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/AbstractKotlinSpringDocTest.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/AbstractKotlinSpringDocTest.kt deleted file mode 100644 index 04c85ebfc..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/AbstractKotlinSpringDocTest.kt +++ /dev/null @@ -1,84 +0,0 @@ -/* - * - * * Copyright 2019-2020 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 - -import org.junit.jupiter.api.Test -import org.skyscreamer.jsonassert.JSONAssert -import org.slf4j.LoggerFactory -import org.springdoc.core.utils.Constants -import org.springframework.beans.factory.annotation.Autowired -import org.springframework.boot.test.autoconfigure.web.reactive.AutoConfigureWebTestClient -import org.springframework.boot.test.autoconfigure.web.reactive.WebFluxTest -import org.springframework.test.context.ActiveProfiles -import org.springframework.test.context.TestPropertySource -import org.springframework.test.web.reactive.server.WebTestClient -import java.nio.charset.StandardCharsets -import java.nio.file.Files -import java.nio.file.Paths - -@WebFluxTest -@ActiveProfiles("test") -@AutoConfigureWebTestClient(timeout = "3600000") -@TestPropertySource(properties = ["springdoc.api-docs.version=openapi_3_0"]) -abstract class AbstractKotlinSpringDocTest { - - @Autowired - private val webTestClient: WebTestClient? = null - - private val logger = LoggerFactory.getLogger(AbstractKotlinSpringDocTest::class.java) - - @Test - @Throws(Exception::class) - fun testApp() { - var result: String? = null - try { - val getResult = - webTestClient!!.get().uri(Constants.DEFAULT_API_DOCS_URL).exchange() - .expectStatus().isOk.expectBody().returnResult() - - result = String(getResult.responseBody!!) - val className = javaClass.simpleName - val testNumber = className.replace("[^0-9]".toRegex(), "") - - val expected = getContent("results/app$testNumber.json") - JSONAssert.assertEquals(expected, result, true) - } catch (e: AssertionError) { - logger.error(result) - throw e - } - } - - companion object { - @Throws(Exception::class) - fun getContent(fileName: String): String { - try { - val path = Paths.get( - AbstractKotlinSpringDocTest::class.java.classLoader.getResource( - fileName - )!!.toURI() - ) - val fileBytes = Files.readAllBytes(path) - return String(fileBytes, StandardCharsets.UTF_8) - } catch (e: Exception) { - throw RuntimeException("Failed to read file: $fileName", e) - } - - } - } -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/app10/ExampleController.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/app10/ExampleController.kt deleted file mode 100644 index e88e0a6c1..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/app10/ExampleController.kt +++ /dev/null @@ -1,20 +0,0 @@ -package test.org.springdoc.api.app10 - -import org.springframework.web.bind.annotation.GetMapping -import org.springframework.web.bind.annotation.RequestParam -import org.springframework.web.bind.annotation.RestController -import test.org.springdoc.api.app8.Greeting - -data class Greeting(val greeting: String) - -@RestController -class ExampleController { - @GetMapping("/") - fun greet(@RequestParam name: String?) = Greeting("Hello ${name ?: "world"}") - - @GetMapping("/test") - fun test(@RequestParam name: String) = Greeting("Hello $name") - - @GetMapping("/test-with-default") - fun testWithDefault(@RequestParam(defaultValue = "world") name: String) = Greeting("Hello $name") -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/app10/SpringDocApp10Test.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/app10/SpringDocApp10Test.kt deleted file mode 100644 index 50d51183b..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/app10/SpringDocApp10Test.kt +++ /dev/null @@ -1,31 +0,0 @@ -/* - * - * * Copyright 2019-2023 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.app10 - -import org.springframework.boot.autoconfigure.SpringBootApplication -import org.springframework.context.annotation.ComponentScan -import test.org.springdoc.api.AbstractKotlinSpringDocTest - -class SpringDocApp10Test : AbstractKotlinSpringDocTest() { - - @SpringBootApplication - @ComponentScan(basePackages = ["org.springdoc", "test.org.springdoc.api.app10"]) - open class DemoApplication - -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/app11/SpringDocApp11Test.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/app11/SpringDocApp11Test.kt deleted file mode 100644 index f8f2b79ca..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/app11/SpringDocApp11Test.kt +++ /dev/null @@ -1,31 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app11 - -import org.springframework.boot.autoconfigure.SpringBootApplication -import org.springframework.context.annotation.ComponentScan -import test.org.springdoc.api.AbstractKotlinSpringDocTest - -class SpringDocApp11Test : AbstractKotlinSpringDocTest() { - - @SpringBootApplication - @ComponentScan(basePackages = ["org.springdoc", "test.org.springdoc.api.app11"]) - class DemoApplication - -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/app11/SystemStatusController.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/app11/SystemStatusController.kt deleted file mode 100644 index f407aa069..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/app11/SystemStatusController.kt +++ /dev/null @@ -1,59 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app11 - -import io.swagger.v3.oas.annotations.media.Schema -import kotlinx.coroutines.reactor.mono -import org.springframework.web.bind.annotation.GetMapping -import org.springframework.web.bind.annotation.RequestMapping -import org.springframework.web.bind.annotation.RestController - -enum class SystemStatus(val status: String) { - OK("OK") -} - -data class PersonDTO( - @Deprecated ("no-email") val email: String, - val firstName: String, - val lastName: String -) - -data class SystemStatusResponse( - @Deprecated ("will be removed in next version") - val systemStatus: SystemStatus, - - @Deprecated ("") - val emptyTest:String, - - @Deprecated ("should be ignored") - @Schema(description = "nonEmptyDesc") - val nonEmptyDesc:String -) - -@RestController -@RequestMapping("/status") -class SystemStatusController { - @GetMapping - suspend fun index() = SystemStatusResponse(SystemStatus.OK,"","") - - @GetMapping("/foo") - fun foo(personDTO: PersonDTO) = mono { - SystemStatusResponse(SystemStatus.OK,"","") - } -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/app2/SpringDocApp2Test.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/app2/SpringDocApp2Test.kt deleted file mode 100644 index 6990adc0b..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/app2/SpringDocApp2Test.kt +++ /dev/null @@ -1,31 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app2 - -import org.springframework.boot.autoconfigure.SpringBootApplication -import org.springframework.context.annotation.ComponentScan -import test.org.springdoc.api.AbstractKotlinSpringDocTest - -class SpringDocApp2Test : AbstractKotlinSpringDocTest() { - - @SpringBootApplication - @ComponentScan(basePackages = ["org.springdoc", "test.org.springdoc.api.app2"]) - open class DemoApplication - -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/app2/SystemStatusController.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/app2/SystemStatusController.kt deleted file mode 100644 index 8ff57bd4c..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/app2/SystemStatusController.kt +++ /dev/null @@ -1,59 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app2 - -import jakarta.validation.Valid -import kotlinx.coroutines.reactor.mono -import org.springframework.http.HttpStatus -import org.springframework.web.bind.annotation.GetMapping -import org.springframework.web.bind.annotation.PathVariable -import org.springframework.web.bind.annotation.PostMapping -import org.springframework.web.bind.annotation.RequestBody -import org.springframework.web.bind.annotation.RequestMapping -import org.springframework.web.bind.annotation.ResponseStatus -import org.springframework.web.bind.annotation.RestController - -enum class SystemStatus(val status: String) { - OK("OK") -} - -data class SystemStatusResponse( - val status: SystemStatus -) - -@RestController -@RequestMapping("/status") -class SystemStatusController { - @GetMapping - suspend fun index() = SystemStatusResponse(SystemStatus.OK) - - @GetMapping("/foo") - fun foo() = mono { - SystemStatusResponse(SystemStatus.OK) - } - - @PostMapping("{token}/activate") - @ResponseStatus(HttpStatus.NO_CONTENT) - suspend fun activateUser( - @PathVariable token: String, - @RequestBody @Valid request: String - ) { - // do something - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/app3/SpringDocApp3Test.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/app3/SpringDocApp3Test.kt deleted file mode 100644 index e2998ced1..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/app3/SpringDocApp3Test.kt +++ /dev/null @@ -1,31 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app3 - -import org.springframework.boot.autoconfigure.SpringBootApplication -import org.springframework.context.annotation.ComponentScan -import test.org.springdoc.api.AbstractKotlinSpringDocTest - -class SpringDocApp3Test : AbstractKotlinSpringDocTest() { - - @SpringBootApplication - @ComponentScan(basePackages = ["org.springdoc", "test.org.springdoc.api.app3"]) - open class DemoApplication - -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/app3/SystemStatusController.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/app3/SystemStatusController.kt deleted file mode 100644 index 7877ae038..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/app3/SystemStatusController.kt +++ /dev/null @@ -1,45 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app3 - -import kotlinx.coroutines.reactor.mono -import org.springframework.web.bind.annotation.GetMapping -import org.springframework.web.bind.annotation.RequestMapping -import org.springframework.web.bind.annotation.RestController - -enum class SystemStatus(val status: String) { - OK("OK") -} - -data class SystemStatusResponse( - val status: SystemStatus -) - -@RestController -@RequestMapping("/status") -class SystemStatusController { - @GetMapping - suspend fun index() = SystemStatusResponse(SystemStatus.OK) - - @GetMapping("/foo") - @Deprecated("") - fun foo() = mono { - SystemStatusResponse(SystemStatus.OK) - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/app4/HelloController.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/app4/HelloController.kt deleted file mode 100644 index 6d0d9199e..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/app4/HelloController.kt +++ /dev/null @@ -1,37 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app4 - -import org.springframework.web.bind.annotation.GetMapping -import org.springframework.web.bind.annotation.RequestMapping -import org.springframework.web.bind.annotation.RestController - - -data class Person( - val name: String, - val nickname: String? -) - -@RestController -@RequestMapping("/test") -class HelloController { - @GetMapping - suspend fun index(s: Person) = s - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/app4/SpringDocApp4Test.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/app4/SpringDocApp4Test.kt deleted file mode 100644 index 958febce5..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/app4/SpringDocApp4Test.kt +++ /dev/null @@ -1,31 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app4 - -import org.springframework.boot.autoconfigure.SpringBootApplication -import org.springframework.context.annotation.ComponentScan -import test.org.springdoc.api.AbstractKotlinSpringDocTest - -class SpringDocApp4Test : AbstractKotlinSpringDocTest() { - - @SpringBootApplication - @ComponentScan(basePackages = ["org.springdoc", "test.org.springdoc.api.app4"]) - open class DemoApplication - -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/app5/HelloController.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/app5/HelloController.kt deleted file mode 100644 index 38fa97b62..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/app5/HelloController.kt +++ /dev/null @@ -1,46 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app5 - -import kotlinx.coroutines.delay -import kotlinx.coroutines.flow.Flow -import kotlinx.coroutines.flow.flow -import org.springframework.web.bind.annotation.GetMapping -import org.springframework.web.bind.annotation.RequestMapping -import org.springframework.web.bind.annotation.RestController - - -data class Person( - val name: String, - val nickname: String? -) - -@RestController -@RequestMapping("/test") -class HelloController { - - @GetMapping("/") - fun foo(): Flow = flow { // flow builder - for (i in 1..3) { - delay(100) // pretend we are doing something useful here - emit(i) // emit next value - } - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/app5/SpringDocApp5Test.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/app5/SpringDocApp5Test.kt deleted file mode 100644 index 0a0dca615..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/app5/SpringDocApp5Test.kt +++ /dev/null @@ -1,31 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app5 - -import org.springframework.boot.autoconfigure.SpringBootApplication -import org.springframework.context.annotation.ComponentScan -import test.org.springdoc.api.AbstractKotlinSpringDocTest - -class SpringDocApp5Test : AbstractKotlinSpringDocTest() { - - @SpringBootApplication - @ComponentScan(basePackages = ["org.springdoc", "test.org.springdoc.api.app5"]) - open class DemoApplication - -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/app6/ByteArrayController.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/app6/ByteArrayController.kt deleted file mode 100644 index 584d2f3ed..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/app6/ByteArrayController.kt +++ /dev/null @@ -1,38 +0,0 @@ -/* - * - * * 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.app6 - -import io.swagger.v3.oas.annotations.media.Schema -import org.springframework.web.bind.annotation.GetMapping -import org.springframework.web.bind.annotation.RequestMapping -import org.springframework.web.bind.annotation.RestController - -data class Foo( - @Schema(description = "Some description about a byte array.") - val data: ByteArray -) - -@RestController -@RequestMapping("/bytearray") -class ByteArrayController { - - @GetMapping("/") - fun getByteArray(): Foo = Foo(byteArrayOf(0)) - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/app6/SpringDocApp6Test.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/app6/SpringDocApp6Test.kt deleted file mode 100644 index 2197721dc..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/app6/SpringDocApp6Test.kt +++ /dev/null @@ -1,31 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app6 - -import org.springframework.boot.autoconfigure.SpringBootApplication -import org.springframework.context.annotation.ComponentScan -import test.org.springdoc.api.AbstractKotlinSpringDocTest - -class SpringDocApp6Test : AbstractKotlinSpringDocTest() { - - @SpringBootApplication - @ComponentScan(basePackages = ["org.springdoc", "test.org.springdoc.api.app6"]) - open class DemoApplication - -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/app7/ExampleController.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/app7/ExampleController.kt deleted file mode 100644 index 657889310..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/app7/ExampleController.kt +++ /dev/null @@ -1,17 +0,0 @@ -package test.org.springdoc.api.app7 - -import io.swagger.v3.oas.annotations.Parameter -import org.springframework.web.bind.annotation.GetMapping -import org.springframework.web.bind.annotation.RequestParam -import org.springframework.web.bind.annotation.RestController - -data class Greeting(val greeting: String) - -@RestController -interface ExampleController { - @GetMapping("/") - fun greet(@RequestParam name: String?): Greeting - - @GetMapping("/test") - fun test(@RequestParam @Parameter(required = true) name: String?): Greeting -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/app7/SpringDocApp7Test.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/app7/SpringDocApp7Test.kt deleted file mode 100644 index 46800d614..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/app7/SpringDocApp7Test.kt +++ /dev/null @@ -1,46 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app7 - -import org.springframework.aop.framework.ProxyFactory -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.AbstractKotlinSpringDocTest - -class SpringDocApp7Test : AbstractKotlinSpringDocTest() { - - @SpringBootApplication - @ComponentScan(basePackages = ["org.springdoc", "test.org.springdoc.api.app7"]) - open class DemoApplication{ - @Bean - fun controller(applicationContext: GenericApplicationContext): ExampleController { - return createProxy(ExampleController::class.java) - } - - private fun createProxy(clazz: Class): T { - val proxyFactory = ProxyFactory(clazz) - proxyFactory.targetClass = clazz - @Suppress("UNCHECKED_CAST") - return proxyFactory.proxy as T - } - } - -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/app8/ExampleController.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/app8/ExampleController.kt deleted file mode 100644 index 939318ecc..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/app8/ExampleController.kt +++ /dev/null @@ -1,17 +0,0 @@ -package test.org.springdoc.api.app8 - -import io.swagger.v3.oas.annotations.Parameter -import org.springframework.web.bind.annotation.GetMapping -import org.springframework.web.bind.annotation.RequestParam -import org.springframework.web.bind.annotation.RestController - -data class Greeting(val greeting: String) - -@RestController -interface ExampleController { - @GetMapping("/") - fun greet(@RequestParam name: String?): Greeting - - @GetMapping("/test") - fun test(@RequestParam @Parameter(required = true) name: String?): Greeting -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/app8/SpringDocApp8Test.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/app8/SpringDocApp8Test.kt deleted file mode 100644 index 59c916891..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/app8/SpringDocApp8Test.kt +++ /dev/null @@ -1,49 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app8 - -import org.springdoc.core.utils.Constants -import org.springframework.aop.framework.ProxyFactory -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 org.springframework.test.context.TestPropertySource -import test.org.springdoc.api.AbstractKotlinSpringDocTest - -@TestPropertySource(properties = [Constants.SPRINGDOC_NULLABLE_REQUEST_PARAMETER_ENABLED+"=false"]) -class SpringDocApp8Test : AbstractKotlinSpringDocTest() { - - @SpringBootApplication - @ComponentScan(basePackages = ["org.springdoc", "test.org.springdoc.api.app8"]) - class DemoApplication{ - @Bean - fun controller(applicationContext: GenericApplicationContext): ExampleController { - return createProxy(ExampleController::class.java) - } - - private fun createProxy(clazz: Class): T { - val proxyFactory = ProxyFactory(clazz) - proxyFactory.targetClass = clazz - @Suppress("UNCHECKED_CAST") - return proxyFactory.proxy as T - } - } - -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/app9/DemoController.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/app9/DemoController.kt deleted file mode 100644 index e49d7dc0c..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/app9/DemoController.kt +++ /dev/null @@ -1,72 +0,0 @@ -package test.org.springdoc.api.app9 - -import io.swagger.v3.oas.annotations.media.Schema -import org.springframework.web.bind.annotation.GetMapping -import org.springframework.web.bind.annotation.RequestMapping -import org.springframework.web.bind.annotation.RestController - -@RestController -@RequestMapping("/api/demo") -class DocumentsApiController { - - @GetMapping - suspend fun getDocuments( request: DemoRequest - ): DemoDto = DemoDto(42) -} - -data class DemoDto( - var id: Long, -) - -class DemoRequest ( - - @field:Schema(required = true, defaultValue = "a default value") - val requiredNullableDefault: String?, - - @field:Schema(required = true) - val requiredNullableNoDefault: String?, - - @field:Schema(required = true, defaultValue = "a default value") - val requiredNoNullableDefault: String, - - @field:Schema(required = true) - val requiredNoNullableNoDefault: String, - - @field:Schema(requiredMode = Schema.RequiredMode.REQUIRED, defaultValue = "a default value") - val requiredNullableDefault1: String?, - - @field:Schema(requiredMode = Schema.RequiredMode.REQUIRED) - val requiredNullableNoDefault1: String?, - - @field:Schema(requiredMode = Schema.RequiredMode.REQUIRED, defaultValue = "a default value") - val requiredNoNullableDefault1: String, - - @field:Schema(requiredMode = Schema.RequiredMode.REQUIRED) - val requiredNoNullableNoDefault1: String, - - @field:Schema(requiredMode = Schema.RequiredMode.NOT_REQUIRED, defaultValue = "a default value") - val noRequiredNullableDefault2: String?, - - @field:Schema(requiredMode = Schema.RequiredMode.NOT_REQUIRED) - val noRequiredNullableNoDefault2: String?, - - @field:Schema(requiredMode = Schema.RequiredMode.NOT_REQUIRED, defaultValue = "a default value") - val noRequiredNoNullableDefault2: String, - - @field:Schema(requiredMode = Schema.RequiredMode.NOT_REQUIRED) - val noRequiredNoNullableNoDefault2: String, - - @field:Schema(defaultValue = "a default value") - val noRequiredNullableDefault: String?, - - @field:Schema - val noRequiredNullableNoDefault: String?, - - @field:Schema(defaultValue = "a default value") - val noRequiredNoNullableDefault: String, - - @field:Schema - val noRequiredNoNullableNoDefault: String, - - -) diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/app9/SpringDocApp9Test.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/app9/SpringDocApp9Test.kt deleted file mode 100644 index 3c4a5a8c3..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/app9/SpringDocApp9Test.kt +++ /dev/null @@ -1,31 +0,0 @@ -/* - * - * * Copyright 2019-2023 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.app9 - -import org.springframework.boot.autoconfigure.SpringBootApplication -import org.springframework.context.annotation.ComponentScan -import test.org.springdoc.api.AbstractKotlinSpringDocTest - -class SpringDocApp9Test : AbstractKotlinSpringDocTest() { - - @SpringBootApplication - @ComponentScan(basePackages = ["org.springdoc", "test.org.springdoc.api.app9"]) - open class DemoApplication - -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v30/AbstractKotlinSpringDocTest.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v30/AbstractKotlinSpringDocTest.kt new file mode 100644 index 000000000..b4e83808c --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v30/AbstractKotlinSpringDocTest.kt @@ -0,0 +1,92 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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 + +import org.junit.jupiter.api.Test +import org.skyscreamer.jsonassert.JSONAssert +import org.slf4j.LoggerFactory +import org.springdoc.core.utils.Constants +import org.springframework.beans.factory.annotation.Autowired +import org.springframework.boot.test.autoconfigure.web.reactive.AutoConfigureWebTestClient +import org.springframework.boot.test.autoconfigure.web.reactive.WebFluxTest +import org.springframework.test.context.ActiveProfiles +import org.springframework.test.context.TestPropertySource +import org.springframework.test.web.reactive.server.WebTestClient +import java.nio.charset.StandardCharsets +import java.nio.file.Files +import java.nio.file.Paths + +@WebFluxTest +@ActiveProfiles("test") +@AutoConfigureWebTestClient(timeout = "3600000") +@TestPropertySource(properties = ["springdoc.api-docs.version=openapi_3_0"]) +abstract class AbstractKotlinSpringDocTest { + + @Autowired + private val webTestClient: WebTestClient? = null + + private val logger = LoggerFactory.getLogger(AbstractKotlinSpringDocTest::class.java) + + @Test + @Throws(Exception::class) + fun testApp() { + var result: String? = null + try { + val getResult = + webTestClient!!.get().uri(Constants.DEFAULT_API_DOCS_URL).exchange() + .expectStatus().isOk.expectBody().returnResult() + + result = String(getResult.responseBody!!) + val className = javaClass.simpleName + val testNumber = className.replace("[^0-9]".toRegex(), "") + + val expected = getContent("results/3.0.1/app$testNumber.json") + JSONAssert.assertEquals(expected, result, true) + } catch (e: AssertionError) { + logger.error(result) + throw e + } + } + + companion object { + @Throws(Exception::class) + fun getContent(fileName: String): String { + try { + val path = Paths.get( + AbstractKotlinSpringDocTest::class.java.classLoader.getResource( + fileName + )!!.toURI() + ) + val fileBytes = Files.readAllBytes(path) + return String(fileBytes, StandardCharsets.UTF_8) + } catch (e: Exception) { + throw RuntimeException("Failed to read file: $fileName", e) + } + + } + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v30/app10/ExampleController.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v30/app10/ExampleController.kt new file mode 100644 index 000000000..aef52b178 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v30/app10/ExampleController.kt @@ -0,0 +1,20 @@ +package test.org.springdoc.api.v30.app10 + +import org.springframework.web.bind.annotation.GetMapping +import org.springframework.web.bind.annotation.RequestParam +import org.springframework.web.bind.annotation.RestController +import test.org.springdoc.api.v30.app8.Greeting + +data class Greeting(val greeting: String) + +@RestController +class ExampleController { + @GetMapping("/") + fun greet(@RequestParam name: String?) = Greeting("Hello ${name ?: "world"}") + + @GetMapping("/test") + fun test(@RequestParam name: String) = Greeting("Hello $name") + + @GetMapping("/test-with-default") + fun testWithDefault(@RequestParam(defaultValue = "world") name: String) = Greeting("Hello $name") +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v30/app10/SpringDocApp10Test.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v30/app10/SpringDocApp10Test.kt new file mode 100644 index 000000000..121737fa6 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v30/app10/SpringDocApp10Test.kt @@ -0,0 +1,31 @@ +/* + * + * * Copyright 2019-2023 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.app10 + +import org.springframework.boot.autoconfigure.SpringBootApplication +import org.springframework.context.annotation.ComponentScan +import test.org.springdoc.api.v30.AbstractKotlinSpringDocTest + +class SpringDocApp10Test : AbstractKotlinSpringDocTest() { + + @SpringBootApplication + @ComponentScan(basePackages = ["org.springdoc", "test.org.springdoc.api.v30.app10"]) + open class DemoApplication + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v30/app11/SpringDocApp11Test.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v30/app11/SpringDocApp11Test.kt new file mode 100644 index 000000000..3f6a7ae66 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v30/app11/SpringDocApp11Test.kt @@ -0,0 +1,31 @@ +/* + * + * * Copyright 2019-2020 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.app11 + +import org.springframework.boot.autoconfigure.SpringBootApplication +import org.springframework.context.annotation.ComponentScan +import test.org.springdoc.api.v30.AbstractKotlinSpringDocTest + +class SpringDocApp11Test : AbstractKotlinSpringDocTest() { + + @SpringBootApplication + @ComponentScan(basePackages = ["org.springdoc", "test.org.springdoc.api.v30.app11"]) + class DemoApplication + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v30/app11/SystemStatusController.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v30/app11/SystemStatusController.kt new file mode 100644 index 000000000..db37e9b41 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v30/app11/SystemStatusController.kt @@ -0,0 +1,59 @@ +/* + * + * * Copyright 2019-2020 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.app11 + +import io.swagger.v3.oas.annotations.media.Schema +import kotlinx.coroutines.reactor.mono +import org.springframework.web.bind.annotation.GetMapping +import org.springframework.web.bind.annotation.RequestMapping +import org.springframework.web.bind.annotation.RestController + +enum class SystemStatus(val status: String) { + OK("OK") +} + +data class PersonDTO( + @Deprecated ("no-email") val email: String, + val firstName: String, + val lastName: String +) + +data class SystemStatusResponse( + @Deprecated ("will be removed in next version") + val systemStatus: SystemStatus, + + @Deprecated ("") + val emptyTest:String, + + @Deprecated ("should be ignored") + @Schema(description = "nonEmptyDesc") + val nonEmptyDesc:String +) + +@RestController +@RequestMapping("/status") +class SystemStatusController { + @GetMapping + suspend fun index() = SystemStatusResponse(SystemStatus.OK,"","") + + @GetMapping("/foo") + fun foo(personDTO: PersonDTO) = mono { + SystemStatusResponse(SystemStatus.OK,"","") + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v30/app2/SpringDocApp2Test.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v30/app2/SpringDocApp2Test.kt new file mode 100644 index 000000000..49e94b21f --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v30/app2/SpringDocApp2Test.kt @@ -0,0 +1,31 @@ +/* + * + * * Copyright 2019-2020 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.app2 + +import org.springframework.boot.autoconfigure.SpringBootApplication +import org.springframework.context.annotation.ComponentScan +import test.org.springdoc.api.v30.AbstractKotlinSpringDocTest + +class SpringDocApp2Test : AbstractKotlinSpringDocTest() { + + @SpringBootApplication + @ComponentScan(basePackages = ["org.springdoc", "test.org.springdoc.api.v30.app2"]) + open class DemoApplication + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v30/app2/SystemStatusController.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v30/app2/SystemStatusController.kt new file mode 100644 index 000000000..ccfdf5822 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v30/app2/SystemStatusController.kt @@ -0,0 +1,59 @@ +/* + * + * * Copyright 2019-2020 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.app2 + +import jakarta.validation.Valid +import kotlinx.coroutines.reactor.mono +import org.springframework.http.HttpStatus +import org.springframework.web.bind.annotation.GetMapping +import org.springframework.web.bind.annotation.PathVariable +import org.springframework.web.bind.annotation.PostMapping +import org.springframework.web.bind.annotation.RequestBody +import org.springframework.web.bind.annotation.RequestMapping +import org.springframework.web.bind.annotation.ResponseStatus +import org.springframework.web.bind.annotation.RestController + +enum class SystemStatus(val status: String) { + OK("OK") +} + +data class SystemStatusResponse( + val status: SystemStatus +) + +@RestController +@RequestMapping("/status") +class SystemStatusController { + @GetMapping + suspend fun index() = SystemStatusResponse(SystemStatus.OK) + + @GetMapping("/foo") + fun foo() = mono { + SystemStatusResponse(SystemStatus.OK) + } + + @PostMapping("{token}/activate") + @ResponseStatus(HttpStatus.NO_CONTENT) + suspend fun activateUser( + @PathVariable token: String, + @RequestBody @Valid request: String + ) { + // do something + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v30/app3/SpringDocApp3Test.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v30/app3/SpringDocApp3Test.kt new file mode 100644 index 000000000..3253d72e0 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v30/app3/SpringDocApp3Test.kt @@ -0,0 +1,31 @@ +/* + * + * * Copyright 2019-2020 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.app3 + +import org.springframework.boot.autoconfigure.SpringBootApplication +import org.springframework.context.annotation.ComponentScan +import test.org.springdoc.api.v30.AbstractKotlinSpringDocTest + +class SpringDocApp3Test : AbstractKotlinSpringDocTest() { + + @SpringBootApplication + @ComponentScan(basePackages = ["org.springdoc", "test.org.springdoc.api.v30.app3"]) + open class DemoApplication + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v30/app3/SystemStatusController.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v30/app3/SystemStatusController.kt new file mode 100644 index 000000000..de44f2a3c --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v30/app3/SystemStatusController.kt @@ -0,0 +1,45 @@ +/* + * + * * Copyright 2019-2020 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.app3 + +import kotlinx.coroutines.reactor.mono +import org.springframework.web.bind.annotation.GetMapping +import org.springframework.web.bind.annotation.RequestMapping +import org.springframework.web.bind.annotation.RestController + +enum class SystemStatus(val status: String) { + OK("OK") +} + +data class SystemStatusResponse( + val status: SystemStatus +) + +@RestController +@RequestMapping("/status") +class SystemStatusController { + @GetMapping + suspend fun index() = SystemStatusResponse(SystemStatus.OK) + + @GetMapping("/foo") + @Deprecated("") + fun foo() = mono { + SystemStatusResponse(SystemStatus.OK) + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v30/app4/HelloController.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v30/app4/HelloController.kt new file mode 100644 index 000000000..94d495cc8 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v30/app4/HelloController.kt @@ -0,0 +1,37 @@ +/* + * + * * Copyright 2019-2020 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.app4 + +import org.springframework.web.bind.annotation.GetMapping +import org.springframework.web.bind.annotation.RequestMapping +import org.springframework.web.bind.annotation.RestController + + +data class Person( + val name: String, + val nickname: String? +) + +@RestController +@RequestMapping("/test") +class HelloController { + @GetMapping + suspend fun index(s: Person) = s + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v30/app4/SpringDocApp4Test.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v30/app4/SpringDocApp4Test.kt new file mode 100644 index 000000000..248b89073 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v30/app4/SpringDocApp4Test.kt @@ -0,0 +1,31 @@ +/* + * + * * Copyright 2019-2020 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.app4 + +import org.springframework.boot.autoconfigure.SpringBootApplication +import org.springframework.context.annotation.ComponentScan +import test.org.springdoc.api.v30.AbstractKotlinSpringDocTest + +class SpringDocApp4Test : AbstractKotlinSpringDocTest() { + + @SpringBootApplication + @ComponentScan(basePackages = ["org.springdoc", "test.org.springdoc.api.v30.app4"]) + open class DemoApplication + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v30/app5/HelloController.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v30/app5/HelloController.kt new file mode 100644 index 000000000..26fab15d7 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v30/app5/HelloController.kt @@ -0,0 +1,46 @@ +/* + * + * * Copyright 2019-2020 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.app5 + +import kotlinx.coroutines.delay +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.flow +import org.springframework.web.bind.annotation.GetMapping +import org.springframework.web.bind.annotation.RequestMapping +import org.springframework.web.bind.annotation.RestController + + +data class Person( + val name: String, + val nickname: String? +) + +@RestController +@RequestMapping("/test") +class HelloController { + + @GetMapping("/") + fun foo(): Flow = flow { // flow builder + for (i in 1..3) { + delay(100) // pretend we are doing something useful here + emit(i) // emit next value + } + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v30/app5/SpringDocApp5Test.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v30/app5/SpringDocApp5Test.kt new file mode 100644 index 000000000..d1e7da47e --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v30/app5/SpringDocApp5Test.kt @@ -0,0 +1,31 @@ +/* + * + * * Copyright 2019-2020 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.app5 + +import org.springframework.boot.autoconfigure.SpringBootApplication +import org.springframework.context.annotation.ComponentScan +import test.org.springdoc.api.v30.AbstractKotlinSpringDocTest + +class SpringDocApp5Test : AbstractKotlinSpringDocTest() { + + @SpringBootApplication + @ComponentScan(basePackages = ["org.springdoc", "test.org.springdoc.api.v30.app5"]) + open class DemoApplication + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v30/app6/ByteArrayController.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v30/app6/ByteArrayController.kt new file mode 100644 index 000000000..eea1383c9 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v30/app6/ByteArrayController.kt @@ -0,0 +1,38 @@ +/* + * + * * 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.app6 + +import io.swagger.v3.oas.annotations.media.Schema +import org.springframework.web.bind.annotation.GetMapping +import org.springframework.web.bind.annotation.RequestMapping +import org.springframework.web.bind.annotation.RestController + +data class Foo( + @Schema(description = "Some description about a byte array.") + val data: ByteArray +) + +@RestController +@RequestMapping("/bytearray") +class ByteArrayController { + + @GetMapping("/") + fun getByteArray(): Foo = Foo(byteArrayOf(0)) + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v30/app6/SpringDocApp6Test.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v30/app6/SpringDocApp6Test.kt new file mode 100644 index 000000000..b3b203012 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v30/app6/SpringDocApp6Test.kt @@ -0,0 +1,31 @@ +/* + * + * * Copyright 2019-2020 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.app6 + +import org.springframework.boot.autoconfigure.SpringBootApplication +import org.springframework.context.annotation.ComponentScan +import test.org.springdoc.api.v30.AbstractKotlinSpringDocTest + +class SpringDocApp6Test : AbstractKotlinSpringDocTest() { + + @SpringBootApplication + @ComponentScan(basePackages = ["org.springdoc", "test.org.springdoc.api.v30.app6"]) + open class DemoApplication + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v30/app7/ExampleController.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v30/app7/ExampleController.kt new file mode 100644 index 000000000..64afa35d6 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v30/app7/ExampleController.kt @@ -0,0 +1,17 @@ +package test.org.springdoc.api.v30.app7 + +import io.swagger.v3.oas.annotations.Parameter +import org.springframework.web.bind.annotation.GetMapping +import org.springframework.web.bind.annotation.RequestParam +import org.springframework.web.bind.annotation.RestController + +data class Greeting(val greeting: String) + +@RestController +interface ExampleController { + @GetMapping("/") + fun greet(@RequestParam name: String?): Greeting + + @GetMapping("/test") + fun test(@RequestParam @Parameter(required = true) name: String?): Greeting +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v30/app7/SpringDocApp7Test.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v30/app7/SpringDocApp7Test.kt new file mode 100644 index 000000000..8a473d3e5 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v30/app7/SpringDocApp7Test.kt @@ -0,0 +1,46 @@ +/* + * + * * Copyright 2019-2020 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.app7 + +import org.springframework.aop.framework.ProxyFactory +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 + +class SpringDocApp7Test : AbstractKotlinSpringDocTest() { + + @SpringBootApplication + @ComponentScan(basePackages = ["org.springdoc", "test.org.springdoc.api.v30.app7"]) + open class DemoApplication{ + @Bean + fun controller(applicationContext: GenericApplicationContext): ExampleController { + return createProxy(ExampleController::class.java) + } + + private fun createProxy(clazz: Class): T { + val proxyFactory = ProxyFactory(clazz) + proxyFactory.targetClass = clazz + @Suppress("UNCHECKED_CAST") + return proxyFactory.proxy as T + } + } + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v30/app8/ExampleController.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v30/app8/ExampleController.kt new file mode 100644 index 000000000..9778adba4 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v30/app8/ExampleController.kt @@ -0,0 +1,17 @@ +package test.org.springdoc.api.v30.app8 + +import io.swagger.v3.oas.annotations.Parameter +import org.springframework.web.bind.annotation.GetMapping +import org.springframework.web.bind.annotation.RequestParam +import org.springframework.web.bind.annotation.RestController + +data class Greeting(val greeting: String) + +@RestController +interface ExampleController { + @GetMapping("/") + fun greet(@RequestParam name: String?): Greeting + + @GetMapping("/test") + fun test(@RequestParam @Parameter(required = true) name: String?): Greeting +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v30/app8/SpringDocApp8Test.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v30/app8/SpringDocApp8Test.kt new file mode 100644 index 000000000..ad52fde72 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v30/app8/SpringDocApp8Test.kt @@ -0,0 +1,49 @@ +/* + * + * * Copyright 2019-2020 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.app8 + +import org.springdoc.core.utils.Constants +import org.springframework.aop.framework.ProxyFactory +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 org.springframework.test.context.TestPropertySource +import test.org.springdoc.api.v30.AbstractKotlinSpringDocTest + +@TestPropertySource(properties = [Constants.SPRINGDOC_NULLABLE_REQUEST_PARAMETER_ENABLED+"=false"]) +class SpringDocApp8Test : AbstractKotlinSpringDocTest() { + + @SpringBootApplication + @ComponentScan(basePackages = ["org.springdoc", "test.org.springdoc.api.v30.app8"]) + class DemoApplication{ + @Bean + fun controller(applicationContext: GenericApplicationContext): ExampleController { + return createProxy(ExampleController::class.java) + } + + private fun createProxy(clazz: Class): T { + val proxyFactory = ProxyFactory(clazz) + proxyFactory.targetClass = clazz + @Suppress("UNCHECKED_CAST") + return proxyFactory.proxy as T + } + } + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v30/app9/DemoController.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v30/app9/DemoController.kt new file mode 100644 index 000000000..efb1e34de --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v30/app9/DemoController.kt @@ -0,0 +1,72 @@ +package test.org.springdoc.api.v30.app9 + +import io.swagger.v3.oas.annotations.media.Schema +import org.springframework.web.bind.annotation.GetMapping +import org.springframework.web.bind.annotation.RequestMapping +import org.springframework.web.bind.annotation.RestController + +@RestController +@RequestMapping("/api/demo") +class DocumentsApiController { + + @GetMapping + suspend fun getDocuments( request: DemoRequest + ): DemoDto = DemoDto(42) +} + +data class DemoDto( + var id: Long, +) + +class DemoRequest ( + + @field:Schema(required = true, defaultValue = "a default value") + val requiredNullableDefault: String?, + + @field:Schema(required = true) + val requiredNullableNoDefault: String?, + + @field:Schema(required = true, defaultValue = "a default value") + val requiredNoNullableDefault: String, + + @field:Schema(required = true) + val requiredNoNullableNoDefault: String, + + @field:Schema(requiredMode = Schema.RequiredMode.REQUIRED, defaultValue = "a default value") + val requiredNullableDefault1: String?, + + @field:Schema(requiredMode = Schema.RequiredMode.REQUIRED) + val requiredNullableNoDefault1: String?, + + @field:Schema(requiredMode = Schema.RequiredMode.REQUIRED, defaultValue = "a default value") + val requiredNoNullableDefault1: String, + + @field:Schema(requiredMode = Schema.RequiredMode.REQUIRED) + val requiredNoNullableNoDefault1: String, + + @field:Schema(requiredMode = Schema.RequiredMode.NOT_REQUIRED, defaultValue = "a default value") + val noRequiredNullableDefault2: String?, + + @field:Schema(requiredMode = Schema.RequiredMode.NOT_REQUIRED) + val noRequiredNullableNoDefault2: String?, + + @field:Schema(requiredMode = Schema.RequiredMode.NOT_REQUIRED, defaultValue = "a default value") + val noRequiredNoNullableDefault2: String, + + @field:Schema(requiredMode = Schema.RequiredMode.NOT_REQUIRED) + val noRequiredNoNullableNoDefault2: String, + + @field:Schema(defaultValue = "a default value") + val noRequiredNullableDefault: String?, + + @field:Schema + val noRequiredNullableNoDefault: String?, + + @field:Schema(defaultValue = "a default value") + val noRequiredNoNullableDefault: String, + + @field:Schema + val noRequiredNoNullableNoDefault: String, + + +) diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v30/app9/SpringDocApp9Test.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v30/app9/SpringDocApp9Test.kt new file mode 100644 index 000000000..92dba2234 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v30/app9/SpringDocApp9Test.kt @@ -0,0 +1,31 @@ +/* + * + * * Copyright 2019-2023 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.app9 + +import org.springframework.boot.autoconfigure.SpringBootApplication +import org.springframework.context.annotation.ComponentScan +import test.org.springdoc.api.v30.AbstractKotlinSpringDocTest + +class SpringDocApp9Test : AbstractKotlinSpringDocTest() { + + @SpringBootApplication + @ComponentScan(basePackages = ["org.springdoc", "test.org.springdoc.api.v30.app9"]) + open class DemoApplication + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v31/AbstractKotlinSpringDocTest.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v31/AbstractKotlinSpringDocTest.kt new file mode 100644 index 000000000..51c1660e8 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v31/AbstractKotlinSpringDocTest.kt @@ -0,0 +1,90 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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 + +import org.junit.jupiter.api.Test +import org.skyscreamer.jsonassert.JSONAssert +import org.slf4j.LoggerFactory +import org.springdoc.core.utils.Constants +import org.springframework.beans.factory.annotation.Autowired +import org.springframework.boot.test.autoconfigure.web.reactive.AutoConfigureWebTestClient +import org.springframework.boot.test.autoconfigure.web.reactive.WebFluxTest +import org.springframework.test.context.ActiveProfiles +import org.springframework.test.web.reactive.server.WebTestClient +import java.nio.charset.StandardCharsets +import java.nio.file.Files +import java.nio.file.Paths + +@WebFluxTest +@ActiveProfiles("test") +@AutoConfigureWebTestClient(timeout = "3600000") +abstract class AbstractKotlinSpringDocTest { + + @Autowired + private val webTestClient: WebTestClient? = null + + private val logger = LoggerFactory.getLogger(AbstractKotlinSpringDocTest::class.java) + + @Test + @Throws(Exception::class) + fun testApp() { + var result: String? = null + try { + val getResult = + webTestClient!!.get().uri(Constants.DEFAULT_API_DOCS_URL).exchange() + .expectStatus().isOk.expectBody().returnResult() + + result = String(getResult.responseBody!!) + val className = javaClass.simpleName + val testNumber = className.replace("[^0-9]".toRegex(), "") + + val expected = getContent("results/3.1.0/app$testNumber.json") + JSONAssert.assertEquals(expected, result, true) + } catch (e: AssertionError) { + logger.error(result) + throw e + } + } + + companion object { + @Throws(Exception::class) + fun getContent(fileName: String): String { + try { + val path = Paths.get( + AbstractKotlinSpringDocTest::class.java.classLoader.getResource( + fileName + )!!.toURI() + ) + val fileBytes = Files.readAllBytes(path) + return String(fileBytes, StandardCharsets.UTF_8) + } catch (e: Exception) { + throw RuntimeException("Failed to read file: $fileName", e) + } + + } + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v31/app10/ExampleController.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v31/app10/ExampleController.kt new file mode 100644 index 000000000..853824584 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v31/app10/ExampleController.kt @@ -0,0 +1,20 @@ +package test.org.springdoc.api.v31.app10 + +import org.springframework.web.bind.annotation.GetMapping +import org.springframework.web.bind.annotation.RequestParam +import org.springframework.web.bind.annotation.RestController +import test.org.springdoc.api.v30.app8.Greeting + +data class Greeting(val greeting: String) + +@RestController +class ExampleController { + @GetMapping("/") + fun greet(@RequestParam name: String?) = Greeting("Hello ${name ?: "world"}") + + @GetMapping("/test") + fun test(@RequestParam name: String) = Greeting("Hello $name") + + @GetMapping("/test-with-default") + fun testWithDefault(@RequestParam(defaultValue = "world") name: String) = Greeting("Hello $name") +} \ No newline at end of file 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 new file mode 100644 index 000000000..b753c3037 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v31/app10/SpringDocApp10Test.kt @@ -0,0 +1,31 @@ +/* + * + * * Copyright 2019-2023 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.app10 + +import org.springframework.boot.autoconfigure.SpringBootApplication +import org.springframework.context.annotation.ComponentScan +import test.org.springdoc.api.v30.AbstractKotlinSpringDocTest + +class SpringDocApp10Test : AbstractKotlinSpringDocTest() { + + @SpringBootApplication + @ComponentScan(basePackages = ["org.springdoc", "test.org.springdoc.api.v31.app10"]) + open class DemoApplication + +} \ No newline at end of file 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 new file mode 100644 index 000000000..b9e740b8b --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v31/app11/SpringDocApp11Test.kt @@ -0,0 +1,31 @@ +/* + * + * * Copyright 2019-2020 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.app11 + +import org.springframework.boot.autoconfigure.SpringBootApplication +import org.springframework.context.annotation.ComponentScan +import test.org.springdoc.api.v30.AbstractKotlinSpringDocTest + +class SpringDocApp11Test : AbstractKotlinSpringDocTest() { + + @SpringBootApplication + @ComponentScan(basePackages = ["org.springdoc", "test.org.springdoc.api.v31.app11"]) + class DemoApplication + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v31/app11/SystemStatusController.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v31/app11/SystemStatusController.kt new file mode 100644 index 000000000..145911386 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v31/app11/SystemStatusController.kt @@ -0,0 +1,59 @@ +/* + * + * * Copyright 2019-2020 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.app11 + +import io.swagger.v3.oas.annotations.media.Schema +import kotlinx.coroutines.reactor.mono +import org.springframework.web.bind.annotation.GetMapping +import org.springframework.web.bind.annotation.RequestMapping +import org.springframework.web.bind.annotation.RestController + +enum class SystemStatus(val status: String) { + OK("OK") +} + +data class PersonDTO( + @Deprecated ("no-email") val email: String, + val firstName: String, + val lastName: String +) + +data class SystemStatusResponse( + @Deprecated ("will be removed in next version") + val systemStatus: SystemStatus, + + @Deprecated ("") + val emptyTest:String, + + @Deprecated ("should be ignored") + @Schema(description = "nonEmptyDesc") + val nonEmptyDesc:String +) + +@RestController +@RequestMapping("/status") +class SystemStatusController { + @GetMapping + suspend fun index() = SystemStatusResponse(SystemStatus.OK,"","") + + @GetMapping("/foo") + fun foo(personDTO: PersonDTO) = mono { + SystemStatusResponse(SystemStatus.OK,"","") + } +} \ No newline at end of file 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 new file mode 100644 index 000000000..222137f6d --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v31/app2/SpringDocApp2Test.kt @@ -0,0 +1,31 @@ +/* + * + * * Copyright 2019-2020 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.app2 + +import org.springframework.boot.autoconfigure.SpringBootApplication +import org.springframework.context.annotation.ComponentScan +import test.org.springdoc.api.v30.AbstractKotlinSpringDocTest + +class SpringDocApp2Test : AbstractKotlinSpringDocTest() { + + @SpringBootApplication + @ComponentScan(basePackages = ["org.springdoc", "test.org.springdoc.api.v31.app2"]) + open class DemoApplication + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v31/app2/SystemStatusController.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v31/app2/SystemStatusController.kt new file mode 100644 index 000000000..03281517a --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v31/app2/SystemStatusController.kt @@ -0,0 +1,59 @@ +/* + * + * * Copyright 2019-2020 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.app2 + +import jakarta.validation.Valid +import kotlinx.coroutines.reactor.mono +import org.springframework.http.HttpStatus +import org.springframework.web.bind.annotation.GetMapping +import org.springframework.web.bind.annotation.PathVariable +import org.springframework.web.bind.annotation.PostMapping +import org.springframework.web.bind.annotation.RequestBody +import org.springframework.web.bind.annotation.RequestMapping +import org.springframework.web.bind.annotation.ResponseStatus +import org.springframework.web.bind.annotation.RestController + +enum class SystemStatus(val status: String) { + OK("OK") +} + +data class SystemStatusResponse( + val status: SystemStatus +) + +@RestController +@RequestMapping("/status") +class SystemStatusController { + @GetMapping + suspend fun index() = SystemStatusResponse(SystemStatus.OK) + + @GetMapping("/foo") + fun foo() = mono { + SystemStatusResponse(SystemStatus.OK) + } + + @PostMapping("{token}/activate") + @ResponseStatus(HttpStatus.NO_CONTENT) + suspend fun activateUser( + @PathVariable token: String, + @RequestBody @Valid request: String + ) { + // do something + } +} 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 new file mode 100644 index 000000000..eb475f349 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v31/app3/SpringDocApp3Test.kt @@ -0,0 +1,31 @@ +/* + * + * * Copyright 2019-2020 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.app3 + +import org.springframework.boot.autoconfigure.SpringBootApplication +import org.springframework.context.annotation.ComponentScan +import test.org.springdoc.api.v30.AbstractKotlinSpringDocTest + +class SpringDocApp3Test : AbstractKotlinSpringDocTest() { + + @SpringBootApplication + @ComponentScan(basePackages = ["org.springdoc", "test.org.springdoc.api.v31.app3"]) + open class DemoApplication + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v31/app3/SystemStatusController.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v31/app3/SystemStatusController.kt new file mode 100644 index 000000000..25f1478e6 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v31/app3/SystemStatusController.kt @@ -0,0 +1,45 @@ +/* + * + * * Copyright 2019-2020 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.app3 + +import kotlinx.coroutines.reactor.mono +import org.springframework.web.bind.annotation.GetMapping +import org.springframework.web.bind.annotation.RequestMapping +import org.springframework.web.bind.annotation.RestController + +enum class SystemStatus(val status: String) { + OK("OK") +} + +data class SystemStatusResponse( + val status: SystemStatus +) + +@RestController +@RequestMapping("/status") +class SystemStatusController { + @GetMapping + suspend fun index() = SystemStatusResponse(SystemStatus.OK) + + @GetMapping("/foo") + @Deprecated("") + fun foo() = mono { + SystemStatusResponse(SystemStatus.OK) + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v31/app4/HelloController.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v31/app4/HelloController.kt new file mode 100644 index 000000000..f1ff201e3 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v31/app4/HelloController.kt @@ -0,0 +1,37 @@ +/* + * + * * Copyright 2019-2020 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.app4 + +import org.springframework.web.bind.annotation.GetMapping +import org.springframework.web.bind.annotation.RequestMapping +import org.springframework.web.bind.annotation.RestController + + +data class Person( + val name: String, + val nickname: String? +) + +@RestController +@RequestMapping("/test") +class HelloController { + @GetMapping + suspend fun index(s: Person) = s + +} 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 new file mode 100644 index 000000000..f56c9576e --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v31/app4/SpringDocApp4Test.kt @@ -0,0 +1,31 @@ +/* + * + * * Copyright 2019-2020 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.app4 + +import org.springframework.boot.autoconfigure.SpringBootApplication +import org.springframework.context.annotation.ComponentScan +import test.org.springdoc.api.v30.AbstractKotlinSpringDocTest + +class SpringDocApp4Test : AbstractKotlinSpringDocTest() { + + @SpringBootApplication + @ComponentScan(basePackages = ["org.springdoc", "test.org.springdoc.api.v31.app4"]) + open class DemoApplication + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v31/app5/HelloController.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v31/app5/HelloController.kt new file mode 100644 index 000000000..6eb8e828e --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v31/app5/HelloController.kt @@ -0,0 +1,46 @@ +/* + * + * * Copyright 2019-2020 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.app5 + +import kotlinx.coroutines.delay +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.flow +import org.springframework.web.bind.annotation.GetMapping +import org.springframework.web.bind.annotation.RequestMapping +import org.springframework.web.bind.annotation.RestController + + +data class Person( + val name: String, + val nickname: String? +) + +@RestController +@RequestMapping("/test") +class HelloController { + + @GetMapping("/") + fun foo(): Flow = flow { // flow builder + for (i in 1..3) { + delay(100) // pretend we are doing something useful here + emit(i) // emit next value + } + } + +} 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 new file mode 100644 index 000000000..34fe86409 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v31/app5/SpringDocApp5Test.kt @@ -0,0 +1,31 @@ +/* + * + * * Copyright 2019-2020 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.app5 + +import org.springframework.boot.autoconfigure.SpringBootApplication +import org.springframework.context.annotation.ComponentScan +import test.org.springdoc.api.v30.AbstractKotlinSpringDocTest + +class SpringDocApp5Test : AbstractKotlinSpringDocTest() { + + @SpringBootApplication + @ComponentScan(basePackages = ["org.springdoc", "test.org.springdoc.api.v31.app5"]) + open class DemoApplication + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v31/app6/ByteArrayController.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v31/app6/ByteArrayController.kt new file mode 100644 index 000000000..5ae608680 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v31/app6/ByteArrayController.kt @@ -0,0 +1,38 @@ +/* + * + * * 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.app6 + +import io.swagger.v3.oas.annotations.media.Schema +import org.springframework.web.bind.annotation.GetMapping +import org.springframework.web.bind.annotation.RequestMapping +import org.springframework.web.bind.annotation.RestController + +data class Foo( + @Schema(description = "Some description about a byte array.") + val data: ByteArray +) + +@RestController +@RequestMapping("/bytearray") +class ByteArrayController { + + @GetMapping("/") + fun getByteArray(): Foo = Foo(byteArrayOf(0)) + +} 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 new file mode 100644 index 000000000..8c8a7c5aa --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v31/app6/SpringDocApp6Test.kt @@ -0,0 +1,31 @@ +/* + * + * * Copyright 2019-2020 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.app6 + +import org.springframework.boot.autoconfigure.SpringBootApplication +import org.springframework.context.annotation.ComponentScan +import test.org.springdoc.api.v30.AbstractKotlinSpringDocTest + +class SpringDocApp6Test : AbstractKotlinSpringDocTest() { + + @SpringBootApplication + @ComponentScan(basePackages = ["org.springdoc", "test.org.springdoc.api.v31.app6"]) + open class DemoApplication + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v31/app7/ExampleController.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v31/app7/ExampleController.kt new file mode 100644 index 000000000..bc0852278 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v31/app7/ExampleController.kt @@ -0,0 +1,17 @@ +package test.org.springdoc.api.v31.app7 + +import io.swagger.v3.oas.annotations.Parameter +import org.springframework.web.bind.annotation.GetMapping +import org.springframework.web.bind.annotation.RequestParam +import org.springframework.web.bind.annotation.RestController + +data class Greeting(val greeting: String) + +@RestController +interface ExampleController { + @GetMapping("/") + fun greet(@RequestParam name: String?): Greeting + + @GetMapping("/test") + fun test(@RequestParam @Parameter(required = true) name: String?): Greeting +} \ No newline at end of file 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 new file mode 100644 index 000000000..8dc8915c9 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v31/app7/SpringDocApp7Test.kt @@ -0,0 +1,46 @@ +/* + * + * * Copyright 2019-2020 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.app7 + +import org.springframework.aop.framework.ProxyFactory +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 + +class SpringDocApp7Test : AbstractKotlinSpringDocTest() { + + @SpringBootApplication + @ComponentScan(basePackages = ["org.springdoc", "test.org.springdoc.api.v31.app7"]) + open class DemoApplication{ + @Bean + fun controller(applicationContext: GenericApplicationContext): ExampleController { + return createProxy(ExampleController::class.java) + } + + private fun createProxy(clazz: Class): T { + val proxyFactory = ProxyFactory(clazz) + proxyFactory.targetClass = clazz + @Suppress("UNCHECKED_CAST") + return proxyFactory.proxy as T + } + } + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v31/app8/ExampleController.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v31/app8/ExampleController.kt new file mode 100644 index 000000000..074eed409 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v31/app8/ExampleController.kt @@ -0,0 +1,17 @@ +package test.org.springdoc.api.v31.app8 + +import io.swagger.v3.oas.annotations.Parameter +import org.springframework.web.bind.annotation.GetMapping +import org.springframework.web.bind.annotation.RequestParam +import org.springframework.web.bind.annotation.RestController + +data class Greeting(val greeting: String) + +@RestController +interface ExampleController { + @GetMapping("/") + fun greet(@RequestParam name: String?): Greeting + + @GetMapping("/test") + fun test(@RequestParam @Parameter(required = true) name: String?): Greeting +} \ No newline at end of file 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 new file mode 100644 index 000000000..aef6d155d --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v31/app8/SpringDocApp8Test.kt @@ -0,0 +1,49 @@ +/* + * + * * Copyright 2019-2020 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.app8 + +import org.springdoc.core.utils.Constants +import org.springframework.aop.framework.ProxyFactory +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 org.springframework.test.context.TestPropertySource +import test.org.springdoc.api.v30.AbstractKotlinSpringDocTest + +@TestPropertySource(properties = [Constants.SPRINGDOC_NULLABLE_REQUEST_PARAMETER_ENABLED+"=false"]) +class SpringDocApp8Test : AbstractKotlinSpringDocTest() { + + @SpringBootApplication + @ComponentScan(basePackages = ["org.springdoc", "test.org.springdoc.api.v31.app8"]) + class DemoApplication{ + @Bean + fun controller(applicationContext: GenericApplicationContext): ExampleController { + return createProxy(ExampleController::class.java) + } + + private fun createProxy(clazz: Class): T { + val proxyFactory = ProxyFactory(clazz) + proxyFactory.targetClass = clazz + @Suppress("UNCHECKED_CAST") + return proxyFactory.proxy as T + } + } + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v31/app9/DemoController.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v31/app9/DemoController.kt new file mode 100644 index 000000000..1957c6f9e --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v31/app9/DemoController.kt @@ -0,0 +1,72 @@ +package test.org.springdoc.api.v31.app9 + +import io.swagger.v3.oas.annotations.media.Schema +import org.springframework.web.bind.annotation.GetMapping +import org.springframework.web.bind.annotation.RequestMapping +import org.springframework.web.bind.annotation.RestController + +@RestController +@RequestMapping("/api/demo") +class DocumentsApiController { + + @GetMapping + suspend fun getDocuments( request: DemoRequest + ): DemoDto = DemoDto(42) +} + +data class DemoDto( + var id: Long, +) + +class DemoRequest ( + + @field:Schema(required = true, defaultValue = "a default value") + val requiredNullableDefault: String?, + + @field:Schema(required = true) + val requiredNullableNoDefault: String?, + + @field:Schema(required = true, defaultValue = "a default value") + val requiredNoNullableDefault: String, + + @field:Schema(required = true) + val requiredNoNullableNoDefault: String, + + @field:Schema(requiredMode = Schema.RequiredMode.REQUIRED, defaultValue = "a default value") + val requiredNullableDefault1: String?, + + @field:Schema(requiredMode = Schema.RequiredMode.REQUIRED) + val requiredNullableNoDefault1: String?, + + @field:Schema(requiredMode = Schema.RequiredMode.REQUIRED, defaultValue = "a default value") + val requiredNoNullableDefault1: String, + + @field:Schema(requiredMode = Schema.RequiredMode.REQUIRED) + val requiredNoNullableNoDefault1: String, + + @field:Schema(requiredMode = Schema.RequiredMode.NOT_REQUIRED, defaultValue = "a default value") + val noRequiredNullableDefault2: String?, + + @field:Schema(requiredMode = Schema.RequiredMode.NOT_REQUIRED) + val noRequiredNullableNoDefault2: String?, + + @field:Schema(requiredMode = Schema.RequiredMode.NOT_REQUIRED, defaultValue = "a default value") + val noRequiredNoNullableDefault2: String, + + @field:Schema(requiredMode = Schema.RequiredMode.NOT_REQUIRED) + val noRequiredNoNullableNoDefault2: String, + + @field:Schema(defaultValue = "a default value") + val noRequiredNullableDefault: String?, + + @field:Schema + val noRequiredNullableNoDefault: String?, + + @field:Schema(defaultValue = "a default value") + val noRequiredNoNullableDefault: String, + + @field:Schema + val noRequiredNoNullableNoDefault: String, + + +) 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 new file mode 100644 index 000000000..207740f45 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/kotlin/test/org/springdoc/api/v31/app9/SpringDocApp9Test.kt @@ -0,0 +1,31 @@ +/* + * + * * Copyright 2019-2023 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.app9 + +import org.springframework.boot.autoconfigure.SpringBootApplication +import org.springframework.context.annotation.ComponentScan +import test.org.springdoc.api.v30.AbstractKotlinSpringDocTest + +class SpringDocApp9Test : AbstractKotlinSpringDocTest() { + + @SpringBootApplication + @ComponentScan(basePackages = ["org.springdoc", "test.org.springdoc.api.v31.app9"]) + open class DemoApplication + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/resources/results/app1.json b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/resources/results/3.0.1/app1.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/resources/results/app1.json rename to springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/resources/results/3.0.1/app1.json diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/resources/results/app10.json b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/resources/results/3.0.1/app10.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/resources/results/app10.json rename to springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/resources/results/3.0.1/app10.json diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/resources/results/app11.json b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/resources/results/3.0.1/app11.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/resources/results/app11.json rename to springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/resources/results/3.0.1/app11.json diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/resources/results/app2.json b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/resources/results/3.0.1/app2.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/resources/results/app2.json rename to springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/resources/results/3.0.1/app2.json diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/resources/results/app21.json b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/resources/results/3.0.1/app21.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/resources/results/app21.json rename to springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/resources/results/3.0.1/app21.json diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/resources/results/app3.json b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/resources/results/3.0.1/app3.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/resources/results/app3.json rename to springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/resources/results/3.0.1/app3.json diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/resources/results/app4.json b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/resources/results/3.0.1/app4.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/resources/results/app4.json rename to springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/resources/results/3.0.1/app4.json diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/resources/results/app5.json b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/resources/results/3.0.1/app5.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/resources/results/app5.json rename to springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/resources/results/3.0.1/app5.json diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/resources/results/app6.json b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/resources/results/3.0.1/app6.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/resources/results/app6.json rename to springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/resources/results/3.0.1/app6.json diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/resources/results/app7.json b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/resources/results/3.0.1/app7.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/resources/results/app7.json rename to springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/resources/results/3.0.1/app7.json diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/resources/results/app8.json b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/resources/results/3.0.1/app8.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/resources/results/app8.json rename to springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/resources/results/3.0.1/app8.json diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/resources/results/app9.json b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/resources/results/3.0.1/app9.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/resources/results/app9.json rename to springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/resources/results/3.0.1/app9.json diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/resources/results/3.1.0/app1.json b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/resources/results/3.1.0/app1.json new file mode 100644 index 000000000..611c6c404 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/resources/results/3.1.0/app1.json @@ -0,0 +1,51 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "Kotlin API", + "license": { + "name": "Apache 2.0", + "url": "http://springdoc.org" + }, + "version": "v1" + }, + "servers": [ + { + "url": "", + "description": "Generated server url" + } + ], + "paths": { + "/test/{id}": { + "get": { + "tags": [ + "controller-with-continuation-parameter" + ], + "summary": "Ignore Continuation parameter", + "operationId": "get", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "string" + } + } + } + } + } + } + } + }, + "components": {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/resources/results/3.1.0/app10.json b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/resources/results/3.1.0/app10.json new file mode 100644 index 000000000..b115cb24d --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/resources/results/3.1.0/app10.json @@ -0,0 +1,121 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "", + "description": "Generated server url" + } + ], + "paths": { + "/": { + "get": { + "tags": [ + "example-controller" + ], + "operationId": "greet", + "parameters": [ + { + "name": "name", + "in": "query", + "required": false, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/Greeting" + } + } + } + } + } + } + }, + "/test": { + "get": { + "tags": [ + "example-controller" + ], + "operationId": "test", + "parameters": [ + { + "name": "name", + "in": "query", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/Greeting" + } + } + } + } + } + } + }, + "/test-with-default": { + "get": { + "tags": [ + "example-controller" + ], + "operationId": "testWithDefault", + "parameters": [ + { + "name": "name", + "in": "query", + "required": false, + "schema": { + "type": "string", + "default": "world" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/Greeting" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "Greeting": { + "required": [ + "greeting" + ], + "type": "object", + "properties": { + "greeting": { + "type": "string" + } + } + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/resources/results/3.1.0/app11.json b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/resources/results/3.1.0/app11.json new file mode 100644 index 000000000..e658d38d2 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/resources/results/3.1.0/app11.json @@ -0,0 +1,117 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "", + "description": "Generated server url" + } + ], + "paths": { + "/status": { + "get": { + "tags": [ + "system-status-controller" + ], + "operationId": "index", + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/SystemStatusResponse" + } + } + } + } + } + } + }, + "/status/foo": { + "get": { + "tags": [ + "system-status-controller" + ], + "operationId": "foo", + "parameters": [ + { + "name": "personDTO", + "in": "query", + "required": true, + "schema": { + "$ref": "#/components/schemas/PersonDTO" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/SystemStatusResponse" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "SystemStatusResponse": { + "required": [ + "emptyTest", + "nonEmptyDesc", + "systemStatus" + ], + "type": "object", + "properties": { + "systemStatus": { + "type": "string", + "description": "will be removed in next version", + "deprecated": true, + "enum": [ + "OK" + ] + }, + "emptyTest": { + "type": "string", + "deprecated": true + }, + "nonEmptyDesc": { + "type": "string", + "description": "nonEmptyDesc", + "deprecated": true + } + } + }, + "PersonDTO": { + "required": [ + "email", + "firstName", + "lastName" + ], + "type": "object", + "properties": { + "email": { + "type": "string", + "description": "no-email", + "deprecated": true + }, + "firstName": { + "type": "string" + }, + "lastName": { + "type": "string" + } + } + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/resources/results/3.1.0/app2.json b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/resources/results/3.1.0/app2.json new file mode 100644 index 000000000..979aafe3b --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/resources/results/3.1.0/app2.json @@ -0,0 +1,107 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "", + "description": "Generated server url" + } + ], + "paths": { + "/status/{token}/activate": { + "post": { + "tags": [ + "system-status-controller" + ], + "operationId": "activateUser", + "parameters": [ + { + "name": "token", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "string" + } + } + }, + "required": true + }, + "responses": { + "204": { + "description": "No Content", + "content": {} + } + } + } + }, + "/status": { + "get": { + "tags": [ + "system-status-controller" + ], + "operationId": "index", + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/SystemStatusResponse" + } + } + } + } + } + } + }, + "/status/foo": { + "get": { + "tags": [ + "system-status-controller" + ], + "operationId": "foo", + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/SystemStatusResponse" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "SystemStatusResponse": { + "required": [ + "status" + ], + "type": "object", + "properties": { + "status": { + "type": "string", + "enum": [ + "OK" + ] + } + } + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/resources/results/3.1.0/app21.json b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/resources/results/3.1.0/app21.json new file mode 100644 index 000000000..6412410d1 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/resources/results/3.1.0/app21.json @@ -0,0 +1,62 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "", + "description": "Generated server url" + } + ], + "paths": { + "/api/v2/test/test2": { + "get": { + "tags": [ + "Test" + ], + "operationId": "greet1", + "parameters": [ + { + "name": "name", + "in": "header", + "required": false, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK" + } + } + } + }, + "/api/v2/test/": { + "get": { + "tags": [ + "Test" + ], + "operationId": "greet", + "parameters": [ + { + "name": "name", + "in": "query", + "required": false, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK" + } + } + } + } + }, + "components": {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/resources/results/3.1.0/app3.json b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/resources/results/3.1.0/app3.json new file mode 100644 index 000000000..b7c467abb --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/resources/results/3.1.0/app3.json @@ -0,0 +1,74 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "", + "description": "Generated server url" + } + ], + "paths": { + "/status": { + "get": { + "tags": [ + "system-status-controller" + ], + "operationId": "index", + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/SystemStatusResponse" + } + } + } + } + } + } + }, + "/status/foo": { + "get": { + "tags": [ + "system-status-controller" + ], + "operationId": "foo", + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/SystemStatusResponse" + } + } + } + } + }, + "deprecated": true + } + } + }, + "components": { + "schemas": { + "SystemStatusResponse": { + "required": [ + "status" + ], + "type": "object", + "properties": { + "status": { + "type": "string", + "enum": [ + "OK" + ] + } + } + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/resources/results/3.1.0/app4.json b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/resources/results/3.1.0/app4.json new file mode 100644 index 000000000..b064b6abb --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/resources/results/3.1.0/app4.json @@ -0,0 +1,63 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "", + "description": "Generated server url" + } + ], + "paths": { + "/test": { + "get": { + "tags": [ + "hello-controller" + ], + "operationId": "index", + "parameters": [ + { + "name": "s", + "in": "query", + "required": true, + "schema": { + "$ref": "#/components/schemas/Person" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/Person" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "Person": { + "required": [ + "name" + ], + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "nickname": { + "type": "string" + } + } + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/resources/results/3.1.0/app5.json b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/resources/results/3.1.0/app5.json new file mode 100644 index 000000000..8c5a14c58 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/resources/results/3.1.0/app5.json @@ -0,0 +1,40 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "", + "description": "Generated server url" + } + ], + "paths": { + "/test/": { + "get": { + "tags": [ + "hello-controller" + ], + "operationId": "foo", + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "array", + "items": { + "type": "integer", + "format": "int32" + } + } + } + } + } + } + } + } + }, + "components": {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/resources/results/3.1.0/app6.json b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/resources/results/3.1.0/app6.json new file mode 100644 index 000000000..21c36b6fc --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/resources/results/3.1.0/app6.json @@ -0,0 +1,52 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "", + "description": "Generated server url" + } + ], + "paths": { + "/bytearray/": { + "get": { + "tags": [ + "byte-array-controller" + ], + "operationId": "getByteArray", + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/Foo" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "Foo": { + "required": [ + "data" + ], + "type": "object", + "properties": { + "data": { + "type": "string", + "description":"Some description about a byte array.", + "format": "byte" + } + } + } + } + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/resources/results/3.1.0/app7.json b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/resources/results/3.1.0/app7.json new file mode 100644 index 000000000..496a95b69 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/resources/results/3.1.0/app7.json @@ -0,0 +1,90 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "", + "description": "Generated server url" + } + ], + "paths": { + "/": { + "get": { + "tags": [ + "example-controller" + ], + "operationId": "greet", + "parameters": [ + { + "name": "name", + "in": "query", + "required": false, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/Greeting" + } + } + } + } + } + } + }, + "/test": { + "get": { + "tags": [ + "example-controller" + ], + "operationId": "test", + "parameters": [ + { + "name": "name", + "in": "query", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/Greeting" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "Greeting": { + "required": [ + "greeting" + ], + "type": "object", + "properties": { + "greeting": { + "type": "string" + } + } + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/resources/results/3.1.0/app8.json b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/resources/results/3.1.0/app8.json new file mode 100644 index 000000000..496a95b69 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/resources/results/3.1.0/app8.json @@ -0,0 +1,90 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "", + "description": "Generated server url" + } + ], + "paths": { + "/": { + "get": { + "tags": [ + "example-controller" + ], + "operationId": "greet", + "parameters": [ + { + "name": "name", + "in": "query", + "required": false, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/Greeting" + } + } + } + } + } + } + }, + "/test": { + "get": { + "tags": [ + "example-controller" + ], + "operationId": "test", + "parameters": [ + { + "name": "name", + "in": "query", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/Greeting" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "Greeting": { + "required": [ + "greeting" + ], + "type": "object", + "properties": { + "greeting": { + "type": "string" + } + } + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/resources/results/3.1.0/app9.json b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/resources/results/3.1.0/app9.json new file mode 100644 index 000000000..ec665f3d2 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webflux-tests/src/test/resources/results/3.1.0/app9.json @@ -0,0 +1,133 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "", + "description": "Generated server url" + } + ], + "paths": { + "/api/demo": { + "get": { + "tags": [ + "documents-api-controller" + ], + "operationId": "getDocuments", + "parameters": [ + { + "name": "request", + "in": "query", + "required": true, + "schema": { + "$ref": "#/components/schemas/DemoRequest" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/DemoDto" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "DemoRequest": { + "required": [ + "noRequiredNoNullableNoDefault", + "requiredNoNullableDefault", + "requiredNoNullableDefault1", + "requiredNoNullableNoDefault", + "requiredNoNullableNoDefault1", + "requiredNullableDefault", + "requiredNullableDefault1", + "requiredNullableNoDefault", + "requiredNullableNoDefault1" + ], + "type": "object", + "properties": { + "requiredNullableDefault": { + "type": "string", + "default": "a default value" + }, + "requiredNullableNoDefault": { + "type": "string" + }, + "requiredNoNullableDefault": { + "type": "string", + "default": "a default value" + }, + "requiredNoNullableNoDefault": { + "type": "string" + }, + "requiredNullableDefault1": { + "type": "string", + "default": "a default value" + }, + "requiredNullableNoDefault1": { + "type": "string" + }, + "requiredNoNullableDefault1": { + "type": "string", + "default": "a default value" + }, + "requiredNoNullableNoDefault1": { + "type": "string" + }, + "noRequiredNullableDefault2": { + "type": "string", + "default": "a default value" + }, + "noRequiredNullableNoDefault2": { + "type": "string" + }, + "noRequiredNoNullableDefault2": { + "type": "string", + "default": "a default value" + }, + "noRequiredNoNullableNoDefault2": { + "type": "string" + }, + "noRequiredNullableDefault": { + "type": "string", + "default": "a default value" + }, + "noRequiredNullableNoDefault": { + "type": "string" + }, + "noRequiredNoNullableDefault": { + "type": "string", + "default": "a default value" + }, + "noRequiredNoNullableNoDefault": { + "type": "string" + } + } + }, + "DemoDto": { + "required": [ + "id" + ], + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + } + } + } + } + } +} 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 224717cc6..a29e4d2bc 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.1 + 2.8.2 4.0.0 springdoc-openapi-kotlin-webmvc-tests diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/java/test/org/springdoc/api/app12/EnumController.java b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/java/test/org/springdoc/api/app12/EnumController.java index 7bdd2ffe2..71cd71a2b 100644 --- a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/java/test/org/springdoc/api/app12/EnumController.java +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/java/test/org/springdoc/api/app12/EnumController.java @@ -1,7 +1,7 @@ package test.org.springdoc.api.app12; import jakarta.annotation.Nullable; -import test.org.springdoc.api.app12.SpringDocApp12Test.MyEnum; +import test.org.springdoc.api.v30.app12.SpringDocApp12Test.MyEnum; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/AbstractKotlinSpringDocMVCTest.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/AbstractKotlinSpringDocMVCTest.kt deleted file mode 100644 index 129ce3197..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/AbstractKotlinSpringDocMVCTest.kt +++ /dev/null @@ -1,83 +0,0 @@ -/* - * - * * Copyright 2019-2020 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 - -import org.junit.jupiter.api.Test -import org.skyscreamer.jsonassert.JSONAssert -import org.slf4j.LoggerFactory -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 -import java.nio.charset.StandardCharsets -import java.nio.file.Files -import java.nio.file.Paths - -@SpringBootTest -@AutoConfigureMockMvc -@ActiveProfiles("test") -@TestPropertySource(properties = ["springdoc.api-docs.version=openapi_3_0"]) -abstract class AbstractKotlinSpringDocMVCTest { - - @Autowired - val mockMvc: MockMvc? = null - - private val logger = LoggerFactory.getLogger(AbstractKotlinSpringDocMVCTest::class.java) - - @Test - fun testApp() { - var result: String? = null - try { - val response = mockMvc!!.perform(MockMvcRequestBuilders.get("/v3/api-docs")) - .andExpect(MockMvcResultMatchers.status().isOk).andReturn() - - result = response.response.contentAsString - val className = javaClass.simpleName - val testNumber = className.replace("[^0-9]".toRegex(), "") - - val expected = getContent("results/app$testNumber.json") - JSONAssert.assertEquals(expected, result, true) - } catch (e: AssertionError) { - logger.error(result) - throw e - } - } - - companion object { - @Throws(Exception::class) - fun getContent(fileName: String): String { - try { - val path = Paths.get( - AbstractKotlinSpringDocMVCTest::class.java.classLoader.getResource( - fileName - )!!.toURI() - ) - val fileBytes = Files.readAllBytes(path) - return String(fileBytes, StandardCharsets.UTF_8) - } catch (e: Exception) { - throw RuntimeException("Failed to read file: $fileName", e) - } - - } - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/app10/ExampleController.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/app10/ExampleController.kt deleted file mode 100644 index 077d6bc2f..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/app10/ExampleController.kt +++ /dev/null @@ -1,20 +0,0 @@ -package test.org.springdoc.api.app10 - -import org.springframework.web.bind.annotation.GetMapping -import org.springframework.web.bind.annotation.RequestParam -import org.springframework.web.bind.annotation.RestController -import test.org.springdoc.api.app8.Greeting - -data class Greeting(val greeting: String) - -@RestController -class ExampleController { - @GetMapping("/") - fun greet(@RequestParam name: String?) = Greeting("Hello ${name ?: "world"}") - - @GetMapping("/test") - fun test(@RequestParam name: String) = Greeting("Hello $name") - - @GetMapping("/test-with-default") - fun testWithDefault(@RequestParam(defaultValue = "world") name: String) = Greeting("Hello $name") -} diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/app10/SpringDocApp10Test.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/app10/SpringDocApp10Test.kt deleted file mode 100644 index 300a3c02d..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/app10/SpringDocApp10Test.kt +++ /dev/null @@ -1,31 +0,0 @@ -/* - * - * * Copyright 2019-2023 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.app10 - -import org.springframework.boot.autoconfigure.SpringBootApplication -import org.springframework.context.annotation.ComponentScan -import test.org.springdoc.api.AbstractKotlinSpringDocMVCTest - -class SpringDocApp10Test : AbstractKotlinSpringDocMVCTest() { - - @SpringBootApplication - @ComponentScan(basePackages = ["org.springdoc", "test.org.springdoc.api.app10"]) - class DemoApplication - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/app11/ExampleController.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/app11/ExampleController.kt deleted file mode 100644 index 79116e0b4..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/app11/ExampleController.kt +++ /dev/null @@ -1,96 +0,0 @@ -package test.org.springdoc.api.app11 - -import io.swagger.v3.oas.annotations.Operation -import io.swagger.v3.oas.annotations.media.Schema -import org.springframework.web.bind.annotation.GetMapping -import org.springframework.web.bind.annotation.RequestBody -import org.springframework.web.bind.annotation.RequestParam -import org.springframework.web.bind.annotation.RestController - -@RestController -class ExampleController { - - @Operation( - summary = "foo api", - description = """ - this api is foo - - #### Custom exception case - | Http Status | Error Code | Error Message | Error Data | Remark | - |-------------|-------------|--------------|------------|-----------| - | 403 | NO_PERMISSION |This request is only available to administrators. | | | - | 400 | STORE_NOT_FOUND |Store not found. | | | - """ - ) - @GetMapping("/foo/trim-kotlin-indent") - fun readFoo(@RequestParam name: String?) = FooResponse("Hello ${name ?: "world"}") - -} - -data class FooResponse( - val name: String, -) - -@RestController -class ExampleController2 { - - @GetMapping("/foo/trim-kotlin-indent/schema") - fun readFoo( - @RequestBody request: FooRequestWithSchema, - ) = FooResponseWithSchema( - name = "Hello ${request.age ?: "world"}", - subFoo = SubFooResponseWithSchema(subName = "sub foo name"), - ) -} - -@Schema( - name = "foo request", - description = """ - foo request class description - with kotlin indent - """ -) -data class FooRequestWithSchema( - @Schema( - name = "age", - description = """ - foo request field with kotlin indent - """ - ) - val age: Int, -) - -@Schema( - name = "foo response", - description = """ - foo response class description - with kotlin indent - """ -) -data class FooResponseWithSchema( - @Schema( - name = "name", - description = """ - foo response fields with kotlin indent - """ - ) - val name: String, - val subFoo: SubFooResponseWithSchema -) - -@Schema( - name = "sub foo response", - description = """ - sub foo response class description - with kotlin indent - """ -) -data class SubFooResponseWithSchema( - @Schema( - name = "subName", - description = """ - sub foo response fields with kotlin indent - """ - ) - val subName: String, -) diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/app11/SpringDocApp11Test.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/app11/SpringDocApp11Test.kt deleted file mode 100644 index 36ba93710..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/app11/SpringDocApp11Test.kt +++ /dev/null @@ -1,31 +0,0 @@ -/* - * - * * Copyright 2019-2023 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.app11 - -import org.springframework.boot.autoconfigure.SpringBootApplication -import org.springframework.context.annotation.ComponentScan -import org.springframework.test.context.TestPropertySource -import test.org.springdoc.api.AbstractKotlinSpringDocMVCTest - -@TestPropertySource(properties = ["springdoc.trim-kotlin-indent=true"]) -class SpringDocApp11Test : AbstractKotlinSpringDocMVCTest() { - @SpringBootApplication - @ComponentScan(basePackages = ["org.springdoc", "test.org.springdoc.api.app11"]) - class DemoApplication -} diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/app12/SpringDocApp12Test.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/app12/SpringDocApp12Test.kt deleted file mode 100644 index f522f7de3..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/app12/SpringDocApp12Test.kt +++ /dev/null @@ -1,35 +0,0 @@ -/* - * - * * Copyright 2019-2023 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.app12 - -import org.springframework.boot.autoconfigure.SpringBootApplication -import org.springframework.context.annotation.ComponentScan -import test.org.springdoc.api.AbstractKotlinSpringDocMVCTest - -class SpringDocApp12Test : AbstractKotlinSpringDocMVCTest() { - - @SpringBootApplication - @ComponentScan(basePackages = ["org.springdoc", "test.org.springdoc.api.app12"]) - class DemoApplication - - enum class MyEnum { - A, B; - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/app13/SpringDocApp13Test.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/app13/SpringDocApp13Test.kt deleted file mode 100644 index 13c893550..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/app13/SpringDocApp13Test.kt +++ /dev/null @@ -1,33 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app13 - -import org.springframework.boot.autoconfigure.SpringBootApplication -import org.springframework.test.context.TestPropertySource -import test.org.springdoc.api.AbstractKotlinSpringDocMVCTest - -@TestPropertySource(properties = ["springdoc.api-docs.version=openapi_3_1"]) -class SpringDocApp13Test : AbstractKotlinSpringDocMVCTest() { - - @SpringBootApplication - class DemoApplication { - } - - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/app13/TestController.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/app13/TestController.kt deleted file mode 100644 index e13610707..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/app13/TestController.kt +++ /dev/null @@ -1,50 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app13 - - -import io.swagger.v3.oas.annotations.media.Schema -import org.springframework.web.bind.annotation.PostMapping -import org.springframework.web.bind.annotation.RequestBody -import org.springframework.web.bind.annotation.RequestMapping -import org.springframework.web.bind.annotation.RestController - -@Schema(description = "Generic description") -data class KeyValue( - val key: String, - val value: String, -) - -@Schema -data class SomeDTO( - @Schema(description = "Description A") val fieldA: KeyValue, - @Schema(description = "Description B") val fieldB: KeyValue, -) - - - -@RestController -@RequestMapping("/test") -class TestController { - @PostMapping("/test") - fun create(@RequestBody some: SomeDTO) { - - } -} - diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/app14/SpringDocApp14Test.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/app14/SpringDocApp14Test.kt deleted file mode 100644 index 967f289c9..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/app14/SpringDocApp14Test.kt +++ /dev/null @@ -1,29 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app14 - -import org.springframework.boot.autoconfigure.SpringBootApplication -import test.org.springdoc.api.AbstractKotlinSpringDocMVCTest - -class SpringDocApp14Test : AbstractKotlinSpringDocMVCTest() { - - @SpringBootApplication - class DemoApplication - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/app14/TestController.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/app14/TestController.kt deleted file mode 100644 index 3f220e658..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/app14/TestController.kt +++ /dev/null @@ -1,47 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app14 - -import io.swagger.v3.oas.annotations.media.Schema -import org.springframework.web.bind.annotation.PostMapping -import org.springframework.web.bind.annotation.RequestBody -import org.springframework.web.bind.annotation.RequestMapping -import org.springframework.web.bind.annotation.RestController - -@Schema(description = "Generic description") -data class KeyValue( - val key: String, - val value: String, -) - -@Schema -data class SomeDTO( - @Schema(description = "Description A", allOf = [KeyValue::class]) val field_a: KeyValue, - @Schema(description = "Description B", allOf = [KeyValue::class]) val field_b: KeyValue, -) - -@RestController -@RequestMapping("/test") -class TestController { - - @PostMapping("/test") - fun create(@RequestBody some: SomeDTO) { - - } -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/app2/SpringDocApp2Test.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/app2/SpringDocApp2Test.kt deleted file mode 100644 index 253caa4be..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/app2/SpringDocApp2Test.kt +++ /dev/null @@ -1,29 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app2 - -import org.springframework.boot.autoconfigure.SpringBootApplication -import test.org.springdoc.api.AbstractKotlinSpringDocMVCTest - -class SpringDocApp2Test : AbstractKotlinSpringDocMVCTest() { - - @SpringBootApplication - class DemoApplication - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/app2/SystemStatusController.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/app2/SystemStatusController.kt deleted file mode 100644 index 5205485dd..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/app2/SystemStatusController.kt +++ /dev/null @@ -1,43 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app2 - -import org.springframework.web.bind.annotation.GetMapping -import org.springframework.web.bind.annotation.RequestMapping -import org.springframework.web.bind.annotation.RestController - -enum class SystemStatus(val status: String) { - OK("OK") -} - -data class SystemStatusResponse( - val status: SystemStatus -) - -@RestController -@RequestMapping("/status") -class SystemStatusController { - @GetMapping - fun index() = SystemStatusResponse(SystemStatus.OK) - - @GetMapping("/foo") - fun foo() = - SystemStatusResponse(SystemStatus.OK) - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/app3/SpringDocApp3Test.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/app3/SpringDocApp3Test.kt deleted file mode 100644 index 856022f3a..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/app3/SpringDocApp3Test.kt +++ /dev/null @@ -1,31 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app3 - -import org.springframework.boot.autoconfigure.SpringBootApplication -import org.springframework.context.annotation.ComponentScan -import test.org.springdoc.api.AbstractKotlinSpringDocMVCTest - -class SpringDocApp3Test : AbstractKotlinSpringDocMVCTest() { - - @SpringBootApplication - @ComponentScan(basePackages = ["org.springdoc", "test.org.springdoc.api.app3"]) - class DemoApplication - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/app3/SystemStatusController.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/app3/SystemStatusController.kt deleted file mode 100644 index c07452e9c..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/app3/SystemStatusController.kt +++ /dev/null @@ -1,43 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app3 - -import org.springframework.web.bind.annotation.GetMapping -import org.springframework.web.bind.annotation.RequestMapping -import org.springframework.web.bind.annotation.RestController - -enum class SystemStatus(val status: String) { - OK("OK") -} - -data class SystemStatusResponse( - val status: SystemStatus -) - -@RestController -@RequestMapping("/status") -class SystemStatusController { - @GetMapping - fun index() = SystemStatusResponse(SystemStatus.OK) - - @GetMapping("/foo") - @Deprecated("") - fun foo() = SystemStatusResponse(SystemStatus.OK) - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/app4/HelloController.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/app4/HelloController.kt deleted file mode 100644 index 6d0d9199e..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/app4/HelloController.kt +++ /dev/null @@ -1,37 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app4 - -import org.springframework.web.bind.annotation.GetMapping -import org.springframework.web.bind.annotation.RequestMapping -import org.springframework.web.bind.annotation.RestController - - -data class Person( - val name: String, - val nickname: String? -) - -@RestController -@RequestMapping("/test") -class HelloController { - @GetMapping - suspend fun index(s: Person) = s - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/app4/SpringDocApp4Test.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/app4/SpringDocApp4Test.kt deleted file mode 100644 index d66e0fd9f..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/app4/SpringDocApp4Test.kt +++ /dev/null @@ -1,31 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app4 - -import org.springframework.boot.autoconfigure.SpringBootApplication -import org.springframework.context.annotation.ComponentScan -import test.org.springdoc.api.AbstractKotlinSpringDocMVCTest - -class SpringDocApp4Test : AbstractKotlinSpringDocMVCTest() { - - @SpringBootApplication - @ComponentScan(basePackages = ["org.springdoc", "test.org.springdoc.api.app4"]) - class DemoApplication - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/app5/ListController.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/app5/ListController.kt deleted file mode 100644 index 262f508b8..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/app5/ListController.kt +++ /dev/null @@ -1,31 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app5 - -import org.springframework.web.bind.annotation.GetMapping -import org.springframework.web.bind.annotation.RequestMapping -import org.springframework.web.bind.annotation.RestController - -@RestController -@RequestMapping("/test") -class ListController { - - @GetMapping("/") - fun foo(): List = listOf(1, 2, 3) -} diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/app5/SpringDocApp5Test.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/app5/SpringDocApp5Test.kt deleted file mode 100644 index 6d87b74dd..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/app5/SpringDocApp5Test.kt +++ /dev/null @@ -1,31 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app5 - -import org.springframework.boot.autoconfigure.SpringBootApplication -import org.springframework.context.annotation.ComponentScan -import test.org.springdoc.api.AbstractKotlinSpringDocMVCTest - -class SpringDocApp5Test : AbstractKotlinSpringDocMVCTest() { - - @SpringBootApplication - @ComponentScan(basePackages = ["org.springdoc", "test.org.springdoc.api.app5"]) - class DemoApplication - -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/app6/ByteArrayController.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/app6/ByteArrayController.kt deleted file mode 100644 index 78fda637e..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/app6/ByteArrayController.kt +++ /dev/null @@ -1,34 +0,0 @@ -/* - * - * * 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.app6 - -import org.springframework.web.bind.annotation.GetMapping -import org.springframework.web.bind.annotation.RequestMapping -import org.springframework.web.bind.annotation.RestController - -data class Foo(val data: ByteArray) - -@RestController -@RequestMapping("/bytearray") -class ByteArrayController { - - @GetMapping("/") - fun getByteArray(): Foo = Foo(byteArrayOf(0)) - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/app6/SpringDocApp6Test.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/app6/SpringDocApp6Test.kt deleted file mode 100644 index ef9ca29a5..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/app6/SpringDocApp6Test.kt +++ /dev/null @@ -1,31 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app6 - -import org.springframework.boot.autoconfigure.SpringBootApplication -import org.springframework.context.annotation.ComponentScan -import test.org.springdoc.api.AbstractKotlinSpringDocMVCTest - -class SpringDocApp6Test : AbstractKotlinSpringDocMVCTest() { - - @SpringBootApplication - @ComponentScan(basePackages = ["org.springdoc", "test.org.springdoc.api.app6"]) - class DemoApplication - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/app7/ExampleController.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/app7/ExampleController.kt deleted file mode 100644 index 4f8ca13de..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/app7/ExampleController.kt +++ /dev/null @@ -1,17 +0,0 @@ -package test.org.springdoc.api.app7 - -import io.swagger.v3.oas.annotations.Parameter -import org.springframework.web.bind.annotation.GetMapping -import org.springframework.web.bind.annotation.RequestParam -import org.springframework.web.bind.annotation.RestController - -data class Greeting(val greeting: String) - -@RestController -interface ExampleController { - @GetMapping("/") - fun greet(@RequestParam name: String?): Greeting - - @GetMapping("/test") - fun test(@RequestParam @Parameter(required = true) name: String?): Greeting -} diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/app7/SpringDocApp7Test.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/app7/SpringDocApp7Test.kt deleted file mode 100644 index 5b321c55f..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/app7/SpringDocApp7Test.kt +++ /dev/null @@ -1,46 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app7 - -import org.springframework.aop.framework.ProxyFactory -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.AbstractKotlinSpringDocMVCTest - -class SpringDocApp7Test : AbstractKotlinSpringDocMVCTest() { - - @SpringBootApplication - @ComponentScan(basePackages = ["org.springdoc", "test.org.springdoc.api.app7"]) - class DemoApplication{ - @Bean - fun controller(applicationContext: GenericApplicationContext): ExampleController { - return createProxy(ExampleController::class.java) - } - - private fun createProxy(clazz: Class): T { - val proxyFactory = ProxyFactory(clazz) - proxyFactory.targetClass = clazz - @Suppress("UNCHECKED_CAST") - return proxyFactory.proxy as T - } - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/app8/ExampleController.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/app8/ExampleController.kt deleted file mode 100644 index 061b2b9eb..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/app8/ExampleController.kt +++ /dev/null @@ -1,17 +0,0 @@ -package test.org.springdoc.api.app8 - -import io.swagger.v3.oas.annotations.Parameter -import org.springframework.web.bind.annotation.GetMapping -import org.springframework.web.bind.annotation.RequestParam -import org.springframework.web.bind.annotation.RestController - -data class Greeting(val greeting: String) - -@RestController -interface ExampleController { - @GetMapping("/") - fun greet(@RequestParam name: String?): Greeting - - @GetMapping("/test") - fun test(@RequestParam @Parameter(required = true) name: String?): Greeting -} diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/app8/SpringDocApp8Test.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/app8/SpringDocApp8Test.kt deleted file mode 100644 index 3d00589d4..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/app8/SpringDocApp8Test.kt +++ /dev/null @@ -1,49 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app8 - -import org.springdoc.core.utils.Constants -import org.springframework.aop.framework.ProxyFactory -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 org.springframework.test.context.TestPropertySource -import test.org.springdoc.api.AbstractKotlinSpringDocMVCTest - -@TestPropertySource(properties = [Constants.SPRINGDOC_NULLABLE_REQUEST_PARAMETER_ENABLED+"=false"]) -class SpringDocApp8Test : AbstractKotlinSpringDocMVCTest() { - - @SpringBootApplication - @ComponentScan(basePackages = ["org.springdoc", "test.org.springdoc.api.app8"]) - class DemoApplication{ - @Bean - fun controller(applicationContext: GenericApplicationContext): ExampleController { - return createProxy(ExampleController::class.java) - } - - private fun createProxy(clazz: Class): T { - val proxyFactory = ProxyFactory(clazz) - proxyFactory.targetClass = clazz - @Suppress("UNCHECKED_CAST") - return proxyFactory.proxy as T - } - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/app9/DemoController.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/app9/DemoController.kt deleted file mode 100644 index 6b8793276..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/app9/DemoController.kt +++ /dev/null @@ -1,71 +0,0 @@ -package test.org.springdoc.api.app9 - -import io.swagger.v3.oas.annotations.media.Schema -import org.springframework.web.bind.annotation.GetMapping -import org.springframework.web.bind.annotation.RequestMapping -import org.springframework.web.bind.annotation.RestController - -@RestController -@RequestMapping("/api/demo") -class DocumentsApiController { - - @GetMapping - suspend fun getDocuments( request: DemoRequest - ): DemoDto = DemoDto(42) -} - -data class DemoDto( - var id: Long, -) - -class DemoRequest ( - - @field:Schema(required = true, defaultValue = "a default value") - val requiredNullableDefault: String?, - - @field:Schema(required = true) - val requiredNullableNoDefault: String?, - - @field:Schema(required = true, defaultValue = "a default value") - val requiredNoNullableDefault: String, - - @field:Schema(required = true) - val requiredNoNullableNoDefault: String, - - @field:Schema(requiredMode = Schema.RequiredMode.REQUIRED, defaultValue = "a default value") - val requiredNullableDefault1: String?, - - @field:Schema(requiredMode = Schema.RequiredMode.REQUIRED) - val requiredNullableNoDefault1: String?, - - @field:Schema(requiredMode = Schema.RequiredMode.REQUIRED, defaultValue = "a default value") - val requiredNoNullableDefault1: String, - - @field:Schema(requiredMode = Schema.RequiredMode.REQUIRED) - val requiredNoNullableNoDefault1: String, - - @field:Schema(requiredMode = Schema.RequiredMode.NOT_REQUIRED, defaultValue = "a default value") - val noRequiredNullableDefault2: String?, - - @field:Schema(requiredMode = Schema.RequiredMode.NOT_REQUIRED) - val noRequiredNullableNoDefault2: String?, - - @field:Schema(requiredMode = Schema.RequiredMode.NOT_REQUIRED, defaultValue = "a default value") - val noRequiredNoNullableDefault2: String, - - @field:Schema(requiredMode = Schema.RequiredMode.NOT_REQUIRED) - val noRequiredNoNullableNoDefault2: String, - - @field:Schema(defaultValue = "a default value") - val noRequiredNullableDefault: String?, - - @field:Schema - val noRequiredNullableNoDefault: String?, - - @field:Schema(defaultValue = "a default value") - val noRequiredNoNullableDefault: String, - - @field:Schema - val noRequiredNoNullableNoDefault: String, - -) diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/app9/SpringDocApp9Test.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/app9/SpringDocApp9Test.kt deleted file mode 100644 index 424b16a56..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/app9/SpringDocApp9Test.kt +++ /dev/null @@ -1,9 +0,0 @@ -package test.org.springdoc.api.app9 - -import org.springframework.boot.autoconfigure.SpringBootApplication -import test.org.springdoc.api.AbstractKotlinSpringDocMVCTest - -class SpringDocApp9Test: AbstractKotlinSpringDocMVCTest() { - @SpringBootApplication - class DemoApplication -} diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v30/AbstractKotlinSpringDocMVCTest.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v30/AbstractKotlinSpringDocMVCTest.kt new file mode 100644 index 000000000..ca3efc3a7 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v30/AbstractKotlinSpringDocMVCTest.kt @@ -0,0 +1,91 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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 + +import org.junit.jupiter.api.Test +import org.skyscreamer.jsonassert.JSONAssert +import org.slf4j.LoggerFactory +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 +import java.nio.charset.StandardCharsets +import java.nio.file.Files +import java.nio.file.Paths + +@SpringBootTest +@AutoConfigureMockMvc +@ActiveProfiles("test") +@TestPropertySource(properties = ["springdoc.api-docs.version=openapi_3_0"]) +abstract class AbstractKotlinSpringDocMVCTest { + + @Autowired + val mockMvc: MockMvc? = null + + private val logger = LoggerFactory.getLogger(AbstractKotlinSpringDocMVCTest::class.java) + + @Test + fun testApp() { + var result: String? = null + try { + val response = mockMvc!!.perform(MockMvcRequestBuilders.get("/v3/api-docs")) + .andExpect(MockMvcResultMatchers.status().isOk).andReturn() + + result = response.response.contentAsString + val className = javaClass.simpleName + val testNumber = className.replace("[^0-9]".toRegex(), "") + + val expected = getContent("results/3.0.1/app$testNumber.json") + JSONAssert.assertEquals(expected, result, true) + } catch (e: AssertionError) { + logger.error(result) + throw e + } + } + + companion object { + @Throws(Exception::class) + fun getContent(fileName: String): String { + try { + val path = Paths.get( + AbstractKotlinSpringDocMVCTest::class.java.classLoader.getResource( + fileName + )!!.toURI() + ) + val fileBytes = Files.readAllBytes(path) + return String(fileBytes, StandardCharsets.UTF_8) + } catch (e: Exception) { + throw RuntimeException("Failed to read file: $fileName", e) + } + + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v30/app10/ExampleController.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v30/app10/ExampleController.kt new file mode 100644 index 000000000..f6a934d51 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v30/app10/ExampleController.kt @@ -0,0 +1,20 @@ +package test.org.springdoc.api.v30.app10 + +import org.springframework.web.bind.annotation.GetMapping +import org.springframework.web.bind.annotation.RequestParam +import org.springframework.web.bind.annotation.RestController +import test.org.springdoc.api.v30.app8.Greeting + +data class Greeting(val greeting: String) + +@RestController +class ExampleController { + @GetMapping("/") + fun greet(@RequestParam name: String?) = Greeting("Hello ${name ?: "world"}") + + @GetMapping("/test") + fun test(@RequestParam name: String) = Greeting("Hello $name") + + @GetMapping("/test-with-default") + fun testWithDefault(@RequestParam(defaultValue = "world") name: String) = Greeting("Hello $name") +} diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v30/app10/SpringDocApp10Test.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v30/app10/SpringDocApp10Test.kt new file mode 100644 index 000000000..c6da84742 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v30/app10/SpringDocApp10Test.kt @@ -0,0 +1,31 @@ +/* + * + * * Copyright 2019-2023 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.app10 + +import org.springframework.boot.autoconfigure.SpringBootApplication +import org.springframework.context.annotation.ComponentScan +import test.org.springdoc.api.v30.AbstractKotlinSpringDocMVCTest + +class SpringDocApp10Test : AbstractKotlinSpringDocMVCTest() { + + @SpringBootApplication + @ComponentScan(basePackages = ["org.springdoc", "test.org.springdoc.api.v30.app10"]) + class DemoApplication + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v30/app11/ExampleController.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v30/app11/ExampleController.kt new file mode 100644 index 000000000..9d76259b1 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v30/app11/ExampleController.kt @@ -0,0 +1,96 @@ +package test.org.springdoc.api.v30.app11 + +import io.swagger.v3.oas.annotations.Operation +import io.swagger.v3.oas.annotations.media.Schema +import org.springframework.web.bind.annotation.GetMapping +import org.springframework.web.bind.annotation.RequestBody +import org.springframework.web.bind.annotation.RequestParam +import org.springframework.web.bind.annotation.RestController + +@RestController +class ExampleController { + + @Operation( + summary = "foo api", + description = """ + this api is foo + + #### Custom exception case + | Http Status | Error Code | Error Message | Error Data | Remark | + |-------------|-------------|--------------|------------|-----------| + | 403 | NO_PERMISSION |This request is only available to administrators. | | | + | 400 | STORE_NOT_FOUND |Store not found. | | | + """ + ) + @GetMapping("/foo/trim-kotlin-indent") + fun readFoo(@RequestParam name: String?) = FooResponse("Hello ${name ?: "world"}") + +} + +data class FooResponse( + val name: String, +) + +@RestController +class ExampleController2 { + + @GetMapping("/foo/trim-kotlin-indent/schema") + fun readFoo( + @RequestBody request: FooRequestWithSchema, + ) = FooResponseWithSchema( + name = "Hello ${request.age ?: "world"}", + subFoo = SubFooResponseWithSchema(subName = "sub foo name"), + ) +} + +@Schema( + name = "foo request", + description = """ + foo request class description + with kotlin indent + """ +) +data class FooRequestWithSchema( + @Schema( + name = "age", + description = """ + foo request field with kotlin indent + """ + ) + val age: Int, +) + +@Schema( + name = "foo response", + description = """ + foo response class description + with kotlin indent + """ +) +data class FooResponseWithSchema( + @Schema( + name = "name", + description = """ + foo response fields with kotlin indent + """ + ) + val name: String, + val subFoo: SubFooResponseWithSchema +) + +@Schema( + name = "sub foo response", + description = """ + sub foo response class description + with kotlin indent + """ +) +data class SubFooResponseWithSchema( + @Schema( + name = "subName", + description = """ + sub foo response fields with kotlin indent + """ + ) + val subName: String, +) diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v30/app11/SpringDocApp11Test.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v30/app11/SpringDocApp11Test.kt new file mode 100644 index 000000000..7629835f1 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v30/app11/SpringDocApp11Test.kt @@ -0,0 +1,31 @@ +/* + * + * * Copyright 2019-2023 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.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 + +@TestPropertySource(properties = ["springdoc.trim-kotlin-indent=true"]) +class SpringDocApp11Test : AbstractKotlinSpringDocMVCTest() { + @SpringBootApplication + @ComponentScan(basePackages = ["org.springdoc", "test.org.springdoc.api.v30.app11"]) + class DemoApplication +} diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v30/app12/SpringDocApp12Test.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v30/app12/SpringDocApp12Test.kt new file mode 100644 index 000000000..448192da6 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v30/app12/SpringDocApp12Test.kt @@ -0,0 +1,35 @@ +/* + * + * * Copyright 2019-2023 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.app12 + +import org.springframework.boot.autoconfigure.SpringBootApplication +import org.springframework.context.annotation.ComponentScan +import test.org.springdoc.api.v30.AbstractKotlinSpringDocMVCTest + +class SpringDocApp12Test : AbstractKotlinSpringDocMVCTest() { + + @SpringBootApplication + @ComponentScan(basePackages = ["org.springdoc", "test.org.springdoc.api.v30.app12", "test.org.springdoc.api.app12"]) + class DemoApplication + + enum class MyEnum { + A, B; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v30/app13/SpringDocApp13Test.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v30/app13/SpringDocApp13Test.kt new file mode 100644 index 000000000..de0d251ee --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v30/app13/SpringDocApp13Test.kt @@ -0,0 +1,33 @@ +/* + * + * * Copyright 2019-2020 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.app13 + +import org.springframework.boot.autoconfigure.SpringBootApplication +import org.springframework.test.context.TestPropertySource +import test.org.springdoc.api.v30.AbstractKotlinSpringDocMVCTest + +@TestPropertySource(properties = ["springdoc.api-docs.version=openapi_3_1"]) +class SpringDocApp13Test : AbstractKotlinSpringDocMVCTest() { + + @SpringBootApplication + class DemoApplication { + } + + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v30/app13/TestController.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v30/app13/TestController.kt new file mode 100644 index 000000000..e9feb4c50 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v30/app13/TestController.kt @@ -0,0 +1,50 @@ +/* + * + * * Copyright 2019-2020 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.app13 + + +import io.swagger.v3.oas.annotations.media.Schema +import org.springframework.web.bind.annotation.PostMapping +import org.springframework.web.bind.annotation.RequestBody +import org.springframework.web.bind.annotation.RequestMapping +import org.springframework.web.bind.annotation.RestController + +@Schema(description = "Generic description") +data class KeyValue( + val key: String, + val value: String, +) + +@Schema +data class SomeDTO( + @Schema(description = "Description A") val fieldA: KeyValue, + @Schema(description = "Description B") val fieldB: KeyValue, +) + + + +@RestController +@RequestMapping("/test") +class TestController { + @PostMapping("/test") + fun create(@RequestBody some: SomeDTO) { + + } +} + diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v30/app14/SpringDocApp14Test.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v30/app14/SpringDocApp14Test.kt new file mode 100644 index 000000000..52068bd62 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v30/app14/SpringDocApp14Test.kt @@ -0,0 +1,29 @@ +/* + * + * * Copyright 2019-2020 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.app14 + +import org.springframework.boot.autoconfigure.SpringBootApplication +import test.org.springdoc.api.v30.AbstractKotlinSpringDocMVCTest + +class SpringDocApp14Test : AbstractKotlinSpringDocMVCTest() { + + @SpringBootApplication + class DemoApplication + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v30/app14/TestController.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v30/app14/TestController.kt new file mode 100644 index 000000000..3dcc3b1c5 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v30/app14/TestController.kt @@ -0,0 +1,47 @@ +/* + * + * * Copyright 2019-2020 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.app14 + +import io.swagger.v3.oas.annotations.media.Schema +import org.springframework.web.bind.annotation.PostMapping +import org.springframework.web.bind.annotation.RequestBody +import org.springframework.web.bind.annotation.RequestMapping +import org.springframework.web.bind.annotation.RestController + +@Schema(description = "Generic description") +data class KeyValue( + val key: String, + val value: String, +) + +@Schema +data class SomeDTO( + @Schema(description = "Description A", allOf = [KeyValue::class]) val field_a: KeyValue, + @Schema(description = "Description B", allOf = [KeyValue::class]) val field_b: KeyValue, +) + +@RestController +@RequestMapping("/test") +class TestController { + + @PostMapping("/test") + fun create(@RequestBody some: SomeDTO) { + + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v30/app2/SpringDocApp2Test.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v30/app2/SpringDocApp2Test.kt new file mode 100644 index 000000000..8efd5fac7 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v30/app2/SpringDocApp2Test.kt @@ -0,0 +1,29 @@ +/* + * + * * Copyright 2019-2020 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.app2 + +import org.springframework.boot.autoconfigure.SpringBootApplication +import test.org.springdoc.api.v30.AbstractKotlinSpringDocMVCTest + +class SpringDocApp2Test : AbstractKotlinSpringDocMVCTest() { + + @SpringBootApplication + class DemoApplication + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v30/app2/SystemStatusController.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v30/app2/SystemStatusController.kt new file mode 100644 index 000000000..43484e033 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v30/app2/SystemStatusController.kt @@ -0,0 +1,43 @@ +/* + * + * * Copyright 2019-2020 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.app2 + +import org.springframework.web.bind.annotation.GetMapping +import org.springframework.web.bind.annotation.RequestMapping +import org.springframework.web.bind.annotation.RestController + +enum class SystemStatus(val status: String) { + OK("OK") +} + +data class SystemStatusResponse( + val status: SystemStatus +) + +@RestController +@RequestMapping("/status") +class SystemStatusController { + @GetMapping + fun index() = SystemStatusResponse(SystemStatus.OK) + + @GetMapping("/foo") + fun foo() = + SystemStatusResponse(SystemStatus.OK) + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v30/app3/SpringDocApp3Test.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v30/app3/SpringDocApp3Test.kt new file mode 100644 index 000000000..e3a872246 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v30/app3/SpringDocApp3Test.kt @@ -0,0 +1,31 @@ +/* + * + * * Copyright 2019-2020 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.app3 + +import org.springframework.boot.autoconfigure.SpringBootApplication +import org.springframework.context.annotation.ComponentScan +import test.org.springdoc.api.v30.AbstractKotlinSpringDocMVCTest + +class SpringDocApp3Test : AbstractKotlinSpringDocMVCTest() { + + @SpringBootApplication + @ComponentScan(basePackages = ["org.springdoc", "test.org.springdoc.api.v30.app3"]) + class DemoApplication + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v30/app3/SystemStatusController.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v30/app3/SystemStatusController.kt new file mode 100644 index 000000000..970a7df71 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v30/app3/SystemStatusController.kt @@ -0,0 +1,43 @@ +/* + * + * * Copyright 2019-2020 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.app3 + +import org.springframework.web.bind.annotation.GetMapping +import org.springframework.web.bind.annotation.RequestMapping +import org.springframework.web.bind.annotation.RestController + +enum class SystemStatus(val status: String) { + OK("OK") +} + +data class SystemStatusResponse( + val status: SystemStatus +) + +@RestController +@RequestMapping("/status") +class SystemStatusController { + @GetMapping + fun index() = SystemStatusResponse(SystemStatus.OK) + + @GetMapping("/foo") + @Deprecated("") + fun foo() = SystemStatusResponse(SystemStatus.OK) + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v30/app4/HelloController.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v30/app4/HelloController.kt new file mode 100644 index 000000000..94d495cc8 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v30/app4/HelloController.kt @@ -0,0 +1,37 @@ +/* + * + * * Copyright 2019-2020 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.app4 + +import org.springframework.web.bind.annotation.GetMapping +import org.springframework.web.bind.annotation.RequestMapping +import org.springframework.web.bind.annotation.RestController + + +data class Person( + val name: String, + val nickname: String? +) + +@RestController +@RequestMapping("/test") +class HelloController { + @GetMapping + suspend fun index(s: Person) = s + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v30/app4/SpringDocApp4Test.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v30/app4/SpringDocApp4Test.kt new file mode 100644 index 000000000..12bf40fed --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v30/app4/SpringDocApp4Test.kt @@ -0,0 +1,31 @@ +/* + * + * * Copyright 2019-2020 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.app4 + +import org.springframework.boot.autoconfigure.SpringBootApplication +import org.springframework.context.annotation.ComponentScan +import test.org.springdoc.api.v30.AbstractKotlinSpringDocMVCTest + +class SpringDocApp4Test : AbstractKotlinSpringDocMVCTest() { + + @SpringBootApplication + @ComponentScan(basePackages = ["org.springdoc", "test.org.springdoc.api.v30.app4"]) + class DemoApplication + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v30/app5/ListController.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v30/app5/ListController.kt new file mode 100644 index 000000000..be4ea76f1 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v30/app5/ListController.kt @@ -0,0 +1,31 @@ +/* + * + * * Copyright 2019-2020 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.app5 + +import org.springframework.web.bind.annotation.GetMapping +import org.springframework.web.bind.annotation.RequestMapping +import org.springframework.web.bind.annotation.RestController + +@RestController +@RequestMapping("/test") +class ListController { + + @GetMapping("/") + fun foo(): List = listOf(1, 2, 3) +} diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v30/app5/SpringDocApp5Test.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v30/app5/SpringDocApp5Test.kt new file mode 100644 index 000000000..d0f27c312 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v30/app5/SpringDocApp5Test.kt @@ -0,0 +1,31 @@ +/* + * + * * Copyright 2019-2020 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.app5 + +import org.springframework.boot.autoconfigure.SpringBootApplication +import org.springframework.context.annotation.ComponentScan +import test.org.springdoc.api.v30.AbstractKotlinSpringDocMVCTest + +class SpringDocApp5Test : AbstractKotlinSpringDocMVCTest() { + + @SpringBootApplication + @ComponentScan(basePackages = ["org.springdoc", "test.org.springdoc.api.v30.app5"]) + class DemoApplication + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v30/app6/ByteArrayController.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v30/app6/ByteArrayController.kt new file mode 100644 index 000000000..3d38ef2e6 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v30/app6/ByteArrayController.kt @@ -0,0 +1,34 @@ +/* + * + * * 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.app6 + +import org.springframework.web.bind.annotation.GetMapping +import org.springframework.web.bind.annotation.RequestMapping +import org.springframework.web.bind.annotation.RestController + +data class Foo(val data: ByteArray) + +@RestController +@RequestMapping("/bytearray") +class ByteArrayController { + + @GetMapping("/") + fun getByteArray(): Foo = Foo(byteArrayOf(0)) + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v30/app6/SpringDocApp6Test.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v30/app6/SpringDocApp6Test.kt new file mode 100644 index 000000000..b9c96e777 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v30/app6/SpringDocApp6Test.kt @@ -0,0 +1,31 @@ +/* + * + * * Copyright 2019-2020 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.app6 + +import org.springframework.boot.autoconfigure.SpringBootApplication +import org.springframework.context.annotation.ComponentScan +import test.org.springdoc.api.v30.AbstractKotlinSpringDocMVCTest + +class SpringDocApp6Test : AbstractKotlinSpringDocMVCTest() { + + @SpringBootApplication + @ComponentScan(basePackages = ["org.springdoc", "test.org.springdoc.api.v30.app6"]) + class DemoApplication + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v30/app7/ExampleController.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v30/app7/ExampleController.kt new file mode 100644 index 000000000..351b60f88 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v30/app7/ExampleController.kt @@ -0,0 +1,17 @@ +package test.org.springdoc.api.v30.app7 + +import io.swagger.v3.oas.annotations.Parameter +import org.springframework.web.bind.annotation.GetMapping +import org.springframework.web.bind.annotation.RequestParam +import org.springframework.web.bind.annotation.RestController + +data class Greeting(val greeting: String) + +@RestController +interface ExampleController { + @GetMapping("/") + fun greet(@RequestParam name: String?): Greeting + + @GetMapping("/test") + fun test(@RequestParam @Parameter(required = true) name: String?): Greeting +} diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v30/app7/SpringDocApp7Test.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v30/app7/SpringDocApp7Test.kt new file mode 100644 index 000000000..d4c6c38aa --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v30/app7/SpringDocApp7Test.kt @@ -0,0 +1,46 @@ +/* + * + * * Copyright 2019-2020 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.app7 + +import org.springframework.aop.framework.ProxyFactory +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 + +class SpringDocApp7Test : AbstractKotlinSpringDocMVCTest() { + + @SpringBootApplication + @ComponentScan(basePackages = ["org.springdoc", "test.org.springdoc.api.v30.app7"]) + class DemoApplication{ + @Bean + fun controller(applicationContext: GenericApplicationContext): ExampleController { + return createProxy(ExampleController::class.java) + } + + private fun createProxy(clazz: Class): T { + val proxyFactory = ProxyFactory(clazz) + proxyFactory.targetClass = clazz + @Suppress("UNCHECKED_CAST") + return proxyFactory.proxy as T + } + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v30/app8/ExampleController.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v30/app8/ExampleController.kt new file mode 100644 index 000000000..60058ec9d --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v30/app8/ExampleController.kt @@ -0,0 +1,17 @@ +package test.org.springdoc.api.v30.app8 + +import io.swagger.v3.oas.annotations.Parameter +import org.springframework.web.bind.annotation.GetMapping +import org.springframework.web.bind.annotation.RequestParam +import org.springframework.web.bind.annotation.RestController + +data class Greeting(val greeting: String) + +@RestController +interface ExampleController { + @GetMapping("/") + fun greet(@RequestParam name: String?): Greeting + + @GetMapping("/test") + fun test(@RequestParam @Parameter(required = true) name: String?): Greeting +} diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v30/app8/SpringDocApp8Test.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v30/app8/SpringDocApp8Test.kt new file mode 100644 index 000000000..a6a17dca9 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v30/app8/SpringDocApp8Test.kt @@ -0,0 +1,49 @@ +/* + * + * * Copyright 2019-2020 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.app8 + +import org.springdoc.core.utils.Constants +import org.springframework.aop.framework.ProxyFactory +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 org.springframework.test.context.TestPropertySource +import test.org.springdoc.api.v30.AbstractKotlinSpringDocMVCTest + +@TestPropertySource(properties = [Constants.SPRINGDOC_NULLABLE_REQUEST_PARAMETER_ENABLED+"=false"]) +class SpringDocApp8Test : AbstractKotlinSpringDocMVCTest() { + + @SpringBootApplication + @ComponentScan(basePackages = ["org.springdoc", "test.org.springdoc.api.v30.app8"]) + class DemoApplication{ + @Bean + fun controller(applicationContext: GenericApplicationContext): ExampleController { + return createProxy(ExampleController::class.java) + } + + private fun createProxy(clazz: Class): T { + val proxyFactory = ProxyFactory(clazz) + proxyFactory.targetClass = clazz + @Suppress("UNCHECKED_CAST") + return proxyFactory.proxy as T + } + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v30/app9/DemoController.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v30/app9/DemoController.kt new file mode 100644 index 000000000..7e3e12eda --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v30/app9/DemoController.kt @@ -0,0 +1,71 @@ +package test.org.springdoc.api.v30.app9 + +import io.swagger.v3.oas.annotations.media.Schema +import org.springframework.web.bind.annotation.GetMapping +import org.springframework.web.bind.annotation.RequestMapping +import org.springframework.web.bind.annotation.RestController + +@RestController +@RequestMapping("/api/demo") +class DocumentsApiController { + + @GetMapping + suspend fun getDocuments( request: DemoRequest + ): DemoDto = DemoDto(42) +} + +data class DemoDto( + var id: Long, +) + +class DemoRequest ( + + @field:Schema(required = true, defaultValue = "a default value") + val requiredNullableDefault: String?, + + @field:Schema(required = true) + val requiredNullableNoDefault: String?, + + @field:Schema(required = true, defaultValue = "a default value") + val requiredNoNullableDefault: String, + + @field:Schema(required = true) + val requiredNoNullableNoDefault: String, + + @field:Schema(requiredMode = Schema.RequiredMode.REQUIRED, defaultValue = "a default value") + val requiredNullableDefault1: String?, + + @field:Schema(requiredMode = Schema.RequiredMode.REQUIRED) + val requiredNullableNoDefault1: String?, + + @field:Schema(requiredMode = Schema.RequiredMode.REQUIRED, defaultValue = "a default value") + val requiredNoNullableDefault1: String, + + @field:Schema(requiredMode = Schema.RequiredMode.REQUIRED) + val requiredNoNullableNoDefault1: String, + + @field:Schema(requiredMode = Schema.RequiredMode.NOT_REQUIRED, defaultValue = "a default value") + val noRequiredNullableDefault2: String?, + + @field:Schema(requiredMode = Schema.RequiredMode.NOT_REQUIRED) + val noRequiredNullableNoDefault2: String?, + + @field:Schema(requiredMode = Schema.RequiredMode.NOT_REQUIRED, defaultValue = "a default value") + val noRequiredNoNullableDefault2: String, + + @field:Schema(requiredMode = Schema.RequiredMode.NOT_REQUIRED) + val noRequiredNoNullableNoDefault2: String, + + @field:Schema(defaultValue = "a default value") + val noRequiredNullableDefault: String?, + + @field:Schema + val noRequiredNullableNoDefault: String?, + + @field:Schema(defaultValue = "a default value") + val noRequiredNoNullableDefault: String, + + @field:Schema + val noRequiredNoNullableNoDefault: String, + +) diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v30/app9/SpringDocApp9Test.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v30/app9/SpringDocApp9Test.kt new file mode 100644 index 000000000..070591c3c --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v30/app9/SpringDocApp9Test.kt @@ -0,0 +1,9 @@ +package test.org.springdoc.api.v30.app9 + +import org.springframework.boot.autoconfigure.SpringBootApplication +import test.org.springdoc.api.v30.AbstractKotlinSpringDocMVCTest + +class SpringDocApp9Test: AbstractKotlinSpringDocMVCTest() { + @SpringBootApplication + class DemoApplication +} 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 new file mode 100644 index 000000000..bf7f9e4f7 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v31/AbstractKotlinSpringDocMVCTest.kt @@ -0,0 +1,91 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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 + +import org.junit.jupiter.api.Test +import org.skyscreamer.jsonassert.JSONAssert +import org.slf4j.LoggerFactory +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 +import java.nio.charset.StandardCharsets +import java.nio.file.Files +import java.nio.file.Paths + +@SpringBootTest +@AutoConfigureMockMvc +@ActiveProfiles("test") +@TestPropertySource(properties = ["springdoc.api-docs.version=openapi_3_0"]) +abstract class AbstractKotlinSpringDocMVCTest { + + @Autowired + val mockMvc: MockMvc? = null + + private val logger = LoggerFactory.getLogger(AbstractKotlinSpringDocMVCTest::class.java) + + @Test + fun testApp() { + var result: String? = null + try { + val response = mockMvc!!.perform(MockMvcRequestBuilders.get("/v3/api-docs")) + .andExpect(MockMvcResultMatchers.status().isOk).andReturn() + + result = response.response.contentAsString + val className = javaClass.simpleName + val testNumber = className.replace("[^0-9]".toRegex(), "") + + val expected = getContent("results/3.1.0/app$testNumber.json") + JSONAssert.assertEquals(expected, result, true) + } catch (e: AssertionError) { + logger.error(result) + throw e + } + } + + companion object { + @Throws(Exception::class) + fun getContent(fileName: String): String { + try { + val path = Paths.get( + AbstractKotlinSpringDocMVCTest::class.java.classLoader.getResource( + fileName + )!!.toURI() + ) + val fileBytes = Files.readAllBytes(path) + return String(fileBytes, StandardCharsets.UTF_8) + } catch (e: Exception) { + throw RuntimeException("Failed to read file: $fileName", e) + } + + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v31/app10/ExampleController.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v31/app10/ExampleController.kt new file mode 100644 index 000000000..558f23c08 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v31/app10/ExampleController.kt @@ -0,0 +1,20 @@ +package test.org.springdoc.api.v31.app10 + +import org.springframework.web.bind.annotation.GetMapping +import org.springframework.web.bind.annotation.RequestParam +import org.springframework.web.bind.annotation.RestController +import test.org.springdoc.api.v30.app8.Greeting + +data class Greeting(val greeting: String) + +@RestController +class ExampleController { + @GetMapping("/") + fun greet(@RequestParam name: String?) = Greeting("Hello ${name ?: "world"}") + + @GetMapping("/test") + fun test(@RequestParam name: String) = Greeting("Hello $name") + + @GetMapping("/test-with-default") + fun testWithDefault(@RequestParam(defaultValue = "world") name: String) = Greeting("Hello $name") +} 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 new file mode 100644 index 000000000..07eab19ac --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v31/app10/SpringDocApp10Test.kt @@ -0,0 +1,31 @@ +/* + * + * * Copyright 2019-2023 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.app10 + +import org.springframework.boot.autoconfigure.SpringBootApplication +import org.springframework.context.annotation.ComponentScan +import test.org.springdoc.api.v30.AbstractKotlinSpringDocMVCTest + +class SpringDocApp10Test : AbstractKotlinSpringDocMVCTest() { + + @SpringBootApplication + @ComponentScan(basePackages = ["org.springdoc", "test.org.springdoc.api.v31.app10"]) + class DemoApplication + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v31/app11/ExampleController.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v31/app11/ExampleController.kt new file mode 100644 index 000000000..a1a1cab17 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v31/app11/ExampleController.kt @@ -0,0 +1,96 @@ +package test.org.springdoc.api.v31.app11 + +import io.swagger.v3.oas.annotations.Operation +import io.swagger.v3.oas.annotations.media.Schema +import org.springframework.web.bind.annotation.GetMapping +import org.springframework.web.bind.annotation.RequestBody +import org.springframework.web.bind.annotation.RequestParam +import org.springframework.web.bind.annotation.RestController + +@RestController +class ExampleController { + + @Operation( + summary = "foo api", + description = """ + this api is foo + + #### Custom exception case + | Http Status | Error Code | Error Message | Error Data | Remark | + |-------------|-------------|--------------|------------|-----------| + | 403 | NO_PERMISSION |This request is only available to administrators. | | | + | 400 | STORE_NOT_FOUND |Store not found. | | | + """ + ) + @GetMapping("/foo/trim-kotlin-indent") + fun readFoo(@RequestParam name: String?) = FooResponse("Hello ${name ?: "world"}") + +} + +data class FooResponse( + val name: String, +) + +@RestController +class ExampleController2 { + + @GetMapping("/foo/trim-kotlin-indent/schema") + fun readFoo( + @RequestBody request: FooRequestWithSchema, + ) = FooResponseWithSchema( + name = "Hello ${request.age ?: "world"}", + subFoo = SubFooResponseWithSchema(subName = "sub foo name"), + ) +} + +@Schema( + name = "foo request", + description = """ + foo request class description + with kotlin indent + """ +) +data class FooRequestWithSchema( + @Schema( + name = "age", + description = """ + foo request field with kotlin indent + """ + ) + val age: Int, +) + +@Schema( + name = "foo response", + description = """ + foo response class description + with kotlin indent + """ +) +data class FooResponseWithSchema( + @Schema( + name = "name", + description = """ + foo response fields with kotlin indent + """ + ) + val name: String, + val subFoo: SubFooResponseWithSchema +) + +@Schema( + name = "sub foo response", + description = """ + sub foo response class description + with kotlin indent + """ +) +data class SubFooResponseWithSchema( + @Schema( + name = "subName", + description = """ + sub foo response fields with kotlin indent + """ + ) + val subName: String, +) 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 new file mode 100644 index 000000000..32c35f763 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v31/app11/SpringDocApp11Test.kt @@ -0,0 +1,31 @@ +/* + * + * * Copyright 2019-2023 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.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 + +@TestPropertySource(properties = ["springdoc.trim-kotlin-indent=true"]) +class SpringDocApp11Test : AbstractKotlinSpringDocMVCTest() { + @SpringBootApplication + @ComponentScan(basePackages = ["org.springdoc", "test.org.springdoc.api.v31.app11"]) + class DemoApplication +} 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 new file mode 100644 index 000000000..a5c7ad736 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v31/app12/SpringDocApp12Test.kt @@ -0,0 +1,35 @@ +/* + * + * * Copyright 2019-2023 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.app12 + +import org.springframework.boot.autoconfigure.SpringBootApplication +import org.springframework.context.annotation.ComponentScan +import test.org.springdoc.api.v30.AbstractKotlinSpringDocMVCTest + +class SpringDocApp12Test : AbstractKotlinSpringDocMVCTest() { + + @SpringBootApplication + @ComponentScan(basePackages = ["org.springdoc", "test.org.springdoc.api.v31.app12", "test.org.springdoc.api.app12"]) + class DemoApplication + + enum class MyEnum { + A, B; + } + +} 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 new file mode 100644 index 000000000..eedc437f3 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v31/app13/SpringDocApp13Test.kt @@ -0,0 +1,33 @@ +/* + * + * * Copyright 2019-2020 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.app13 + +import org.springframework.boot.autoconfigure.SpringBootApplication +import org.springframework.test.context.TestPropertySource +import test.org.springdoc.api.v30.AbstractKotlinSpringDocMVCTest + +@TestPropertySource(properties = ["springdoc.api-docs.version=openapi_3_1"]) +class SpringDocApp13Test : AbstractKotlinSpringDocMVCTest() { + + @SpringBootApplication + class DemoApplication { + } + + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v31/app13/TestController.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v31/app13/TestController.kt new file mode 100644 index 000000000..054b141b9 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v31/app13/TestController.kt @@ -0,0 +1,50 @@ +/* + * + * * Copyright 2019-2020 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.app13 + + +import io.swagger.v3.oas.annotations.media.Schema +import org.springframework.web.bind.annotation.PostMapping +import org.springframework.web.bind.annotation.RequestBody +import org.springframework.web.bind.annotation.RequestMapping +import org.springframework.web.bind.annotation.RestController + +@Schema(description = "Generic description") +data class KeyValue( + val key: String, + val value: String, +) + +@Schema +data class SomeDTO( + @Schema(description = "Description A") val fieldA: KeyValue, + @Schema(description = "Description B") val fieldB: KeyValue, +) + + + +@RestController +@RequestMapping("/test") +class TestController { + @PostMapping("/test") + fun create(@RequestBody some: SomeDTO) { + + } +} + 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 new file mode 100644 index 000000000..0a039c9b4 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v31/app14/SpringDocApp14Test.kt @@ -0,0 +1,29 @@ +/* + * + * * Copyright 2019-2020 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.app14 + +import org.springframework.boot.autoconfigure.SpringBootApplication +import test.org.springdoc.api.v30.AbstractKotlinSpringDocMVCTest + +class SpringDocApp14Test : AbstractKotlinSpringDocMVCTest() { + + @SpringBootApplication + class DemoApplication + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v31/app14/TestController.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v31/app14/TestController.kt new file mode 100644 index 000000000..feb0099a9 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v31/app14/TestController.kt @@ -0,0 +1,47 @@ +/* + * + * * Copyright 2019-2020 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.app14 + +import io.swagger.v3.oas.annotations.media.Schema +import org.springframework.web.bind.annotation.PostMapping +import org.springframework.web.bind.annotation.RequestBody +import org.springframework.web.bind.annotation.RequestMapping +import org.springframework.web.bind.annotation.RestController + +@Schema(description = "Generic description") +data class KeyValue( + val key: String, + val value: String, +) + +@Schema +data class SomeDTO( + @Schema(description = "Description A", allOf = [KeyValue::class]) val field_a: KeyValue, + @Schema(description = "Description B", allOf = [KeyValue::class]) val field_b: KeyValue, +) + +@RestController +@RequestMapping("/test") +class TestController { + + @PostMapping("/test") + fun create(@RequestBody some: SomeDTO) { + + } +} \ No newline at end of file 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 new file mode 100644 index 000000000..2bce75616 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v31/app2/SpringDocApp2Test.kt @@ -0,0 +1,29 @@ +/* + * + * * Copyright 2019-2020 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.app2 + +import org.springframework.boot.autoconfigure.SpringBootApplication +import test.org.springdoc.api.v30.AbstractKotlinSpringDocMVCTest + +class SpringDocApp2Test : AbstractKotlinSpringDocMVCTest() { + + @SpringBootApplication + class DemoApplication + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v31/app2/SystemStatusController.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v31/app2/SystemStatusController.kt new file mode 100644 index 000000000..2c91ee198 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v31/app2/SystemStatusController.kt @@ -0,0 +1,43 @@ +/* + * + * * Copyright 2019-2020 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.app2 + +import org.springframework.web.bind.annotation.GetMapping +import org.springframework.web.bind.annotation.RequestMapping +import org.springframework.web.bind.annotation.RestController + +enum class SystemStatus(val status: String) { + OK("OK") +} + +data class SystemStatusResponse( + val status: SystemStatus +) + +@RestController +@RequestMapping("/status") +class SystemStatusController { + @GetMapping + fun index() = SystemStatusResponse(SystemStatus.OK) + + @GetMapping("/foo") + fun foo() = + SystemStatusResponse(SystemStatus.OK) + +} 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 new file mode 100644 index 000000000..d6d36c472 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v31/app3/SpringDocApp3Test.kt @@ -0,0 +1,31 @@ +/* + * + * * Copyright 2019-2020 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.app3 + +import org.springframework.boot.autoconfigure.SpringBootApplication +import org.springframework.context.annotation.ComponentScan +import test.org.springdoc.api.v30.AbstractKotlinSpringDocMVCTest + +class SpringDocApp3Test : AbstractKotlinSpringDocMVCTest() { + + @SpringBootApplication + @ComponentScan(basePackages = ["org.springdoc", "test.org.springdoc.api.v31.app3"]) + class DemoApplication + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v31/app3/SystemStatusController.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v31/app3/SystemStatusController.kt new file mode 100644 index 000000000..9e0645677 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v31/app3/SystemStatusController.kt @@ -0,0 +1,43 @@ +/* + * + * * Copyright 2019-2020 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.app3 + +import org.springframework.web.bind.annotation.GetMapping +import org.springframework.web.bind.annotation.RequestMapping +import org.springframework.web.bind.annotation.RestController + +enum class SystemStatus(val status: String) { + OK("OK") +} + +data class SystemStatusResponse( + val status: SystemStatus +) + +@RestController +@RequestMapping("/status") +class SystemStatusController { + @GetMapping + fun index() = SystemStatusResponse(SystemStatus.OK) + + @GetMapping("/foo") + @Deprecated("") + fun foo() = SystemStatusResponse(SystemStatus.OK) + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v31/app4/HelloController.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v31/app4/HelloController.kt new file mode 100644 index 000000000..f1ff201e3 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v31/app4/HelloController.kt @@ -0,0 +1,37 @@ +/* + * + * * Copyright 2019-2020 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.app4 + +import org.springframework.web.bind.annotation.GetMapping +import org.springframework.web.bind.annotation.RequestMapping +import org.springframework.web.bind.annotation.RestController + + +data class Person( + val name: String, + val nickname: String? +) + +@RestController +@RequestMapping("/test") +class HelloController { + @GetMapping + suspend fun index(s: Person) = s + +} 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 new file mode 100644 index 000000000..2759ab955 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v31/app4/SpringDocApp4Test.kt @@ -0,0 +1,31 @@ +/* + * + * * Copyright 2019-2020 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.app4 + +import org.springframework.boot.autoconfigure.SpringBootApplication +import org.springframework.context.annotation.ComponentScan +import test.org.springdoc.api.v30.AbstractKotlinSpringDocMVCTest + +class SpringDocApp4Test : AbstractKotlinSpringDocMVCTest() { + + @SpringBootApplication + @ComponentScan(basePackages = ["org.springdoc", "test.org.springdoc.api.v31.app4"]) + class DemoApplication + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v31/app5/ListController.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v31/app5/ListController.kt new file mode 100644 index 000000000..a3eb0eebb --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v31/app5/ListController.kt @@ -0,0 +1,31 @@ +/* + * + * * Copyright 2019-2020 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.app5 + +import org.springframework.web.bind.annotation.GetMapping +import org.springframework.web.bind.annotation.RequestMapping +import org.springframework.web.bind.annotation.RestController + +@RestController +@RequestMapping("/test") +class ListController { + + @GetMapping("/") + fun foo(): List = listOf(1, 2, 3) +} 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 new file mode 100644 index 000000000..33358bcc5 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v31/app5/SpringDocApp5Test.kt @@ -0,0 +1,31 @@ +/* + * + * * Copyright 2019-2020 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.app5 + +import org.springframework.boot.autoconfigure.SpringBootApplication +import org.springframework.context.annotation.ComponentScan +import test.org.springdoc.api.v30.AbstractKotlinSpringDocMVCTest + +class SpringDocApp5Test : AbstractKotlinSpringDocMVCTest() { + + @SpringBootApplication + @ComponentScan(basePackages = ["org.springdoc", "test.org.springdoc.api.v31.app5"]) + class DemoApplication + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v31/app6/ByteArrayController.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v31/app6/ByteArrayController.kt new file mode 100644 index 000000000..1e468b12b --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v31/app6/ByteArrayController.kt @@ -0,0 +1,34 @@ +/* + * + * * 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.app6 + +import org.springframework.web.bind.annotation.GetMapping +import org.springframework.web.bind.annotation.RequestMapping +import org.springframework.web.bind.annotation.RestController + +data class Foo(val data: ByteArray) + +@RestController +@RequestMapping("/bytearray") +class ByteArrayController { + + @GetMapping("/") + fun getByteArray(): Foo = Foo(byteArrayOf(0)) + +} 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 new file mode 100644 index 000000000..e09f33a0e --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v31/app6/SpringDocApp6Test.kt @@ -0,0 +1,31 @@ +/* + * + * * Copyright 2019-2020 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.app6 + +import org.springframework.boot.autoconfigure.SpringBootApplication +import org.springframework.context.annotation.ComponentScan +import test.org.springdoc.api.v30.AbstractKotlinSpringDocMVCTest + +class SpringDocApp6Test : AbstractKotlinSpringDocMVCTest() { + + @SpringBootApplication + @ComponentScan(basePackages = ["org.springdoc", "test.org.springdoc.api.v31.app6"]) + class DemoApplication + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v31/app7/ExampleController.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v31/app7/ExampleController.kt new file mode 100644 index 000000000..7675ccc3f --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v31/app7/ExampleController.kt @@ -0,0 +1,17 @@ +package test.org.springdoc.api.v31.app7 + +import io.swagger.v3.oas.annotations.Parameter +import org.springframework.web.bind.annotation.GetMapping +import org.springframework.web.bind.annotation.RequestParam +import org.springframework.web.bind.annotation.RestController + +data class Greeting(val greeting: String) + +@RestController +interface ExampleController { + @GetMapping("/") + fun greet(@RequestParam name: String?): Greeting + + @GetMapping("/test") + fun test(@RequestParam @Parameter(required = true) name: String?): Greeting +} 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 new file mode 100644 index 000000000..6841c4503 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v31/app7/SpringDocApp7Test.kt @@ -0,0 +1,46 @@ +/* + * + * * Copyright 2019-2020 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.app7 + +import org.springframework.aop.framework.ProxyFactory +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 + +class SpringDocApp7Test : AbstractKotlinSpringDocMVCTest() { + + @SpringBootApplication + @ComponentScan(basePackages = ["org.springdoc", "test.org.springdoc.api.v31.app7"]) + class DemoApplication{ + @Bean + fun controller(applicationContext: GenericApplicationContext): ExampleController { + return createProxy(ExampleController::class.java) + } + + private fun createProxy(clazz: Class): T { + val proxyFactory = ProxyFactory(clazz) + proxyFactory.targetClass = clazz + @Suppress("UNCHECKED_CAST") + return proxyFactory.proxy as T + } + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v31/app8/ExampleController.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v31/app8/ExampleController.kt new file mode 100644 index 000000000..6d78841cd --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v31/app8/ExampleController.kt @@ -0,0 +1,17 @@ +package test.org.springdoc.api.v31.app8 + +import io.swagger.v3.oas.annotations.Parameter +import org.springframework.web.bind.annotation.GetMapping +import org.springframework.web.bind.annotation.RequestParam +import org.springframework.web.bind.annotation.RestController + +data class Greeting(val greeting: String) + +@RestController +interface ExampleController { + @GetMapping("/") + fun greet(@RequestParam name: String?): Greeting + + @GetMapping("/test") + fun test(@RequestParam @Parameter(required = true) name: String?): Greeting +} 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 new file mode 100644 index 000000000..a8251dbc2 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v31/app8/SpringDocApp8Test.kt @@ -0,0 +1,49 @@ +/* + * + * * Copyright 2019-2020 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.app8 + +import org.springdoc.core.utils.Constants +import org.springframework.aop.framework.ProxyFactory +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 org.springframework.test.context.TestPropertySource +import test.org.springdoc.api.v30.AbstractKotlinSpringDocMVCTest + +@TestPropertySource(properties = [Constants.SPRINGDOC_NULLABLE_REQUEST_PARAMETER_ENABLED+"=false"]) +class SpringDocApp8Test : AbstractKotlinSpringDocMVCTest() { + + @SpringBootApplication + @ComponentScan(basePackages = ["org.springdoc", "test.org.springdoc.api.v31.app8"]) + class DemoApplication{ + @Bean + fun controller(applicationContext: GenericApplicationContext): ExampleController { + return createProxy(ExampleController::class.java) + } + + private fun createProxy(clazz: Class): T { + val proxyFactory = ProxyFactory(clazz) + proxyFactory.targetClass = clazz + @Suppress("UNCHECKED_CAST") + return proxyFactory.proxy as T + } + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v31/app9/DemoController.kt b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v31/app9/DemoController.kt new file mode 100644 index 000000000..89de59a98 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v31/app9/DemoController.kt @@ -0,0 +1,71 @@ +package test.org.springdoc.api.v31.app9 + +import io.swagger.v3.oas.annotations.media.Schema +import org.springframework.web.bind.annotation.GetMapping +import org.springframework.web.bind.annotation.RequestMapping +import org.springframework.web.bind.annotation.RestController + +@RestController +@RequestMapping("/api/demo") +class DocumentsApiController { + + @GetMapping + suspend fun getDocuments( request: DemoRequest + ): DemoDto = DemoDto(42) +} + +data class DemoDto( + var id: Long, +) + +class DemoRequest ( + + @field:Schema(required = true, defaultValue = "a default value") + val requiredNullableDefault: String?, + + @field:Schema(required = true) + val requiredNullableNoDefault: String?, + + @field:Schema(required = true, defaultValue = "a default value") + val requiredNoNullableDefault: String, + + @field:Schema(required = true) + val requiredNoNullableNoDefault: String, + + @field:Schema(requiredMode = Schema.RequiredMode.REQUIRED, defaultValue = "a default value") + val requiredNullableDefault1: String?, + + @field:Schema(requiredMode = Schema.RequiredMode.REQUIRED) + val requiredNullableNoDefault1: String?, + + @field:Schema(requiredMode = Schema.RequiredMode.REQUIRED, defaultValue = "a default value") + val requiredNoNullableDefault1: String, + + @field:Schema(requiredMode = Schema.RequiredMode.REQUIRED) + val requiredNoNullableNoDefault1: String, + + @field:Schema(requiredMode = Schema.RequiredMode.NOT_REQUIRED, defaultValue = "a default value") + val noRequiredNullableDefault2: String?, + + @field:Schema(requiredMode = Schema.RequiredMode.NOT_REQUIRED) + val noRequiredNullableNoDefault2: String?, + + @field:Schema(requiredMode = Schema.RequiredMode.NOT_REQUIRED, defaultValue = "a default value") + val noRequiredNoNullableDefault2: String, + + @field:Schema(requiredMode = Schema.RequiredMode.NOT_REQUIRED) + val noRequiredNoNullableNoDefault2: String, + + @field:Schema(defaultValue = "a default value") + val noRequiredNullableDefault: String?, + + @field:Schema + val noRequiredNullableNoDefault: String?, + + @field:Schema(defaultValue = "a default value") + val noRequiredNoNullableDefault: String, + + @field:Schema + val noRequiredNoNullableNoDefault: String, + +) 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 new file mode 100644 index 000000000..bef0623e6 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/kotlin/test/org/springdoc/api/v31/app9/SpringDocApp9Test.kt @@ -0,0 +1,9 @@ +package test.org.springdoc.api.v31.app9 + +import org.springframework.boot.autoconfigure.SpringBootApplication +import test.org.springdoc.api.v30.AbstractKotlinSpringDocMVCTest + +class SpringDocApp9Test: AbstractKotlinSpringDocMVCTest() { + @SpringBootApplication + class DemoApplication +} diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/resources/results/app1.json b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/resources/results/3.0.1/app1.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/resources/results/app1.json rename to springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/resources/results/3.0.1/app1.json diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/resources/results/app10.json b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/resources/results/3.0.1/app10.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/resources/results/app10.json rename to springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/resources/results/3.0.1/app10.json diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/resources/results/app11.json b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/resources/results/3.0.1/app11.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/resources/results/app11.json rename to springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/resources/results/3.0.1/app11.json diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/resources/results/app12.json b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/resources/results/3.0.1/app12.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/resources/results/app12.json rename to springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/resources/results/3.0.1/app12.json diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/resources/results/app13.json b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/resources/results/3.0.1/app13.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/resources/results/app13.json rename to springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/resources/results/3.0.1/app13.json diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/resources/results/app14.json b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/resources/results/3.0.1/app14.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/resources/results/app14.json rename to springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/resources/results/3.0.1/app14.json diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/resources/results/app2.json b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/resources/results/3.0.1/app2.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/resources/results/app2.json rename to springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/resources/results/3.0.1/app2.json diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/resources/results/app3.json b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/resources/results/3.0.1/app3.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/resources/results/app3.json rename to springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/resources/results/3.0.1/app3.json diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/resources/results/app4.json b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/resources/results/3.0.1/app4.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/resources/results/app4.json rename to springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/resources/results/3.0.1/app4.json diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/resources/results/app5.json b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/resources/results/3.0.1/app5.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/resources/results/app5.json rename to springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/resources/results/3.0.1/app5.json diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/resources/results/app6.json b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/resources/results/3.0.1/app6.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/resources/results/app6.json rename to springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/resources/results/3.0.1/app6.json diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/resources/results/app7.json b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/resources/results/3.0.1/app7.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/resources/results/app7.json rename to springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/resources/results/3.0.1/app7.json diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/resources/results/app8.json b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/resources/results/3.0.1/app8.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/resources/results/app8.json rename to springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/resources/results/3.0.1/app8.json diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/resources/results/app9.json b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/resources/results/3.0.1/app9.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/resources/results/app9.json rename to springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/resources/results/3.0.1/app9.json diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/resources/results/3.1.0/app1.json b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/resources/results/3.1.0/app1.json new file mode 100644 index 000000000..611c6c404 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/resources/results/3.1.0/app1.json @@ -0,0 +1,51 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "Kotlin API", + "license": { + "name": "Apache 2.0", + "url": "http://springdoc.org" + }, + "version": "v1" + }, + "servers": [ + { + "url": "", + "description": "Generated server url" + } + ], + "paths": { + "/test/{id}": { + "get": { + "tags": [ + "controller-with-continuation-parameter" + ], + "summary": "Ignore Continuation parameter", + "operationId": "get", + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "string" + } + } + } + } + } + } + } + }, + "components": {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/resources/results/3.1.0/app10.json b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/resources/results/3.1.0/app10.json new file mode 100644 index 000000000..6c1d0bb05 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/resources/results/3.1.0/app10.json @@ -0,0 +1,121 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/": { + "get": { + "tags": [ + "example-controller" + ], + "operationId": "greet", + "parameters": [ + { + "name": "name", + "in": "query", + "required": false, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/Greeting" + } + } + } + } + } + } + }, + "/test": { + "get": { + "tags": [ + "example-controller" + ], + "operationId": "test", + "parameters": [ + { + "name": "name", + "in": "query", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/Greeting" + } + } + } + } + } + } + }, + "/test-with-default": { + "get": { + "tags": [ + "example-controller" + ], + "operationId": "testWithDefault", + "parameters": [ + { + "name": "name", + "in": "query", + "required": false, + "schema": { + "type": "string", + "default": "world" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/Greeting" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "Greeting": { + "required": [ + "greeting" + ], + "type": "object", + "properties": { + "greeting": { + "type": "string" + } + } + } + } + } +} 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 new file mode 100644 index 000000000..a15b4ed94 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/resources/results/3.1.0/app11.json @@ -0,0 +1,136 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/foo/trim-kotlin-indent": { + "get": { + "tags": [ + "example-controller" + ], + "summary": "foo api", + "description": "\nthis api is foo\n\n#### Custom exception case\n| Http Status | Error Code | Error Message | Error Data | Remark |\n|-------------|-------------|--------------|------------|-----------|\n| 403 | NO_PERMISSION |This request is only available to administrators. | | |\n| 400 | STORE_NOT_FOUND |Store not found. | | |\n", + "operationId": "readFoo", + "parameters": [ + { + "name": "name", + "in": "query", + "required": false, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/FooResponse" + } + } + } + } + } + } + }, + "/foo/trim-kotlin-indent/schema": { + "get": { + "tags": [ + "example-controller-2" + ], + "operationId": "readFoo_1", + "parameters": [ + { + "name": "request", + "in": "query", + "required": true, + "schema": { + "$ref": "#/components/schemas/foo request" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/foo response" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "FooResponse": { + "required": [ + "name" + ], + "type": "object", + "properties": { + "name": { + "type": "string" + } + } + }, + "foo request": { + "required": [ + "age" + ], + "type": "object", + "properties": { + "age": { + "type": "integer", + "description": "\nfoo request field with kotlin indent\n", + "format": "int32" + } + }, + "description": "\nfoo request class description\nwith kotlin indent\n" + }, + "foo response": { + "required": [ + "name", + "subFoo" + ], + "type": "object", + "properties": { + "name": { + "type": "string", + "description": "\nfoo response fields with kotlin indent\n" + }, + "subFoo": { + "$ref": "#/components/schemas/sub foo response" + } + }, + "description": "\nfoo response class description\nwith kotlin indent\n" + }, + "sub foo response": { + "required": [ + "subName" + ], + "type": "object", + "properties": { + "subName": { + "type": "string", + "description": "\nsub foo response fields with kotlin indent\n" + } + }, + "description": "\nsub foo response class description\nwith kotlin indent\n" + } + } + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/resources/results/3.1.0/app12.json b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/resources/results/3.1.0/app12.json new file mode 100644 index 000000000..868d8de2b --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/resources/results/3.1.0/app12.json @@ -0,0 +1,50 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/test-enum-2": { + "get": { + "tags": [ + "enum-controller" + ], + "operationId": "testEnum2", + "parameters": [ + { + "name": "e", + "in": "query", + "required": false, + "schema": { + "type": "string", + "enum": [ + "A", + "B" + ] + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + } + }, + "components": {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/resources/results/3.1.0/app13.json b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/resources/results/3.1.0/app13.json new file mode 100644 index 000000000..6bf07eb5b --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/resources/results/3.1.0/app13.json @@ -0,0 +1,68 @@ +{ + "openapi" : "3.1.0", + "info" : { + "title" : "OpenAPI definition", + "version" : "v0" + }, + "servers" : [ { + "url" : "http://localhost", + "description" : "Generated server url" + } ], + "paths" : { + "/test/test" : { + "post" : { + "tags" : [ "test-controller" ], + "operationId" : "create", + "requestBody" : { + "content" : { + "application/json" : { + "schema" : { + "$ref" : "#/components/schemas/SomeDTO" + } + } + }, + "required" : true + }, + "responses" : { + "200" : { + "description" : "OK" + } + } + } + } + }, + "components" : { + "schemas" : { + "KeyValue" : { + "required" : [ "key", "value" ], + "type" : "object", + "description" : "Generic description", + "properties" : { + "key" : { + "type" : "string" + }, + "value" : { + "type" : "string" + } + } + }, + "SomeDTO" : { + "required": [ + "fieldA", + "fieldB" + ], + "type": "object", + "properties": { + "fieldA": { + "description": "Description A", + "$ref": "#/components/schemas/KeyValue" + }, + "fieldB": { + "description": "Description B", + "$ref": "#/components/schemas/KeyValue" + } + } + } + } + } +} \ 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 new file mode 100644 index 000000000..987ebdff3 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/resources/results/3.1.0/app14.json @@ -0,0 +1,81 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/test/test": { + "post": { + "tags": [ + "test-controller" + ], + "operationId": "create", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/SomeDTO" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "OK" + } + } + } + } + }, + "components": { + "schemas": { + "KeyValue": { + "required": [ + "key", + "value" + ], + "type": "object", + "description": "Generic description", + "allOf": [ + { + "$ref": "#/components/schemas/KeyValue" + }, + { + "type": "object", + "properties": { + "key": { + "type": "string" + }, + "value": { + "type": "string" + } + } + } + ] + }, + "SomeDTO": { + "required": [ + "field_a", + "field_b" + ], + "type": "object", + "properties": { + "field_a": { + "$ref": "#/components/schemas/KeyValue" + }, + "field_b": { + "$ref": "#/components/schemas/KeyValue" + } + } + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/resources/results/3.1.0/app2.json b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/resources/results/3.1.0/app2.json new file mode 100644 index 000000000..956fd589c --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/resources/results/3.1.0/app2.json @@ -0,0 +1,73 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/status": { + "get": { + "tags": [ + "system-status-controller" + ], + "operationId": "index", + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/SystemStatusResponse" + } + } + } + } + } + } + }, + "/status/foo": { + "get": { + "tags": [ + "system-status-controller" + ], + "operationId": "foo", + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/SystemStatusResponse" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "SystemStatusResponse": { + "required": [ + "status" + ], + "type": "object", + "properties": { + "status": { + "type": "string", + "enum": [ + "OK" + ] + } + } + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/resources/results/3.1.0/app3.json b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/resources/results/3.1.0/app3.json new file mode 100644 index 000000000..65a4798da --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/resources/results/3.1.0/app3.json @@ -0,0 +1,74 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/status": { + "get": { + "tags": [ + "system-status-controller" + ], + "operationId": "index", + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/SystemStatusResponse" + } + } + } + } + } + } + }, + "/status/foo": { + "get": { + "tags": [ + "system-status-controller" + ], + "operationId": "foo", + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/SystemStatusResponse" + } + } + } + } + }, + "deprecated": true + } + } + }, + "components": { + "schemas": { + "SystemStatusResponse": { + "required": [ + "status" + ], + "type": "object", + "properties": { + "status": { + "type": "string", + "enum": [ + "OK" + ] + } + } + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/resources/results/3.1.0/app4.json b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/resources/results/3.1.0/app4.json new file mode 100644 index 000000000..e374b0e9a --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/resources/results/3.1.0/app4.json @@ -0,0 +1,63 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/test": { + "get": { + "tags": [ + "hello-controller" + ], + "operationId": "index", + "parameters": [ + { + "name": "s", + "in": "query", + "required": true, + "schema": { + "$ref": "#/components/schemas/Person" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/Person" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "Person": { + "required": [ + "name" + ], + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "nickname": { + "type": "string" + } + } + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/resources/results/3.1.0/app5.json b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/resources/results/3.1.0/app5.json new file mode 100644 index 000000000..2b7a7f5bf --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/resources/results/3.1.0/app5.json @@ -0,0 +1,40 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/test/": { + "get": { + "tags": [ + "list-controller" + ], + "operationId": "foo", + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "array", + "items": { + "type": "integer", + "format": "int32" + } + } + } + } + } + } + } + } + }, + "components": {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/resources/results/3.1.0/app6.json b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/resources/results/3.1.0/app6.json new file mode 100644 index 000000000..5b159ebcd --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/resources/results/3.1.0/app6.json @@ -0,0 +1,51 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/bytearray/": { + "get": { + "tags": [ + "byte-array-controller" + ], + "operationId": "getByteArray", + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/Foo" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "Foo": { + "required": [ + "data" + ], + "type": "object", + "properties": { + "data": { + "type": "string", + "format": "byte" + } + } + } + } + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/resources/results/3.1.0/app7.json b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/resources/results/3.1.0/app7.json new file mode 100644 index 000000000..60439b2ba --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/resources/results/3.1.0/app7.json @@ -0,0 +1,90 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/": { + "get": { + "tags": [ + "example-controller" + ], + "operationId": "greet", + "parameters": [ + { + "name": "name", + "in": "query", + "required": false, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/Greeting" + } + } + } + } + } + } + }, + "/test": { + "get": { + "tags": [ + "example-controller" + ], + "operationId": "test", + "parameters": [ + { + "name": "name", + "in": "query", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/Greeting" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "Greeting": { + "required": [ + "greeting" + ], + "type": "object", + "properties": { + "greeting": { + "type": "string" + } + } + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/resources/results/3.1.0/app8.json b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/resources/results/3.1.0/app8.json new file mode 100644 index 000000000..60439b2ba --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/resources/results/3.1.0/app8.json @@ -0,0 +1,90 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/": { + "get": { + "tags": [ + "example-controller" + ], + "operationId": "greet", + "parameters": [ + { + "name": "name", + "in": "query", + "required": false, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/Greeting" + } + } + } + } + } + } + }, + "/test": { + "get": { + "tags": [ + "example-controller" + ], + "operationId": "test", + "parameters": [ + { + "name": "name", + "in": "query", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/Greeting" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "Greeting": { + "required": [ + "greeting" + ], + "type": "object", + "properties": { + "greeting": { + "type": "string" + } + } + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/resources/results/3.1.0/app9.json b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/resources/results/3.1.0/app9.json new file mode 100644 index 000000000..99fc92a3a --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-kotlin-webmvc-tests/src/test/resources/results/3.1.0/app9.json @@ -0,0 +1,133 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/api/demo": { + "get": { + "tags": [ + "documents-api-controller" + ], + "operationId": "getDocuments", + "parameters": [ + { + "name": "request", + "in": "query", + "required": true, + "schema": { + "$ref": "#/components/schemas/DemoRequest" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/DemoDto" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "DemoRequest": { + "required": [ + "noRequiredNoNullableNoDefault", + "requiredNoNullableDefault", + "requiredNoNullableDefault1", + "requiredNoNullableNoDefault", + "requiredNoNullableNoDefault1", + "requiredNullableDefault", + "requiredNullableDefault1", + "requiredNullableNoDefault", + "requiredNullableNoDefault1" + ], + "type": "object", + "properties": { + "requiredNullableDefault": { + "type": "string", + "default": "a default value" + }, + "requiredNullableNoDefault": { + "type": "string" + }, + "requiredNoNullableDefault": { + "type": "string", + "default": "a default value" + }, + "requiredNoNullableNoDefault": { + "type": "string" + }, + "requiredNullableDefault1": { + "type": "string", + "default": "a default value" + }, + "requiredNullableNoDefault1": { + "type": "string" + }, + "requiredNoNullableDefault1": { + "type": "string", + "default": "a default value" + }, + "requiredNoNullableNoDefault1": { + "type": "string" + }, + "noRequiredNullableDefault2": { + "type": "string", + "default": "a default value" + }, + "noRequiredNullableNoDefault2": { + "type": "string" + }, + "noRequiredNoNullableDefault2": { + "type": "string", + "default": "a default value" + }, + "noRequiredNoNullableNoDefault2": { + "type": "string" + }, + "noRequiredNullableDefault": { + "type": "string", + "default": "a default value" + }, + "noRequiredNullableNoDefault": { + "type": "string" + }, + "noRequiredNoNullableDefault": { + "type": "string", + "default": "a default value" + }, + "noRequiredNoNullableNoDefault": { + "type": "string" + } + } + }, + "DemoDto": { + "required": [ + "id" + ], + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + } + } + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/pom.xml b/springdoc-openapi-tests/springdoc-openapi-security-tests/pom.xml index d3aad5a71..1b56ed4e5 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.1 + 2.8.2 springdoc-openapi-security-tests diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/AbstractSpringDocTest.java b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/AbstractSpringDocTest.java deleted file mode 100644 index 6bff84da3..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/AbstractSpringDocTest.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * - * * Copyright 2019-2020 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; - -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; - -import org.junit.jupiter.api.Test; -import org.springdoc.core.utils.Constants; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration; -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.context.annotation.Configuration; -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.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; - -@ActiveProfiles("test") -@SpringBootTest -@AutoConfigureMockMvc -@TestPropertySource(properties = "springdoc.api-docs.version=openapi_3_0" ) -public abstract class AbstractSpringDocTest { - - public static String className; - - @Autowired - protected MockMvc mockMvc; - - public static String getContent(String fileName) { - try { - Path path = Paths.get(AbstractSpringDocTest.class.getClassLoader().getResource(fileName).toURI()); - byte[] fileBytes = Files.readAllBytes(path); - return new String(fileBytes, StandardCharsets.UTF_8); - } - catch (Exception e) { - throw new RuntimeException("Failed to read file: " + fileName, e); - } - } - - @Test - void testApp() throws Exception { - className = getClass().getSimpleName(); - String testNumber = className.replaceAll("[^0-9]", ""); - MvcResult mockMvcResult = mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL)).andExpect(status().isOk()) - .andExpect(jsonPath("$.openapi", is("3.0.1"))).andReturn(); - String result = mockMvcResult.getResponse().getContentAsString(); - String expected = getContent("results/app" + testNumber + ".json"); - assertEquals(expected, result, true); - } - - @Configuration - @EnableAutoConfiguration(exclude = { SecurityAutoConfiguration.class }) - static class ContextConfiguration {} -} diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/app1/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/app1/HelloController.java deleted file mode 100644 index 063133377..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/app1/HelloController.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app1; - -import org.springframework.security.core.annotation.AuthenticationPrincipal; -import org.springframework.security.core.userdetails.User; -import org.springframework.security.oauth2.client.OAuth2AuthorizedClient; -import org.springframework.security.oauth2.client.annotation.RegisteredOAuth2AuthorizedClient; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RestController; - -@RestController -public class HelloController { - - @PostMapping(value = "/persons") - public String persons(@RequestBody() Person person) { - return "OK"; - } - - @PostMapping(value = "/persons-with-user") - public String personsWithUser(@RequestBody() Person person, - @AuthenticationPrincipal User user) { - return "OK"; - } - - @PostMapping(value = "/persons-with-oauth2-user") - public String personsWithUser(@RequestBody() Person person, - @RegisteredOAuth2AuthorizedClient OAuth2AuthorizedClient authorizedClient, - @AuthenticationPrincipal User user) { - return "OK"; - } - -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/app1/Person.java b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/app1/Person.java deleted file mode 100644 index f33d80b6f..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/app1/Person.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app1; - -public class Person { - - private String name; - - public Person() { - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/app1/SpringDocApp1Test.java b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/app1/SpringDocApp1Test.java deleted file mode 100644 index 4daff5662..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/app1/SpringDocApp1Test.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app1; - -import io.swagger.v3.oas.models.OpenAPI; -import io.swagger.v3.oas.models.info.Info; -import io.swagger.v3.oas.models.info.License; -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.Bean; - -public class SpringDocApp1Test extends AbstractSpringDocTest { - - @SpringBootApplication(scanBasePackages = { "test.org.springdoc.api.configuration,test.org.springdoc.api.app1" }) - static class SpringDocTestApp { - @Bean - public OpenAPI customOpenAPI() { - return new OpenAPI() - .info(new Info().title("Security API").version("v1") - .license(new License().name("Apache 2.0").url("http://springdoc.org"))); - } - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/app10/AuthorizationServerConfig.java b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/app10/AuthorizationServerConfig.java deleted file mode 100644 index cf0c68acd..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/app10/AuthorizationServerConfig.java +++ /dev/null @@ -1,78 +0,0 @@ -package test.org.springdoc.api.app10; - -import java.util.UUID; - -import com.nimbusds.jose.jwk.JWKSet; -import com.nimbusds.jose.jwk.RSAKey; -import com.nimbusds.jose.jwk.source.JWKSource; -import com.nimbusds.jose.proc.SecurityContext; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.security.config.annotation.web.builders.HttpSecurity; -import org.springframework.security.oauth2.core.AuthorizationGrantType; -import org.springframework.security.oauth2.jwt.JwtDecoder; -import org.springframework.security.oauth2.server.authorization.InMemoryOAuth2AuthorizationService; -import org.springframework.security.oauth2.server.authorization.OAuth2AuthorizationService; -import org.springframework.security.oauth2.server.authorization.client.InMemoryRegisteredClientRepository; -import org.springframework.security.oauth2.server.authorization.client.RegisteredClient; -import org.springframework.security.oauth2.server.authorization.client.RegisteredClientRepository; -import org.springframework.security.oauth2.server.authorization.config.annotation.web.configuration.OAuth2AuthorizationServerConfiguration; -import org.springframework.security.oauth2.server.authorization.settings.AuthorizationServerSettings; -import org.springframework.security.oauth2.server.authorization.settings.ClientSettings; -import org.springframework.security.web.SecurityFilterChain; - -/* - * @author James Selvakumar - * @since 8.0.0 - */ -@Configuration -public class AuthorizationServerConfig -{ - @Bean - public SecurityFilterChain authorizationServerSecurityFilterChain(HttpSecurity http) throws Exception - { - OAuth2AuthorizationServerConfiguration.applyDefaultSecurity(http); - return http.build(); - } - - @Bean - public RegisteredClientRepository registeredClientRepository() { - RegisteredClient registeredClient = RegisteredClient.withId(UUID.randomUUID().toString()) - .clientId("messaging-client") - .clientSecret("{noop}secret") - .authorizationGrantType(AuthorizationGrantType.CLIENT_CREDENTIALS) - .scope("message.read") - .scope("message.write") - .clientSettings(ClientSettings.builder().requireAuthorizationConsent(true).build()) - .build(); - - return new InMemoryRegisteredClientRepository(registeredClient); - } - - @Bean - public OAuth2AuthorizationService authorizationService() - { - return new InMemoryOAuth2AuthorizationService(); - } - - @Bean - public AuthorizationServerSettings authorizationServerSettings() - { - return AuthorizationServerSettings.builder().build(); - } - - @Bean - public JWKSource jwkSource() - { - RSAKey rsaKey = Jwks.generateRsa(); - JWKSet jwkSet = new JWKSet(rsaKey); - return (jwkSelector, securityContext) -> jwkSelector.select(jwkSet); - } - - @Bean - public JwtDecoder jwtDecoder(JWKSource jwkSource) - { - return OAuth2AuthorizationServerConfiguration.jwtDecoder(jwkSource); - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/app10/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/app10/HelloController.java deleted file mode 100644 index fbbc34c13..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/app10/HelloController.java +++ /dev/null @@ -1,20 +0,0 @@ -package test.org.springdoc.api.app10; - -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -/* - * @author James Selvakumar - * @since 8.0.0 - */ -@RestController -@RequestMapping("/api") -public class HelloController -{ - @GetMapping("/hello") - public String hello() - { - return "Hello"; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/app10/Jwks.java b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/app10/Jwks.java deleted file mode 100644 index aaa2ec209..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/app10/Jwks.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2023. mCruncher Sdn Bhd, Cyberjaya, Malaysia. - * All rights reserved. - */ -package test.org.springdoc.api.app10; - - -import java.security.KeyPair; -import java.security.interfaces.RSAPrivateKey; -import java.security.interfaces.RSAPublicKey; -import java.util.UUID; - -import com.nimbusds.jose.jwk.RSAKey; - - -/** - * @author Joe Grandja - * @since 0.1.0 - */ -public final class Jwks -{ - private Jwks() - { - //final class constructor should be hidden - } - - public static RSAKey generateRsa() - { - KeyPair keyPair = KeyGeneratorUtils.generateRsaKey(); - RSAPublicKey publicKey = (RSAPublicKey) keyPair.getPublic(); - RSAPrivateKey privateKey = (RSAPrivateKey) keyPair.getPrivate(); - return new RSAKey.Builder(publicKey) - .privateKey(privateKey) - .keyID(UUID.randomUUID().toString()) - .build(); - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/app10/KeyGeneratorUtils.java b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/app10/KeyGeneratorUtils.java deleted file mode 100644 index aafe10f62..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/app10/KeyGeneratorUtils.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2023. mCruncher Sdn Bhd, Cyberjaya, Malaysia. - * All rights reserved. - */ -package test.org.springdoc.api.app10; - -import java.security.KeyPair; -import java.security.KeyPairGenerator; - -/** - * @author Joe Grandja - * @since 0.1.0 - */ -public final class KeyGeneratorUtils -{ - private KeyGeneratorUtils() - { - //final class constructor should be hidden - } - - static KeyPair generateRsaKey() - { - KeyPair keyPair; - try { - KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("RSA"); - keyPairGenerator.initialize(2048); - keyPair = keyPairGenerator.generateKeyPair(); - } catch (Exception ex) { - throw new IllegalStateException(ex); - } - return keyPair; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/app10/SpringDocApp10Test.java b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/app10/SpringDocApp10Test.java deleted file mode 100644 index 3ed51ff96..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/app10/SpringDocApp10Test.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app10; - -import java.util.Optional; - -import io.swagger.v3.core.converter.ModelConverter; -import io.swagger.v3.core.converter.ModelConverters; -import org.junit.jupiter.api.AfterAll; -import org.junit.jupiter.api.BeforeAll; -import org.springdoc.core.converters.SchemaPropertyDeprecatingConverter; -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.test.context.TestPropertySource; - -@TestPropertySource(properties = {"springdoc.show-oauth2-endpoints=true", "springdoc.model-converters.deprecating-converter.enabled=false"}) -public class SpringDocApp10Test extends AbstractSpringDocTest { - - @BeforeAll - public static void init() { - Optional deprecatingConverterOptional = - ModelConverters.getInstance().getConverters() - .stream().filter(modelConverter -> modelConverter instanceof SchemaPropertyDeprecatingConverter).findAny(); - deprecatingConverterOptional.ifPresent(ModelConverters.getInstance()::removeConverter); - } - - @AfterAll - public static void clean() { - Optional deprecatingConverterOptional = - ModelConverters.getInstance().getConverters() - .stream().filter(modelConverter -> modelConverter instanceof SchemaPropertyDeprecatingConverter).findAny(); - deprecatingConverterOptional.ifPresent(ModelConverters.getInstance()::addConverter); - } - - @SpringBootApplication - static class SpringDocTestApp { - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/app11/AuthorizationServerConfig.java b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/app11/AuthorizationServerConfig.java deleted file mode 100644 index f9e60d6ac..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/app11/AuthorizationServerConfig.java +++ /dev/null @@ -1,75 +0,0 @@ -package test.org.springdoc.api.app11; - -import java.util.UUID; - -import com.nimbusds.jose.jwk.JWKSet; -import com.nimbusds.jose.jwk.RSAKey; -import com.nimbusds.jose.jwk.source.JWKSource; -import com.nimbusds.jose.proc.SecurityContext; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.security.config.Customizer; -import org.springframework.security.config.annotation.web.builders.HttpSecurity; -import org.springframework.security.oauth2.core.AuthorizationGrantType; -import org.springframework.security.oauth2.jwt.JwtDecoder; -import org.springframework.security.oauth2.server.authorization.InMemoryOAuth2AuthorizationService; -import org.springframework.security.oauth2.server.authorization.OAuth2AuthorizationService; -import org.springframework.security.oauth2.server.authorization.client.InMemoryRegisteredClientRepository; -import org.springframework.security.oauth2.server.authorization.client.RegisteredClient; -import org.springframework.security.oauth2.server.authorization.client.RegisteredClientRepository; -import org.springframework.security.oauth2.server.authorization.config.annotation.web.configuration.OAuth2AuthorizationServerConfiguration; -import org.springframework.security.oauth2.server.authorization.config.annotation.web.configurers.OAuth2AuthorizationServerConfigurer; -import org.springframework.security.oauth2.server.authorization.settings.AuthorizationServerSettings; -import org.springframework.security.oauth2.server.authorization.settings.ClientSettings; -import org.springframework.security.web.SecurityFilterChain; - -/* - * @author yuta.saito - */ -@Configuration -public class AuthorizationServerConfig { - @Bean - public SecurityFilterChain authorizationServerSecurityFilterChain(HttpSecurity http) throws Exception { - OAuth2AuthorizationServerConfiguration.applyDefaultSecurity(http); - http.getConfigurer(OAuth2AuthorizationServerConfigurer.class) - .oidc(Customizer.withDefaults()); - return http.build(); - } - - @Bean - public RegisteredClientRepository registeredClientRepository() { - RegisteredClient registeredClient = RegisteredClient.withId(UUID.randomUUID().toString()) - .clientId("messaging-client") - .clientSecret("{noop}secret") - .authorizationGrantType(AuthorizationGrantType.CLIENT_CREDENTIALS) - .scope("message.read") - .scope("message.write") - .clientSettings(ClientSettings.builder().requireAuthorizationConsent(true).build()) - .build(); - - return new InMemoryRegisteredClientRepository(registeredClient); - } - - @Bean - public OAuth2AuthorizationService authorizationService() { - return new InMemoryOAuth2AuthorizationService(); - } - - @Bean - public AuthorizationServerSettings authorizationServerSettings() { - return AuthorizationServerSettings.builder().build(); - } - - @Bean - public JWKSource jwkSource() { - RSAKey rsaKey = Jwks.generateRsa(); - JWKSet jwkSet = new JWKSet(rsaKey); - return (jwkSelector, securityContext) -> jwkSelector.select(jwkSet); - } - - @Bean - public JwtDecoder jwtDecoder(JWKSource jwkSource) { - return OAuth2AuthorizationServerConfiguration.jwtDecoder(jwkSource); - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/app11/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/app11/HelloController.java deleted file mode 100644 index 52548cd1f..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/app11/HelloController.java +++ /dev/null @@ -1,17 +0,0 @@ -package test.org.springdoc.api.app11; - -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -/* - * @author yuta.saito - */ -@RestController -@RequestMapping("/api") -public class HelloController { - @GetMapping("/hello") - public String hello() { - return "Hello"; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/app11/Jwks.java b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/app11/Jwks.java deleted file mode 100644 index ab8d9cc79..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/app11/Jwks.java +++ /dev/null @@ -1,29 +0,0 @@ -package test.org.springdoc.api.app11; - - -import java.security.KeyPair; -import java.security.interfaces.RSAPrivateKey; -import java.security.interfaces.RSAPublicKey; -import java.util.UUID; - -import com.nimbusds.jose.jwk.RSAKey; - - -/** - * @author yuta.saito - */ -public final class Jwks { - private Jwks() { - //final class constructor should be hidden - } - - public static RSAKey generateRsa() { - KeyPair keyPair = KeyGeneratorUtils.generateRsaKey(); - RSAPublicKey publicKey = (RSAPublicKey) keyPair.getPublic(); - RSAPrivateKey privateKey = (RSAPrivateKey) keyPair.getPrivate(); - return new RSAKey.Builder(publicKey) - .privateKey(privateKey) - .keyID(UUID.randomUUID().toString()) - .build(); - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/app11/KeyGeneratorUtils.java b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/app11/KeyGeneratorUtils.java deleted file mode 100644 index 49ae4597d..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/app11/KeyGeneratorUtils.java +++ /dev/null @@ -1,26 +0,0 @@ -package test.org.springdoc.api.app11; - -import java.security.KeyPair; -import java.security.KeyPairGenerator; - -/** - * @author yuta.saito - */ -public final class KeyGeneratorUtils { - private KeyGeneratorUtils() { - //final class constructor should be hidden - } - - static KeyPair generateRsaKey() { - KeyPair keyPair; - try { - KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("RSA"); - keyPairGenerator.initialize(2048); - keyPair = keyPairGenerator.generateKeyPair(); - } - catch (Exception ex) { - throw new IllegalStateException(ex); - } - return keyPair; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/app11/SpringDocApp11Test.java b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/app11/SpringDocApp11Test.java deleted file mode 100644 index 91cf142a9..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/app11/SpringDocApp11Test.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * - * * Copyright 2019-2023 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.app11; - -import java.util.Optional; - -import io.swagger.v3.core.converter.ModelConverter; -import io.swagger.v3.core.converter.ModelConverters; -import org.junit.jupiter.api.AfterAll; -import org.junit.jupiter.api.BeforeAll; -import org.springdoc.core.converters.SchemaPropertyDeprecatingConverter; -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.test.context.TestPropertySource; - -@TestPropertySource(properties = { "springdoc.show-oauth2-endpoints=true", "springdoc.model-converters.deprecating-converter.enabled=false" }) -public class SpringDocApp11Test extends AbstractSpringDocTest { - - @BeforeAll - public static void init() { - Optional deprecatingConverterOptional = - ModelConverters.getInstance().getConverters() - .stream().filter(modelConverter -> modelConverter instanceof SchemaPropertyDeprecatingConverter).findAny(); - deprecatingConverterOptional.ifPresent(ModelConverters.getInstance()::removeConverter); - } - - @AfterAll - public static void clean() { - Optional deprecatingConverterOptional = - ModelConverters.getInstance().getConverters() - .stream().filter(modelConverter -> modelConverter instanceof SchemaPropertyDeprecatingConverter).findAny(); - deprecatingConverterOptional.ifPresent(ModelConverters.getInstance()::addConverter); - } - - @SpringBootApplication - static class SpringDocTestApp { - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/app12/AuthorizationServerConfig.java b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/app12/AuthorizationServerConfig.java deleted file mode 100644 index 06a888fe6..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/app12/AuthorizationServerConfig.java +++ /dev/null @@ -1,75 +0,0 @@ -package test.org.springdoc.api.app12; - -import java.util.UUID; - -import com.nimbusds.jose.jwk.JWKSet; -import com.nimbusds.jose.jwk.RSAKey; -import com.nimbusds.jose.jwk.source.JWKSource; -import com.nimbusds.jose.proc.SecurityContext; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.security.config.Customizer; -import org.springframework.security.config.annotation.web.builders.HttpSecurity; -import org.springframework.security.oauth2.core.AuthorizationGrantType; -import org.springframework.security.oauth2.jwt.JwtDecoder; -import org.springframework.security.oauth2.server.authorization.InMemoryOAuth2AuthorizationService; -import org.springframework.security.oauth2.server.authorization.OAuth2AuthorizationService; -import org.springframework.security.oauth2.server.authorization.client.InMemoryRegisteredClientRepository; -import org.springframework.security.oauth2.server.authorization.client.RegisteredClient; -import org.springframework.security.oauth2.server.authorization.client.RegisteredClientRepository; -import org.springframework.security.oauth2.server.authorization.config.annotation.web.configuration.OAuth2AuthorizationServerConfiguration; -import org.springframework.security.oauth2.server.authorization.config.annotation.web.configurers.OAuth2AuthorizationServerConfigurer; -import org.springframework.security.oauth2.server.authorization.settings.AuthorizationServerSettings; -import org.springframework.security.oauth2.server.authorization.settings.ClientSettings; -import org.springframework.security.web.SecurityFilterChain; - -/* - * @author yuta.saito - */ -@Configuration -public class AuthorizationServerConfig { - @Bean - public SecurityFilterChain authorizationServerSecurityFilterChain(HttpSecurity http) throws Exception { - OAuth2AuthorizationServerConfiguration.applyDefaultSecurity(http); - http.getConfigurer(OAuth2AuthorizationServerConfigurer.class) - .oidc(oidc -> oidc.clientRegistrationEndpoint(Customizer.withDefaults())); - return http.build(); - } - - @Bean - public RegisteredClientRepository registeredClientRepository() { - RegisteredClient registeredClient = RegisteredClient.withId(UUID.randomUUID().toString()) - .clientId("messaging-client") - .clientSecret("{noop}secret") - .authorizationGrantType(AuthorizationGrantType.CLIENT_CREDENTIALS) - .scope("message.read") - .scope("message.write") - .clientSettings(ClientSettings.builder().requireAuthorizationConsent(true).build()) - .build(); - - return new InMemoryRegisteredClientRepository(registeredClient); - } - - @Bean - public OAuth2AuthorizationService authorizationService() { - return new InMemoryOAuth2AuthorizationService(); - } - - @Bean - public AuthorizationServerSettings authorizationServerSettings() { - return AuthorizationServerSettings.builder().build(); - } - - @Bean - public JWKSource jwkSource() { - RSAKey rsaKey = Jwks.generateRsa(); - JWKSet jwkSet = new JWKSet(rsaKey); - return (jwkSelector, securityContext) -> jwkSelector.select(jwkSet); - } - - @Bean - public JwtDecoder jwtDecoder(JWKSource jwkSource) { - return OAuth2AuthorizationServerConfiguration.jwtDecoder(jwkSource); - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/app12/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/app12/HelloController.java deleted file mode 100644 index 74e1ca709..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/app12/HelloController.java +++ /dev/null @@ -1,17 +0,0 @@ -package test.org.springdoc.api.app12; - -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -/* - * @author yuta.saito - */ -@RestController -@RequestMapping("/api") -public class HelloController { - @GetMapping("/hello") - public String hello() { - return "Hello"; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/app12/Jwks.java b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/app12/Jwks.java deleted file mode 100644 index 2df2f0a1c..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/app12/Jwks.java +++ /dev/null @@ -1,29 +0,0 @@ -package test.org.springdoc.api.app12; - - -import java.security.KeyPair; -import java.security.interfaces.RSAPrivateKey; -import java.security.interfaces.RSAPublicKey; -import java.util.UUID; - -import com.nimbusds.jose.jwk.RSAKey; - - -/** - * @author yuta.saito - */ -public final class Jwks { - private Jwks() { - //final class constructor should be hidden - } - - public static RSAKey generateRsa() { - KeyPair keyPair = KeyGeneratorUtils.generateRsaKey(); - RSAPublicKey publicKey = (RSAPublicKey) keyPair.getPublic(); - RSAPrivateKey privateKey = (RSAPrivateKey) keyPair.getPrivate(); - return new RSAKey.Builder(publicKey) - .privateKey(privateKey) - .keyID(UUID.randomUUID().toString()) - .build(); - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/app12/KeyGeneratorUtils.java b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/app12/KeyGeneratorUtils.java deleted file mode 100644 index 46efd9d2e..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/app12/KeyGeneratorUtils.java +++ /dev/null @@ -1,26 +0,0 @@ -package test.org.springdoc.api.app12; - -import java.security.KeyPair; -import java.security.KeyPairGenerator; - -/** - * @author yuta.saito - */ -public final class KeyGeneratorUtils { - private KeyGeneratorUtils() { - //final class constructor should be hidden - } - - static KeyPair generateRsaKey() { - KeyPair keyPair; - try { - KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("RSA"); - keyPairGenerator.initialize(2048); - keyPair = keyPairGenerator.generateKeyPair(); - } - catch (Exception ex) { - throw new IllegalStateException(ex); - } - return keyPair; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/app12/SpringDocApp12Test.java b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/app12/SpringDocApp12Test.java deleted file mode 100644 index 4bfb122eb..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/app12/SpringDocApp12Test.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * - * * Copyright 2019-2023 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.app12; - -import java.util.Optional; - -import io.swagger.v3.core.converter.ModelConverter; -import io.swagger.v3.core.converter.ModelConverters; -import org.junit.jupiter.api.AfterAll; -import org.junit.jupiter.api.BeforeAll; -import org.springdoc.core.converters.SchemaPropertyDeprecatingConverter; -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.test.context.TestPropertySource; - -@TestPropertySource(properties = { "springdoc.show-oauth2-endpoints=true", "springdoc.model-converters.deprecating-converter.enabled=false" }) -public class SpringDocApp12Test extends AbstractSpringDocTest { - - @BeforeAll - public static void init() { - Optional deprecatingConverterOptional = - ModelConverters.getInstance().getConverters() - .stream().filter(modelConverter -> modelConverter instanceof SchemaPropertyDeprecatingConverter).findAny(); - deprecatingConverterOptional.ifPresent(ModelConverters.getInstance()::removeConverter); - } - - @AfterAll - public static void clean() { - Optional deprecatingConverterOptional = - ModelConverters.getInstance().getConverters() - .stream().filter(modelConverter -> modelConverter instanceof SchemaPropertyDeprecatingConverter).findAny(); - deprecatingConverterOptional.ifPresent(ModelConverters.getInstance()::addConverter); - } - - @SpringBootApplication - static class SpringDocTestApp { - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/app2/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/app2/HelloController.java deleted file mode 100644 index fa2b8b670..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/app2/HelloController.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app2; - -import org.springframework.security.core.Authentication; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RestController; - -@RestController -public class HelloController { - - @GetMapping("oneParameterAndAuthentication") - public Object oneParameterAndAuthentication(@RequestBody String req, Authentication authentication) { - return null; - } - - @GetMapping("noParametersAndAuthentication") - public Object noParametersAndAuthentication(Authentication authentication) { - return null; - } - - @GetMapping("oneParameterAndUser") - public Object oneParameterAndUser(@RequestBody String req, User user) { - return null; - } - - @GetMapping("noParametersAndUser") - public Object noParametersAndUser(User user) { - return null; - } -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/app2/SpringDocApp2Test.java b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/app2/SpringDocApp2Test.java deleted file mode 100644 index bfc2cc649..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/app2/SpringDocApp2Test.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app2; - -import io.swagger.v3.oas.models.OpenAPI; -import io.swagger.v3.oas.models.info.Info; -import io.swagger.v3.oas.models.info.License; -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.Bean; - -public class SpringDocApp2Test extends AbstractSpringDocTest { - - @SpringBootApplication(scanBasePackages = { "test.org.springdoc.api.configuration,test.org.springdoc.api.app2" }) - static class SpringDocTestApp { - @Bean - public OpenAPI customOpenAPI() { - return new OpenAPI() - .info(new Info().title("Security API").version("v1") - .license(new License().name("Apache 2.0").url("http://springdoc.org"))); - } - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/app2/User.java b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/app2/User.java deleted file mode 100644 index a59358a4b..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/app2/User.java +++ /dev/null @@ -1,43 +0,0 @@ -package test.org.springdoc.api.app2; - -import java.util.Collection; - -import org.springframework.security.core.Authentication; -import org.springframework.security.core.GrantedAuthority; - -public class User implements Authentication { - @Override - public Collection getAuthorities() { - return null; - } - - @Override - public Object getCredentials() { - return null; - } - - @Override - public Object getDetails() { - return null; - } - - @Override - public Object getPrincipal() { - return null; - } - - @Override - public boolean isAuthenticated() { - return false; - } - - @Override - public void setAuthenticated(boolean isAuthenticated) throws IllegalArgumentException { - - } - - @Override - public String getName() { - return null; - } -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/app3/SpringOauth2Test.java b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/app3/SpringOauth2Test.java deleted file mode 100644 index 210c3f908..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/app3/SpringOauth2Test.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app3; - -import org.junit.jupiter.api.Test; - -import org.springframework.boot.SpringBootConfiguration; -import org.springframework.boot.test.context.runner.WebApplicationContextRunner; - -import static org.assertj.core.api.Assertions.assertThat; - -public class SpringOauth2Test { - - private final WebApplicationContextRunner contextRunner = new WebApplicationContextRunner() - .withUserConfiguration(TestApp.class); - - @Test - void configurations_successfully_loaded() { - contextRunner - .run(context -> assertThat(context) - .hasNotFailed() - .doesNotHaveBean("springSecurityOAuth2Provider") - ); - } - - @SpringBootConfiguration - static class TestApp { - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/app5/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/app5/HelloController.java deleted file mode 100644 index a069ad6b3..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/app5/HelloController.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app5; - -import org.springframework.security.core.Authentication; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RestController; - -@RestController -public class HelloController { - - - @GetMapping - public Authentication doGet() { - return null; - } - - @PostMapping - public Sample doPost() { - return null; - } -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/app5/Sample.java b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/app5/Sample.java deleted file mode 100644 index 14eca023f..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/app5/Sample.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app5; - -import org.springframework.security.core.Authentication; - -public class Sample { - private String toto; - - private Authentication authentication; - - public String getToto() { - return toto; - } - - public void setToto(String toto) { - this.toto = toto; - } - - public Authentication getAuthentication() { - return authentication; - } - - public void setAuthentication(Authentication authentication) { - this.authentication = authentication; - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/app5/SpringDocApp5Test.java b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/app5/SpringDocApp5Test.java deleted file mode 100644 index d9fcfd384..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/app5/SpringDocApp5Test.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app5; - -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; - -public class SpringDocApp5Test extends AbstractSpringDocTest { - - @SpringBootApplication(scanBasePackages = { "test.org.springdoc.api.configuration,test.org.springdoc.api.app5" }) - static class SpringDocTestApp {} - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/app6/SpringDocApp6Test.java b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/app6/SpringDocApp6Test.java deleted file mode 100644 index 3e774fb8e..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/app6/SpringDocApp6Test.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app6; - -import test.org.springdoc.api.AbstractSpringDocTest; -import test.org.springdoc.api.app6.security.MyUserDetailsService; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.Bean; -import org.springframework.test.context.TestPropertySource; - -@TestPropertySource(properties = "springdoc.show-login-endpoint=true") -public class SpringDocApp6Test extends AbstractSpringDocTest { - - @SpringBootApplication(scanBasePackages = { "test.org.springdoc.api.configuration,test.org.springdoc.api.app6" }) - static class SpringDocTestApp { - @Bean - MyUserDetailsService userDetailsService() { - return new MyUserDetailsService(); - } - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/app6/SpringDocConfig.java b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/app6/SpringDocConfig.java deleted file mode 100644 index 3a9fb09aa..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/app6/SpringDocConfig.java +++ /dev/null @@ -1,31 +0,0 @@ -package test.org.springdoc.api.app6; - -import io.swagger.v3.oas.models.Components; -import io.swagger.v3.oas.models.OpenAPI; -import io.swagger.v3.oas.models.info.Info; -import io.swagger.v3.oas.models.security.SecurityRequirement; -import io.swagger.v3.oas.models.security.SecurityScheme; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - - -@Configuration -public class SpringDocConfig { - - - @Bean - public OpenAPI myOpenAPI() { - final String securitySchemeName = "bearerAuth"; - return new OpenAPI().info(new Info().title("My MWE API") - .description("This document specifies the API") - .version("v23")) - .addSecurityItem(new SecurityRequirement().addList(securitySchemeName)) - .components(new Components().addSecuritySchemes(securitySchemeName, - new SecurityScheme() - .type(SecurityScheme.Type.HTTP) - .scheme("bearer") - .bearerFormat("JWT"))); - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/app6/controllers/MyController.java b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/app6/controllers/MyController.java deleted file mode 100644 index 264be090e..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/app6/controllers/MyController.java +++ /dev/null @@ -1,30 +0,0 @@ -package test.org.springdoc.api.app6.controllers; - -import java.util.List; - -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.responses.ApiResponse; -import io.swagger.v3.oas.annotations.tags.Tag; - -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - - -@RestController -@RequestMapping("/fax") -@Tag(name = "Fax stuff", description = "For managing fax machines.") -public class MyController { - - @Operation(summary = "Get information about currently existing fax machines") - @ApiResponse(responseCode = "200", description = "list of existing fax machines") - @GetMapping("list") - public List getFaxList(@RequestParam(name = "vendorName", required = false) - @Parameter(description = "vendor name to restrict the list") String vendorFilter) { - - return null; - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/app6/security/JWTAuthenticationFilter.java b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/app6/security/JWTAuthenticationFilter.java deleted file mode 100644 index 7f64be2d9..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/app6/security/JWTAuthenticationFilter.java +++ /dev/null @@ -1,113 +0,0 @@ -package test.org.springdoc.api.app6.security; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.Date; -import java.util.HashMap; - -import com.fasterxml.jackson.databind.ObjectMapper; -import io.jsonwebtoken.Jwts; -import io.jsonwebtoken.SignatureAlgorithm; -import jakarta.servlet.FilterChain; -import jakarta.servlet.ServletException; -import jakarta.servlet.http.HttpServletRequest; -import jakarta.servlet.http.HttpServletResponse; - -import org.springframework.security.authentication.AuthenticationManager; -import org.springframework.security.authentication.InternalAuthenticationServiceException; -import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; -import org.springframework.security.core.Authentication; -import org.springframework.security.core.AuthenticationException; -import org.springframework.security.core.userdetails.User; -import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter; - - -public class JWTAuthenticationFilter extends UsernamePasswordAuthenticationFilter { - - - private final AuthenticationManager authenticationManager; - - - private final long lifetime; - - - private final String key; - - - public JWTAuthenticationFilter(AuthenticationManager authenticationManager, long lifetime, - String key) { - this.authenticationManager = authenticationManager; - this.lifetime = lifetime; - this.key = key; - } - - - @Override - public Authentication attemptAuthentication(HttpServletRequest req, HttpServletResponse res) - throws AuthenticationException { - try { - - UserCredentials credentials = - new ObjectMapper().readValue(req.getInputStream(), UserCredentials.class); - - return authenticationManager.authenticate( - new UsernamePasswordAuthenticationToken(credentials.getUsername(), - credentials.getPassword(), new ArrayList<>())); - - } - catch (IOException e) { - throw new InternalAuthenticationServiceException("Error processing credentials", e); - } - } - - - @Override - protected void successfulAuthentication(HttpServletRequest req, HttpServletResponse res, - FilterChain chain, Authentication auth) - throws IOException, ServletException { - Date notBefore = new Date(); - Date expirationDate = new Date(notBefore.getTime() + lifetime); - - String token = Jwts.builder() - .setClaims(new HashMap<>()) - .setSubject(((User) auth.getPrincipal()).getUsername()) - .setNotBefore(notBefore) - .setExpiration(expirationDate) - .signWith(SignatureAlgorithm.HS512, key) - .compact(); - res.addHeader(WebSecurity.HeaderString, WebSecurity.TokenPrefix + token); - - } - - - private static class UserCredentials { - - - private String username; - - - private String password; - - - String getUsername() { - return username; - } - - - public void setUsername(String username) { - this.username = username; - } - - - String getPassword() { - return password; - } - - - public void setPassword(String password) { - this.password = password; - } - - } - -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/app6/security/JWTAuthorizationFilter.java b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/app6/security/JWTAuthorizationFilter.java deleted file mode 100644 index fe1b34f7b..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/app6/security/JWTAuthorizationFilter.java +++ /dev/null @@ -1,83 +0,0 @@ -package test.org.springdoc.api.app6.security; - -import java.io.IOException; -import java.util.ArrayList; - -import io.jsonwebtoken.ExpiredJwtException; -import io.jsonwebtoken.Jwts; -import jakarta.servlet.FilterChain; -import jakarta.servlet.ServletException; -import jakarta.servlet.http.HttpServletRequest; -import jakarta.servlet.http.HttpServletResponse; - -import org.springframework.security.authentication.AuthenticationManager; -import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; -import org.springframework.security.core.context.SecurityContextHolder; -import org.springframework.security.web.authentication.www.BasicAuthenticationFilter; - - -public class JWTAuthorizationFilter extends BasicAuthenticationFilter { - - - public static final String AUTH_ERROR_ATTRIBUTE = "authError"; - - - private final String key; - - - public JWTAuthorizationFilter(AuthenticationManager authManager, String key) { - super(authManager); - this.key = key; - } - - - @Override - protected void doFilterInternal(HttpServletRequest req, HttpServletResponse res, FilterChain chain) - throws IOException, ServletException { - String header = req.getHeader(WebSecurity.HeaderString); - - if (header == null || !header.startsWith(WebSecurity.TokenPrefix)) { - chain.doFilter(req, res); - return; - } - - UsernamePasswordAuthenticationToken authentication = getAuthentication(req); - - SecurityContextHolder.getContext().setAuthentication(authentication); - - chain.doFilter(req, res); - } - - - /** - * Check the validity of the JWT (JWS, more precisely) as submitted via the - * {@link HttpServletRequest}. - * - * @param request the {@link HttpServletRequest} containing a JWS. - * @return a {@link UsernamePasswordAuthenticationToken} if the JWS is - * valid, {@code null} otherwise. - */ - - private UsernamePasswordAuthenticationToken getAuthentication(HttpServletRequest request) { - String token = request.getHeader(WebSecurity.HeaderString); - if (token != null) { - String user = null; - try { - user = Jwts.parser() - .setSigningKey(key) - .parseClaimsJws(token.replace(WebSecurity.TokenPrefix, "")) - .getBody() - .getSubject(); - } - catch (ExpiredJwtException e) { - request.setAttribute(AUTH_ERROR_ATTRIBUTE, e.getMessage()); - } - if (user != null) { - return new UsernamePasswordAuthenticationToken(user, null, new ArrayList<>()); - } - return null; - } - return null; - } - -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/app6/security/MyUserDetailsService.java b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/app6/security/MyUserDetailsService.java deleted file mode 100644 index 8972f5f28..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/app6/security/MyUserDetailsService.java +++ /dev/null @@ -1,29 +0,0 @@ -package test.org.springdoc.api.app6.security; - -import java.util.Collections; - -import org.springframework.security.core.userdetails.User; -import org.springframework.security.core.userdetails.UserDetails; -import org.springframework.security.core.userdetails.UserDetailsService; -import org.springframework.security.core.userdetails.UsernameNotFoundException; -import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; -import org.springframework.stereotype.Service; - - -@Service -public class MyUserDetailsService implements UserDetailsService { - - @Override - public UserDetails loadUserByUsername(String username) - throws UsernameNotFoundException { - BCryptPasswordEncoder encoder = new BCryptPasswordEncoder(); - - - if (!username.equals("demouser")) { - throw new UsernameNotFoundException(username); - } - - return new User("demouser", encoder.encode("secret"), Collections.emptyList()); - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/app6/security/WebSecurity.java b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/app6/security/WebSecurity.java deleted file mode 100644 index 2311650ec..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/app6/security/WebSecurity.java +++ /dev/null @@ -1,120 +0,0 @@ -/* - * - * * - * * * Copyright 2019-2020 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.app6.security; - -import org.springdoc.core.properties.SpringDocConfigProperties; - -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.core.annotation.Order; -import org.springframework.security.authentication.AuthenticationManager; -import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; -import org.springframework.security.config.annotation.web.builders.HttpSecurity; -import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; -import org.springframework.security.config.http.SessionCreationPolicy; -import org.springframework.security.core.userdetails.UserDetailsService; -import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; -import org.springframework.security.web.SecurityFilterChain; -import org.springframework.web.cors.CorsConfiguration; -import org.springframework.web.cors.CorsConfigurationSource; -import org.springframework.web.cors.UrlBasedCorsConfigurationSource; - -import static org.springdoc.core.utils.Constants.ALL_PATTERN; - -@Configuration -@EnableWebSecurity -@Order(200) -public class WebSecurity { - - - public static final String TokenPrefix = "Bearer "; - - - public static final String HeaderString = "Authorization"; - - - private final UserDetailsService userDetailsService; - - - @Autowired - SpringDocConfigProperties configProperties; - - - private long lifetime = 123456789L; - - - private String key = - "YRv13MrZah/rHJPMGIN6AjdjB09F9gpIC7i9mdFwdIDZ296doUg/nhG/mQ/CnlxPNtcWR6z6RCKtW5cCspGM9w=="; - - - public WebSecurity(UserDetailsService userDetailsService) { - this.userDetailsService = userDetailsService; - - } - - - @Bean - public SecurityFilterChain securityWebFilterChain(HttpSecurity http, AuthenticationManager authenticationManager) throws Exception { - String apiDocsPath = configProperties.getApiDocs().getPath(); - http.cors() - .and() - .csrf() - .disable() - .authorizeRequests() - .requestMatchers(apiDocsPath + ALL_PATTERN) - .permitAll() - .requestMatchers(apiDocsPath.substring(0, apiDocsPath.lastIndexOf("/") + 1) + "api-docs.yaml") - .permitAll() - .anyRequest() - .authenticated() - .and() - .exceptionHandling() - .and() - .addFilter(new JWTAuthenticationFilter(authenticationManager, lifetime, key)) - .addFilter(new JWTAuthorizationFilter(authenticationManager, key)) - // this disables session creation on Spring Security - .sessionManagement() - .sessionCreationPolicy(SessionCreationPolicy.STATELESS); - return http.build(); - } - - - @Autowired - public void configure(AuthenticationManagerBuilder auth) - throws Exception { - auth.userDetailsService(userDetailsService).passwordEncoder(new BCryptPasswordEncoder()); - } - - - @Bean - CorsConfigurationSource corsConfigurationSource() { - final UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(); - - CorsConfiguration configuration = new CorsConfiguration().applyPermitDefaultValues(); - - configuration.addExposedHeader(HeaderString); - source.registerCorsConfiguration(ALL_PATTERN, configuration); - - return source; - } - -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/app7/AnotherPerson.java b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/app7/AnotherPerson.java deleted file mode 100644 index c70e2a495..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/app7/AnotherPerson.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app7; - -import io.swagger.v3.oas.annotations.Hidden; - -public class AnotherPerson { - - @Hidden - private String name; - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/app7/CurrentUser.java b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/app7/CurrentUser.java deleted file mode 100644 index 069063533..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/app7/CurrentUser.java +++ /dev/null @@ -1,16 +0,0 @@ -package test.org.springdoc.api.app7; - -import java.lang.annotation.Documented; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -import org.springframework.security.core.annotation.AuthenticationPrincipal; - -@Target({ ElementType.PARAMETER, ElementType.TYPE, ElementType.FIELD }) -@Retention(RetentionPolicy.RUNTIME) -@Documented -@AuthenticationPrincipal -public @interface CurrentUser { -} diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/app7/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/app7/HelloController.java deleted file mode 100644 index e1163d029..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/app7/HelloController.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app7; - -import org.springdoc.core.annotations.ParameterObject; - -import org.springframework.security.core.annotation.AuthenticationPrincipal; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RestController; - -@RestController -public class HelloController { - - @PostMapping(value = "/hello") - public String hello( - @AuthenticationPrincipal Person person1, - @CurrentUser Person person2, - @ParameterObject AnotherPerson person3, - @ParameterObject TheOtherPerson person4) { - return "OK"; - } - -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/app7/Person.java b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/app7/Person.java deleted file mode 100644 index 97f8781ae..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/app7/Person.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app7; - -public class Person { - - private String name; - - public Person() { - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/app7/SpringDocApp7Test.java b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/app7/SpringDocApp7Test.java deleted file mode 100644 index 9d2852a10..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/app7/SpringDocApp7Test.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app7; - -import io.swagger.v3.oas.models.OpenAPI; -import io.swagger.v3.oas.models.info.Info; -import io.swagger.v3.oas.models.info.License; -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.Bean; - -public class SpringDocApp7Test extends AbstractSpringDocTest { - - @SpringBootApplication(scanBasePackages = { "test.org.springdoc.api.configuration,test.org.springdoc.api.app7" }) - static class SpringDocTestApp { - @Bean - public OpenAPI customOpenAPI() { - return new OpenAPI() - .info(new Info().title("Security API").version("v1") - .license(new License().name("Apache 2.0").url("http://springdoc.org"))); - } - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/app7/TheOtherPerson.java b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/app7/TheOtherPerson.java deleted file mode 100644 index 7a8aa431b..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/app7/TheOtherPerson.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app7; - -public class TheOtherPerson { - - @CurrentUser - private String name; - - public TheOtherPerson() { - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/app8/SpringDocApp8Test.java b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/app8/SpringDocApp8Test.java deleted file mode 100644 index 23ad69b4f..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/app8/SpringDocApp8Test.java +++ /dev/null @@ -1,24 +0,0 @@ -package test.org.springdoc.api.app8; - -import io.swagger.v3.oas.models.OpenAPI; -import io.swagger.v3.oas.models.info.Info; -import io.swagger.v3.oas.models.info.License; -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.Bean; -import org.springframework.test.context.TestPropertySource; - -@TestPropertySource(properties = "springdoc.show-login-endpoint=true") -public class SpringDocApp8Test extends AbstractSpringDocTest { - - @SpringBootApplication(scanBasePackages = { "test.org.springdoc.api.configuration,test.org.springdoc.api.app8" }) - static class SpringDocTestApp { - @Bean - public OpenAPI customOpenAPI() { - return new OpenAPI() - .info(new Info().title("Security API").version("v1") - .license(new License().name("Apache 2.0").url("http://springdoc.org"))); - } - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/app8/security/WebConfig.java b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/app8/security/WebConfig.java deleted file mode 100644 index 402368e8a..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/app8/security/WebConfig.java +++ /dev/null @@ -1,22 +0,0 @@ -package test.org.springdoc.api.app8.security; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.core.annotation.Order; -import org.springframework.security.config.annotation.web.builders.HttpSecurity; -import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; -import org.springframework.security.web.SecurityFilterChain; - -@Configuration -@EnableWebSecurity -@Order(200) -public class WebConfig { - - @Bean - public SecurityFilterChain securityWebFilterChain(HttpSecurity http) throws Exception { - http.formLogin() - .loginProcessingUrl("/api/login"); - return http.build(); - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/app9/SpringDocApp9Test.java b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/app9/SpringDocApp9Test.java deleted file mode 100644 index bc0071734..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/app9/SpringDocApp9Test.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.app9; - -import io.swagger.v3.oas.models.OpenAPI; -import io.swagger.v3.oas.models.info.Info; -import io.swagger.v3.oas.models.info.License; -import test.org.springdoc.api.AbstractSpringDocTest; - -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.Bean; -import org.springframework.test.context.TestPropertySource; - -@TestPropertySource(properties = { "springdoc.show-login-endpoint=true", "springdoc.enable-spring-security=false" }) -public class SpringDocApp9Test extends AbstractSpringDocTest { - - @SpringBootApplication(scanBasePackages = { "test.org.springdoc.api.configuration","test.org.springdoc.api.app9" }) - static class SpringDocTestApp { - @Bean - public OpenAPI customOpenAPI() { - return new OpenAPI() - .info(new Info().title("Security API").version("v1") - .license(new License().name("Apache 2.0").url("http://springdoc.org"))); - } - } -} diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/app9/WebConfig.java b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/app9/WebConfig.java deleted file mode 100644 index fb15dcaf4..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/app9/WebConfig.java +++ /dev/null @@ -1,22 +0,0 @@ -package test.org.springdoc.api.app9; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.core.annotation.Order; -import org.springframework.security.config.annotation.web.builders.HttpSecurity; -import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; -import org.springframework.security.web.SecurityFilterChain; - -@Configuration -@EnableWebSecurity -@Order(200) -public class WebConfig { - - @Bean - public SecurityFilterChain securityWebFilterChain(HttpSecurity http) throws Exception { - http.formLogin() - .loginProcessingUrl("/api/login"); - return http.build(); - } - -} diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/configuration/SecurityConfiguration.java b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/configuration/SecurityConfiguration.java deleted file mode 100644 index 6ffda6210..000000000 --- a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/configuration/SecurityConfiguration.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * - * * Copyright 2019-2020 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.configuration; - -import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Lazy; -import org.springframework.security.authentication.AuthenticationManager; -import org.springframework.security.config.annotation.authentication.configuration.AuthenticationConfiguration; -import org.springframework.security.config.annotation.web.builders.HttpSecurity; -import org.springframework.security.web.SecurityFilterChain; - -@Configuration -class SecurityConfiguration { - - @Bean - @ConditionalOnMissingBean - @Lazy(false) - public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception { - http.securityMatcher("/**") - .authorizeHttpRequests((requests) -> requests.requestMatchers("/**").permitAll()); - return http.build(); - } - - @Bean - public AuthenticationManager authenticationManager(AuthenticationConfiguration authConfig) throws Exception { - return authConfig.getAuthenticationManager(); - } -} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v30/AbstractSpringDocTest.java b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v30/AbstractSpringDocTest.java new file mode 100644 index 000000000..e3aeff89b --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v30/AbstractSpringDocTest.java @@ -0,0 +1,90 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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; + +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; + +import org.junit.jupiter.api.Test; +import org.springdoc.core.utils.Constants; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration; +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.context.annotation.Configuration; +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.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; + +@ActiveProfiles("test") +@SpringBootTest +@AutoConfigureMockMvc +@TestPropertySource(properties = "springdoc.api-docs.version=openapi_3_0" ) +public abstract class AbstractSpringDocTest { + + public static String className; + + @Autowired + protected MockMvc mockMvc; + + public static String getContent(String fileName) { + try { + Path path = Paths.get(AbstractSpringDocTest.class.getClassLoader().getResource(fileName).toURI()); + byte[] fileBytes = Files.readAllBytes(path); + return new String(fileBytes, StandardCharsets.UTF_8); + } + catch (Exception e) { + throw new RuntimeException("Failed to read file: " + fileName, e); + } + } + + @Test + void testApp() throws Exception { + className = getClass().getSimpleName(); + String testNumber = className.replaceAll("[^0-9]", ""); + MvcResult mockMvcResult = mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL)).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 + ".json"); + assertEquals(expected, result, true); + } + + @Configuration + @EnableAutoConfiguration(exclude = { SecurityAutoConfiguration.class }) + static class ContextConfiguration {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v30/app1/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v30/app1/HelloController.java new file mode 100644 index 000000000..9096ddb8f --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v30/app1/HelloController.java @@ -0,0 +1,58 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app1; + +import org.springframework.security.core.annotation.AuthenticationPrincipal; +import org.springframework.security.core.userdetails.User; +import org.springframework.security.oauth2.client.OAuth2AuthorizedClient; +import org.springframework.security.oauth2.client.annotation.RegisteredOAuth2AuthorizedClient; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class HelloController { + + @PostMapping(value = "/persons") + public String persons(@RequestBody() Person person) { + return "OK"; + } + + @PostMapping(value = "/persons-with-user") + public String personsWithUser(@RequestBody() Person person, + @AuthenticationPrincipal User user) { + return "OK"; + } + + @PostMapping(value = "/persons-with-oauth2-user") + public String personsWithUser(@RequestBody() Person person, + @RegisteredOAuth2AuthorizedClient OAuth2AuthorizedClient authorizedClient, + @AuthenticationPrincipal User user) { + return "OK"; + } + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v30/app1/Person.java b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v30/app1/Person.java new file mode 100644 index 000000000..694a8c714 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v30/app1/Person.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app1; + +public class Person { + + private String name; + + public Person() { + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v30/app1/SpringDocApp1Test.java b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v30/app1/SpringDocApp1Test.java new file mode 100644 index 000000000..3e89b712d --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v30/app1/SpringDocApp1Test.java @@ -0,0 +1,48 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app1; + +import io.swagger.v3.oas.models.OpenAPI; +import io.swagger.v3.oas.models.info.Info; +import io.swagger.v3.oas.models.info.License; +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; + +public class SpringDocApp1Test extends AbstractSpringDocTest { + + @SpringBootApplication(scanBasePackages = { "test.org.springdoc.api.v30.configuration","test.org.springdoc.api.v30.app1" }) + static class SpringDocTestApp { + @Bean + public OpenAPI customOpenAPI() { + return new OpenAPI() + .info(new Info().title("Security API").version("v1") + .license(new License().name("Apache 2.0").url("http://springdoc.org"))); + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v30/app10/AuthorizationServerConfig.java b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v30/app10/AuthorizationServerConfig.java new file mode 100644 index 000000000..c7ac5fb32 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v30/app10/AuthorizationServerConfig.java @@ -0,0 +1,104 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app10; + +import java.util.UUID; + +import com.nimbusds.jose.jwk.JWKSet; +import com.nimbusds.jose.jwk.RSAKey; +import com.nimbusds.jose.jwk.source.JWKSource; +import com.nimbusds.jose.proc.SecurityContext; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.security.config.annotation.web.builders.HttpSecurity; +import org.springframework.security.oauth2.core.AuthorizationGrantType; +import org.springframework.security.oauth2.jwt.JwtDecoder; +import org.springframework.security.oauth2.server.authorization.InMemoryOAuth2AuthorizationService; +import org.springframework.security.oauth2.server.authorization.OAuth2AuthorizationService; +import org.springframework.security.oauth2.server.authorization.client.InMemoryRegisteredClientRepository; +import org.springframework.security.oauth2.server.authorization.client.RegisteredClient; +import org.springframework.security.oauth2.server.authorization.client.RegisteredClientRepository; +import org.springframework.security.oauth2.server.authorization.config.annotation.web.configuration.OAuth2AuthorizationServerConfiguration; +import org.springframework.security.oauth2.server.authorization.settings.AuthorizationServerSettings; +import org.springframework.security.oauth2.server.authorization.settings.ClientSettings; +import org.springframework.security.web.SecurityFilterChain; + +/* + * @author James Selvakumar + * @since 8.0.0 + */ +@Configuration +public class AuthorizationServerConfig +{ + @Bean + public SecurityFilterChain authorizationServerSecurityFilterChain(HttpSecurity http) throws Exception + { + OAuth2AuthorizationServerConfiguration.applyDefaultSecurity(http); + return http.build(); + } + + @Bean + public RegisteredClientRepository registeredClientRepository() { + RegisteredClient registeredClient = RegisteredClient.withId(UUID.randomUUID().toString()) + .clientId("messaging-client") + .clientSecret("{noop}secret") + .authorizationGrantType(AuthorizationGrantType.CLIENT_CREDENTIALS) + .scope("message.read") + .scope("message.write") + .clientSettings(ClientSettings.builder().requireAuthorizationConsent(true).build()) + .build(); + + return new InMemoryRegisteredClientRepository(registeredClient); + } + + @Bean + public OAuth2AuthorizationService authorizationService() + { + return new InMemoryOAuth2AuthorizationService(); + } + + @Bean + public AuthorizationServerSettings authorizationServerSettings() + { + return AuthorizationServerSettings.builder().build(); + } + + @Bean + public JWKSource jwkSource() + { + RSAKey rsaKey = Jwks.generateRsa(); + JWKSet jwkSet = new JWKSet(rsaKey); + return (jwkSelector, securityContext) -> jwkSelector.select(jwkSet); + } + + @Bean + public JwtDecoder jwtDecoder(JWKSource jwkSource) + { + return OAuth2AuthorizationServerConfiguration.jwtDecoder(jwkSource); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v30/app10/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v30/app10/HelloController.java new file mode 100644 index 000000000..6b33a3987 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v30/app10/HelloController.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.app10; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/* + * @author James Selvakumar + * @since 8.0.0 + */ +@RestController +@RequestMapping("/api") +public class HelloController +{ + @GetMapping("/hello") + public String hello() + { + return "Hello"; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v30/app10/Jwks.java b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v30/app10/Jwks.java new file mode 100644 index 000000000..9c50c0699 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v30/app10/Jwks.java @@ -0,0 +1,58 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app10; + + +import java.security.KeyPair; +import java.security.interfaces.RSAPrivateKey; +import java.security.interfaces.RSAPublicKey; +import java.util.UUID; + +import com.nimbusds.jose.jwk.RSAKey; + + +/** + * @author Joe Grandja + * @since 0.1.0 + */ +public final class Jwks +{ + private Jwks() + { + //final class constructor should be hidden + } + + public static RSAKey generateRsa() + { + KeyPair keyPair = KeyGeneratorUtils.generateRsaKey(); + RSAPublicKey publicKey = (RSAPublicKey) keyPair.getPublic(); + RSAPrivateKey privateKey = (RSAPrivateKey) keyPair.getPrivate(); + return new RSAKey.Builder(publicKey) + .privateKey(privateKey) + .keyID(UUID.randomUUID().toString()) + .build(); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v30/app10/KeyGeneratorUtils.java b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v30/app10/KeyGeneratorUtils.java new file mode 100644 index 000000000..83124d90a --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v30/app10/KeyGeneratorUtils.java @@ -0,0 +1,54 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app10; + +import java.security.KeyPair; +import java.security.KeyPairGenerator; + +/** + * @author Joe Grandja + * @since 0.1.0 + */ +public final class KeyGeneratorUtils +{ + private KeyGeneratorUtils() + { + //final class constructor should be hidden + } + + static KeyPair generateRsaKey() + { + KeyPair keyPair; + try { + KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("RSA"); + keyPairGenerator.initialize(2048); + keyPair = keyPairGenerator.generateKeyPair(); + } catch (Exception ex) { + throw new IllegalStateException(ex); + } + return keyPair; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v30/app10/SpringDocApp10Test.java b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v30/app10/SpringDocApp10Test.java new file mode 100644 index 000000000..ad08803bf --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v30/app10/SpringDocApp10Test.java @@ -0,0 +1,64 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app10; + +import java.util.Optional; + +import io.swagger.v3.core.converter.ModelConverter; +import io.swagger.v3.core.converter.ModelConverters; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.springdoc.core.converters.SchemaPropertyDeprecatingConverter; +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.test.context.TestPropertySource; + +@TestPropertySource(properties = {"springdoc.show-oauth2-endpoints=true", "springdoc.model-converters.deprecating-converter.enabled=false"}) +public class SpringDocApp10Test extends AbstractSpringDocTest { + + @BeforeAll + public static void init() { + Optional deprecatingConverterOptional = + ModelConverters.getInstance().getConverters() + .stream().filter(modelConverter -> modelConverter instanceof SchemaPropertyDeprecatingConverter).findAny(); + deprecatingConverterOptional.ifPresent(ModelConverters.getInstance()::removeConverter); + } + + @AfterAll + public static void clean() { + Optional deprecatingConverterOptional = + ModelConverters.getInstance().getConverters() + .stream().filter(modelConverter -> modelConverter instanceof SchemaPropertyDeprecatingConverter).findAny(); + deprecatingConverterOptional.ifPresent(ModelConverters.getInstance()::addConverter); + } + + @SpringBootApplication + static class SpringDocTestApp { + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v30/app11/AuthorizationServerConfig.java b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v30/app11/AuthorizationServerConfig.java new file mode 100644 index 000000000..ef3730e91 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v30/app11/AuthorizationServerConfig.java @@ -0,0 +1,101 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app11; + +import java.util.UUID; + +import com.nimbusds.jose.jwk.JWKSet; +import com.nimbusds.jose.jwk.RSAKey; +import com.nimbusds.jose.jwk.source.JWKSource; +import com.nimbusds.jose.proc.SecurityContext; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.security.config.Customizer; +import org.springframework.security.config.annotation.web.builders.HttpSecurity; +import org.springframework.security.oauth2.core.AuthorizationGrantType; +import org.springframework.security.oauth2.jwt.JwtDecoder; +import org.springframework.security.oauth2.server.authorization.InMemoryOAuth2AuthorizationService; +import org.springframework.security.oauth2.server.authorization.OAuth2AuthorizationService; +import org.springframework.security.oauth2.server.authorization.client.InMemoryRegisteredClientRepository; +import org.springframework.security.oauth2.server.authorization.client.RegisteredClient; +import org.springframework.security.oauth2.server.authorization.client.RegisteredClientRepository; +import org.springframework.security.oauth2.server.authorization.config.annotation.web.configuration.OAuth2AuthorizationServerConfiguration; +import org.springframework.security.oauth2.server.authorization.config.annotation.web.configurers.OAuth2AuthorizationServerConfigurer; +import org.springframework.security.oauth2.server.authorization.settings.AuthorizationServerSettings; +import org.springframework.security.oauth2.server.authorization.settings.ClientSettings; +import org.springframework.security.web.SecurityFilterChain; + +/* + * @author yuta.saito + */ +@Configuration +public class AuthorizationServerConfig { + @Bean + public SecurityFilterChain authorizationServerSecurityFilterChain(HttpSecurity http) throws Exception { + OAuth2AuthorizationServerConfiguration.applyDefaultSecurity(http); + http.getConfigurer(OAuth2AuthorizationServerConfigurer.class) + .oidc(Customizer.withDefaults()); + return http.build(); + } + + @Bean + public RegisteredClientRepository registeredClientRepository() { + RegisteredClient registeredClient = RegisteredClient.withId(UUID.randomUUID().toString()) + .clientId("messaging-client") + .clientSecret("{noop}secret") + .authorizationGrantType(AuthorizationGrantType.CLIENT_CREDENTIALS) + .scope("message.read") + .scope("message.write") + .clientSettings(ClientSettings.builder().requireAuthorizationConsent(true).build()) + .build(); + + return new InMemoryRegisteredClientRepository(registeredClient); + } + + @Bean + public OAuth2AuthorizationService authorizationService() { + return new InMemoryOAuth2AuthorizationService(); + } + + @Bean + public AuthorizationServerSettings authorizationServerSettings() { + return AuthorizationServerSettings.builder().build(); + } + + @Bean + public JWKSource jwkSource() { + RSAKey rsaKey = Jwks.generateRsa(); + JWKSet jwkSet = new JWKSet(rsaKey); + return (jwkSelector, securityContext) -> jwkSelector.select(jwkSet); + } + + @Bean + public JwtDecoder jwtDecoder(JWKSource jwkSource) { + return OAuth2AuthorizationServerConfiguration.jwtDecoder(jwkSource); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v30/app11/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v30/app11/HelloController.java new file mode 100644 index 000000000..b1559a1d0 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v30/app11/HelloController.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app11; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/* + * @author yuta.saito + */ +@RestController +@RequestMapping("/api") +public class HelloController { + @GetMapping("/hello") + public String hello() { + return "Hello"; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v30/app11/Jwks.java b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v30/app11/Jwks.java new file mode 100644 index 000000000..0cc9d0e89 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v30/app11/Jwks.java @@ -0,0 +1,55 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app11; + + +import java.security.KeyPair; +import java.security.interfaces.RSAPrivateKey; +import java.security.interfaces.RSAPublicKey; +import java.util.UUID; + +import com.nimbusds.jose.jwk.RSAKey; + + +/** + * @author yuta.saito + */ +public final class Jwks { + private Jwks() { + //final class constructor should be hidden + } + + public static RSAKey generateRsa() { + KeyPair keyPair = KeyGeneratorUtils.generateRsaKey(); + RSAPublicKey publicKey = (RSAPublicKey) keyPair.getPublic(); + RSAPrivateKey privateKey = (RSAPrivateKey) keyPair.getPrivate(); + return new RSAKey.Builder(publicKey) + .privateKey(privateKey) + .keyID(UUID.randomUUID().toString()) + .build(); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v30/app11/KeyGeneratorUtils.java b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v30/app11/KeyGeneratorUtils.java new file mode 100644 index 000000000..b613fbfb6 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v30/app11/KeyGeneratorUtils.java @@ -0,0 +1,52 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app11; + +import java.security.KeyPair; +import java.security.KeyPairGenerator; + +/** + * @author yuta.saito + */ +public final class KeyGeneratorUtils { + private KeyGeneratorUtils() { + //final class constructor should be hidden + } + + static KeyPair generateRsaKey() { + KeyPair keyPair; + try { + KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("RSA"); + keyPairGenerator.initialize(2048); + keyPair = keyPairGenerator.generateKeyPair(); + } + catch (Exception ex) { + throw new IllegalStateException(ex); + } + return keyPair; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v30/app11/SpringDocApp11Test.java b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v30/app11/SpringDocApp11Test.java new file mode 100644 index 000000000..de390071c --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v30/app11/SpringDocApp11Test.java @@ -0,0 +1,64 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app11; + +import java.util.Optional; + +import io.swagger.v3.core.converter.ModelConverter; +import io.swagger.v3.core.converter.ModelConverters; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.springdoc.core.converters.SchemaPropertyDeprecatingConverter; +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.test.context.TestPropertySource; + +@TestPropertySource(properties = { "springdoc.show-oauth2-endpoints=true", "springdoc.model-converters.deprecating-converter.enabled=false" }) +public class SpringDocApp11Test extends AbstractSpringDocTest { + + @BeforeAll + public static void init() { + Optional deprecatingConverterOptional = + ModelConverters.getInstance().getConverters() + .stream().filter(modelConverter -> modelConverter instanceof SchemaPropertyDeprecatingConverter).findAny(); + deprecatingConverterOptional.ifPresent(ModelConverters.getInstance()::removeConverter); + } + + @AfterAll + public static void clean() { + Optional deprecatingConverterOptional = + ModelConverters.getInstance().getConverters() + .stream().filter(modelConverter -> modelConverter instanceof SchemaPropertyDeprecatingConverter).findAny(); + deprecatingConverterOptional.ifPresent(ModelConverters.getInstance()::addConverter); + } + + @SpringBootApplication + static class SpringDocTestApp { + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v30/app12/AuthorizationServerConfig.java b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v30/app12/AuthorizationServerConfig.java new file mode 100644 index 000000000..aceb45ead --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v30/app12/AuthorizationServerConfig.java @@ -0,0 +1,101 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app12; + +import java.util.UUID; + +import com.nimbusds.jose.jwk.JWKSet; +import com.nimbusds.jose.jwk.RSAKey; +import com.nimbusds.jose.jwk.source.JWKSource; +import com.nimbusds.jose.proc.SecurityContext; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.security.config.Customizer; +import org.springframework.security.config.annotation.web.builders.HttpSecurity; +import org.springframework.security.oauth2.core.AuthorizationGrantType; +import org.springframework.security.oauth2.jwt.JwtDecoder; +import org.springframework.security.oauth2.server.authorization.InMemoryOAuth2AuthorizationService; +import org.springframework.security.oauth2.server.authorization.OAuth2AuthorizationService; +import org.springframework.security.oauth2.server.authorization.client.InMemoryRegisteredClientRepository; +import org.springframework.security.oauth2.server.authorization.client.RegisteredClient; +import org.springframework.security.oauth2.server.authorization.client.RegisteredClientRepository; +import org.springframework.security.oauth2.server.authorization.config.annotation.web.configuration.OAuth2AuthorizationServerConfiguration; +import org.springframework.security.oauth2.server.authorization.config.annotation.web.configurers.OAuth2AuthorizationServerConfigurer; +import org.springframework.security.oauth2.server.authorization.settings.AuthorizationServerSettings; +import org.springframework.security.oauth2.server.authorization.settings.ClientSettings; +import org.springframework.security.web.SecurityFilterChain; + +/* + * @author yuta.saito + */ +@Configuration +public class AuthorizationServerConfig { + @Bean + public SecurityFilterChain authorizationServerSecurityFilterChain(HttpSecurity http) throws Exception { + OAuth2AuthorizationServerConfiguration.applyDefaultSecurity(http); + http.getConfigurer(OAuth2AuthorizationServerConfigurer.class) + .oidc(oidc -> oidc.clientRegistrationEndpoint(Customizer.withDefaults())); + return http.build(); + } + + @Bean + public RegisteredClientRepository registeredClientRepository() { + RegisteredClient registeredClient = RegisteredClient.withId(UUID.randomUUID().toString()) + .clientId("messaging-client") + .clientSecret("{noop}secret") + .authorizationGrantType(AuthorizationGrantType.CLIENT_CREDENTIALS) + .scope("message.read") + .scope("message.write") + .clientSettings(ClientSettings.builder().requireAuthorizationConsent(true).build()) + .build(); + + return new InMemoryRegisteredClientRepository(registeredClient); + } + + @Bean + public OAuth2AuthorizationService authorizationService() { + return new InMemoryOAuth2AuthorizationService(); + } + + @Bean + public AuthorizationServerSettings authorizationServerSettings() { + return AuthorizationServerSettings.builder().build(); + } + + @Bean + public JWKSource jwkSource() { + RSAKey rsaKey = Jwks.generateRsa(); + JWKSet jwkSet = new JWKSet(rsaKey); + return (jwkSelector, securityContext) -> jwkSelector.select(jwkSet); + } + + @Bean + public JwtDecoder jwtDecoder(JWKSource jwkSource) { + return OAuth2AuthorizationServerConfiguration.jwtDecoder(jwkSource); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v30/app12/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v30/app12/HelloController.java new file mode 100644 index 000000000..5eb93d79a --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v30/app12/HelloController.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app12; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/* + * @author yuta.saito + */ +@RestController +@RequestMapping("/api") +public class HelloController { + @GetMapping("/hello") + public String hello() { + return "Hello"; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v30/app12/Jwks.java b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v30/app12/Jwks.java new file mode 100644 index 000000000..dec189f66 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v30/app12/Jwks.java @@ -0,0 +1,55 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app12; + + +import java.security.KeyPair; +import java.security.interfaces.RSAPrivateKey; +import java.security.interfaces.RSAPublicKey; +import java.util.UUID; + +import com.nimbusds.jose.jwk.RSAKey; + + +/** + * @author yuta.saito + */ +public final class Jwks { + private Jwks() { + //final class constructor should be hidden + } + + public static RSAKey generateRsa() { + KeyPair keyPair = KeyGeneratorUtils.generateRsaKey(); + RSAPublicKey publicKey = (RSAPublicKey) keyPair.getPublic(); + RSAPrivateKey privateKey = (RSAPrivateKey) keyPair.getPrivate(); + return new RSAKey.Builder(publicKey) + .privateKey(privateKey) + .keyID(UUID.randomUUID().toString()) + .build(); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v30/app12/KeyGeneratorUtils.java b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v30/app12/KeyGeneratorUtils.java new file mode 100644 index 000000000..fd1206b08 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v30/app12/KeyGeneratorUtils.java @@ -0,0 +1,52 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app12; + +import java.security.KeyPair; +import java.security.KeyPairGenerator; + +/** + * @author yuta.saito + */ +public final class KeyGeneratorUtils { + private KeyGeneratorUtils() { + //final class constructor should be hidden + } + + static KeyPair generateRsaKey() { + KeyPair keyPair; + try { + KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("RSA"); + keyPairGenerator.initialize(2048); + keyPair = keyPairGenerator.generateKeyPair(); + } + catch (Exception ex) { + throw new IllegalStateException(ex); + } + return keyPair; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v30/app12/SpringDocApp12Test.java b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v30/app12/SpringDocApp12Test.java new file mode 100644 index 000000000..f01d3c04d --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v30/app12/SpringDocApp12Test.java @@ -0,0 +1,64 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app12; + +import java.util.Optional; + +import io.swagger.v3.core.converter.ModelConverter; +import io.swagger.v3.core.converter.ModelConverters; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.springdoc.core.converters.SchemaPropertyDeprecatingConverter; +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.test.context.TestPropertySource; + +@TestPropertySource(properties = { "springdoc.show-oauth2-endpoints=true", "springdoc.model-converters.deprecating-converter.enabled=false" }) +public class SpringDocApp12Test extends AbstractSpringDocTest { + + @BeforeAll + public static void init() { + Optional deprecatingConverterOptional = + ModelConverters.getInstance().getConverters() + .stream().filter(modelConverter -> modelConverter instanceof SchemaPropertyDeprecatingConverter).findAny(); + deprecatingConverterOptional.ifPresent(ModelConverters.getInstance()::removeConverter); + } + + @AfterAll + public static void clean() { + Optional deprecatingConverterOptional = + ModelConverters.getInstance().getConverters() + .stream().filter(modelConverter -> modelConverter instanceof SchemaPropertyDeprecatingConverter).findAny(); + deprecatingConverterOptional.ifPresent(ModelConverters.getInstance()::addConverter); + } + + @SpringBootApplication + static class SpringDocTestApp { + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v30/app2/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v30/app2/HelloController.java new file mode 100644 index 000000000..78c639903 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v30/app2/HelloController.java @@ -0,0 +1,56 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app2; + +import org.springframework.security.core.Authentication; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class HelloController { + + @GetMapping("oneParameterAndAuthentication") + public Object oneParameterAndAuthentication(@RequestBody String req, Authentication authentication) { + return null; + } + + @GetMapping("noParametersAndAuthentication") + public Object noParametersAndAuthentication(Authentication authentication) { + return null; + } + + @GetMapping("oneParameterAndUser") + public Object oneParameterAndUser(@RequestBody String req, User user) { + return null; + } + + @GetMapping("noParametersAndUser") + public Object noParametersAndUser(User user) { + return null; + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v30/app2/SpringDocApp2Test.java b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v30/app2/SpringDocApp2Test.java new file mode 100644 index 000000000..d7cf6a89b --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v30/app2/SpringDocApp2Test.java @@ -0,0 +1,49 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app2; + +import io.swagger.v3.oas.models.OpenAPI; +import io.swagger.v3.oas.models.info.Info; +import io.swagger.v3.oas.models.info.License; +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; + +public class SpringDocApp2Test extends AbstractSpringDocTest { + + @SpringBootApplication(scanBasePackages = { "test.org.springdoc.api.v30.configuration","test.org.springdoc.api.v30.app2" }) + static class SpringDocTestApp { + @Bean + public OpenAPI customOpenAPI() { + return new OpenAPI() + .info(new Info().title("Security API").version("v1") + .license(new License().name("Apache 2.0").url("http://springdoc.org"))); + } + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v30/app2/User.java b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v30/app2/User.java new file mode 100644 index 000000000..aa1791a85 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v30/app2/User.java @@ -0,0 +1,69 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app2; + +import java.util.Collection; + +import org.springframework.security.core.Authentication; +import org.springframework.security.core.GrantedAuthority; + +public class User implements Authentication { + @Override + public Collection getAuthorities() { + return null; + } + + @Override + public Object getCredentials() { + return null; + } + + @Override + public Object getDetails() { + return null; + } + + @Override + public Object getPrincipal() { + return null; + } + + @Override + public boolean isAuthenticated() { + return false; + } + + @Override + public void setAuthenticated(boolean isAuthenticated) throws IllegalArgumentException { + + } + + @Override + public String getName() { + return null; + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v30/app3/SpringOauth2Test.java b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v30/app3/SpringOauth2Test.java new file mode 100644 index 000000000..4a116c17e --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v30/app3/SpringOauth2Test.java @@ -0,0 +1,54 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app3; + +import org.junit.jupiter.api.Test; + +import org.springframework.boot.SpringBootConfiguration; +import org.springframework.boot.test.context.runner.WebApplicationContextRunner; + +import static org.assertj.core.api.Assertions.assertThat; + +public class SpringOauth2Test { + + private final WebApplicationContextRunner contextRunner = new WebApplicationContextRunner() + .withUserConfiguration(TestApp.class); + + @Test + void configurations_successfully_loaded() { + contextRunner + .run(context -> assertThat(context) + .hasNotFailed() + .doesNotHaveBean("springSecurityOAuth2Provider") + ); + } + + @SpringBootConfiguration + static class TestApp { + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v30/app5/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v30/app5/HelloController.java new file mode 100644 index 000000000..a3afb7279 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v30/app5/HelloController.java @@ -0,0 +1,47 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app5; + +import org.springframework.security.core.Authentication; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class HelloController { + + + @GetMapping + public Authentication doGet() { + return null; + } + + @PostMapping + public Sample doPost() { + return null; + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v30/app5/Sample.java b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v30/app5/Sample.java new file mode 100644 index 000000000..fd1ef00ed --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v30/app5/Sample.java @@ -0,0 +1,51 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app5; + +import org.springframework.security.core.Authentication; + +public class Sample { + private String toto; + + private Authentication authentication; + + public String getToto() { + return toto; + } + + public void setToto(String toto) { + this.toto = toto; + } + + public Authentication getAuthentication() { + return authentication; + } + + public void setAuthentication(Authentication authentication) { + this.authentication = authentication; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v30/app5/SpringDocApp5Test.java b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v30/app5/SpringDocApp5Test.java new file mode 100644 index 000000000..115650f46 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v30/app5/SpringDocApp5Test.java @@ -0,0 +1,38 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app5; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp5Test extends AbstractSpringDocTest { + + @SpringBootApplication(scanBasePackages = { "test.org.springdoc.api.v30.configuration","test.org.springdoc.api.v30.app5" }) + static class SpringDocTestApp {} + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v30/app6/SpringDocApp6Test.java b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v30/app6/SpringDocApp6Test.java new file mode 100644 index 000000000..f64b64c1a --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v30/app6/SpringDocApp6Test.java @@ -0,0 +1,47 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app6; + +import test.org.springdoc.api.v30.AbstractSpringDocTest; +import test.org.springdoc.api.v30.app6.security.MyUserDetailsService; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; +import org.springframework.test.context.TestPropertySource; + +@TestPropertySource(properties = "springdoc.show-login-endpoint=true") +public class SpringDocApp6Test extends AbstractSpringDocTest { + + @SpringBootApplication(scanBasePackages = { "test.org.springdoc.api.v30.configuration","test.org.springdoc.api.v30.app6" }) + static class SpringDocTestApp { + @Bean + MyUserDetailsService userDetailsService() { + return new MyUserDetailsService(); + } + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v30/app6/SpringDocConfig.java b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v30/app6/SpringDocConfig.java new file mode 100644 index 000000000..376d6bb0f --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v30/app6/SpringDocConfig.java @@ -0,0 +1,57 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app6; + +import io.swagger.v3.oas.models.Components; +import io.swagger.v3.oas.models.OpenAPI; +import io.swagger.v3.oas.models.info.Info; +import io.swagger.v3.oas.models.security.SecurityRequirement; +import io.swagger.v3.oas.models.security.SecurityScheme; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + + +@Configuration +public class SpringDocConfig { + + + @Bean + public OpenAPI myOpenAPI() { + final String securitySchemeName = "bearerAuth"; + return new OpenAPI().info(new Info().title("My MWE API") + .description("This document specifies the API") + .version("v23")) + .addSecurityItem(new SecurityRequirement().addList(securitySchemeName)) + .components(new Components().addSecuritySchemes(securitySchemeName, + new SecurityScheme() + .type(SecurityScheme.Type.HTTP) + .scheme("bearer") + .bearerFormat("JWT"))); + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v30/app6/controllers/MyController.java b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v30/app6/controllers/MyController.java new file mode 100644 index 000000000..5082f3c9b --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v30/app6/controllers/MyController.java @@ -0,0 +1,56 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app6.controllers; + +import java.util.List; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.tags.Tag; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + + +@RestController +@RequestMapping("/fax") +@Tag(name = "Fax stuff", description = "For managing fax machines.") +public class MyController { + + @Operation(summary = "Get information about currently existing fax machines") + @ApiResponse(responseCode = "200", description = "list of existing fax machines") + @GetMapping("list") + public List getFaxList(@RequestParam(name = "vendorName", required = false) + @Parameter(description = "vendor name to restrict the list") String vendorFilter) { + + return null; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v30/app6/security/JWTAuthenticationFilter.java b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v30/app6/security/JWTAuthenticationFilter.java new file mode 100644 index 000000000..3ecb3625b --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v30/app6/security/JWTAuthenticationFilter.java @@ -0,0 +1,139 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app6.security; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; + +import com.fasterxml.jackson.databind.ObjectMapper; +import io.jsonwebtoken.Jwts; +import io.jsonwebtoken.SignatureAlgorithm; +import jakarta.servlet.FilterChain; +import jakarta.servlet.ServletException; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; + +import org.springframework.security.authentication.AuthenticationManager; +import org.springframework.security.authentication.InternalAuthenticationServiceException; +import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; +import org.springframework.security.core.Authentication; +import org.springframework.security.core.AuthenticationException; +import org.springframework.security.core.userdetails.User; +import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter; + + +public class JWTAuthenticationFilter extends UsernamePasswordAuthenticationFilter { + + + private final AuthenticationManager authenticationManager; + + + private final long lifetime; + + + private final String key; + + + public JWTAuthenticationFilter(AuthenticationManager authenticationManager, long lifetime, + String key) { + this.authenticationManager = authenticationManager; + this.lifetime = lifetime; + this.key = key; + } + + + @Override + public Authentication attemptAuthentication(HttpServletRequest req, HttpServletResponse res) + throws AuthenticationException { + try { + + UserCredentials credentials = + new ObjectMapper().readValue(req.getInputStream(), UserCredentials.class); + + return authenticationManager.authenticate( + new UsernamePasswordAuthenticationToken(credentials.getUsername(), + credentials.getPassword(), new ArrayList<>())); + + } + catch (IOException e) { + throw new InternalAuthenticationServiceException("Error processing credentials", e); + } + } + + + @Override + protected void successfulAuthentication(HttpServletRequest req, HttpServletResponse res, + FilterChain chain, Authentication auth) + throws IOException, ServletException { + Date notBefore = new Date(); + Date expirationDate = new Date(notBefore.getTime() + lifetime); + + String token = Jwts.builder() + .setClaims(new HashMap<>()) + .setSubject(((User) auth.getPrincipal()).getUsername()) + .setNotBefore(notBefore) + .setExpiration(expirationDate) + .signWith(SignatureAlgorithm.HS512, key) + .compact(); + res.addHeader(WebSecurity.HeaderString, WebSecurity.TokenPrefix + token); + + } + + + private static class UserCredentials { + + + private String username; + + + private String password; + + + String getUsername() { + return username; + } + + + public void setUsername(String username) { + this.username = username; + } + + + String getPassword() { + return password; + } + + + public void setPassword(String password) { + this.password = password; + } + + } + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v30/app6/security/JWTAuthorizationFilter.java b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v30/app6/security/JWTAuthorizationFilter.java new file mode 100644 index 000000000..f5dd4bc99 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v30/app6/security/JWTAuthorizationFilter.java @@ -0,0 +1,109 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app6.security; + +import java.io.IOException; +import java.util.ArrayList; + +import io.jsonwebtoken.ExpiredJwtException; +import io.jsonwebtoken.Jwts; +import jakarta.servlet.FilterChain; +import jakarta.servlet.ServletException; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; + +import org.springframework.security.authentication.AuthenticationManager; +import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; +import org.springframework.security.core.context.SecurityContextHolder; +import org.springframework.security.web.authentication.www.BasicAuthenticationFilter; + + +public class JWTAuthorizationFilter extends BasicAuthenticationFilter { + + + public static final String AUTH_ERROR_ATTRIBUTE = "authError"; + + + private final String key; + + + public JWTAuthorizationFilter(AuthenticationManager authManager, String key) { + super(authManager); + this.key = key; + } + + + @Override + protected void doFilterInternal(HttpServletRequest req, HttpServletResponse res, FilterChain chain) + throws IOException, ServletException { + String header = req.getHeader(WebSecurity.HeaderString); + + if (header == null || !header.startsWith(WebSecurity.TokenPrefix)) { + chain.doFilter(req, res); + return; + } + + UsernamePasswordAuthenticationToken authentication = getAuthentication(req); + + SecurityContextHolder.getContext().setAuthentication(authentication); + + chain.doFilter(req, res); + } + + + /** + * Check the validity of the JWT (JWS, more precisely) as submitted via the + * {@link HttpServletRequest}. + * + * @param request the {@link HttpServletRequest} containing a JWS. + * @return a {@link UsernamePasswordAuthenticationToken} if the JWS is + * valid, {@code null} otherwise. + */ + + private UsernamePasswordAuthenticationToken getAuthentication(HttpServletRequest request) { + String token = request.getHeader(WebSecurity.HeaderString); + if (token != null) { + String user = null; + try { + user = Jwts.parser() + .setSigningKey(key) + .parseClaimsJws(token.replace(WebSecurity.TokenPrefix, "")) + .getBody() + .getSubject(); + } + catch (ExpiredJwtException e) { + request.setAttribute(AUTH_ERROR_ATTRIBUTE, e.getMessage()); + } + if (user != null) { + return new UsernamePasswordAuthenticationToken(user, null, new ArrayList<>()); + } + return null; + } + return null; + } + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v30/app6/security/MyUserDetailsService.java b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v30/app6/security/MyUserDetailsService.java new file mode 100644 index 000000000..10edfafba --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v30/app6/security/MyUserDetailsService.java @@ -0,0 +1,55 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app6.security; + +import java.util.Collections; + +import org.springframework.security.core.userdetails.User; +import org.springframework.security.core.userdetails.UserDetails; +import org.springframework.security.core.userdetails.UserDetailsService; +import org.springframework.security.core.userdetails.UsernameNotFoundException; +import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; +import org.springframework.stereotype.Service; + + +@Service +public class MyUserDetailsService implements UserDetailsService { + + @Override + public UserDetails loadUserByUsername(String username) + throws UsernameNotFoundException { + BCryptPasswordEncoder encoder = new BCryptPasswordEncoder(); + + + if (!username.equals("demouser")) { + throw new UsernameNotFoundException(username); + } + + return new User("demouser", encoder.encode("secret"), Collections.emptyList()); + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v30/app6/security/WebSecurity.java b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v30/app6/security/WebSecurity.java new file mode 100644 index 000000000..f09ea0681 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v30/app6/security/WebSecurity.java @@ -0,0 +1,126 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app6.security; + +import org.springdoc.core.properties.SpringDocConfigProperties; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.core.annotation.Order; +import org.springframework.security.authentication.AuthenticationManager; +import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; +import org.springframework.security.config.annotation.web.builders.HttpSecurity; +import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; +import org.springframework.security.config.http.SessionCreationPolicy; +import org.springframework.security.core.userdetails.UserDetailsService; +import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; +import org.springframework.security.web.SecurityFilterChain; +import org.springframework.web.cors.CorsConfiguration; +import org.springframework.web.cors.CorsConfigurationSource; +import org.springframework.web.cors.UrlBasedCorsConfigurationSource; + +import static org.springdoc.core.utils.Constants.ALL_PATTERN; + +@Configuration +@EnableWebSecurity +@Order(200) +public class WebSecurity { + + + public static final String TokenPrefix = "Bearer "; + + + public static final String HeaderString = "Authorization"; + + + private final UserDetailsService userDetailsService; + + + @Autowired + SpringDocConfigProperties configProperties; + + + private long lifetime = 123456789L; + + + private String key = + "YRv13MrZah/rHJPMGIN6AjdjB09F9gpIC7i9mdFwdIDZ296doUg/nhG/mQ/CnlxPNtcWR6z6RCKtW5cCspGM9w=="; + + + public WebSecurity(UserDetailsService userDetailsService) { + this.userDetailsService = userDetailsService; + + } + + + @Bean + public SecurityFilterChain securityWebFilterChain(HttpSecurity http, AuthenticationManager authenticationManager) throws Exception { + String apiDocsPath = configProperties.getApiDocs().getPath(); + http.cors() + .and() + .csrf() + .disable() + .authorizeRequests() + .requestMatchers(apiDocsPath + ALL_PATTERN) + .permitAll() + .requestMatchers(apiDocsPath.substring(0, apiDocsPath.lastIndexOf("/") + 1) + "api-docs.yaml") + .permitAll() + .anyRequest() + .authenticated() + .and() + .exceptionHandling() + .and() + .addFilter(new JWTAuthenticationFilter(authenticationManager, lifetime, key)) + .addFilter(new JWTAuthorizationFilter(authenticationManager, key)) + // this disables session creation on Spring Security + .sessionManagement() + .sessionCreationPolicy(SessionCreationPolicy.STATELESS); + return http.build(); + } + + + @Autowired + public void configure(AuthenticationManagerBuilder auth) + throws Exception { + auth.userDetailsService(userDetailsService).passwordEncoder(new BCryptPasswordEncoder()); + } + + + @Bean + CorsConfigurationSource corsConfigurationSource() { + final UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(); + + CorsConfiguration configuration = new CorsConfiguration().applyPermitDefaultValues(); + + configuration.addExposedHeader(HeaderString); + source.registerCorsConfiguration(ALL_PATTERN, configuration); + + return source; + } + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v30/app7/AnotherPerson.java b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v30/app7/AnotherPerson.java new file mode 100644 index 000000000..fea638cdb --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v30/app7/AnotherPerson.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app7; + +import io.swagger.v3.oas.annotations.Hidden; + +public class AnotherPerson { + + @Hidden + private String name; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v30/app7/CurrentUser.java b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v30/app7/CurrentUser.java new file mode 100644 index 000000000..190d9d581 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v30/app7/CurrentUser.java @@ -0,0 +1,42 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app7; + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import org.springframework.security.core.annotation.AuthenticationPrincipal; + +@Target({ ElementType.PARAMETER, ElementType.TYPE, ElementType.FIELD }) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@AuthenticationPrincipal +public @interface CurrentUser { +} diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v30/app7/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v30/app7/HelloController.java new file mode 100644 index 000000000..36d80bf7a --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v30/app7/HelloController.java @@ -0,0 +1,47 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app7; + +import org.springdoc.core.annotations.ParameterObject; + +import org.springframework.security.core.annotation.AuthenticationPrincipal; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class HelloController { + + @PostMapping(value = "/hello") + public String hello( + @AuthenticationPrincipal Person person1, + @CurrentUser Person person2, + @ParameterObject AnotherPerson person3, + @ParameterObject TheOtherPerson person4) { + return "OK"; + } + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v30/app7/Person.java b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v30/app7/Person.java new file mode 100644 index 000000000..e164d2581 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v30/app7/Person.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app7; + +public class Person { + + private String name; + + public Person() { + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v30/app7/SpringDocApp7Test.java b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v30/app7/SpringDocApp7Test.java new file mode 100644 index 000000000..89f5c95b8 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v30/app7/SpringDocApp7Test.java @@ -0,0 +1,48 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app7; + +import io.swagger.v3.oas.models.OpenAPI; +import io.swagger.v3.oas.models.info.Info; +import io.swagger.v3.oas.models.info.License; +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; + +public class SpringDocApp7Test extends AbstractSpringDocTest { + + @SpringBootApplication(scanBasePackages = { "test.org.springdoc.api.v30.configuration","test.org.springdoc.api.v30.app7" }) + static class SpringDocTestApp { + @Bean + public OpenAPI customOpenAPI() { + return new OpenAPI() + .info(new Info().title("Security API").version("v1") + .license(new License().name("Apache 2.0").url("http://springdoc.org"))); + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v30/app7/TheOtherPerson.java b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v30/app7/TheOtherPerson.java new file mode 100644 index 000000000..ed4fdf9af --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v30/app7/TheOtherPerson.java @@ -0,0 +1,44 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app7; + +public class TheOtherPerson { + + @CurrentUser + private String name; + + public TheOtherPerson() { + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v30/app8/SpringDocApp8Test.java b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v30/app8/SpringDocApp8Test.java new file mode 100644 index 000000000..551114ff9 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v30/app8/SpringDocApp8Test.java @@ -0,0 +1,50 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app8; + +import io.swagger.v3.oas.models.OpenAPI; +import io.swagger.v3.oas.models.info.Info; +import io.swagger.v3.oas.models.info.License; +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; +import org.springframework.test.context.TestPropertySource; + +@TestPropertySource(properties = "springdoc.show-login-endpoint=true") +public class SpringDocApp8Test extends AbstractSpringDocTest { + + @SpringBootApplication(scanBasePackages = { "test.org.springdoc.api.v30.configuration","test.org.springdoc.api.v30.app8" }) + static class SpringDocTestApp { + @Bean + public OpenAPI customOpenAPI() { + return new OpenAPI() + .info(new Info().title("Security API").version("v1") + .license(new License().name("Apache 2.0").url("http://springdoc.org"))); + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v30/app8/security/WebConfig.java b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v30/app8/security/WebConfig.java new file mode 100644 index 000000000..e25024268 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v30/app8/security/WebConfig.java @@ -0,0 +1,48 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app8.security; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.core.annotation.Order; +import org.springframework.security.config.annotation.web.builders.HttpSecurity; +import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; +import org.springframework.security.web.SecurityFilterChain; + +@Configuration +@EnableWebSecurity +@Order(200) +public class WebConfig { + + @Bean + public SecurityFilterChain securityWebFilterChain(HttpSecurity http) throws Exception { + http.formLogin() + .loginProcessingUrl("/api/login"); + return http.build(); + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v30/app9/SpringDocApp9Test.java b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v30/app9/SpringDocApp9Test.java new file mode 100644 index 000000000..9dd8c2478 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v30/app9/SpringDocApp9Test.java @@ -0,0 +1,50 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app9; + +import io.swagger.v3.oas.models.OpenAPI; +import io.swagger.v3.oas.models.info.Info; +import io.swagger.v3.oas.models.info.License; +import test.org.springdoc.api.v30.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; +import org.springframework.test.context.TestPropertySource; + +@TestPropertySource(properties = { "springdoc.show-login-endpoint=true", "springdoc.enable-spring-security=false" }) +public class SpringDocApp9Test extends AbstractSpringDocTest { + + @SpringBootApplication(scanBasePackages = { "test.org.springdoc.api.configuration","test.org.springdoc.api.v30.app9" }) + static class SpringDocTestApp { + @Bean + public OpenAPI customOpenAPI() { + return new OpenAPI() + .info(new Info().title("Security API").version("v1") + .license(new License().name("Apache 2.0").url("http://springdoc.org"))); + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v30/app9/WebConfig.java b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v30/app9/WebConfig.java new file mode 100644 index 000000000..7fcccb97b --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v30/app9/WebConfig.java @@ -0,0 +1,48 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app9; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.core.annotation.Order; +import org.springframework.security.config.annotation.web.builders.HttpSecurity; +import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; +import org.springframework.security.web.SecurityFilterChain; + +@Configuration +@EnableWebSecurity +@Order(200) +public class WebConfig { + + @Bean + public SecurityFilterChain securityWebFilterChain(HttpSecurity http) throws Exception { + http.formLogin() + .loginProcessingUrl("/api/login"); + return http.build(); + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v30/configuration/SecurityConfiguration.java b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v30/configuration/SecurityConfiguration.java new file mode 100644 index 000000000..8766fd19e --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v30/configuration/SecurityConfiguration.java @@ -0,0 +1,54 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.configuration; + +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Lazy; +import org.springframework.security.authentication.AuthenticationManager; +import org.springframework.security.config.annotation.authentication.configuration.AuthenticationConfiguration; +import org.springframework.security.config.annotation.web.builders.HttpSecurity; +import org.springframework.security.web.SecurityFilterChain; + +@Configuration +class SecurityConfiguration { + + @Bean + @ConditionalOnMissingBean + @Lazy(false) + public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception { + http.securityMatcher("/**") + .authorizeHttpRequests((requests) -> requests.requestMatchers("/**").permitAll()); + return http.build(); + } + + @Bean + public AuthenticationManager authenticationManager(AuthenticationConfiguration authConfig) throws Exception { + return authConfig.getAuthenticationManager(); + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v31/AbstractSpringDocTest.java b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v31/AbstractSpringDocTest.java new file mode 100644 index 000000000..7a98bdced --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v31/AbstractSpringDocTest.java @@ -0,0 +1,88 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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; + +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; + +import org.junit.jupiter.api.Test; +import org.springdoc.core.utils.Constants; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration; +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.context.annotation.Configuration; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.web.servlet.MockMvc; +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; + +@ActiveProfiles("test") +@SpringBootTest +@AutoConfigureMockMvc +public abstract class AbstractSpringDocTest { + + public static String className; + + @Autowired + protected MockMvc mockMvc; + + public static String getContent(String fileName) { + try { + Path path = Paths.get(AbstractSpringDocTest.class.getClassLoader().getResource(fileName).toURI()); + byte[] fileBytes = Files.readAllBytes(path); + return new String(fileBytes, StandardCharsets.UTF_8); + } + catch (Exception e) { + throw new RuntimeException("Failed to read file: " + fileName, e); + } + } + + @Test + void testApp() throws Exception { + className = getClass().getSimpleName(); + String testNumber = className.replaceAll("[^0-9]", ""); + MvcResult mockMvcResult = mockMvc.perform(get(Constants.DEFAULT_API_DOCS_URL)).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 + ".json"); + assertEquals(expected, result, true); + } + + @Configuration + @EnableAutoConfiguration(exclude = { SecurityAutoConfiguration.class }) + static class ContextConfiguration {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v31/app1/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v31/app1/HelloController.java new file mode 100644 index 000000000..20af408ac --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v31/app1/HelloController.java @@ -0,0 +1,58 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app1; + +import org.springframework.security.core.annotation.AuthenticationPrincipal; +import org.springframework.security.core.userdetails.User; +import org.springframework.security.oauth2.client.OAuth2AuthorizedClient; +import org.springframework.security.oauth2.client.annotation.RegisteredOAuth2AuthorizedClient; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class HelloController { + + @PostMapping(value = "/persons") + public String persons(@RequestBody() Person person) { + return "OK"; + } + + @PostMapping(value = "/persons-with-user") + public String personsWithUser(@RequestBody() Person person, + @AuthenticationPrincipal User user) { + return "OK"; + } + + @PostMapping(value = "/persons-with-oauth2-user") + public String personsWithUser(@RequestBody() Person person, + @RegisteredOAuth2AuthorizedClient OAuth2AuthorizedClient authorizedClient, + @AuthenticationPrincipal User user) { + return "OK"; + } + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v31/app1/Person.java b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v31/app1/Person.java new file mode 100644 index 000000000..3899a0646 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v31/app1/Person.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app1; + +public class Person { + + private String name; + + public Person() { + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v31/app1/SpringDocApp1Test.java b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v31/app1/SpringDocApp1Test.java new file mode 100644 index 000000000..594d788df --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v31/app1/SpringDocApp1Test.java @@ -0,0 +1,48 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app1; + +import io.swagger.v3.oas.models.OpenAPI; +import io.swagger.v3.oas.models.info.Info; +import io.swagger.v3.oas.models.info.License; +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; + +public class SpringDocApp1Test extends AbstractSpringDocTest { + + @SpringBootApplication(scanBasePackages = { "test.org.springdoc.api.v31.configuration","test.org.springdoc.api.v31.app1" }) + static class SpringDocTestApp { + @Bean + public OpenAPI customOpenAPI() { + return new OpenAPI() + .info(new Info().title("Security API").version("v1") + .license(new License().name("Apache 2.0").url("http://springdoc.org"))); + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v31/app10/AuthorizationServerConfig.java b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v31/app10/AuthorizationServerConfig.java new file mode 100644 index 000000000..91ddca9ec --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v31/app10/AuthorizationServerConfig.java @@ -0,0 +1,104 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app10; + +import java.util.UUID; + +import com.nimbusds.jose.jwk.JWKSet; +import com.nimbusds.jose.jwk.RSAKey; +import com.nimbusds.jose.jwk.source.JWKSource; +import com.nimbusds.jose.proc.SecurityContext; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.security.config.annotation.web.builders.HttpSecurity; +import org.springframework.security.oauth2.core.AuthorizationGrantType; +import org.springframework.security.oauth2.jwt.JwtDecoder; +import org.springframework.security.oauth2.server.authorization.InMemoryOAuth2AuthorizationService; +import org.springframework.security.oauth2.server.authorization.OAuth2AuthorizationService; +import org.springframework.security.oauth2.server.authorization.client.InMemoryRegisteredClientRepository; +import org.springframework.security.oauth2.server.authorization.client.RegisteredClient; +import org.springframework.security.oauth2.server.authorization.client.RegisteredClientRepository; +import org.springframework.security.oauth2.server.authorization.config.annotation.web.configuration.OAuth2AuthorizationServerConfiguration; +import org.springframework.security.oauth2.server.authorization.settings.AuthorizationServerSettings; +import org.springframework.security.oauth2.server.authorization.settings.ClientSettings; +import org.springframework.security.web.SecurityFilterChain; + +/* + * @author James Selvakumar + * @since 8.0.0 + */ +@Configuration +public class AuthorizationServerConfig +{ + @Bean + public SecurityFilterChain authorizationServerSecurityFilterChain(HttpSecurity http) throws Exception + { + OAuth2AuthorizationServerConfiguration.applyDefaultSecurity(http); + return http.build(); + } + + @Bean + public RegisteredClientRepository registeredClientRepository() { + RegisteredClient registeredClient = RegisteredClient.withId(UUID.randomUUID().toString()) + .clientId("messaging-client") + .clientSecret("{noop}secret") + .authorizationGrantType(AuthorizationGrantType.CLIENT_CREDENTIALS) + .scope("message.read") + .scope("message.write") + .clientSettings(ClientSettings.builder().requireAuthorizationConsent(true).build()) + .build(); + + return new InMemoryRegisteredClientRepository(registeredClient); + } + + @Bean + public OAuth2AuthorizationService authorizationService() + { + return new InMemoryOAuth2AuthorizationService(); + } + + @Bean + public AuthorizationServerSettings authorizationServerSettings() + { + return AuthorizationServerSettings.builder().build(); + } + + @Bean + public JWKSource jwkSource() + { + RSAKey rsaKey = Jwks.generateRsa(); + JWKSet jwkSet = new JWKSet(rsaKey); + return (jwkSelector, securityContext) -> jwkSelector.select(jwkSet); + } + + @Bean + public JwtDecoder jwtDecoder(JWKSource jwkSource) + { + return OAuth2AuthorizationServerConfiguration.jwtDecoder(jwkSource); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v31/app10/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v31/app10/HelloController.java new file mode 100644 index 000000000..e9230407a --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v31/app10/HelloController.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.app10; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/* + * @author James Selvakumar + * @since 8.0.0 + */ +@RestController +@RequestMapping("/api") +public class HelloController +{ + @GetMapping("/hello") + public String hello() + { + return "Hello"; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v31/app10/Jwks.java b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v31/app10/Jwks.java new file mode 100644 index 000000000..645258008 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v31/app10/Jwks.java @@ -0,0 +1,58 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app10; + + +import java.security.KeyPair; +import java.security.interfaces.RSAPrivateKey; +import java.security.interfaces.RSAPublicKey; +import java.util.UUID; + +import com.nimbusds.jose.jwk.RSAKey; + + +/** + * @author Joe Grandja + * @since 0.1.0 + */ +public final class Jwks +{ + private Jwks() + { + //final class constructor should be hidden + } + + public static RSAKey generateRsa() + { + KeyPair keyPair = KeyGeneratorUtils.generateRsaKey(); + RSAPublicKey publicKey = (RSAPublicKey) keyPair.getPublic(); + RSAPrivateKey privateKey = (RSAPrivateKey) keyPair.getPrivate(); + return new RSAKey.Builder(publicKey) + .privateKey(privateKey) + .keyID(UUID.randomUUID().toString()) + .build(); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v31/app10/KeyGeneratorUtils.java b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v31/app10/KeyGeneratorUtils.java new file mode 100644 index 000000000..a441df246 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v31/app10/KeyGeneratorUtils.java @@ -0,0 +1,54 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app10; + +import java.security.KeyPair; +import java.security.KeyPairGenerator; + +/** + * @author Joe Grandja + * @since 0.1.0 + */ +public final class KeyGeneratorUtils +{ + private KeyGeneratorUtils() + { + //final class constructor should be hidden + } + + static KeyPair generateRsaKey() + { + KeyPair keyPair; + try { + KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("RSA"); + keyPairGenerator.initialize(2048); + keyPair = keyPairGenerator.generateKeyPair(); + } catch (Exception ex) { + throw new IllegalStateException(ex); + } + return keyPair; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v31/app10/SpringDocApp10Test.java b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v31/app10/SpringDocApp10Test.java new file mode 100644 index 000000000..673c19076 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v31/app10/SpringDocApp10Test.java @@ -0,0 +1,64 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app10; + +import java.util.Optional; + +import io.swagger.v3.core.converter.ModelConverter; +import io.swagger.v3.core.converter.ModelConverters; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.springdoc.core.converters.SchemaPropertyDeprecatingConverter; +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.test.context.TestPropertySource; + +@TestPropertySource(properties = {"springdoc.show-oauth2-endpoints=true", "springdoc.model-converters.deprecating-converter.enabled=false"}) +public class SpringDocApp10Test extends AbstractSpringDocTest { + + @BeforeAll + public static void init() { + Optional deprecatingConverterOptional = + ModelConverters.getInstance().getConverters() + .stream().filter(modelConverter -> modelConverter instanceof SchemaPropertyDeprecatingConverter).findAny(); + deprecatingConverterOptional.ifPresent(ModelConverters.getInstance()::removeConverter); + } + + @AfterAll + public static void clean() { + Optional deprecatingConverterOptional = + ModelConverters.getInstance().getConverters() + .stream().filter(modelConverter -> modelConverter instanceof SchemaPropertyDeprecatingConverter).findAny(); + deprecatingConverterOptional.ifPresent(ModelConverters.getInstance()::addConverter); + } + + @SpringBootApplication + static class SpringDocTestApp { + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v31/app11/AuthorizationServerConfig.java b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v31/app11/AuthorizationServerConfig.java new file mode 100644 index 000000000..05d0e4b4a --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v31/app11/AuthorizationServerConfig.java @@ -0,0 +1,101 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app11; + +import java.util.UUID; + +import com.nimbusds.jose.jwk.JWKSet; +import com.nimbusds.jose.jwk.RSAKey; +import com.nimbusds.jose.jwk.source.JWKSource; +import com.nimbusds.jose.proc.SecurityContext; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.security.config.Customizer; +import org.springframework.security.config.annotation.web.builders.HttpSecurity; +import org.springframework.security.oauth2.core.AuthorizationGrantType; +import org.springframework.security.oauth2.jwt.JwtDecoder; +import org.springframework.security.oauth2.server.authorization.InMemoryOAuth2AuthorizationService; +import org.springframework.security.oauth2.server.authorization.OAuth2AuthorizationService; +import org.springframework.security.oauth2.server.authorization.client.InMemoryRegisteredClientRepository; +import org.springframework.security.oauth2.server.authorization.client.RegisteredClient; +import org.springframework.security.oauth2.server.authorization.client.RegisteredClientRepository; +import org.springframework.security.oauth2.server.authorization.config.annotation.web.configuration.OAuth2AuthorizationServerConfiguration; +import org.springframework.security.oauth2.server.authorization.config.annotation.web.configurers.OAuth2AuthorizationServerConfigurer; +import org.springframework.security.oauth2.server.authorization.settings.AuthorizationServerSettings; +import org.springframework.security.oauth2.server.authorization.settings.ClientSettings; +import org.springframework.security.web.SecurityFilterChain; + +/* + * @author yuta.saito + */ +@Configuration +public class AuthorizationServerConfig { + @Bean + public SecurityFilterChain authorizationServerSecurityFilterChain(HttpSecurity http) throws Exception { + OAuth2AuthorizationServerConfiguration.applyDefaultSecurity(http); + http.getConfigurer(OAuth2AuthorizationServerConfigurer.class) + .oidc(Customizer.withDefaults()); + return http.build(); + } + + @Bean + public RegisteredClientRepository registeredClientRepository() { + RegisteredClient registeredClient = RegisteredClient.withId(UUID.randomUUID().toString()) + .clientId("messaging-client") + .clientSecret("{noop}secret") + .authorizationGrantType(AuthorizationGrantType.CLIENT_CREDENTIALS) + .scope("message.read") + .scope("message.write") + .clientSettings(ClientSettings.builder().requireAuthorizationConsent(true).build()) + .build(); + + return new InMemoryRegisteredClientRepository(registeredClient); + } + + @Bean + public OAuth2AuthorizationService authorizationService() { + return new InMemoryOAuth2AuthorizationService(); + } + + @Bean + public AuthorizationServerSettings authorizationServerSettings() { + return AuthorizationServerSettings.builder().build(); + } + + @Bean + public JWKSource jwkSource() { + RSAKey rsaKey = Jwks.generateRsa(); + JWKSet jwkSet = new JWKSet(rsaKey); + return (jwkSelector, securityContext) -> jwkSelector.select(jwkSet); + } + + @Bean + public JwtDecoder jwtDecoder(JWKSource jwkSource) { + return OAuth2AuthorizationServerConfiguration.jwtDecoder(jwkSource); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v31/app11/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v31/app11/HelloController.java new file mode 100644 index 000000000..07a3cede7 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v31/app11/HelloController.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app11; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/* + * @author yuta.saito + */ +@RestController +@RequestMapping("/api") +public class HelloController { + @GetMapping("/hello") + public String hello() { + return "Hello"; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v31/app11/Jwks.java b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v31/app11/Jwks.java new file mode 100644 index 000000000..2ddf16cfc --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v31/app11/Jwks.java @@ -0,0 +1,55 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app11; + + +import java.security.KeyPair; +import java.security.interfaces.RSAPrivateKey; +import java.security.interfaces.RSAPublicKey; +import java.util.UUID; + +import com.nimbusds.jose.jwk.RSAKey; + + +/** + * @author yuta.saito + */ +public final class Jwks { + private Jwks() { + //final class constructor should be hidden + } + + public static RSAKey generateRsa() { + KeyPair keyPair = KeyGeneratorUtils.generateRsaKey(); + RSAPublicKey publicKey = (RSAPublicKey) keyPair.getPublic(); + RSAPrivateKey privateKey = (RSAPrivateKey) keyPair.getPrivate(); + return new RSAKey.Builder(publicKey) + .privateKey(privateKey) + .keyID(UUID.randomUUID().toString()) + .build(); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v31/app11/KeyGeneratorUtils.java b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v31/app11/KeyGeneratorUtils.java new file mode 100644 index 000000000..1d98681ed --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v31/app11/KeyGeneratorUtils.java @@ -0,0 +1,52 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app11; + +import java.security.KeyPair; +import java.security.KeyPairGenerator; + +/** + * @author yuta.saito + */ +public final class KeyGeneratorUtils { + private KeyGeneratorUtils() { + //final class constructor should be hidden + } + + static KeyPair generateRsaKey() { + KeyPair keyPair; + try { + KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("RSA"); + keyPairGenerator.initialize(2048); + keyPair = keyPairGenerator.generateKeyPair(); + } + catch (Exception ex) { + throw new IllegalStateException(ex); + } + return keyPair; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v31/app11/SpringDocApp11Test.java b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v31/app11/SpringDocApp11Test.java new file mode 100644 index 000000000..ba8a0579b --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v31/app11/SpringDocApp11Test.java @@ -0,0 +1,64 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app11; + +import java.util.Optional; + +import io.swagger.v3.core.converter.ModelConverter; +import io.swagger.v3.core.converter.ModelConverters; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.springdoc.core.converters.SchemaPropertyDeprecatingConverter; +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.test.context.TestPropertySource; + +@TestPropertySource(properties = { "springdoc.show-oauth2-endpoints=true", "springdoc.model-converters.deprecating-converter.enabled=false" }) +public class SpringDocApp11Test extends AbstractSpringDocTest { + + @BeforeAll + public static void init() { + Optional deprecatingConverterOptional = + ModelConverters.getInstance().getConverters() + .stream().filter(modelConverter -> modelConverter instanceof SchemaPropertyDeprecatingConverter).findAny(); + deprecatingConverterOptional.ifPresent(ModelConverters.getInstance()::removeConverter); + } + + @AfterAll + public static void clean() { + Optional deprecatingConverterOptional = + ModelConverters.getInstance().getConverters() + .stream().filter(modelConverter -> modelConverter instanceof SchemaPropertyDeprecatingConverter).findAny(); + deprecatingConverterOptional.ifPresent(ModelConverters.getInstance()::addConverter); + } + + @SpringBootApplication + static class SpringDocTestApp { + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v31/app12/AuthorizationServerConfig.java b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v31/app12/AuthorizationServerConfig.java new file mode 100644 index 000000000..617ad3f45 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v31/app12/AuthorizationServerConfig.java @@ -0,0 +1,101 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app12; + +import java.util.UUID; + +import com.nimbusds.jose.jwk.JWKSet; +import com.nimbusds.jose.jwk.RSAKey; +import com.nimbusds.jose.jwk.source.JWKSource; +import com.nimbusds.jose.proc.SecurityContext; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.security.config.Customizer; +import org.springframework.security.config.annotation.web.builders.HttpSecurity; +import org.springframework.security.oauth2.core.AuthorizationGrantType; +import org.springframework.security.oauth2.jwt.JwtDecoder; +import org.springframework.security.oauth2.server.authorization.InMemoryOAuth2AuthorizationService; +import org.springframework.security.oauth2.server.authorization.OAuth2AuthorizationService; +import org.springframework.security.oauth2.server.authorization.client.InMemoryRegisteredClientRepository; +import org.springframework.security.oauth2.server.authorization.client.RegisteredClient; +import org.springframework.security.oauth2.server.authorization.client.RegisteredClientRepository; +import org.springframework.security.oauth2.server.authorization.config.annotation.web.configuration.OAuth2AuthorizationServerConfiguration; +import org.springframework.security.oauth2.server.authorization.config.annotation.web.configurers.OAuth2AuthorizationServerConfigurer; +import org.springframework.security.oauth2.server.authorization.settings.AuthorizationServerSettings; +import org.springframework.security.oauth2.server.authorization.settings.ClientSettings; +import org.springframework.security.web.SecurityFilterChain; + +/* + * @author yuta.saito + */ +@Configuration +public class AuthorizationServerConfig { + @Bean + public SecurityFilterChain authorizationServerSecurityFilterChain(HttpSecurity http) throws Exception { + OAuth2AuthorizationServerConfiguration.applyDefaultSecurity(http); + http.getConfigurer(OAuth2AuthorizationServerConfigurer.class) + .oidc(oidc -> oidc.clientRegistrationEndpoint(Customizer.withDefaults())); + return http.build(); + } + + @Bean + public RegisteredClientRepository registeredClientRepository() { + RegisteredClient registeredClient = RegisteredClient.withId(UUID.randomUUID().toString()) + .clientId("messaging-client") + .clientSecret("{noop}secret") + .authorizationGrantType(AuthorizationGrantType.CLIENT_CREDENTIALS) + .scope("message.read") + .scope("message.write") + .clientSettings(ClientSettings.builder().requireAuthorizationConsent(true).build()) + .build(); + + return new InMemoryRegisteredClientRepository(registeredClient); + } + + @Bean + public OAuth2AuthorizationService authorizationService() { + return new InMemoryOAuth2AuthorizationService(); + } + + @Bean + public AuthorizationServerSettings authorizationServerSettings() { + return AuthorizationServerSettings.builder().build(); + } + + @Bean + public JWKSource jwkSource() { + RSAKey rsaKey = Jwks.generateRsa(); + JWKSet jwkSet = new JWKSet(rsaKey); + return (jwkSelector, securityContext) -> jwkSelector.select(jwkSet); + } + + @Bean + public JwtDecoder jwtDecoder(JWKSource jwkSource) { + return OAuth2AuthorizationServerConfiguration.jwtDecoder(jwkSource); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v31/app12/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v31/app12/HelloController.java new file mode 100644 index 000000000..3b09300dd --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v31/app12/HelloController.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app12; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/* + * @author yuta.saito + */ +@RestController +@RequestMapping("/api") +public class HelloController { + @GetMapping("/hello") + public String hello() { + return "Hello"; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v31/app12/Jwks.java b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v31/app12/Jwks.java new file mode 100644 index 000000000..334e71f48 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v31/app12/Jwks.java @@ -0,0 +1,55 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app12; + + +import java.security.KeyPair; +import java.security.interfaces.RSAPrivateKey; +import java.security.interfaces.RSAPublicKey; +import java.util.UUID; + +import com.nimbusds.jose.jwk.RSAKey; + + +/** + * @author yuta.saito + */ +public final class Jwks { + private Jwks() { + //final class constructor should be hidden + } + + public static RSAKey generateRsa() { + KeyPair keyPair = KeyGeneratorUtils.generateRsaKey(); + RSAPublicKey publicKey = (RSAPublicKey) keyPair.getPublic(); + RSAPrivateKey privateKey = (RSAPrivateKey) keyPair.getPrivate(); + return new RSAKey.Builder(publicKey) + .privateKey(privateKey) + .keyID(UUID.randomUUID().toString()) + .build(); + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v31/app12/KeyGeneratorUtils.java b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v31/app12/KeyGeneratorUtils.java new file mode 100644 index 000000000..13e7a8ffe --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v31/app12/KeyGeneratorUtils.java @@ -0,0 +1,52 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app12; + +import java.security.KeyPair; +import java.security.KeyPairGenerator; + +/** + * @author yuta.saito + */ +public final class KeyGeneratorUtils { + private KeyGeneratorUtils() { + //final class constructor should be hidden + } + + static KeyPair generateRsaKey() { + KeyPair keyPair; + try { + KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("RSA"); + keyPairGenerator.initialize(2048); + keyPair = keyPairGenerator.generateKeyPair(); + } + catch (Exception ex) { + throw new IllegalStateException(ex); + } + return keyPair; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v31/app12/SpringDocApp12Test.java b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v31/app12/SpringDocApp12Test.java new file mode 100644 index 000000000..1fcc97688 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v31/app12/SpringDocApp12Test.java @@ -0,0 +1,64 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app12; + +import java.util.Optional; + +import io.swagger.v3.core.converter.ModelConverter; +import io.swagger.v3.core.converter.ModelConverters; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.springdoc.core.converters.SchemaPropertyDeprecatingConverter; +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.test.context.TestPropertySource; + +@TestPropertySource(properties = { "springdoc.show-oauth2-endpoints=true", "springdoc.model-converters.deprecating-converter.enabled=false" }) +public class SpringDocApp12Test extends AbstractSpringDocTest { + + @BeforeAll + public static void init() { + Optional deprecatingConverterOptional = + ModelConverters.getInstance().getConverters() + .stream().filter(modelConverter -> modelConverter instanceof SchemaPropertyDeprecatingConverter).findAny(); + deprecatingConverterOptional.ifPresent(ModelConverters.getInstance()::removeConverter); + } + + @AfterAll + public static void clean() { + Optional deprecatingConverterOptional = + ModelConverters.getInstance().getConverters() + .stream().filter(modelConverter -> modelConverter instanceof SchemaPropertyDeprecatingConverter).findAny(); + deprecatingConverterOptional.ifPresent(ModelConverters.getInstance()::addConverter); + } + + @SpringBootApplication + static class SpringDocTestApp { + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v31/app2/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v31/app2/HelloController.java new file mode 100644 index 000000000..c1d4ab916 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v31/app2/HelloController.java @@ -0,0 +1,56 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app2; + +import org.springframework.security.core.Authentication; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class HelloController { + + @GetMapping("oneParameterAndAuthentication") + public Object oneParameterAndAuthentication(@RequestBody String req, Authentication authentication) { + return null; + } + + @GetMapping("noParametersAndAuthentication") + public Object noParametersAndAuthentication(Authentication authentication) { + return null; + } + + @GetMapping("oneParameterAndUser") + public Object oneParameterAndUser(@RequestBody String req, User user) { + return null; + } + + @GetMapping("noParametersAndUser") + public Object noParametersAndUser(User user) { + return null; + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v31/app2/SpringDocApp2Test.java b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v31/app2/SpringDocApp2Test.java new file mode 100644 index 000000000..131afbc59 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v31/app2/SpringDocApp2Test.java @@ -0,0 +1,49 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app2; + +import io.swagger.v3.oas.models.OpenAPI; +import io.swagger.v3.oas.models.info.Info; +import io.swagger.v3.oas.models.info.License; +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; + +public class SpringDocApp2Test extends AbstractSpringDocTest { + + @SpringBootApplication(scanBasePackages = { "test.org.springdoc.api.v31.configuration","test.org.springdoc.api.v31.app2" }) + static class SpringDocTestApp { + @Bean + public OpenAPI customOpenAPI() { + return new OpenAPI() + .info(new Info().title("Security API").version("v1") + .license(new License().name("Apache 2.0").url("http://springdoc.org"))); + } + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v31/app2/User.java b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v31/app2/User.java new file mode 100644 index 000000000..d6dd32fbc --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v31/app2/User.java @@ -0,0 +1,69 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app2; + +import java.util.Collection; + +import org.springframework.security.core.Authentication; +import org.springframework.security.core.GrantedAuthority; + +public class User implements Authentication { + @Override + public Collection getAuthorities() { + return null; + } + + @Override + public Object getCredentials() { + return null; + } + + @Override + public Object getDetails() { + return null; + } + + @Override + public Object getPrincipal() { + return null; + } + + @Override + public boolean isAuthenticated() { + return false; + } + + @Override + public void setAuthenticated(boolean isAuthenticated) throws IllegalArgumentException { + + } + + @Override + public String getName() { + return null; + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v31/app3/SpringOauth2Test.java b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v31/app3/SpringOauth2Test.java new file mode 100644 index 000000000..3bedbcc55 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v31/app3/SpringOauth2Test.java @@ -0,0 +1,54 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app3; + +import org.junit.jupiter.api.Test; + +import org.springframework.boot.SpringBootConfiguration; +import org.springframework.boot.test.context.runner.WebApplicationContextRunner; + +import static org.assertj.core.api.Assertions.assertThat; + +public class SpringOauth2Test { + + private final WebApplicationContextRunner contextRunner = new WebApplicationContextRunner() + .withUserConfiguration(TestApp.class); + + @Test + void configurations_successfully_loaded() { + contextRunner + .run(context -> assertThat(context) + .hasNotFailed() + .doesNotHaveBean("springSecurityOAuth2Provider") + ); + } + + @SpringBootConfiguration + static class TestApp { + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v31/app5/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v31/app5/HelloController.java new file mode 100644 index 000000000..1f1a196f1 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v31/app5/HelloController.java @@ -0,0 +1,47 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app5; + +import org.springframework.security.core.Authentication; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class HelloController { + + + @GetMapping + public Authentication doGet() { + return null; + } + + @PostMapping + public Sample doPost() { + return null; + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v31/app5/Sample.java b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v31/app5/Sample.java new file mode 100644 index 000000000..172d46177 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v31/app5/Sample.java @@ -0,0 +1,51 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app5; + +import org.springframework.security.core.Authentication; + +public class Sample { + private String toto; + + private Authentication authentication; + + public String getToto() { + return toto; + } + + public void setToto(String toto) { + this.toto = toto; + } + + public Authentication getAuthentication() { + return authentication; + } + + public void setAuthentication(Authentication authentication) { + this.authentication = authentication; + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v31/app5/SpringDocApp5Test.java b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v31/app5/SpringDocApp5Test.java new file mode 100644 index 000000000..cb5136ff5 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v31/app5/SpringDocApp5Test.java @@ -0,0 +1,38 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app5; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +public class SpringDocApp5Test extends AbstractSpringDocTest { + + @SpringBootApplication(scanBasePackages = { "test.org.springdoc.api.v31.configuration","test.org.springdoc.api.v31.app5" }) + static class SpringDocTestApp {} + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v31/app6/SpringDocApp6Test.java b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v31/app6/SpringDocApp6Test.java new file mode 100644 index 000000000..799ba828a --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v31/app6/SpringDocApp6Test.java @@ -0,0 +1,47 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app6; + +import test.org.springdoc.api.v31.AbstractSpringDocTest; +import test.org.springdoc.api.v31.app6.security.MyUserDetailsService; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; +import org.springframework.test.context.TestPropertySource; + +@TestPropertySource(properties = "springdoc.show-login-endpoint=true") +public class SpringDocApp6Test extends AbstractSpringDocTest { + + @SpringBootApplication(scanBasePackages = { "test.org.springdoc.api.v31.configuration","test.org.springdoc.api.v31.app6" }) + static class SpringDocTestApp { + @Bean + MyUserDetailsService userDetailsService() { + return new MyUserDetailsService(); + } + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v31/app6/SpringDocConfig.java b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v31/app6/SpringDocConfig.java new file mode 100644 index 000000000..1988aa243 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v31/app6/SpringDocConfig.java @@ -0,0 +1,57 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app6; + +import io.swagger.v3.oas.models.Components; +import io.swagger.v3.oas.models.OpenAPI; +import io.swagger.v3.oas.models.info.Info; +import io.swagger.v3.oas.models.security.SecurityRequirement; +import io.swagger.v3.oas.models.security.SecurityScheme; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + + +@Configuration +public class SpringDocConfig { + + + @Bean + public OpenAPI myOpenAPI() { + final String securitySchemeName = "bearerAuth"; + return new OpenAPI().info(new Info().title("My MWE API") + .description("This document specifies the API") + .version("v23")) + .addSecurityItem(new SecurityRequirement().addList(securitySchemeName)) + .components(new Components().addSecuritySchemes(securitySchemeName, + new SecurityScheme() + .type(SecurityScheme.Type.HTTP) + .scheme("bearer") + .bearerFormat("JWT"))); + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v31/app6/controllers/MyController.java b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v31/app6/controllers/MyController.java new file mode 100644 index 000000000..ae0e32f33 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v31/app6/controllers/MyController.java @@ -0,0 +1,56 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app6.controllers; + +import java.util.List; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.tags.Tag; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + + +@RestController +@RequestMapping("/fax") +@Tag(name = "Fax stuff", description = "For managing fax machines.") +public class MyController { + + @Operation(summary = "Get information about currently existing fax machines") + @ApiResponse(responseCode = "200", description = "list of existing fax machines") + @GetMapping("list") + public List getFaxList(@RequestParam(name = "vendorName", required = false) + @Parameter(description = "vendor name to restrict the list") String vendorFilter) { + + return null; + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v31/app6/security/JWTAuthenticationFilter.java b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v31/app6/security/JWTAuthenticationFilter.java new file mode 100644 index 000000000..fb22cbc27 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v31/app6/security/JWTAuthenticationFilter.java @@ -0,0 +1,139 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app6.security; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; + +import com.fasterxml.jackson.databind.ObjectMapper; +import io.jsonwebtoken.Jwts; +import io.jsonwebtoken.SignatureAlgorithm; +import jakarta.servlet.FilterChain; +import jakarta.servlet.ServletException; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; + +import org.springframework.security.authentication.AuthenticationManager; +import org.springframework.security.authentication.InternalAuthenticationServiceException; +import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; +import org.springframework.security.core.Authentication; +import org.springframework.security.core.AuthenticationException; +import org.springframework.security.core.userdetails.User; +import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter; + + +public class JWTAuthenticationFilter extends UsernamePasswordAuthenticationFilter { + + + private final AuthenticationManager authenticationManager; + + + private final long lifetime; + + + private final String key; + + + public JWTAuthenticationFilter(AuthenticationManager authenticationManager, long lifetime, + String key) { + this.authenticationManager = authenticationManager; + this.lifetime = lifetime; + this.key = key; + } + + + @Override + public Authentication attemptAuthentication(HttpServletRequest req, HttpServletResponse res) + throws AuthenticationException { + try { + + UserCredentials credentials = + new ObjectMapper().readValue(req.getInputStream(), UserCredentials.class); + + return authenticationManager.authenticate( + new UsernamePasswordAuthenticationToken(credentials.getUsername(), + credentials.getPassword(), new ArrayList<>())); + + } + catch (IOException e) { + throw new InternalAuthenticationServiceException("Error processing credentials", e); + } + } + + + @Override + protected void successfulAuthentication(HttpServletRequest req, HttpServletResponse res, + FilterChain chain, Authentication auth) + throws IOException, ServletException { + Date notBefore = new Date(); + Date expirationDate = new Date(notBefore.getTime() + lifetime); + + String token = Jwts.builder() + .setClaims(new HashMap<>()) + .setSubject(((User) auth.getPrincipal()).getUsername()) + .setNotBefore(notBefore) + .setExpiration(expirationDate) + .signWith(SignatureAlgorithm.HS512, key) + .compact(); + res.addHeader(WebSecurity.HeaderString, WebSecurity.TokenPrefix + token); + + } + + + private static class UserCredentials { + + + private String username; + + + private String password; + + + String getUsername() { + return username; + } + + + public void setUsername(String username) { + this.username = username; + } + + + String getPassword() { + return password; + } + + + public void setPassword(String password) { + this.password = password; + } + + } + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v31/app6/security/JWTAuthorizationFilter.java b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v31/app6/security/JWTAuthorizationFilter.java new file mode 100644 index 000000000..9efe60711 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v31/app6/security/JWTAuthorizationFilter.java @@ -0,0 +1,109 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app6.security; + +import java.io.IOException; +import java.util.ArrayList; + +import io.jsonwebtoken.ExpiredJwtException; +import io.jsonwebtoken.Jwts; +import jakarta.servlet.FilterChain; +import jakarta.servlet.ServletException; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; + +import org.springframework.security.authentication.AuthenticationManager; +import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; +import org.springframework.security.core.context.SecurityContextHolder; +import org.springframework.security.web.authentication.www.BasicAuthenticationFilter; + + +public class JWTAuthorizationFilter extends BasicAuthenticationFilter { + + + public static final String AUTH_ERROR_ATTRIBUTE = "authError"; + + + private final String key; + + + public JWTAuthorizationFilter(AuthenticationManager authManager, String key) { + super(authManager); + this.key = key; + } + + + @Override + protected void doFilterInternal(HttpServletRequest req, HttpServletResponse res, FilterChain chain) + throws IOException, ServletException { + String header = req.getHeader(WebSecurity.HeaderString); + + if (header == null || !header.startsWith(WebSecurity.TokenPrefix)) { + chain.doFilter(req, res); + return; + } + + UsernamePasswordAuthenticationToken authentication = getAuthentication(req); + + SecurityContextHolder.getContext().setAuthentication(authentication); + + chain.doFilter(req, res); + } + + + /** + * Check the validity of the JWT (JWS, more precisely) as submitted via the + * {@link HttpServletRequest}. + * + * @param request the {@link HttpServletRequest} containing a JWS. + * @return a {@link UsernamePasswordAuthenticationToken} if the JWS is + * valid, {@code null} otherwise. + */ + + private UsernamePasswordAuthenticationToken getAuthentication(HttpServletRequest request) { + String token = request.getHeader(WebSecurity.HeaderString); + if (token != null) { + String user = null; + try { + user = Jwts.parser() + .setSigningKey(key) + .parseClaimsJws(token.replace(WebSecurity.TokenPrefix, "")) + .getBody() + .getSubject(); + } + catch (ExpiredJwtException e) { + request.setAttribute(AUTH_ERROR_ATTRIBUTE, e.getMessage()); + } + if (user != null) { + return new UsernamePasswordAuthenticationToken(user, null, new ArrayList<>()); + } + return null; + } + return null; + } + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v31/app6/security/MyUserDetailsService.java b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v31/app6/security/MyUserDetailsService.java new file mode 100644 index 000000000..545a77545 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v31/app6/security/MyUserDetailsService.java @@ -0,0 +1,55 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app6.security; + +import java.util.Collections; + +import org.springframework.security.core.userdetails.User; +import org.springframework.security.core.userdetails.UserDetails; +import org.springframework.security.core.userdetails.UserDetailsService; +import org.springframework.security.core.userdetails.UsernameNotFoundException; +import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; +import org.springframework.stereotype.Service; + + +@Service +public class MyUserDetailsService implements UserDetailsService { + + @Override + public UserDetails loadUserByUsername(String username) + throws UsernameNotFoundException { + BCryptPasswordEncoder encoder = new BCryptPasswordEncoder(); + + + if (!username.equals("demouser")) { + throw new UsernameNotFoundException(username); + } + + return new User("demouser", encoder.encode("secret"), Collections.emptyList()); + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v31/app6/security/WebSecurity.java b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v31/app6/security/WebSecurity.java new file mode 100644 index 000000000..96fac8801 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v31/app6/security/WebSecurity.java @@ -0,0 +1,126 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app6.security; + +import org.springdoc.core.properties.SpringDocConfigProperties; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.core.annotation.Order; +import org.springframework.security.authentication.AuthenticationManager; +import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; +import org.springframework.security.config.annotation.web.builders.HttpSecurity; +import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; +import org.springframework.security.config.http.SessionCreationPolicy; +import org.springframework.security.core.userdetails.UserDetailsService; +import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; +import org.springframework.security.web.SecurityFilterChain; +import org.springframework.web.cors.CorsConfiguration; +import org.springframework.web.cors.CorsConfigurationSource; +import org.springframework.web.cors.UrlBasedCorsConfigurationSource; + +import static org.springdoc.core.utils.Constants.ALL_PATTERN; + +@Configuration +@EnableWebSecurity +@Order(200) +public class WebSecurity { + + + public static final String TokenPrefix = "Bearer "; + + + public static final String HeaderString = "Authorization"; + + + private final UserDetailsService userDetailsService; + + + @Autowired + SpringDocConfigProperties configProperties; + + + private long lifetime = 123456789L; + + + private String key = + "YRv13MrZah/rHJPMGIN6AjdjB09F9gpIC7i9mdFwdIDZ296doUg/nhG/mQ/CnlxPNtcWR6z6RCKtW5cCspGM9w=="; + + + public WebSecurity(UserDetailsService userDetailsService) { + this.userDetailsService = userDetailsService; + + } + + + @Bean + public SecurityFilterChain securityWebFilterChain(HttpSecurity http, AuthenticationManager authenticationManager) throws Exception { + String apiDocsPath = configProperties.getApiDocs().getPath(); + http.cors() + .and() + .csrf() + .disable() + .authorizeRequests() + .requestMatchers(apiDocsPath + ALL_PATTERN) + .permitAll() + .requestMatchers(apiDocsPath.substring(0, apiDocsPath.lastIndexOf("/") + 1) + "api-docs.yaml") + .permitAll() + .anyRequest() + .authenticated() + .and() + .exceptionHandling() + .and() + .addFilter(new JWTAuthenticationFilter(authenticationManager, lifetime, key)) + .addFilter(new JWTAuthorizationFilter(authenticationManager, key)) + // this disables session creation on Spring Security + .sessionManagement() + .sessionCreationPolicy(SessionCreationPolicy.STATELESS); + return http.build(); + } + + + @Autowired + public void configure(AuthenticationManagerBuilder auth) + throws Exception { + auth.userDetailsService(userDetailsService).passwordEncoder(new BCryptPasswordEncoder()); + } + + + @Bean + CorsConfigurationSource corsConfigurationSource() { + final UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(); + + CorsConfiguration configuration = new CorsConfiguration().applyPermitDefaultValues(); + + configuration.addExposedHeader(HeaderString); + source.registerCorsConfiguration(ALL_PATTERN, configuration); + + return source; + } + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v31/app7/AnotherPerson.java b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v31/app7/AnotherPerson.java new file mode 100644 index 000000000..a139a74bc --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v31/app7/AnotherPerson.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app7; + +import io.swagger.v3.oas.annotations.Hidden; + +public class AnotherPerson { + + @Hidden + private String name; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v31/app7/CurrentUser.java b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v31/app7/CurrentUser.java new file mode 100644 index 000000000..fe9848f24 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v31/app7/CurrentUser.java @@ -0,0 +1,42 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app7; + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import org.springframework.security.core.annotation.AuthenticationPrincipal; + +@Target({ ElementType.PARAMETER, ElementType.TYPE, ElementType.FIELD }) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@AuthenticationPrincipal +public @interface CurrentUser { +} diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v31/app7/HelloController.java b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v31/app7/HelloController.java new file mode 100644 index 000000000..cbb673d1d --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v31/app7/HelloController.java @@ -0,0 +1,47 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app7; + +import org.springdoc.core.annotations.ParameterObject; + +import org.springframework.security.core.annotation.AuthenticationPrincipal; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class HelloController { + + @PostMapping(value = "/hello") + public String hello( + @AuthenticationPrincipal Person person1, + @CurrentUser Person person2, + @ParameterObject AnotherPerson person3, + @ParameterObject TheOtherPerson person4) { + return "OK"; + } + +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v31/app7/Person.java b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v31/app7/Person.java new file mode 100644 index 000000000..6539276f0 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v31/app7/Person.java @@ -0,0 +1,43 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app7; + +public class Person { + + private String name; + + public Person() { + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v31/app7/SpringDocApp7Test.java b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v31/app7/SpringDocApp7Test.java new file mode 100644 index 000000000..1b2f4cff3 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v31/app7/SpringDocApp7Test.java @@ -0,0 +1,48 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app7; + +import io.swagger.v3.oas.models.OpenAPI; +import io.swagger.v3.oas.models.info.Info; +import io.swagger.v3.oas.models.info.License; +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; + +public class SpringDocApp7Test extends AbstractSpringDocTest { + + @SpringBootApplication(scanBasePackages = { "test.org.springdoc.api.v31.configuration","test.org.springdoc.api.v31.app7" }) + static class SpringDocTestApp { + @Bean + public OpenAPI customOpenAPI() { + return new OpenAPI() + .info(new Info().title("Security API").version("v1") + .license(new License().name("Apache 2.0").url("http://springdoc.org"))); + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v31/app7/TheOtherPerson.java b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v31/app7/TheOtherPerson.java new file mode 100644 index 000000000..a8c4372d0 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v31/app7/TheOtherPerson.java @@ -0,0 +1,44 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app7; + +public class TheOtherPerson { + + @CurrentUser + private String name; + + public TheOtherPerson() { + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v31/app8/SpringDocApp8Test.java b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v31/app8/SpringDocApp8Test.java new file mode 100644 index 000000000..aae8f2b19 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v31/app8/SpringDocApp8Test.java @@ -0,0 +1,50 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app8; + +import io.swagger.v3.oas.models.OpenAPI; +import io.swagger.v3.oas.models.info.Info; +import io.swagger.v3.oas.models.info.License; +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; +import org.springframework.test.context.TestPropertySource; + +@TestPropertySource(properties = "springdoc.show-login-endpoint=true") +public class SpringDocApp8Test extends AbstractSpringDocTest { + + @SpringBootApplication(scanBasePackages = { "test.org.springdoc.api.v31.configuration","test.org.springdoc.api.v31.app8" }) + static class SpringDocTestApp { + @Bean + public OpenAPI customOpenAPI() { + return new OpenAPI() + .info(new Info().title("Security API").version("v1") + .license(new License().name("Apache 2.0").url("http://springdoc.org"))); + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v31/app8/security/WebConfig.java b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v31/app8/security/WebConfig.java new file mode 100644 index 000000000..dafe043eb --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v31/app8/security/WebConfig.java @@ -0,0 +1,48 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app8.security; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.core.annotation.Order; +import org.springframework.security.config.annotation.web.builders.HttpSecurity; +import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; +import org.springframework.security.web.SecurityFilterChain; + +@Configuration +@EnableWebSecurity +@Order(200) +public class WebConfig { + + @Bean + public SecurityFilterChain securityWebFilterChain(HttpSecurity http) throws Exception { + http.formLogin() + .loginProcessingUrl("/api/login"); + return http.build(); + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v31/app9/SpringDocApp9Test.java b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v31/app9/SpringDocApp9Test.java new file mode 100644 index 000000000..c8692c60b --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v31/app9/SpringDocApp9Test.java @@ -0,0 +1,50 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app9; + +import io.swagger.v3.oas.models.OpenAPI; +import io.swagger.v3.oas.models.info.Info; +import io.swagger.v3.oas.models.info.License; +import test.org.springdoc.api.v31.AbstractSpringDocTest; + +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; +import org.springframework.test.context.TestPropertySource; + +@TestPropertySource(properties = { "springdoc.show-login-endpoint=true", "springdoc.enable-spring-security=false" }) +public class SpringDocApp9Test extends AbstractSpringDocTest { + + @SpringBootApplication(scanBasePackages = { "test.org.springdoc.api.v31.configuration","test.org.springdoc.api.v31.app9" }) + static class SpringDocTestApp { + @Bean + public OpenAPI customOpenAPI() { + return new OpenAPI() + .info(new Info().title("Security API").version("v1") + .license(new License().name("Apache 2.0").url("http://springdoc.org"))); + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v31/app9/WebConfig.java b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v31/app9/WebConfig.java new file mode 100644 index 000000000..0c93146f1 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v31/app9/WebConfig.java @@ -0,0 +1,48 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.app9; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.core.annotation.Order; +import org.springframework.security.config.annotation.web.builders.HttpSecurity; +import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; +import org.springframework.security.web.SecurityFilterChain; + +@Configuration +@EnableWebSecurity +@Order(200) +public class WebConfig { + + @Bean + public SecurityFilterChain securityWebFilterChain(HttpSecurity http) throws Exception { + http.formLogin() + .loginProcessingUrl("/api/login"); + return http.build(); + } + +} diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v31/configuration/SecurityConfiguration.java b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v31/configuration/SecurityConfiguration.java new file mode 100644 index 000000000..24132aaab --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/java/test/org/springdoc/api/v31/configuration/SecurityConfiguration.java @@ -0,0 +1,54 @@ +/* + * + * * + * * * + * * * * + * * * * * + * * * * * * 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.configuration; + +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Lazy; +import org.springframework.security.authentication.AuthenticationManager; +import org.springframework.security.config.annotation.authentication.configuration.AuthenticationConfiguration; +import org.springframework.security.config.annotation.web.builders.HttpSecurity; +import org.springframework.security.web.SecurityFilterChain; + +@Configuration +class SecurityConfiguration { + + @Bean + @ConditionalOnMissingBean + @Lazy(false) + public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception { + http.securityMatcher("/**") + .authorizeHttpRequests((requests) -> requests.requestMatchers("/**").permitAll()); + return http.build(); + } + + @Bean + public AuthenticationManager authenticationManager(AuthenticationConfiguration authConfig) throws Exception { + return authConfig.getAuthenticationManager(); + } +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/resources/results/app1.json b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/resources/results/3.0.1/app1.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/resources/results/app1.json rename to springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/resources/results/3.0.1/app1.json diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/resources/results/app10.json b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/resources/results/3.0.1/app10.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/resources/results/app10.json rename to springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/resources/results/3.0.1/app10.json diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/resources/results/app11.json b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/resources/results/3.0.1/app11.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/resources/results/app11.json rename to springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/resources/results/3.0.1/app11.json diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/resources/results/app12.json b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/resources/results/3.0.1/app12.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/resources/results/app12.json rename to springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/resources/results/3.0.1/app12.json diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/resources/results/app2.json b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/resources/results/3.0.1/app2.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/resources/results/app2.json rename to springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/resources/results/3.0.1/app2.json diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/resources/results/app5.json b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/resources/results/3.0.1/app5.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/resources/results/app5.json rename to springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/resources/results/3.0.1/app5.json diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/resources/results/app6.json b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/resources/results/3.0.1/app6.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/resources/results/app6.json rename to springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/resources/results/3.0.1/app6.json diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/resources/results/app7.json b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/resources/results/3.0.1/app7.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/resources/results/app7.json rename to springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/resources/results/3.0.1/app7.json diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/resources/results/app8.json b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/resources/results/3.0.1/app8.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/resources/results/app8.json rename to springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/resources/results/3.0.1/app8.json diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/resources/results/app9.json b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/resources/results/3.0.1/app9.json similarity index 100% rename from springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/resources/results/app9.json rename to springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/resources/results/3.0.1/app9.json diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/resources/results/3.1.0/app1.json b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/resources/results/3.1.0/app1.json new file mode 100644 index 000000000..6e603a59c --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/resources/results/3.1.0/app1.json @@ -0,0 +1,121 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "Security API", + "license": { + "name": "Apache 2.0", + "url": "http://springdoc.org" + }, + "version": "v1" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/persons": { + "post": { + "tags": [ + "hello-controller" + ], + "operationId": "persons", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Person" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/persons-with-user": { + "post": { + "tags": [ + "hello-controller" + ], + "operationId": "personsWithUser", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Person" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/persons-with-oauth2-user": { + "post": { + "tags": [ + "hello-controller" + ], + "operationId": "personsWithUser_1", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Person" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "Person": { + "type": "object", + "properties": { + "name": { + "type": "string" + } + } + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/resources/results/3.1.0/app10.json b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/resources/results/3.1.0/app10.json new file mode 100644 index 000000000..0b39dfe1b --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/resources/results/3.1.0/app10.json @@ -0,0 +1,523 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/api/hello": { + "get": { + "tags": [ + "hello-controller" + ], + "operationId": "hello", + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/oauth2/jwks": { + "get": { + "tags": [ + "authorization-server-endpoints" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "keys": { + "type": "array", + "items": { + "type": "object", + "additionalProperties": true + } + } + } + } + } + } + }, + "500": { + "description": "Internal Server Error" + }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/OAuth2Error" + } + } + } + } + } + } + }, + "/.well-known/oauth-authorization-server": { + "get": { + "tags": [ + "authorization-server-endpoints" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/OAuth2AuthorizationServerMetadata" + } + } + } + }, + "500": { + "description": "Internal Server Error" + } + } + } + }, + "/.well-known/oauth-authorization-server/{subpath}": { + "get": { + "tags": [ + "authorization-server-endpoints" + ], + "summary": "Valid when multiple issuers are allowed", + "parameters": [ + { + "name": "subpath", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/OAuth2AuthorizationServerMetadata" + } + } + } + }, + "500": { + "description": "Internal Server Error" + } + } + } + }, + "/oauth2/token": { + "post": { + "tags": [ + "authorization-server-endpoints" + ], + "parameters": [ + { + "name": "Authorization", + "in": "header", + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/x-www-form-urlencoded": { + "schema": { + "type": "object", + "properties": { + "grant_type": { + "type": "string", + "enum": [ + "authorization_code", + "refresh_token", + "client_credentials" + ] + }, + "code": { + "type": "string" + }, + "redirect_uri": { + "type": "string" + }, + "refresh_token": { + "type": "string" + }, + "scope": { + "type": "string" + }, + "client_id": { + "type": "string" + }, + "client_secret": { + "type": "string" + }, + "client_assertion_type": { + "type": "string" + }, + "client_assertion": { + "type": "string" + }, + "additionalParameters": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + } + } + } + } + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/OAuth2Token" + } + } + } + }, + "500": { + "description": "Internal Server Error" + }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/OAuth2Error" + } + } + } + }, + "401": { + "description": "Unauthorized", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/OAuth2Error" + } + } + } + } + } + } + }, + "/oauth2/authorize": { + "post": { + "tags": [ + "authorization-server-endpoints" + ], + "parameters": [ + { + "name": "parameters", + "in": "query", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "text/html": {} + } + }, + "500": { + "description": "Internal Server Error" + }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/OAuth2Error" + } + } + } + }, + "302": { + "description": "Found", + "headers": { + "Location": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/oauth2/introspect": { + "post": { + "tags": [ + "authorization-server-endpoints" + ], + "requestBody": { + "content": { + "application/x-www-form-urlencoded": { + "schema": { + "type": "object", + "properties": { + "token": { + "type": "string" + }, + "token_type_hint": { + "type": "string" + }, + "additionalParameters": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + } + } + } + } + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/OAuth2TokenIntrospection" + } + } + } + }, + "500": { + "description": "Internal Server Error" + }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/OAuth2Error" + } + } + } + } + } + } + }, + "/oauth2/revoke": { + "post": { + "tags": [ + "authorization-server-endpoints" + ], + "requestBody": { + "content": { + "application/x-www-form-urlencoded": { + "schema": { + "type": "object", + "properties": { + "token": { + "type": "string" + }, + "token_type_hint": { + "type": "string" + } + } + } + } + } + }, + "responses": { + "200": { + "description": "OK" + }, + "500": { + "description": "Internal Server Error" + }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/OAuth2Error" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "OAuth2Error": { + "type": "object", + "properties": { + "errorCode": { + "type": "string" + }, + "description": { + "type": "string" + }, + "uri": { + "type": "string" + } + } + }, + "OAuth2AuthorizationServerMetadata": { + "type": "object", + "properties": { + "response_types_supported": { + "type": "array", + "items": { + "type": "string" + } + }, + "grant_types_supported": { + "type": "array", + "items": { + "type": "string" + } + }, + "revocation_endpoint": { + "type": "string" + }, + "introspection_endpoint": { + "type": "string" + }, + "authorization_endpoint": { + "type": "string" + }, + "jwks_uri": { + "type": "string" + }, + "token_endpoint": { + "type": "string" + }, + "issuer": { + "type": "string" + }, + "introspection_endpoint_auth_methods_supported": { + "type": "array", + "items": { + "type": "string" + } + }, + "code_challenge_methods_supported": { + "type": "array", + "items": { + "type": "string" + } + }, + "token_endpoint_auth_methods_supported": { + "type": "array", + "items": { + "type": "string" + } + }, + "revocation_endpoint_auth_methods_supported": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "OAuth2Token": { + "type": "object", + "properties": { + "scope": { + "type": "string" + }, + "refresh_token": { + "type": "string" + }, + "expires_in": { + "type": "integer", + "format": "int64" + }, + "token_type": { + "type": "string" + }, + "access_token": { + "type": "string" + } + } + }, + "OAuth2TokenIntrospection": { + "type": "object", + "properties": { + "jti": { + "type": "string" + }, + "scope": { + "type": "string" + }, + "iat": { + "type": "integer", + "format": "int64" + }, + "token_type": { + "type": "string" + }, + "aud": { + "type": "array", + "items": { + "type": "string" + } + }, + "client_id": { + "type": "string" + }, + "exp": { + "type": "integer", + "format": "int64" + }, + "iss": { + "type": "string" + }, + "username": { + "type": "string" + }, + "sub": { + "type": "string" + }, + "nbf": { + "type": "integer", + "format": "int64" + }, + "active": { + "type": "boolean" + } + } + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/resources/results/3.1.0/app11.json b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/resources/results/3.1.0/app11.json new file mode 100644 index 000000000..4063d7c4e --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/resources/results/3.1.0/app11.json @@ -0,0 +1,674 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/api/hello": { + "get": { + "tags": [ + "hello-controller" + ], + "operationId": "hello", + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/oauth2/jwks": { + "get": { + "tags": [ + "authorization-server-endpoints" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "keys": { + "type": "array", + "items": { + "type": "object", + "additionalProperties": true + } + } + } + } + } + } + }, + "500": { + "description": "Internal Server Error" + }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/OAuth2Error" + } + } + } + } + } + } + }, + "/.well-known/oauth-authorization-server": { + "get": { + "tags": [ + "authorization-server-endpoints" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/OAuth2AuthorizationServerMetadata" + } + } + } + }, + "500": { + "description": "Internal Server Error" + } + } + } + }, + "/.well-known/oauth-authorization-server/{subpath}": { + "get": { + "tags": [ + "authorization-server-endpoints" + ], + "summary": "Valid when multiple issuers are allowed", + "parameters": [ + { + "name": "subpath", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/OAuth2AuthorizationServerMetadata" + } + } + } + }, + "500": { + "description": "Internal Server Error" + } + } + } + }, + "/oauth2/token": { + "post": { + "tags": [ + "authorization-server-endpoints" + ], + "parameters": [ + { + "name": "Authorization", + "in": "header", + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/x-www-form-urlencoded": { + "schema": { + "type": "object", + "properties": { + "grant_type": { + "type": "string", + "enum": [ + "authorization_code", + "refresh_token", + "client_credentials" + ] + }, + "code": { + "type": "string" + }, + "redirect_uri": { + "type": "string" + }, + "refresh_token": { + "type": "string" + }, + "scope": { + "type": "string" + }, + "client_id": { + "type": "string" + }, + "client_secret": { + "type": "string" + }, + "client_assertion_type": { + "type": "string" + }, + "client_assertion": { + "type": "string" + }, + "additionalParameters": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + } + } + } + } + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/OAuth2Token" + } + } + } + }, + "500": { + "description": "Internal Server Error" + }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/OAuth2Error" + } + } + } + }, + "401": { + "description": "Unauthorized", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/OAuth2Error" + } + } + } + } + } + } + }, + "/oauth2/authorize": { + "post": { + "tags": [ + "authorization-server-endpoints" + ], + "parameters": [ + { + "name": "parameters", + "in": "query", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "text/html": {} + } + }, + "500": { + "description": "Internal Server Error" + }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/OAuth2Error" + } + } + } + }, + "302": { + "description": "Found", + "headers": { + "Location": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/oauth2/introspect": { + "post": { + "tags": [ + "authorization-server-endpoints" + ], + "requestBody": { + "content": { + "application/x-www-form-urlencoded": { + "schema": { + "type": "object", + "properties": { + "token": { + "type": "string" + }, + "token_type_hint": { + "type": "string" + }, + "additionalParameters": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + } + } + } + } + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/OAuth2TokenIntrospection" + } + } + } + }, + "500": { + "description": "Internal Server Error" + }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/OAuth2Error" + } + } + } + } + } + } + }, + "/oauth2/revoke": { + "post": { + "tags": [ + "authorization-server-endpoints" + ], + "requestBody": { + "content": { + "application/x-www-form-urlencoded": { + "schema": { + "type": "object", + "properties": { + "token": { + "type": "string" + }, + "token_type_hint": { + "type": "string" + } + } + } + } + } + }, + "responses": { + "200": { + "description": "OK" + }, + "500": { + "description": "Internal Server Error" + }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/OAuth2Error" + } + } + } + } + } + } + }, + "/.well-known/openid-configuration": { + "get": { + "tags": [ + "authorization-server-endpoints" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/OidcProviderConfiguration" + } + } + } + }, + "500": { + "description": "Internal Server Error" + } + } + } + }, + "/{subpath}/.well-known/openid-configuration": { + "get": { + "tags": [ + "authorization-server-endpoints" + ], + "summary": "Valid when multiple issuers are allowed", + "parameters": [ + { + "name": "subpath", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/OidcProviderConfiguration" + } + } + } + }, + "500": { + "description": "Internal Server Error" + } + } + } + }, + "/userinfo": { + "get": { + "tags": [ + "authorization-server-endpoints" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + } + } + }, + "500": { + "description": "Internal Server Error" + } + } + } + } + }, + "components": { + "schemas": { + "OAuth2Error": { + "type": "object", + "properties": { + "errorCode": { + "type": "string" + }, + "description": { + "type": "string" + }, + "uri": { + "type": "string" + } + } + }, + "OAuth2AuthorizationServerMetadata": { + "type": "object", + "properties": { + "response_types_supported": { + "type": "array", + "items": { + "type": "string" + } + }, + "grant_types_supported": { + "type": "array", + "items": { + "type": "string" + } + }, + "revocation_endpoint": { + "type": "string" + }, + "introspection_endpoint": { + "type": "string" + }, + "authorization_endpoint": { + "type": "string" + }, + "jwks_uri": { + "type": "string" + }, + "token_endpoint": { + "type": "string" + }, + "issuer": { + "type": "string" + }, + "introspection_endpoint_auth_methods_supported": { + "type": "array", + "items": { + "type": "string" + } + }, + "code_challenge_methods_supported": { + "type": "array", + "items": { + "type": "string" + } + }, + "token_endpoint_auth_methods_supported": { + "type": "array", + "items": { + "type": "string" + } + }, + "revocation_endpoint_auth_methods_supported": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "OAuth2Token": { + "type": "object", + "properties": { + "scope": { + "type": "string" + }, + "refresh_token": { + "type": "string" + }, + "expires_in": { + "type": "integer", + "format": "int64" + }, + "token_type": { + "type": "string" + }, + "access_token": { + "type": "string" + } + } + }, + "OAuth2TokenIntrospection": { + "type": "object", + "properties": { + "jti": { + "type": "string" + }, + "scope": { + "type": "string" + }, + "iat": { + "type": "integer", + "format": "int64" + }, + "token_type": { + "type": "string" + }, + "aud": { + "type": "array", + "items": { + "type": "string" + } + }, + "client_id": { + "type": "string" + }, + "exp": { + "type": "integer", + "format": "int64" + }, + "iss": { + "type": "string" + }, + "username": { + "type": "string" + }, + "sub": { + "type": "string" + }, + "nbf": { + "type": "integer", + "format": "int64" + }, + "active": { + "type": "boolean" + } + } + }, + "OidcProviderConfiguration": { + "type": "object", + "properties": { + "subject_types_supported": { + "type": "string" + }, + "response_types_supported": { + "type": "array", + "items": { + "type": "string" + } + }, + "grant_types_supported": { + "type": "array", + "items": { + "type": "string" + } + }, + "revocation_endpoint": { + "type": "string" + }, + "introspection_endpoint": { + "type": "string" + }, + "authorization_endpoint": { + "type": "string" + }, + "userinfo_endpoint": { + "type": "string" + }, + "jwks_uri": { + "type": "string" + }, + "scopes_supported": { + "type": "string" + }, + "token_endpoint": { + "type": "string" + }, + "issuer": { + "type": "string" + }, + "introspection_endpoint_auth_methods_supported": { + "type": "array", + "items": { + "type": "string" + } + }, + "code_challenge_methods_supported": { + "type": "array", + "items": { + "type": "string" + } + }, + "token_endpoint_auth_methods_supported": { + "type": "array", + "items": { + "type": "string" + } + }, + "revocation_endpoint_auth_methods_supported": { + "type": "array", + "items": { + "type": "string" + } + }, + "id_token_signing_alg_values_supported": { + "type": "string" + } + } + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/resources/results/3.1.0/app12.json b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/resources/results/3.1.0/app12.json new file mode 100644 index 000000000..94f1bac29 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/resources/results/3.1.0/app12.json @@ -0,0 +1,860 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/api/hello": { + "get": { + "tags": [ + "hello-controller" + ], + "operationId": "hello", + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/oauth2/jwks": { + "get": { + "tags": [ + "authorization-server-endpoints" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "keys": { + "type": "array", + "items": { + "type": "object", + "additionalProperties": true + } + } + } + } + } + } + }, + "500": { + "description": "Internal Server Error" + }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/OAuth2Error" + } + } + } + } + } + } + }, + "/.well-known/oauth-authorization-server": { + "get": { + "tags": [ + "authorization-server-endpoints" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/OAuth2AuthorizationServerMetadata" + } + } + } + }, + "500": { + "description": "Internal Server Error" + } + } + } + }, + "/.well-known/oauth-authorization-server/{subpath}": { + "get": { + "tags": [ + "authorization-server-endpoints" + ], + "summary": "Valid when multiple issuers are allowed", + "parameters": [ + { + "name": "subpath", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/OAuth2AuthorizationServerMetadata" + } + } + } + }, + "500": { + "description": "Internal Server Error" + } + } + } + }, + "/oauth2/token": { + "post": { + "tags": [ + "authorization-server-endpoints" + ], + "parameters": [ + { + "name": "Authorization", + "in": "header", + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/x-www-form-urlencoded": { + "schema": { + "type": "object", + "properties": { + "grant_type": { + "type": "string", + "enum": [ + "authorization_code", + "refresh_token", + "client_credentials" + ] + }, + "code": { + "type": "string" + }, + "redirect_uri": { + "type": "string" + }, + "refresh_token": { + "type": "string" + }, + "scope": { + "type": "string" + }, + "client_id": { + "type": "string" + }, + "client_secret": { + "type": "string" + }, + "client_assertion_type": { + "type": "string" + }, + "client_assertion": { + "type": "string" + }, + "additionalParameters": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + } + } + } + } + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/OAuth2Token" + } + } + } + }, + "500": { + "description": "Internal Server Error" + }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/OAuth2Error" + } + } + } + }, + "401": { + "description": "Unauthorized", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/OAuth2Error" + } + } + } + } + } + } + }, + "/oauth2/authorize": { + "post": { + "tags": [ + "authorization-server-endpoints" + ], + "parameters": [ + { + "name": "parameters", + "in": "query", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "text/html": {} + } + }, + "500": { + "description": "Internal Server Error" + }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/OAuth2Error" + } + } + } + }, + "302": { + "description": "Found", + "headers": { + "Location": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/oauth2/introspect": { + "post": { + "tags": [ + "authorization-server-endpoints" + ], + "requestBody": { + "content": { + "application/x-www-form-urlencoded": { + "schema": { + "type": "object", + "properties": { + "token": { + "type": "string" + }, + "token_type_hint": { + "type": "string" + }, + "additionalParameters": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + } + } + } + } + }, + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/OAuth2TokenIntrospection" + } + } + } + }, + "500": { + "description": "Internal Server Error" + }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/OAuth2Error" + } + } + } + } + } + } + }, + "/oauth2/revoke": { + "post": { + "tags": [ + "authorization-server-endpoints" + ], + "requestBody": { + "content": { + "application/x-www-form-urlencoded": { + "schema": { + "type": "object", + "properties": { + "token": { + "type": "string" + }, + "token_type_hint": { + "type": "string" + } + } + } + } + } + }, + "responses": { + "200": { + "description": "OK" + }, + "500": { + "description": "Internal Server Error" + }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/OAuth2Error" + } + } + } + } + } + } + }, + "/.well-known/openid-configuration": { + "get": { + "tags": [ + "authorization-server-endpoints" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/OidcProviderConfiguration" + } + } + } + }, + "500": { + "description": "Internal Server Error" + } + } + } + }, + "/{subpath}/.well-known/openid-configuration": { + "get": { + "tags": [ + "authorization-server-endpoints" + ], + "summary": "Valid when multiple issuers are allowed", + "parameters": [ + { + "name": "subpath", + "in": "path", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/OidcProviderConfiguration" + } + } + } + }, + "500": { + "description": "Internal Server Error" + } + } + } + }, + "/userinfo": { + "get": { + "tags": [ + "authorization-server-endpoints" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + } + } + }, + "500": { + "description": "Internal Server Error" + } + } + } + }, + "/connect/register": { + "post": { + "tags": [ + "authorization-server-endpoints" + ], + "parameters": [ + { + "name": "Authorization", + "in": "header", + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ClientRegistrationRequest" + } + } + } + }, + "responses": { + "201": { + "description": "Created", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ClientRegistrationResponse" + } + } + } + }, + "500": { + "description": "Internal Server Error" + }, + "400": { + "description": "Bad Request", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/OAuth2Error" + } + } + } + }, + "401": { + "description": "Unauthorized", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/OAuth2Error" + } + } + } + }, + "403": { + "description": "Forbidden", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/OAuth2Error" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "OAuth2Error": { + "type": "object", + "properties": { + "errorCode": { + "type": "string" + }, + "description": { + "type": "string" + }, + "uri": { + "type": "string" + } + } + }, + "OAuth2AuthorizationServerMetadata": { + "type": "object", + "properties": { + "response_types_supported": { + "type": "array", + "items": { + "type": "string" + } + }, + "grant_types_supported": { + "type": "array", + "items": { + "type": "string" + } + }, + "revocation_endpoint": { + "type": "string" + }, + "introspection_endpoint": { + "type": "string" + }, + "authorization_endpoint": { + "type": "string" + }, + "jwks_uri": { + "type": "string" + }, + "token_endpoint": { + "type": "string" + }, + "issuer": { + "type": "string" + }, + "introspection_endpoint_auth_methods_supported": { + "type": "array", + "items": { + "type": "string" + } + }, + "code_challenge_methods_supported": { + "type": "array", + "items": { + "type": "string" + } + }, + "token_endpoint_auth_methods_supported": { + "type": "array", + "items": { + "type": "string" + } + }, + "revocation_endpoint_auth_methods_supported": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "OAuth2Token": { + "type": "object", + "properties": { + "scope": { + "type": "string" + }, + "refresh_token": { + "type": "string" + }, + "expires_in": { + "type": "integer", + "format": "int64" + }, + "token_type": { + "type": "string" + }, + "access_token": { + "type": "string" + } + } + }, + "OAuth2TokenIntrospection": { + "type": "object", + "properties": { + "jti": { + "type": "string" + }, + "scope": { + "type": "string" + }, + "iat": { + "type": "integer", + "format": "int64" + }, + "token_type": { + "type": "string" + }, + "aud": { + "type": "array", + "items": { + "type": "string" + } + }, + "client_id": { + "type": "string" + }, + "exp": { + "type": "integer", + "format": "int64" + }, + "iss": { + "type": "string" + }, + "username": { + "type": "string" + }, + "sub": { + "type": "string" + }, + "nbf": { + "type": "integer", + "format": "int64" + }, + "active": { + "type": "boolean" + } + } + }, + "OidcProviderConfiguration": { + "type": "object", + "properties": { + "subject_types_supported": { + "type": "string" + }, + "response_types_supported": { + "type": "array", + "items": { + "type": "string" + } + }, + "grant_types_supported": { + "type": "array", + "items": { + "type": "string" + } + }, + "revocation_endpoint": { + "type": "string" + }, + "introspection_endpoint": { + "type": "string" + }, + "authorization_endpoint": { + "type": "string" + }, + "userinfo_endpoint": { + "type": "string" + }, + "jwks_uri": { + "type": "string" + }, + "scopes_supported": { + "type": "string" + }, + "token_endpoint": { + "type": "string" + }, + "issuer": { + "type": "string" + }, + "introspection_endpoint_auth_methods_supported": { + "type": "array", + "items": { + "type": "string" + } + }, + "code_challenge_methods_supported": { + "type": "array", + "items": { + "type": "string" + } + }, + "token_endpoint_auth_methods_supported": { + "type": "array", + "items": { + "type": "string" + } + }, + "revocation_endpoint_auth_methods_supported": { + "type": "array", + "items": { + "type": "string" + } + }, + "id_token_signing_alg_values_supported": { + "type": "string" + } + } + }, + "ClientRegistrationResponse": { + "type": "object", + "properties": { + "registration_client_uri": { + "type": "string" + }, + "client_id_issued_at": { + "type": "integer", + "format": "int64" + }, + "redirect_uris": { + "type": "array", + "items": { + "type": "string" + } + }, + "grant_types": { + "type": "array", + "items": { + "type": "string" + } + }, + "response_types": { + "type": "array", + "items": { + "type": "string" + } + }, + "client_name": { + "type": "string" + }, + "jwks_uri": { + "type": "string" + }, + "client_id": { + "type": "string" + }, + "client_secret": { + "type": "string" + }, + "scope": { + "type": "string" + }, + "token_endpoint_auth_signing_alg": { + "type": "string" + }, + "client_secret_expires_at": { + "type": "integer", + "format": "int64" + }, + "registration_access_token": { + "type": "string" + }, + "id_token_signed_response_alg": { + "type": "string" + }, + "token_endpoint_auth_method": { + "type": "string" + } + } + }, + "ClientRegistrationRequest": { + "type": "object", + "properties": { + "client_id_issued_at": { + "type": "string", + "format": "date-time" + }, + "redirect_uris": { + "type": "array", + "items": { + "type": "string" + } + }, + "grant_types": { + "type": "array", + "items": { + "type": "string" + } + }, + "response_types": { + "type": "array", + "items": { + "type": "string" + } + }, + "client_name": { + "type": "string" + }, + "jwks_uri": { + "type": "string" + }, + "client_id": { + "type": "string" + }, + "client_secret": { + "type": "string" + }, + "scope": { + "type": "string" + }, + "token_endpoint_auth_signing_alg": { + "type": "string" + }, + "client_secret_expires_at": { + "type": "string", + "format": "date-time" + }, + "id_token_signed_response_alg": { + "type": "string" + }, + "token_endpoint_auth_method": { + "type": "string" + } + } + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/resources/results/3.1.0/app2.json b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/resources/results/3.1.0/app2.json new file mode 100644 index 000000000..94152006b --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/resources/results/3.1.0/app2.json @@ -0,0 +1,120 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "Security API", + "license": { + "name": "Apache 2.0", + "url": "http://springdoc.org" + }, + "version": "v1" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/oneParameterAndUser": { + "get": { + "tags": [ + "hello-controller" + ], + "operationId": "oneParameterAndUser", + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "string" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/oneParameterAndAuthentication": { + "get": { + "tags": [ + "hello-controller" + ], + "operationId": "oneParameterAndAuthentication", + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "string" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/noParametersAndUser": { + "get": { + "tags": [ + "hello-controller" + ], + "operationId": "noParametersAndUser", + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "object" + } + } + } + } + } + } + }, + "/noParametersAndAuthentication": { + "get": { + "tags": [ + "hello-controller" + ], + "operationId": "noParametersAndAuthentication", + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "object" + } + } + } + } + } + } + } + }, + "components": {} +} diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/resources/results/3.1.0/app5.json b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/resources/results/3.1.0/app5.json new file mode 100644 index 000000000..81768909d --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/resources/results/3.1.0/app5.json @@ -0,0 +1,58 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "OpenAPI definition", + "version": "v0" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/": { + "get": { + "tags": [ + "hello-controller" + ], + "operationId": "doGet", + "responses": { + "200": { + "description": "OK" + } + } + }, + "post": { + "tags": [ + "hello-controller" + ], + "operationId": "doPost", + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/Sample" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "Sample": { + "type": "object", + "properties": { + "toto": { + "type": "string" + } + } + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/resources/results/3.1.0/app6.json b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/resources/results/3.1.0/app6.json new file mode 100644 index 000000000..71968e301 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/resources/results/3.1.0/app6.json @@ -0,0 +1,103 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "My MWE API", + "description": "This document specifies the API", + "version": "v23" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "security": [ + { + "bearerAuth": [] + } + ], + "tags": [ + { + "name": "Fax stuff", + "description": "For managing fax machines." + } + ], + "paths": { + "/fax/list": { + "get": { + "tags": [ + "Fax stuff" + ], + "summary": "Get information about currently existing fax machines", + "operationId": "getFaxList", + "parameters": [ + { + "name": "vendorName", + "in": "query", + "description": "vendor name to restrict the list", + "required": false, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "list of existing fax machines", + "content": { + "*/*": { + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + } + } + } + } + } + }, + "/login": { + "post": { + "tags": [ + "login-endpoint" + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "username": { + "type": "string" + }, + "password": { + "type": "string" + } + } + } + } + } + }, + "responses": { + "200": { + "description": "OK" + }, + "401": { + "description": "Unauthorized" + } + } + } + } + }, + "components": { + "securitySchemes": { + "bearerAuth": { + "type": "http", + "scheme": "bearer", + "bearerFormat": "JWT" + } + } + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/resources/results/3.1.0/app7.json b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/resources/results/3.1.0/app7.json new file mode 100644 index 000000000..56eb8cc20 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/resources/results/3.1.0/app7.json @@ -0,0 +1,41 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "Security API", + "license": { + "name": "Apache 2.0", + "url": "http://springdoc.org" + }, + "version": "v1" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/hello": { + "post": { + "tags": [ + "hello-controller" + ], + "operationId": "hello", + "responses": { + "200": { + "description": "OK", + "content": { + "*/*": { + "schema": { + "type": "string" + } + } + } + } + } + } + } + }, + "components": { + } +} diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/resources/results/3.1.0/app8.json b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/resources/results/3.1.0/app8.json new file mode 100644 index 000000000..a53412fe2 --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/resources/results/3.1.0/app8.json @@ -0,0 +1,52 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "Security API", + "license": { + "name": "Apache 2.0", + "url": "http://springdoc.org" + }, + "version": "v1" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": { + "/api/login": { + "post": { + "tags": [ + "login-endpoint" + ], + "requestBody": { + "content": { + "application/x-www-form-urlencoded": { + "schema": { + "type": "object", + "properties": { + "username": { + "type": "string" + }, + "password": { + "type": "string" + } + } + } + } + } + }, + "responses": { + "200": { + "description": "OK" + }, + "401": { + "description": "Unauthorized" + } + } + } + } + }, + "components": {} +} \ No newline at end of file diff --git a/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/resources/results/3.1.0/app9.json b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/resources/results/3.1.0/app9.json new file mode 100644 index 000000000..f2e4244bd --- /dev/null +++ b/springdoc-openapi-tests/springdoc-openapi-security-tests/src/test/resources/results/3.1.0/app9.json @@ -0,0 +1,19 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "Security API", + "license": { + "name": "Apache 2.0", + "url": "http://springdoc.org" + }, + "version": "v1" + }, + "servers": [ + { + "url": "http://localhost", + "description": "Generated server url" + } + ], + "paths": {}, + "components": {} +}